aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.gitignore11
-rw-r--r--.travis.yml6
-rw-r--r--BUILD37
-rw-r--r--CHANGES.txt82
-rw-r--r--Makefile.am146
-rw-r--r--Protobuf.podspec4
-rw-r--r--README.md4
-rw-r--r--cmake/extract_includes.bat.in2
-rw-r--r--cmake/libprotoc.cmake13
-rw-r--r--cmake/tests.cmake1
-rw-r--r--composer.json6
-rw-r--r--configure.ac5
-rw-r--r--conformance/ConformanceJava.java185
-rw-r--r--conformance/Makefile.am88
-rw-r--r--conformance/conformance.proto185
-rw-r--r--conformance/conformance_cpp.cc3
-rw-r--r--conformance/conformance_objc.m1
-rwxr-xr-xconformance/conformance_php.php112
-rwxr-xr-xconformance/conformance_python.py7
-rwxr-xr-xconformance/conformance_ruby.rb10
-rw-r--r--conformance/conformance_test.cc261
-rw-r--r--conformance/conformance_test.h28
-rw-r--r--conformance/failure_list_cpp.txt7
-rw-r--r--conformance/failure_list_csharp.txt2
-rw-r--r--conformance/failure_list_java.txt8
-rw-r--r--conformance/failure_list_php.txt611
-rw-r--r--conformance/failure_list_php_c.txt235
-rw-r--r--conformance/failure_list_python.txt6
-rw-r--r--conformance/failure_list_python_cpp.txt6
-rw-r--r--conformance/failure_list_ruby.txt6
-rw-r--r--csharp/Google.Protobuf.Tools.nuspec2
-rw-r--r--csharp/README.md54
-rw-r--r--csharp/compatibility_tests/v3.0.0/protos/csharp/protos/unittest_issues.proto126
-rw-r--r--csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/map_unittest_proto3.proto120
-rw-r--r--csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_import_proto3.proto68
-rw-r--r--csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_import_public_proto3.proto (renamed from src/google/protobuf/arena_nc.cc)19
-rw-r--r--csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_proto3.proto388
-rw-r--r--csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_well_known_types.proto114
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/ByteStringTest.cs171
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedInputStreamExtensions.cs53
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedInputStreamTest.cs598
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedOutputStreamTest.cs419
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Collections/MapFieldTest.cs532
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs746
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Compatibility/PropertyInfoExtensionsTest.cs98
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs117
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/DeprecatedMemberTest.cs55
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/EqualityTester.cs64
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/FieldCodecTest.cs196
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/GeneratedMessageTest.cs723
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj19
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/IssuesTest.cs82
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/JsonParserTest.cs939
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/JsonTokenizerTest.cs408
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs259
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs218
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Reflection/TypeRegistryTest.cs94
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/SampleEnum.cs42
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/SampleMessages.cs99
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/TestCornerCases.cs62
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/TestProtos/ForeignMessagePartial.cs45
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs116
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/DurationTest.cs132
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/FieldMaskTest.cs62
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs115
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs421
-rw-r--r--csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/project.json44
-rwxr-xr-xcsharp/compatibility_tests/v3.0.0/test.sh102
-rwxr-xr-xcsharp/generate_protos.sh10
-rw-r--r--csharp/protos/unittest_custom_options_proto3.proto336
-rw-r--r--csharp/src/AddressBook/Addressbook.cs6
-rw-r--r--csharp/src/Google.Protobuf.Conformance/Conformance.cs3696
-rw-r--r--csharp/src/Google.Protobuf.Conformance/Program.cs8
-rw-r--r--csharp/src/Google.Protobuf.Conformance/project.json4
-rwxr-xr-x[-rw-r--r--]csharp/src/Google.Protobuf.Test/ByteStringTest.cs66
-rw-r--r--csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs16
-rwxr-xr-xcsharp/src/Google.Protobuf.Test/Compatibility/StreamExtensionsTest.cs67
-rwxr-xr-x[-rw-r--r--]csharp/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs2
-rwxr-xr-x[-rw-r--r--]csharp/src/Google.Protobuf.Test/FieldCodecTest.cs5
-rw-r--r--csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj4
-rw-r--r--csharp/src/Google.Protobuf.Test/Reflection/CustomOptionsTest.cs271
-rw-r--r--csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs10
-rw-r--r--csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs3688
-rw-r--r--csharp/src/Google.Protobuf.Test/TestProtos/UnittestCustomOptionsProto3.cs2625
-rw-r--r--csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs30
-rw-r--r--csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs84
-rw-r--r--csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs18
-rw-r--r--csharp/src/Google.Protobuf.Test/project.json5
-rwxr-xr-x[-rw-r--r--]csharp/src/Google.Protobuf/ByteString.cs58
-rw-r--r--csharp/src/Google.Protobuf/Collections/MapField.cs4
-rwxr-xr-x[-rw-r--r--]csharp/src/Google.Protobuf/Collections/RepeatedField.cs3
-rwxr-xr-x[-rw-r--r--]csharp/src/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs4
-rwxr-xr-xcsharp/src/Google.Protobuf/Compatibility/StreamExtensions.cs66
-rwxr-xr-x[-rw-r--r--]csharp/src/Google.Protobuf/Compatibility/TypeExtensions.cs2
-rwxr-xr-x[-rw-r--r--]csharp/src/Google.Protobuf/JsonFormatter.cs2
-rw-r--r--csharp/src/Google.Protobuf/Reflection/CustomOptions.cs390
-rw-r--r--csharp/src/Google.Protobuf/Reflection/Descriptor.cs960
-rw-r--r--csharp/src/Google.Protobuf/Reflection/EnumDescriptor.cs5
-rw-r--r--csharp/src/Google.Protobuf/Reflection/EnumValueDescriptor.cs5
-rw-r--r--csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs5
-rw-r--r--csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs5
-rwxr-xr-x[-rw-r--r--]csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs7
-rw-r--r--csharp/src/Google.Protobuf/Reflection/MethodDescriptor.cs5
-rw-r--r--csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs5
-rw-r--r--csharp/src/Google.Protobuf/Reflection/ServiceDescriptor.cs5
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/Any.cs148
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/Api.cs203
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs88
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs14
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs388
-rwxr-xr-x[-rw-r--r--]csharp/src/Google.Protobuf/WellKnownTypes/FieldMaskPartial.cs2
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs15
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs52
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs88
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/Type.cs137
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs54
-rw-r--r--csharp/src/Google.Protobuf/project.json2
-rw-r--r--csharp/src/global.json5
-rw-r--r--docs/third_party.md9
-rwxr-xr-xgenerate_changelog.py1
-rw-r--r--java/core/pom.xml2
-rw-r--r--java/core/src/main/java/com/google/protobuf/AbstractMessageLite.java1
-rw-r--r--java/core/src/main/java/com/google/protobuf/AbstractParser.java2
-rw-r--r--java/core/src/main/java/com/google/protobuf/ByteString.java18
-rw-r--r--java/core/src/main/java/com/google/protobuf/CodedInputStream.java7
-rw-r--r--java/core/src/main/java/com/google/protobuf/Descriptors.java2
-rw-r--r--java/core/src/main/java/com/google/protobuf/DynamicMessage.java2
-rw-r--r--java/core/src/main/java/com/google/protobuf/ExtensionRegistry.java1
-rw-r--r--java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java7
-rw-r--r--java/core/src/main/java/com/google/protobuf/FieldSet.java1
-rw-r--r--java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java163
-rw-r--r--java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java26
-rw-r--r--java/core/src/main/java/com/google/protobuf/LazyFieldLite.java25
-rw-r--r--java/core/src/main/java/com/google/protobuf/MapEntry.java2
-rw-r--r--java/core/src/main/java/com/google/protobuf/MapFieldLite.java4
-rw-r--r--java/core/src/main/java/com/google/protobuf/MessageLiteToString.java4
-rw-r--r--java/core/src/main/java/com/google/protobuf/SmallSortedMap.java21
-rw-r--r--java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java35
-rw-r--r--java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java62
-rw-r--r--java/core/src/test/java/com/google/protobuf/CodedInputStreamTest.java78
-rw-r--r--java/core/src/test/java/com/google/protobuf/LazyFieldLiteTest.java24
-rw-r--r--java/core/src/test/java/com/google/protobuf/LazyMessageLiteTest.java13
-rw-r--r--java/core/src/test/java/com/google/protobuf/LiteTest.java26
-rw-r--r--java/core/src/test/java/com/google/protobuf/MapForProto2LiteTest.java1
-rw-r--r--java/core/src/test/java/com/google/protobuf/MapForProto2Test.java105
-rw-r--r--java/core/src/test/java/com/google/protobuf/MapTest.java157
-rw-r--r--java/core/src/test/java/com/google/protobuf/ParserTest.java40
-rw-r--r--java/core/src/test/java/com/google/protobuf/UnknownFieldSetLiteTest.java8
-rw-r--r--java/pom.xml2
-rw-r--r--java/util/pom.xml2
-rw-r--r--java/util/src/main/java/com/google/protobuf/util/Durations.java8
-rw-r--r--java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java7
-rw-r--r--java/util/src/main/java/com/google/protobuf/util/JsonFormat.java58
-rw-r--r--java/util/src/main/java/com/google/protobuf/util/Timestamps.java8
-rw-r--r--java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java55
-rw-r--r--java/util/src/test/proto/com/google/protobuf/util/json_test.proto5
-rw-r--r--javanano/pom.xml2
-rw-r--r--javanano/src/main/java/com/google/protobuf/nano/InternalNano.java4
-rw-r--r--javanano/src/test/java/com/google/protobuf/nano/NanoTest.java5
-rw-r--r--jenkins/docker/Dockerfile6
-rw-r--r--jenkins/docker32/Dockerfile4
-rw-r--r--js/binary/decoder.js83
-rw-r--r--js/binary/decoder_test.js23
-rw-r--r--js/binary/encoder.js74
-rw-r--r--js/binary/message_test.js60
-rw-r--r--js/binary/proto_test.js41
-rw-r--r--js/binary/reader.js96
-rw-r--r--js/binary/utils.js10
-rw-r--r--js/binary/writer.js415
-rw-r--r--js/commonjs/export.js1
-rw-r--r--js/commonjs/export_testdeps.js1
-rw-r--r--js/gulpfile.js6
-rw-r--r--js/jasmine.json5
-rw-r--r--js/map.js112
-rwxr-xr-xjs/maps_test.js65
-rw-r--r--js/message.js39
-rw-r--r--js/message_test.js25
-rw-r--r--js/package.json4
-rw-r--r--js/proto3_test.js38
-rw-r--r--js/test.proto3
-rw-r--r--js/test8.proto50
-rw-r--r--m4/ax_cxx_compile_stdcxx.m4982
-rw-r--r--m4/ax_prog_cc_for_build.m4125
-rw-r--r--m4/ax_prog_cxx_for_build.m4110
-rwxr-xr-xobjectivec/DevTools/compile_testing_protos.sh2
-rwxr-xr-xobjectivec/DevTools/full_mac_build.sh35
-rw-r--r--objectivec/GPBArray.h50
-rw-r--r--objectivec/GPBArray.m4
-rw-r--r--objectivec/GPBBootstrap.h6
-rw-r--r--objectivec/GPBDictionary.h544
-rw-r--r--objectivec/GPBDictionary.m8
-rw-r--r--objectivec/GPBMessage.m16
-rw-r--r--objectivec/GPBUtilities.h5
-rw-r--r--objectivec/GPBUtilities.m135
-rw-r--r--objectivec/GPBWellKnownTypes.h17
-rw-r--r--objectivec/GPBWellKnownTypes.m52
-rw-r--r--objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj4
-rw-r--r--objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj4
-rw-r--r--objectivec/README.md2
-rw-r--r--objectivec/Tests/GPBARCUnittestProtos.m2
-rw-r--r--objectivec/Tests/GPBArrayTests.m173
-rw-r--r--objectivec/Tests/GPBDictionaryTests.m186
-rw-r--r--objectivec/Tests/GPBMessageTests.m31
-rw-r--r--objectivec/Tests/GPBUnittestProtos.m2
-rw-r--r--objectivec/Tests/GPBUtilitiesTests.m200
-rw-r--r--objectivec/Tests/GPBWellKnownTypesTest.m162
-rw-r--r--objectivec/Tests/unittest_deprecated.proto95
-rw-r--r--objectivec/Tests/unittest_deprecated_file.proto76
-rw-r--r--objectivec/google/protobuf/Type.pbobjc.h14
-rw-r--r--php/README.md2
-rw-r--r--php/composer.json27
-rw-r--r--php/ext/google/protobuf/def.c30
-rw-r--r--php/ext/google/protobuf/encode_decode.c113
-rw-r--r--php/ext/google/protobuf/message.c73
-rw-r--r--php/ext/google/protobuf/package.xml24
-rw-r--r--php/ext/google/protobuf/protobuf.h16
-rw-r--r--php/ext/google/protobuf/storage.c51
-rw-r--r--php/ext/google/protobuf/upb.c2279
-rw-r--r--php/ext/google/protobuf/upb.h896
-rw-r--r--php/phpunit.xml14
-rw-r--r--php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php260
-rw-r--r--php/src/Google/Protobuf/Internal/DescriptorProto.php325
-rw-r--r--php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php82
-rw-r--r--php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php112
-rw-r--r--php/src/Google/Protobuf/Internal/EnumDescriptorProto.php114
-rw-r--r--php/src/Google/Protobuf/Internal/EnumOptions.php158
-rw-r--r--php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php114
-rw-r--r--php/src/Google/Protobuf/Internal/EnumValueOptions.php115
-rw-r--r--php/src/Google/Protobuf/Internal/FieldDescriptorProto.php424
-rw-r--r--php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php29
-rw-r--r--php/src/Google/Protobuf/Internal/FieldDescriptorProto_Type.php120
-rw-r--r--php/src/Google/Protobuf/Internal/FieldOptions.php429
-rw-r--r--php/src/Google/Protobuf/Internal/FieldOptions_CType.php29
-rw-r--r--php/src/Google/Protobuf/Internal/FieldOptions_JSType.php37
-rw-r--r--php/src/Google/Protobuf/Internal/FileDescriptorProto.php477
-rw-r--r--php/src/Google/Protobuf/Internal/FileDescriptorSet.php59
-rw-r--r--php/src/Google/Protobuf/Internal/FileOptions.php741
-rw-r--r--php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php41
-rw-r--r--php/src/Google/Protobuf/Internal/GPBUtil.php9
-rw-r--r--php/src/Google/Protobuf/Internal/GPBWire.php85
-rw-r--r--php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php75
-rw-r--r--php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php198
-rw-r--r--php/src/Google/Protobuf/Internal/InputStream.php78
-rw-r--r--php/src/Google/Protobuf/Internal/Message.php142
-rw-r--r--php/src/Google/Protobuf/Internal/MessageOptions.php334
-rw-r--r--php/src/Google/Protobuf/Internal/MethodDescriptorProto.php237
-rw-r--r--php/src/Google/Protobuf/Internal/MethodOptions.php143
-rw-r--r--php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php39
-rw-r--r--php/src/Google/Protobuf/Internal/OneofDescriptorProto.php86
-rw-r--r--php/src/Google/Protobuf/Internal/OneofOptions.php66
-rw-r--r--php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php114
-rw-r--r--php/src/Google/Protobuf/Internal/ServiceOptions.php115
-rw-r--r--php/src/Google/Protobuf/Internal/SourceCodeInfo.php191
-rw-r--r--php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php379
-rw-r--r--php/src/Google/Protobuf/Internal/UninterpretedOption.php246
-rw-r--r--php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php90
-rw-r--r--php/src/Google/Protobuf/descriptor.php19
-rw-r--r--php/src/Google/Protobuf/descriptor_internal.pb.php2532
-rw-r--r--php/tests/array_test.php1
-rwxr-xr-xphp/tests/autoload.php25
-rw-r--r--php/tests/encode_decode_test.php58
-rwxr-xr-xphp/tests/gdb_test.sh12
-rw-r--r--php/tests/generated_class_test.php38
-rw-r--r--php/tests/map_field_test.php1
-rw-r--r--php/tests/memory_leak_test.php10
-rw-r--r--php/tests/php_implementation_test.php31
-rw-r--r--php/tests/proto/test.proto (renamed from php/tests/test.proto)10
-rw-r--r--php/tests/proto/test_include.proto (renamed from php/tests/test_include.proto)0
-rw-r--r--php/tests/proto/test_no_namespace.proto10
-rw-r--r--php/tests/test.pb.php1385
-rwxr-xr-xphp/tests/test.sh9
-rw-r--r--php/tests/test_base.php95
-rw-r--r--php/tests/test_include.pb.php36
-rw-r--r--php/tests/test_no_namespace.pb.php34
-rw-r--r--php/tests/test_no_namespace.proto5
-rw-r--r--php/tests/test_util.php7
-rw-r--r--php/tests/well_known_test.php11
-rw-r--r--phpunit.xml13
-rw-r--r--protobuf.bzl52
-rw-r--r--protoc-artifacts/pom.xml2
-rw-r--r--python/README.md2
-rw-r--r--python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/factory_test1.proto55
-rw-r--r--python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/factory_test2.proto77
-rw-r--r--python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/more_extensions.proto58
-rw-r--r--python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/more_extensions_dynamic.proto49
-rw-r--r--python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/more_messages.proto51
-rw-r--r--python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/test_bad_identifiers.proto52
-rw-r--r--python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/descriptor.proto620
-rw-r--r--python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest.proto719
-rw-r--r--python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_custom_options.proto387
-rw-r--r--python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_import.proto64
-rw-r--r--python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_import_public.proto40
-rw-r--r--python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_mset.proto72
-rw-r--r--python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_no_generic_services.proto52
-rwxr-xr-xpython/compatibility_tests/v2.5.0/setup.py87
-rwxr-xr-xpython/compatibility_tests/v2.5.0/test.sh104
-rw-r--r--python/compatibility_tests/v2.5.0/tests/__init__.py4
-rw-r--r--python/compatibility_tests/v2.5.0/tests/google/__init__.py4
-rw-r--r--python/compatibility_tests/v2.5.0/tests/google/protobuf/__init__.py4
-rw-r--r--python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/__init__.py (renamed from src/google/protobuf/arena_nc_test.py)36
-rwxr-xr-xpython/compatibility_tests/v2.5.0/tests/google/protobuf/internal/descriptor_test.py613
-rwxr-xr-xpython/compatibility_tests/v2.5.0/tests/google/protobuf/internal/generator_test.py269
-rw-r--r--python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/golden_messagebin0 -> 509 bytes
-rw-r--r--python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/golden_packed_fields_messagebin0 -> 142 bytes
-rwxr-xr-xpython/compatibility_tests/v2.5.0/tests/google/protobuf/internal/message_test.py494
-rwxr-xr-xpython/compatibility_tests/v2.5.0/tests/google/protobuf/internal/service_reflection_test.py136
-rwxr-xr-xpython/compatibility_tests/v2.5.0/tests/google/protobuf/internal/test_util.py651
-rwxr-xr-xpython/compatibility_tests/v2.5.0/tests/google/protobuf/internal/text_format_test.py620
-rw-r--r--python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/text_format_unittest_data.txt128
-rw-r--r--python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/text_format_unittest_extensions_data.txt128
-rwxr-xr-xpython/compatibility_tests/v2.5.0/tests/google/protobuf/internal/wire_format_test.py253
-rwxr-xr-xpython/google/protobuf/__init__.py2
-rw-r--r--python/google/protobuf/descriptor_pool.py99
-rwxr-xr-xpython/google/protobuf/internal/decoder.py22
-rw-r--r--python/google/protobuf/internal/descriptor_pool_test.py47
-rw-r--r--python/google/protobuf/internal/message_factory_test.py20
-rwxr-xr-xpython/google/protobuf/internal/python_message.py56
-rwxr-xr-xpython/google/protobuf/internal/reflection_test.py67
-rwxr-xr-xpython/google/protobuf/internal/test_util.py154
-rw-r--r--python/google/protobuf/internal/testing_refleaks.py2
-rwxr-xr-xpython/google/protobuf/internal/text_format_test.py30
-rwxr-xr-xpython/google/protobuf/internal/type_checkers.py15
-rw-r--r--python/google/protobuf/json_format.py4
-rw-r--r--python/google/protobuf/pyext/descriptor_pool.cc67
-rw-r--r--python/google/protobuf/pyext/extension_dict.cc79
-rw-r--r--python/google/protobuf/pyext/map_container.cc2
-rw-r--r--python/google/protobuf/pyext/message.cc413
-rw-r--r--python/google/protobuf/pyext/message.h24
-rw-r--r--python/google/protobuf/pyext/message_factory.cc66
-rw-r--r--python/google/protobuf/pyext/message_factory.h12
-rw-r--r--python/google/protobuf/pyext/safe_numerics.h164
-rwxr-xr-xpython/setup.py8
-rw-r--r--ruby/Rakefile4
-rw-r--r--ruby/ext/google/protobuf_c/defs.c4
-rw-r--r--ruby/ext/google/protobuf_c/encode_decode.c8
-rw-r--r--ruby/ext/google/protobuf_c/message.c44
-rw-r--r--ruby/ext/google/protobuf_c/upb.c2914
-rw-r--r--ruby/ext/google/protobuf_c/upb.h1226
-rw-r--r--ruby/google-protobuf.gemspec2
-rw-r--r--ruby/lib/google/protobuf/repeated_field.rb2
-rw-r--r--ruby/tests/basic.rb19
-rw-r--r--src/Makefile.am32
-rw-r--r--src/google/protobuf/any.cc8
-rw-r--r--src/google/protobuf/any.pb.cc244
-rw-r--r--src/google/protobuf/any.pb.h120
-rw-r--r--src/google/protobuf/api.pb.cc880
-rw-r--r--src/google/protobuf/api.pb.h437
-rw-r--r--src/google/protobuf/api.proto1
-rwxr-xr-xsrc/google/protobuf/arena.cc41
-rw-r--r--src/google/protobuf/arena.h47
-rw-r--r--src/google/protobuf/arena_test_util.h31
-rw-r--r--src/google/protobuf/arena_unittest.cc9
-rw-r--r--src/google/protobuf/arenastring.cc2
-rwxr-xr-xsrc/google/protobuf/arenastring.h42
-rw-r--r--src/google/protobuf/arenastring_unittest.cc22
-rw-r--r--src/google/protobuf/compiler/code_generator.cc18
-rw-r--r--src/google/protobuf/compiler/code_generator.h13
-rw-r--r--src/google/protobuf/compiler/command_line_interface.cc159
-rw-r--r--src/google/protobuf/compiler/command_line_interface.h41
-rw-r--r--src/google/protobuf/compiler/command_line_interface_unittest.cc89
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc2
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_enum.cc41
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_enum.h8
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_enum_field.cc29
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_enum_field.h7
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_extension.cc6
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_field.cc4
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_field.h26
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_file.cc656
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_file.h37
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_generator.cc2
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_helpers.cc33
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_helpers.h18
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_map_field.cc36
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_map_field.h5
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_message.cc2393
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_message.h57
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_message_field.cc99
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_message_field.h17
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_primitive_field.cc77
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_primitive_field.h7
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_service.cc58
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_service.h5
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_string_field.cc756
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_string_field.h12
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_unittest.cc101
-rw-r--r--src/google/protobuf/compiler/cpp/metadata_test.cc6
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_doc_comment.cc2
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_field_base.cc6
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_helpers.cc1
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_helpers.h16
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_message.cc31
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_message.h2
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_names.h9
-rw-r--r--src/google/protobuf/compiler/importer.cc4
-rw-r--r--src/google/protobuf/compiler/importer.h2
-rw-r--r--src/google/protobuf/compiler/importer_unittest.cc2
-rw-r--r--src/google/protobuf/compiler/java/java_context.cc8
-rw-r--r--src/google/protobuf/compiler/java/java_context.h8
-rw-r--r--src/google/protobuf/compiler/java/java_doc_comment.cc2
-rw-r--r--src/google/protobuf/compiler/java/java_enum.cc68
-rw-r--r--src/google/protobuf/compiler/java/java_enum.h4
-rw-r--r--src/google/protobuf/compiler/java/java_enum_field.cc5
-rw-r--r--src/google/protobuf/compiler/java/java_enum_field.h4
-rw-r--r--src/google/protobuf/compiler/java/java_enum_field_lite.cc6
-rw-r--r--src/google/protobuf/compiler/java/java_enum_field_lite.h4
-rw-r--r--src/google/protobuf/compiler/java/java_enum_lite.cc6
-rw-r--r--src/google/protobuf/compiler/java/java_enum_lite.h4
-rw-r--r--src/google/protobuf/compiler/java/java_extension.cc12
-rw-r--r--src/google/protobuf/compiler/java/java_extension.h2
-rw-r--r--src/google/protobuf/compiler/java/java_extension_lite.cc2
-rw-r--r--src/google/protobuf/compiler/java/java_field.cc8
-rw-r--r--src/google/protobuf/compiler/java/java_field.h8
-rw-r--r--src/google/protobuf/compiler/java/java_file.cc12
-rw-r--r--src/google/protobuf/compiler/java/java_file.h4
-rw-r--r--src/google/protobuf/compiler/java/java_generator.cc8
-rw-r--r--src/google/protobuf/compiler/java/java_helpers.cc9
-rw-r--r--src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc3
-rw-r--r--src/google/protobuf/compiler/java/java_map_field.cc137
-rw-r--r--src/google/protobuf/compiler/java/java_map_field.h2
-rw-r--r--src/google/protobuf/compiler/java/java_map_field_lite.cc2
-rw-r--r--src/google/protobuf/compiler/java/java_map_field_lite.h2
-rw-r--r--src/google/protobuf/compiler/java/java_message.cc28
-rw-r--r--src/google/protobuf/compiler/java/java_message_builder.cc4
-rw-r--r--src/google/protobuf/compiler/java/java_message_builder_lite.cc2
-rw-r--r--src/google/protobuf/compiler/java/java_message_field.cc2
-rw-r--r--src/google/protobuf/compiler/java/java_message_field.h4
-rw-r--r--src/google/protobuf/compiler/java/java_message_field_lite.cc3
-rw-r--r--src/google/protobuf/compiler/java/java_message_field_lite.h4
-rw-r--r--src/google/protobuf/compiler/java/java_message_lite.cc76
-rw-r--r--src/google/protobuf/compiler/java/java_name_resolver.h2
-rw-r--r--src/google/protobuf/compiler/java/java_primitive_field.cc5
-rw-r--r--src/google/protobuf/compiler/java/java_primitive_field.h4
-rw-r--r--src/google/protobuf/compiler/java/java_primitive_field_lite.cc6
-rw-r--r--src/google/protobuf/compiler/java/java_primitive_field_lite.h4
-rw-r--r--src/google/protobuf/compiler/java/java_service.cc14
-rw-r--r--src/google/protobuf/compiler/java/java_shared_code_generator.cc23
-rw-r--r--src/google/protobuf/compiler/java/java_shared_code_generator.h10
-rw-r--r--src/google/protobuf/compiler/java/java_string_field.cc5
-rw-r--r--src/google/protobuf/compiler/java/java_string_field.h4
-rw-r--r--src/google/protobuf/compiler/java/java_string_field_lite.cc6
-rw-r--r--src/google/protobuf/compiler/java/java_string_field_lite.h4
-rw-r--r--src/google/protobuf/compiler/js/embed.cc112
-rwxr-xr-xsrc/google/protobuf/compiler/js/js_generator.cc412
-rwxr-xr-xsrc/google/protobuf/compiler/js/js_generator.h39
-rw-r--r--src/google/protobuf/compiler/js/well_known_types/any.js80
-rw-r--r--src/google/protobuf/compiler/js/well_known_types/struct.js168
-rw-r--r--src/google/protobuf/compiler/js/well_known_types/timestamp.js54
-rw-r--r--src/google/protobuf/compiler/js/well_known_types_embed.h43
-rw-r--r--src/google/protobuf/compiler/main.cc8
-rw-r--r--src/google/protobuf/compiler/mock_code_generator.cc23
-rw-r--r--src/google/protobuf/compiler/objectivec/objectivec_enum.cc2
-rw-r--r--src/google/protobuf/compiler/objectivec/objectivec_extension.cc5
-rw-r--r--src/google/protobuf/compiler/objectivec/objectivec_helpers.h86
-rw-r--r--src/google/protobuf/compiler/objectivec/objectivec_message.cc21
-rw-r--r--src/google/protobuf/compiler/objectivec/objectivec_message.h1
-rw-r--r--src/google/protobuf/compiler/parser.cc12
-rw-r--r--src/google/protobuf/compiler/parser.h10
-rw-r--r--src/google/protobuf/compiler/parser_unittest.cc10
-rw-r--r--src/google/protobuf/compiler/php/php_generator.cc786
-rw-r--r--src/google/protobuf/compiler/plugin.cc23
-rw-r--r--src/google/protobuf/compiler/plugin.pb.cc1612
-rw-r--r--src/google/protobuf/compiler/plugin.pb.h765
-rw-r--r--src/google/protobuf/compiler/plugin.proto13
-rw-r--r--src/google/protobuf/compiler/python/python_generator.cc57
-rw-r--r--src/google/protobuf/compiler/python/python_generator.h4
-rw-r--r--src/google/protobuf/compiler/subprocess.cc5
-rw-r--r--src/google/protobuf/compiler/zip_writer.h2
-rw-r--r--src/google/protobuf/descriptor.cc291
-rw-r--r--src/google/protobuf/descriptor.h1
-rw-r--r--src/google/protobuf/descriptor.pb.cc7722
-rw-r--r--src/google/protobuf/descriptor.pb.h3120
-rw-r--r--src/google/protobuf/descriptor.proto32
-rw-r--r--src/google/protobuf/descriptor_database.cc47
-rw-r--r--src/google/protobuf/descriptor_database.h34
-rw-r--r--src/google/protobuf/descriptor_database_unittest.cc18
-rw-r--r--src/google/protobuf/descriptor_unittest.cc160
-rw-r--r--src/google/protobuf/duration.pb.cc252
-rw-r--r--src/google/protobuf/duration.pb.h96
-rw-r--r--src/google/protobuf/dynamic_message.cc139
-rw-r--r--src/google/protobuf/dynamic_message.h90
-rw-r--r--src/google/protobuf/empty.pb.cc191
-rw-r--r--src/google/protobuf/empty.pb.h88
-rw-r--r--src/google/protobuf/extension_set.cc4
-rw-r--r--src/google/protobuf/extension_set_heavy.cc20
-rw-r--r--src/google/protobuf/extension_set_unittest.cc10
-rw-r--r--src/google/protobuf/field_mask.pb.cc209
-rw-r--r--src/google/protobuf/field_mask.pb.h104
-rw-r--r--src/google/protobuf/field_mask.proto1
-rw-r--r--src/google/protobuf/generated_message_reflection.cc603
-rw-r--r--src/google/protobuf/generated_message_reflection.h301
-rw-r--r--src/google/protobuf/generated_message_reflection_unittest.cc136
-rw-r--r--src/google/protobuf/generated_message_util.cc10
-rw-r--r--src/google/protobuf/generated_message_util.h22
-rw-r--r--src/google/protobuf/has_bits.h31
-rw-r--r--src/google/protobuf/io/coded_stream.cc143
-rw-r--r--src/google/protobuf/io/coded_stream.h164
-rw-r--r--src/google/protobuf/io/coded_stream_unittest.cc82
-rw-r--r--src/google/protobuf/io/gzip_stream.cc2
-rw-r--r--src/google/protobuf/io/gzip_stream.h2
-rw-r--r--src/google/protobuf/io/printer.cc36
-rw-r--r--src/google/protobuf/io/printer.h18
-rw-r--r--src/google/protobuf/io/printer_unittest.cc30
-rw-r--r--src/google/protobuf/io/tokenizer.cc6
-rw-r--r--src/google/protobuf/io/tokenizer.h2
-rw-r--r--src/google/protobuf/io/tokenizer_unittest.cc17
-rw-r--r--src/google/protobuf/io/zero_copy_stream_impl.cc22
-rw-r--r--src/google/protobuf/io/zero_copy_stream_unittest.cc4
-rw-r--r--src/google/protobuf/map.h18
-rw-r--r--src/google/protobuf/map_entry.h29
-rw-r--r--src/google/protobuf/map_entry_lite.h28
-rw-r--r--src/google/protobuf/map_field_lite.h7
-rw-r--r--src/google/protobuf/map_proto2_unittest.proto2
-rw-r--r--src/google/protobuf/map_test.cc60
-rw-r--r--src/google/protobuf/map_test_util.cc6
-rw-r--r--src/google/protobuf/map_type_handler.h20
-rw-r--r--src/google/protobuf/message.cc44
-rw-r--r--src/google/protobuf/message.h43
-rw-r--r--src/google/protobuf/message_lite.cc14
-rw-r--r--src/google/protobuf/message_lite.h23
-rw-r--r--src/google/protobuf/message_unittest.cc109
-rw-r--r--src/google/protobuf/metadata.h110
-rw-r--r--src/google/protobuf/reflection_ops.cc12
-rw-r--r--src/google/protobuf/reflection_ops_unittest.cc2
-rw-r--r--src/google/protobuf/repeated_field.h136
-rw-r--r--src/google/protobuf/repeated_field_unittest.cc18
-rw-r--r--src/google/protobuf/source_context.pb.cc211
-rw-r--r--src/google/protobuf/source_context.pb.h103
-rw-r--r--src/google/protobuf/source_context.proto1
-rw-r--r--src/google/protobuf/struct.pb.cc634
-rw-r--r--src/google/protobuf/struct.pb.h253
-rw-r--r--src/google/protobuf/stubs/atomicops.h25
-rw-r--r--src/google/protobuf/stubs/atomicops_internals_arm64_gcc.h26
-rw-r--r--src/google/protobuf/stubs/atomicops_internals_arm_gcc.h10
-rw-r--r--src/google/protobuf/stubs/atomicops_internals_arm_qnx.h10
-rw-r--r--src/google/protobuf/stubs/atomicops_internals_generic_c11_atomic.h10
-rw-r--r--src/google/protobuf/stubs/atomicops_internals_generic_gcc.h2
-rw-r--r--src/google/protobuf/stubs/atomicops_internals_macosx.h225
-rw-r--r--src/google/protobuf/stubs/atomicops_internals_mips_gcc.h34
-rw-r--r--src/google/protobuf/stubs/atomicops_internals_power.h2
-rw-r--r--src/google/protobuf/stubs/atomicops_internals_ppc_gcc.h18
-rw-r--r--src/google/protobuf/stubs/atomicops_internals_solaris.h18
-rw-r--r--src/google/protobuf/stubs/atomicops_internals_tsan.h2
-rw-r--r--src/google/protobuf/stubs/atomicops_internals_x86_gcc.h12
-rw-r--r--src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc7
-rw-r--r--src/google/protobuf/stubs/atomicops_internals_x86_msvc.h4
-rw-r--r--src/google/protobuf/stubs/callback.h30
-rw-r--r--src/google/protobuf/stubs/common.cc13
-rw-r--r--src/google/protobuf/stubs/common.h13
-rw-r--r--src/google/protobuf/stubs/hash.h11
-rw-r--r--src/google/protobuf/stubs/mathlimits.h39
-rw-r--r--src/google/protobuf/stubs/mathutil.h23
-rw-r--r--src/google/protobuf/stubs/platform_macros.h2
-rw-r--r--src/google/protobuf/stubs/port.h16
-rw-r--r--src/google/protobuf/stubs/strutil.cc2
-rw-r--r--src/google/protobuf/test_messages_proto3.proto227
-rw-r--r--src/google/protobuf/test_util.cc10
-rw-r--r--src/google/protobuf/text_format.cc92
-rw-r--r--src/google/protobuf/text_format_unittest.cc18
-rw-r--r--src/google/protobuf/timestamp.pb.cc252
-rw-r--r--src/google/protobuf/timestamp.pb.h96
-rw-r--r--src/google/protobuf/type.pb.cc1608
-rw-r--r--src/google/protobuf/type.pb.h588
-rw-r--r--src/google/protobuf/type.proto11
-rw-r--r--src/google/protobuf/unittest.proto31
-rw-r--r--src/google/protobuf/unittest_lite.proto34
-rw-r--r--src/google/protobuf/unknown_field_set.cc18
-rw-r--r--src/google/protobuf/unknown_field_set_unittest.cc11
-rw-r--r--src/google/protobuf/util/field_comparator.h2
-rw-r--r--src/google/protobuf/util/field_comparator_test.cc16
-rw-r--r--src/google/protobuf/util/field_mask_util.cc34
-rw-r--r--src/google/protobuf/util/field_mask_util.h16
-rw-r--r--src/google/protobuf/util/field_mask_util_test.cc21
-rw-r--r--src/google/protobuf/util/internal/constants.h8
-rw-r--r--src/google/protobuf/util/internal/datapiece.cc40
-rw-r--r--src/google/protobuf/util/internal/default_value_objectwriter.cc8
-rw-r--r--src/google/protobuf/util/internal/default_value_objectwriter.h9
-rw-r--r--src/google/protobuf/util/internal/field_mask_utility.cc2
-rw-r--r--src/google/protobuf/util/internal/json_escaping.cc6
-rw-r--r--src/google/protobuf/util/internal/json_stream_parser.cc30
-rw-r--r--src/google/protobuf/util/internal/json_stream_parser.h3
-rw-r--r--src/google/protobuf/util/internal/json_stream_parser_test.cc29
-rw-r--r--src/google/protobuf/util/internal/proto_writer.cc2
-rw-r--r--src/google/protobuf/util/internal/protostream_objectsource.cc38
-rw-r--r--src/google/protobuf/util/internal/protostream_objectsource.h12
-rw-r--r--src/google/protobuf/util/internal/protostream_objectsource_test.cc26
-rw-r--r--src/google/protobuf/util/internal/protostream_objectwriter.cc5
-rw-r--r--src/google/protobuf/util/internal/protostream_objectwriter_test.cc20
-rw-r--r--src/google/protobuf/util/internal/type_info.cc20
-rw-r--r--src/google/protobuf/util/internal/type_info_test_helper.cc6
-rw-r--r--src/google/protobuf/util/internal/type_info_test_helper.h2
-rw-r--r--src/google/protobuf/util/internal/utility.cc28
-rw-r--r--src/google/protobuf/util/json_format_proto3.proto2
-rw-r--r--src/google/protobuf/util/json_util.cc1
-rw-r--r--src/google/protobuf/util/json_util.h6
-rw-r--r--src/google/protobuf/util/json_util_test.cc46
-rw-r--r--src/google/protobuf/util/message_differencer.cc151
-rw-r--r--src/google/protobuf/util/message_differencer.h1
-rwxr-xr-xsrc/google/protobuf/util/message_differencer_unittest.cc65
-rw-r--r--src/google/protobuf/util/time_util.h4
-rw-r--r--src/google/protobuf/util/type_resolver_util.cc56
-rw-r--r--src/google/protobuf/wire_format.cc33
-rw-r--r--src/google/protobuf/wire_format.h3
-rw-r--r--src/google/protobuf/wire_format_lite.cc237
-rw-r--r--src/google/protobuf/wire_format_lite.h36
-rw-r--r--src/google/protobuf/wire_format_lite_inl.h40
-rw-r--r--src/google/protobuf/wire_format_unittest.cc146
-rw-r--r--src/google/protobuf/wrappers.pb.cc1192
-rw-r--r--src/google/protobuf/wrappers.pb.h596
-rwxr-xr-xtests.sh116
610 files changed, 60730 insertions, 28282 deletions
diff --git a/.gitignore b/.gitignore
index ea865f4e..9e10c141 100644
--- a/.gitignore
+++ b/.gitignore
@@ -47,6 +47,7 @@ any_test.pb.*
map*unittest.pb.*
unittest*.pb.*
cpp_test*.pb.*
+src/google/protobuf/compiler/js/well_known_types_embed.cc
src/google/protobuf/util/**/*.pb.cc
src/google/protobuf/util/**/*.pb.h
@@ -60,6 +61,7 @@ python/build/
python/google/protobuf/compiler/
python/google/protobuf/util/
+src/js_embed
src/protoc
src/unittest_proto_middleman
@@ -119,11 +121,16 @@ conformance/lite/
conformance/nonexistent_tests.txt
conformance/protoc_middleman
conformance/succeeding_tests.txt
+conformance/Conformance/
+conformance/GPBMetadata/
+conformance/Google/
+conformance/Protobuf_test_messages/
+conformance/conformance-php
+conformance/conformance-php-c
# php test output
composer.lock
-php/tests/test.pb.php
-php/tests/test_include.pb.php
+php/tests/generated/
php/ext/google/protobuf/.libs/
php/ext/google/protobuf/Makefile.fragments
php/ext/google/protobuf/Makefile.global
diff --git a/.travis.yml b/.travis.yml
index bd9a5dfb..77662993 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,7 +8,7 @@ language: cpp
os:
- osx
# The Objective C build needs Xcode 7.0 or later.
-osx_image: xcode8
+osx_image: xcode8.1
script:
- ./tests.sh $CONFIG
env:
@@ -63,6 +63,10 @@ matrix:
# fetch pre-built Linux protoc binaries in the test.
- os: linux
env: CONFIG=java_compatibility
+ # The Python compatibility test currently only runs on Linux because it will
+ # fetch pre-built Linux protoc binaries in the test.
+ - os: linux
+ env: CONFIG=python_compatibility
allow_failures:
# These currently do not work on OS X but are being worked on by @haberman.
- os: osx
diff --git a/BUILD b/BUILD
index f17c500a..420fa337 100644
--- a/BUILD
+++ b/BUILD
@@ -27,11 +27,11 @@ config_setting(
# Android builds do not need to link in a separate pthread library.
LINK_OPTS = select({
":android": [],
- "//conditions:default": ["-lpthread"],
+ "//conditions:default": ["-lpthread", "-lm"],
})
load(
- "protobuf",
+ ":protobuf.bzl",
"cc_proto_library",
"py_proto_library",
"internal_copied_filegroup",
@@ -227,6 +227,24 @@ cc_proto_library(
# Protocol Buffers Compiler
################################################################################
+cc_binary(
+ name = "js_embed",
+ srcs = ["src/google/protobuf/compiler/js/embed.cc"],
+ visibility = ["//visibility:public"],
+)
+
+genrule(
+ name = "generate_js_well_known_types_embed",
+ srcs = [
+ "src/google/protobuf/compiler/js/well_known_types/any.js",
+ "src/google/protobuf/compiler/js/well_known_types/struct.js",
+ "src/google/protobuf/compiler/js/well_known_types/timestamp.js",
+ ],
+ outs = ["src/google/protobuf/compiler/js/well_known_types_embed.cc"],
+ cmd = "$(location :js_embed) $(SRCS) > $@",
+ tools = [":js_embed"],
+)
+
cc_library(
name = "protoc_lib",
srcs = [
@@ -304,6 +322,7 @@ cc_library(
"src/google/protobuf/compiler/javanano/javanano_message_field.cc",
"src/google/protobuf/compiler/javanano/javanano_primitive_field.cc",
"src/google/protobuf/compiler/js/js_generator.cc",
+ "src/google/protobuf/compiler/js/well_known_types_embed.cc",
"src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
"src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
"src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
@@ -749,3 +768,17 @@ internal_protobuf_py_tests(
],
deps = [":python_tests"],
)
+
+proto_lang_toolchain(
+ name = "cc_toolchain",
+ command_line = "--cpp_out=$(OUT)",
+ runtime = ":protobuf",
+ visibility = ["//visibility:public"],
+)
+
+proto_lang_toolchain(
+ name = "java_toolchain",
+ command_line = "--java_out=$(OUT)",
+ runtime = ":protobuf_java",
+ visibility = ["//visibility:public"],
+)
diff --git a/CHANGES.txt b/CHANGES.txt
index 7fb2da2e..3b02056b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,75 @@
+2017-01-23 version 3.2.0 (C++/Java/Python/PHP/Ruby/Objective-C/C#/JavaScript/Lite)
+ General
+ * Added protoc version number to protoc plugin protocol. It can be used by
+ protoc plugin to detect which version of protoc is used with the plugin and
+ mitigate known problems in certain version of protoc.
+
+ C++
+ * The default parsing byte size limit has been raised from 64MB to 2GB.
+ * Added rvalue setters for non-arena string fields.
+ * Enabled debug logging for Android.
+ * Fixed a double-free problem when using Reflection::SetAllocatedMessage()
+ with extension fields.
+ * Fixed several deterministic serialization bugs:
+ * MessageLite::SerializeAsString() now respects the global deterministic
+ serialization flag.
+ * Extension fields are serialized deterministically as well. Fixed protocol
+ compiler to correctly report importing-self as an error.
+ * Fixed FileDescriptor::DebugString() to print custom options correctly.
+ * Various performance/codesize optimizations and cleanups.
+
+ Java
+ * The default parsing byte size limit has been raised from 64MB to 2GB.
+ * Added recursion limit when parsing JSON.
+ * Fixed a bug that enumType.getDescriptor().getOptions() doesn't have custom
+ options.
+ * Fixed generated code to support field numbers up to 2^29-1.
+
+ Python
+ * You can now assign NumPy scalars/arrays (np.int32, np.int64) to protobuf
+ fields, and assigning other numeric types has been optimized for
+ performance.
+ * Pure-Python: message types are now garbage-collectable.
+ * Python/C++: a lot of internal cleanup/refactoring.
+
+ PHP (Alpha)
+ * For 64-bit integers type (int64/uint64/sfixed64/fixed64/sint64), use PHP
+ integer on 64-bit environment and PHP string on 32-bit environment.
+ * PHP generated code also conforms to PSR-4 now.
+ * Fixed ZTS build for c extension.
+ * Fixed c extension build on Mac.
+ * Fixed c extension build on 32-bit linux.
+ * Fixed the bug that message without namespace is not found in the descriptor
+ pool. (#2240)
+ * Fixed the bug that repeated field is not iterable in c extension.
+ * Message names Empty will be converted to GPBEmpty in generated code.
+ * Added phpdoc in generated files.
+ * The released API is almost stable. Unless there is large problem, we won't
+ change it. See
+ https://developers.google.com/protocol-buffers/docs/reference/php-generated
+ for more details.
+
+ Objective-C
+ * Added support for push/pop of the stream limit on CodedInputStream for
+ anyone doing manual parsing.
+
+ C#
+ * No changes.
+
+ Ruby
+ * Message objects now support #respond_to? for field getters/setters.
+ * You can now compare “message == non_message_object” and it will return false
+ instead of throwing an exception.
+ * JRuby: fixed #hashCode to properly reflect the values in the message.
+
+ Javascript
+ * Deserialization of repeated fields no longer has quadratic performance
+ behavior.
+ * UTF-8 encoding/decoding now properly supports high codepoints.
+ * Added convenience methods for some well-known types: Any, Struct, and
+ Timestamp. These make it easier to convert data between native JavaScript
+ types and the well-known protobuf types.
+
2016-09-23 version 3.1.0 (C++/Java/Python/PHP/Ruby/Objective-C/C#/JavaScript/Lite)
General
* Proto3 support in PHP (alpha).
@@ -40,23 +112,23 @@
APIs and share the same generated code. Users don’t need to re-generate
code for the same proto definition when they want to switch the
implementation later. The pure PHP package is included in the php/src
- directory, and the c extension is included in the php/ext directory.
-
+ directory, and the c extension is included in the php/ext directory.
+
Both implementations provide idiomatic PHP APIs:
* All messages and enums are defined as PHP classes.
* All message fields can only be accessed via getter/setter.
* Both repeated field elements and map elements are stored in containers
that act like a normal PHP array.
-
+
Unlike several existing third-party PHP implementations for protobuf, our
implementations are built on a "strongly-typed" philosophy: message fields
and array/map containers will throw exceptions eagerly when values of the
incorrect type (not including those that can be type converted, e.g.,
double <-> integer <-> numeric string) are inserted.
-
+
Currently, pure PHP runtime supports php5.5, 5.6 and 7 on linux. C
extension runtime supports php5.5 and 5.6 on linux.
-
+
See php/README.md for more details about installment. See
https://developers.google.com/protocol-buffers/docs/phptutorial for more
details about APIs.
diff --git a/Makefile.am b/Makefile.am
index 4763d949..6b520b39 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -60,6 +60,7 @@ csharp_EXTRA_DIST= \
csharp/keys/Google.Protobuf.public.snk \
csharp/keys/Google.Protobuf.snk \
csharp/keys/README.md \
+ csharp/protos/unittest_custom_options_proto3.proto \
csharp/protos/unittest_issues.proto \
csharp/src/AddressBook/AddPerson.cs \
csharp/src/AddressBook/Addressbook.cs \
@@ -82,6 +83,7 @@ csharp_EXTRA_DIST= \
csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs \
csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs \
csharp/src/Google.Protobuf.Test/Compatibility/PropertyInfoExtensionsTest.cs \
+ csharp/src/Google.Protobuf.Test/Compatibility/StreamExtensionsTest.cs \
csharp/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs \
csharp/src/Google.Protobuf.Test/DeprecatedMemberTest.cs \
csharp/src/Google.Protobuf.Test/EqualityTester.cs \
@@ -92,6 +94,7 @@ csharp_EXTRA_DIST= \
csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs \
csharp/src/Google.Protobuf.Test/JsonParserTest.cs \
csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs \
+ csharp/src/Google.Protobuf.Test/Reflection/CustomOptionsTest.cs \
csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs \
csharp/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs \
csharp/src/Google.Protobuf.Test/Reflection/TypeRegistryTest.cs \
@@ -100,6 +103,8 @@ csharp_EXTRA_DIST= \
csharp/src/Google.Protobuf.Test/TestCornerCases.cs \
csharp/src/Google.Protobuf.Test/TestProtos/ForeignMessagePartial.cs \
csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs \
+ csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs \
+ csharp/src/Google.Protobuf.Test/TestProtos/UnittestCustomOptionsProto3.cs \
csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs \
csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportPublicProto3.cs \
csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs \
@@ -121,6 +126,7 @@ csharp_EXTRA_DIST= \
csharp/src/Google.Protobuf/Collections/ReadOnlyDictionary.cs \
csharp/src/Google.Protobuf/Collections/RepeatedField.cs \
csharp/src/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs \
+ csharp/src/Google.Protobuf/Compatibility/StreamExtensions.cs \
csharp/src/Google.Protobuf/Compatibility/TypeExtensions.cs \
csharp/src/Google.Protobuf/FieldCodec.cs \
csharp/src/Google.Protobuf/FrameworkPortability.cs \
@@ -139,6 +145,7 @@ csharp_EXTRA_DIST= \
csharp/src/Google.Protobuf/MessageParser.cs \
csharp/src/Google.Protobuf/ProtoPreconditions.cs \
csharp/src/Google.Protobuf/Properties/AssemblyInfo.cs \
+ csharp/src/Google.Protobuf/Reflection/CustomOptions.cs \
csharp/src/Google.Protobuf/Reflection/Descriptor.cs \
csharp/src/Google.Protobuf/Reflection/DescriptorBase.cs \
csharp/src/Google.Protobuf/Reflection/DescriptorPool.cs \
@@ -185,6 +192,7 @@ csharp_EXTRA_DIST= \
csharp/src/Google.Protobuf/WellKnownTypes/WrappersPartial.cs \
csharp/src/Google.Protobuf/WireFormat.cs \
csharp/src/Google.Protobuf/project.json \
+ csharp/src/global.json \
csharp/src/packages/repositories.config
java_EXTRA_DIST= \
@@ -524,6 +532,7 @@ objectivec_EXTRA_DIST= \
objectivec/Tests/GPBDictionaryTests+String.m \
objectivec/Tests/GPBDictionaryTests+UInt32.m \
objectivec/Tests/GPBDictionaryTests+UInt64.m \
+ objectivec/Tests/GPBDictionaryTests.m \
objectivec/Tests/GPBDictionaryTests.pddm \
objectivec/Tests/GPBMessageTests+Merge.m \
objectivec/Tests/GPBMessageTests+Runtime.m \
@@ -557,6 +566,8 @@ objectivec_EXTRA_DIST= \
objectivec/Tests/text_format_map_unittest_data.txt \
objectivec/Tests/text_format_unittest_data.txt \
objectivec/Tests/unittest_cycle.proto \
+ objectivec/Tests/unittest_deprecated.proto \
+ objectivec/Tests/unittest_deprecated_file.proto \
objectivec/Tests/unittest_extension_chain_a.proto \
objectivec/Tests/unittest_extension_chain_b.proto \
objectivec/Tests/unittest_extension_chain_c.proto \
@@ -572,56 +583,88 @@ objectivec_EXTRA_DIST= \
objectivec/Tests/UnitTests-Info.plist \
Protobuf.podspec
-php_EXTRA_DIST= \
- php/src/phpdoc.dist.xml \
- php/src/Google/Protobuf/Internal/DescriptorPool.php \
- php/src/Google/Protobuf/Internal/OneofField.php \
- php/src/Google/Protobuf/Internal/MapEntry.php \
- php/src/Google/Protobuf/Internal/InputStream.php \
- php/src/Google/Protobuf/Internal/OutputStream.php \
- php/src/Google/Protobuf/Internal/MessageBuilderContext.php \
- php/src/Google/Protobuf/Internal/MapField.php \
- php/src/Google/Protobuf/Internal/RepeatedField.php \
- php/src/Google/Protobuf/Internal/Message.php \
- php/src/Google/Protobuf/Internal/GPBWire.php \
- php/src/Google/Protobuf/Internal/GPBType.php \
- php/src/Google/Protobuf/Internal/GPBLabel.php \
- php/src/Google/Protobuf/Internal/EnumBuilderContext.php \
- php/src/Google/Protobuf/Internal/GPBUtil.php \
- php/src/Google/Protobuf/descriptor_internal.pb.php \
- php/src/Google/Protobuf/descriptor.php \
- php/tests/encode_decode_test.php \
- php/tests/test.sh \
- php/tests/generated_class_test.php \
- php/tests/array_test.php \
- php/tests/php_implementation_test.php \
- php/tests/test_include.proto \
- php/tests/test_include.pb.php \
- php/tests/map_field_test.php \
- php/tests/test_base.php \
- php/tests/test_no_namespace.proto \
- php/tests/test_no_namespace.pb.php \
- php/tests/test_util.php \
- php/tests/test.proto \
- php/tests/test.pb.php \
- php/tests/memory_leak_test.php \
- php/README.md \
- php/ext/google/protobuf/utf8.h \
- php/ext/google/protobuf/message.c \
- php/ext/google/protobuf/utf8.c \
- php/ext/google/protobuf/package.xml \
- php/ext/google/protobuf/upb.h \
- php/ext/google/protobuf/array.c \
- php/ext/google/protobuf/encode_decode.c \
- php/ext/google/protobuf/protobuf.h \
- php/ext/google/protobuf/type_check.c \
- php/ext/google/protobuf/def.c \
- php/ext/google/protobuf/storage.c \
- php/ext/google/protobuf/map.c \
- php/ext/google/protobuf/config.m4 \
- php/ext/google/protobuf/upb.c \
- php/ext/google/protobuf/protobuf.c \
- phpunit.xml \
+php_EXTRA_DIST= \
+ php/src/phpdoc.dist.xml \
+ php/src/Google/Protobuf/Internal/DescriptorPool.php \
+ php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php \
+ php/src/Google/Protobuf/Internal/OneofField.php \
+ php/src/Google/Protobuf/Internal/MessageOptions.php \
+ php/src/Google/Protobuf/Internal/FileDescriptorProto.php \
+ php/src/Google/Protobuf/Internal/MapEntry.php \
+ php/src/Google/Protobuf/Internal/FieldDescriptorProto.php \
+ php/src/Google/Protobuf/Internal/InputStream.php \
+ php/src/Google/Protobuf/Internal/UninterpretedOption.php \
+ php/src/Google/Protobuf/Internal/ServiceOptions.php \
+ php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php \
+ php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php \
+ php/src/Google/Protobuf/Internal/OneofDescriptorProto.php \
+ php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php \
+ php/src/Google/Protobuf/Internal/OutputStream.php \
+ php/src/Google/Protobuf/Internal/MessageBuilderContext.php \
+ php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php \
+ php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php \
+ php/src/Google/Protobuf/Internal/DescriptorProto.php \
+ php/src/Google/Protobuf/Internal/MapField.php \
+ php/src/Google/Protobuf/Internal/MethodDescriptorProto.php \
+ php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php \
+ php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php \
+ php/src/Google/Protobuf/Internal/RepeatedField.php \
+ php/src/Google/Protobuf/Internal/EnumValueOptions.php \
+ php/src/Google/Protobuf/Internal/MethodOptions.php \
+ php/src/Google/Protobuf/Internal/OneofOptions.php \
+ php/src/Google/Protobuf/Internal/Message.php \
+ php/src/Google/Protobuf/Internal/FileOptions.php \
+ php/src/Google/Protobuf/Internal/FileDescriptorSet.php \
+ php/src/Google/Protobuf/Internal/EnumDescriptorProto.php \
+ php/src/Google/Protobuf/Internal/GPBWire.php \
+ php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php \
+ php/src/Google/Protobuf/Internal/FieldOptions.php \
+ php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php \
+ php/src/Google/Protobuf/Internal/FieldDescriptorProto_Type.php \
+ php/src/Google/Protobuf/Internal/GPBType.php \
+ php/src/Google/Protobuf/Internal/FieldOptions_JSType.php \
+ php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php \
+ php/src/Google/Protobuf/Internal/SourceCodeInfo.php \
+ php/src/Google/Protobuf/Internal/EnumOptions.php \
+ php/src/Google/Protobuf/Internal/GPBLabel.php \
+ php/src/Google/Protobuf/Internal/EnumBuilderContext.php \
+ php/src/Google/Protobuf/Internal/GPBUtil.php \
+ php/src/Google/Protobuf/Internal/FieldOptions_CType.php \
+ php/src/Google/Protobuf/descriptor.php \
+ php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php \
+ php/tests/autoload.php \
+ php/tests/encode_decode_test.php \
+ php/tests/test.sh \
+ php/tests/gdb_test.sh \
+ php/tests/generated_class_test.php \
+ php/tests/array_test.php \
+ php/tests/php_implementation_test.php \
+ php/tests/proto/test_include.proto \
+ php/tests/map_field_test.php \
+ php/tests/test_base.php \
+ php/tests/proto/test_no_namespace.proto \
+ php/tests/test_util.php \
+ php/tests/proto/test.proto \
+ php/tests/memory_leak_test.php \
+ php/tests/well_known_test.php \
+ php/README.md \
+ php/ext/google/protobuf/utf8.h \
+ php/ext/google/protobuf/message.c \
+ php/ext/google/protobuf/utf8.c \
+ php/ext/google/protobuf/package.xml \
+ php/ext/google/protobuf/upb.h \
+ php/ext/google/protobuf/array.c \
+ php/ext/google/protobuf/encode_decode.c \
+ php/ext/google/protobuf/protobuf.h \
+ php/ext/google/protobuf/type_check.c \
+ php/ext/google/protobuf/def.c \
+ php/ext/google/protobuf/storage.c \
+ php/ext/google/protobuf/map.c \
+ php/ext/google/protobuf/config.m4 \
+ php/ext/google/protobuf/upb.c \
+ php/ext/google/protobuf/protobuf.c \
+ php/phpunit.xml \
+ php/composer.json \
composer.json
python_EXTRA_DIST= \
@@ -712,6 +755,7 @@ python_EXTRA_DIST= \
python/google/protobuf/pyext/repeated_composite_container.h \
python/google/protobuf/pyext/repeated_scalar_container.cc \
python/google/protobuf/pyext/repeated_scalar_container.h \
+ python/google/protobuf/pyext/safe_numerics.h \
python/google/protobuf/pyext/scoped_pyobject_ptr.h \
python/google/protobuf/reflection.py \
python/google/protobuf/service.py \
@@ -783,6 +827,7 @@ js_EXTRA_DIST= \
js/binary/decoder.js \
js/binary/decoder_test.js \
js/binary/encoder.js \
+ js/binary/message_test.js \
js/binary/proto_test.js \
js/binary/reader.js \
js/binary/reader_test.js \
@@ -816,6 +861,7 @@ js_EXTRA_DIST= \
js/test3.proto \
js/test4.proto \
js/test5.proto \
+ js/test8.proto \
js/test_bootstrap.js \
js/testbinary.proto \
js/testempty.proto
diff --git a/Protobuf.podspec b/Protobuf.podspec
index 217f6d20..4b88a4df 100644
--- a/Protobuf.podspec
+++ b/Protobuf.podspec
@@ -5,7 +5,7 @@
# dependent projects use the :git notation to refer to the library.
Pod::Spec.new do |s|
s.name = 'Protobuf'
- s.version = '3.1.0'
+ s.version = '3.2.0'
s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.'
s.homepage = 'https://github.com/google/protobuf'
s.license = 'New BSD'
@@ -34,7 +34,7 @@ Pod::Spec.new do |s|
s.user_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1' }
s.pod_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1' }
- s.ios.deployment_target = '7.1'
+ s.ios.deployment_target = '7.0'
s.osx.deployment_target = '10.9'
s.watchos.deployment_target = '2.0'
s.requires_arc = false
diff --git a/README.md b/README.md
index 80e556b1..b26e5424 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
Protocol Buffers - Google's data interchange format
===================================================
-[![Build Status](https://travis-ci.org/google/protobuf.svg?branch=master)](https://travis-ci.org/google/protobuf) [![Build status](https://ci.appveyor.com/api/projects/status/73ctee6ua4w2ruin?svg=true)](https://ci.appveyor.com/project/protobuf/protobuf) [![Build Status](https://grpc-testing.appspot.com/buildStatus/icon?job=protobuf_branch)](https://grpc-testing.appspot.com/job/protobuf_branch) [![Build Status](https://grpc-testing.appspot.com/job/protobuf_branch_32/badge/icon)](https://grpc-testing.appspot.com/job/protobuf_branch_32)
+[![Build Status](https://travis-ci.org/google/protobuf.svg?branch=master)](https://travis-ci.org/google/protobuf) [![Build status](https://ci.appveyor.com/api/projects/status/73ctee6ua4w2ruin?svg=true)](https://ci.appveyor.com/project/protobuf/protobuf) [![Build Status](https://grpc-testing.appspot.com/buildStatus/icon?job=protobuf_branch)](https://grpc-testing.appspot.com/job/protobuf_branch) [![Build Status](https://grpc-testing.appspot.com/job/protobuf_branch_32/badge/icon)](https://grpc-testing.appspot.com/job/protobuf_branch_32) [![Build Status](http://ci.bazel.io/buildStatus/icon?job=protobuf)](http://ci.bazel.io/job/protobuf/)
Copyright 2008 Google Inc.
@@ -74,4 +74,4 @@ Usage
The complete documentation for Protocol Buffers is available via the
web at:
- https://developers.google.com/protocol-buffers/
+https://developers.google.com/protocol-buffers/
diff --git a/cmake/extract_includes.bat.in b/cmake/extract_includes.bat.in
index 4b572bb6..87cbc951 100644
--- a/cmake/extract_includes.bat.in
+++ b/cmake/extract_includes.bat.in
@@ -29,6 +29,7 @@ copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_gen
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_names.h include\google\protobuf\compiler\java\java_names.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\javanano\javanano_generator.h include\google\protobuf\compiler\javanano\javanano_generator.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\js\js_generator.h include\google\protobuf\compiler\js\js_generator.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\js\well_known_types_embed.h include\google\protobuf\compiler\js\well_known_types_embed.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\objectivec\objectivec_generator.h include\google\protobuf\compiler\objectivec\objectivec_generator.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\objectivec\objectivec_helpers.h include\google\protobuf\compiler\objectivec\objectivec_helpers.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\parser.h include\google\protobuf\compiler\parser.h
@@ -82,7 +83,6 @@ copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_intern
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_atomicword_compat.h include\google\protobuf\stubs\atomicops_internals_atomicword_compat.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_generic_c11_atomic.h include\google\protobuf\stubs\atomicops_internals_generic_c11_atomic.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_generic_gcc.h include\google\protobuf\stubs\atomicops_internals_generic_gcc.h
-copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_macosx.h include\google\protobuf\stubs\atomicops_internals_macosx.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_mips_gcc.h include\google\protobuf\stubs\atomicops_internals_mips_gcc.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_power.h include\google\protobuf\stubs\atomicops_internals_power.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_ppc_gcc.h include\google\protobuf\stubs\atomicops_internals_ppc_gcc.h
diff --git a/cmake/libprotoc.cmake b/cmake/libprotoc.cmake
index 71c3494c..215abcd8 100644
--- a/cmake/libprotoc.cmake
+++ b/cmake/libprotoc.cmake
@@ -72,6 +72,7 @@ set(libprotoc_files
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_message_field.cc
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc
${protobuf_source_dir}/src/google/protobuf/compiler/js/js_generator.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/js/well_known_types_embed.cc
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum.cc
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_extension.cc
@@ -93,6 +94,18 @@ set(libprotoc_files
${protobuf_source_dir}/src/google/protobuf/compiler/zip_writer.cc
)
+set(js_well_known_types_sources,
+ ${protobuf_source_dir}/src/google/protobuf/compiler/js/well_known_types/any.js
+ ${protobuf_source_dir}/src/google/protobuf/compiler/js/well_known_types/struct.js
+ ${protobuf_source_dir}/src/google/protobuf/compiler/js/well_known_types/timestamp.js
+)
+add_executable(js_embed ${protobuf_source_dir}/src/google/protobuf/compiler/js/embed.cc)
+add_custom_command(
+ OUTPUT ${protobuf_source_dir}/src/google/protobuf/compiler/js/well_known_types_embed.cc
+ DEPENDS js_embed ${js_well_known_types_sources}
+ COMMAND js_embed ${js_well_known_types_sources} > ${protobuf_source_dir}/src/google/protobuf/compiler/js/well_known_types_embed.cc
+)
+
add_library(libprotoc ${protobuf_SHARED_OR_STATIC}
${libprotoc_files})
target_link_libraries(libprotoc libprotobuf)
diff --git a/cmake/tests.cmake b/cmake/tests.cmake
index 30214e7d..bf8e5a6c 100644
--- a/cmake/tests.cmake
+++ b/cmake/tests.cmake
@@ -214,4 +214,5 @@ target_link_libraries(lite-arena-test libprotobuf-lite gmock_main)
add_custom_target(check
COMMAND tests
+ DEPENDS tests test_plugin
WORKING_DIRECTORY ${protobuf_source_dir})
diff --git a/composer.json b/composer.json
index 6afe71ce..2b04e079 100644
--- a/composer.json
+++ b/composer.json
@@ -13,11 +13,11 @@
},
"autoload": {
"psr-4": {
- "Google\\": "php/src/Google"
+ "Google\\Protobuf\\Internal\\": "php/src/Google/Protobuf/Internal",
+ "GPBMetadata\\Google\\Protobuf\\Internal\\": "php/src/GPBMetadata/Google/Protobuf/Internal"
},
"files": [
- "php/src/Google/Protobuf/descriptor.php",
- "php/src/Google/Protobuf/descriptor_internal.pb.php"
+ "php/src/Google/Protobuf/descriptor.php"
]
}
}
diff --git a/configure.ac b/configure.ac
index 896f3471..6d9c2a01 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,7 +17,7 @@ AC_PREREQ(2.59)
# In the SVN trunk, the version should always be the next anticipated release
# version with the "-pre" suffix. (We used to use "-SNAPSHOT" but this pushed
# the size of one file name in the dist tarfile over the 99-char limit.)
-AC_INIT([Protocol Buffers],[3.1.0],[protobuf@googlegroups.com],[protobuf])
+AC_INIT([Protocol Buffers],[3.2.0],[protobuf@googlegroups.com],[protobuf])
AM_MAINTAINER_MODE([enable])
@@ -60,6 +60,7 @@ AC_ARG_WITH([protoc],
# Checks for programs.
AC_PROG_CC
AC_PROG_CXX
+AC_PROG_CXX_FOR_BUILD
AC_LANG([C++])
ACX_USE_SYSTEM_EXTENSIONS
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
@@ -178,6 +179,8 @@ case "$target_os" in
esac
AM_CONDITIONAL([OBJC_CONFORMANCE_TEST], [test $OBJC_CONFORMANCE_TEST = 1])
+AX_CXX_COMPILE_STDCXX([11], [noext], [optional])
+
# HACK: Make gmock's configure script pick up our copy of CFLAGS and CXXFLAGS,
# since the flags added by ACX_CHECK_SUNCC must be used when compiling gmock
# too.
diff --git a/conformance/ConformanceJava.java b/conformance/ConformanceJava.java
index 43787ffc..7badf2a5 100644
--- a/conformance/ConformanceJava.java
+++ b/conformance/ConformanceJava.java
@@ -1,8 +1,12 @@
-
+import com.google.protobuf.ByteString;
+import com.google.protobuf.CodedInputStream;
import com.google.protobuf.conformance.Conformance;
+import com.google.protobuf.InvalidProtocolBufferException;
+import com.google.protobuf_test_messages.proto3.TestMessagesProto3;
import com.google.protobuf.util.JsonFormat;
import com.google.protobuf.util.JsonFormat.TypeRegistry;
-import com.google.protobuf.InvalidProtocolBufferException;
+import java.io.IOException;
+import java.nio.ByteBuffer;
class ConformanceJava {
private int testCount = 0;
@@ -47,13 +51,182 @@ class ConformanceJava {
writeToStdout(buf);
}
+ private enum BinaryDecoder {
+ BYTE_STRING_DECODER() {
+ @Override
+ public TestMessagesProto3.TestAllTypes parse(ByteString bytes)
+ throws InvalidProtocolBufferException {
+ return TestMessagesProto3.TestAllTypes.parseFrom(bytes);
+ }
+ },
+ BYTE_ARRAY_DECODER() {
+ @Override
+ public TestMessagesProto3.TestAllTypes parse(ByteString bytes)
+ throws InvalidProtocolBufferException {
+ return TestMessagesProto3.TestAllTypes.parseFrom(bytes.toByteArray());
+ }
+ },
+ ARRAY_BYTE_BUFFER_DECODER() {
+ @Override
+ public TestMessagesProto3.TestAllTypes parse(ByteString bytes)
+ throws InvalidProtocolBufferException {
+ ByteBuffer buffer = ByteBuffer.allocate(bytes.size());
+ bytes.copyTo(buffer);
+ buffer.flip();
+ try {
+ return TestMessagesProto3.TestAllTypes.parseFrom(CodedInputStream.newInstance(buffer));
+ } catch (InvalidProtocolBufferException e) {
+ throw e;
+ } catch (IOException e) {
+ throw new RuntimeException(
+ "ByteString based ByteBuffer should not throw IOException.", e);
+ }
+ }
+ },
+ READONLY_ARRAY_BYTE_BUFFER_DECODER() {
+ @Override
+ public TestMessagesProto3.TestAllTypes parse(ByteString bytes)
+ throws InvalidProtocolBufferException {
+ try {
+ return TestMessagesProto3.TestAllTypes.parseFrom(
+ CodedInputStream.newInstance(bytes.asReadOnlyByteBuffer()));
+ } catch (InvalidProtocolBufferException e) {
+ throw e;
+ } catch (IOException e) {
+ throw new RuntimeException(
+ "ByteString based ByteBuffer should not throw IOException.", e);
+ }
+ }
+ },
+ DIRECT_BYTE_BUFFER_DECODER() {
+ @Override
+ public TestMessagesProto3.TestAllTypes parse(ByteString bytes)
+ throws InvalidProtocolBufferException {
+ ByteBuffer buffer = ByteBuffer.allocateDirect(bytes.size());
+ bytes.copyTo(buffer);
+ buffer.flip();
+ try {
+ return TestMessagesProto3.TestAllTypes.parseFrom(CodedInputStream.newInstance(buffer));
+ } catch (InvalidProtocolBufferException e) {
+ throw e;
+ } catch (IOException e) {
+ throw new RuntimeException(
+ "ByteString based ByteBuffer should not throw IOException.", e);
+ }
+ }
+ },
+ READONLY_DIRECT_BYTE_BUFFER_DECODER() {
+ @Override
+ public TestMessagesProto3.TestAllTypes parse(ByteString bytes)
+ throws InvalidProtocolBufferException {
+ ByteBuffer buffer = ByteBuffer.allocateDirect(bytes.size());
+ bytes.copyTo(buffer);
+ buffer.flip();
+ try {
+ return TestMessagesProto3.TestAllTypes.parseFrom(
+ CodedInputStream.newInstance(buffer.asReadOnlyBuffer()));
+ } catch (InvalidProtocolBufferException e) {
+ throw e;
+ } catch (IOException e) {
+ throw new RuntimeException(
+ "ByteString based ByteBuffer should not throw IOException.", e);
+ }
+ }
+ },
+ INPUT_STREAM_DECODER() {
+ @Override
+ public TestMessagesProto3.TestAllTypes parse(ByteString bytes)
+ throws InvalidProtocolBufferException {
+ try {
+ return TestMessagesProto3.TestAllTypes.parseFrom(bytes.newInput());
+ } catch (InvalidProtocolBufferException e) {
+ throw e;
+ } catch (IOException e) {
+ throw new RuntimeException(
+ "ByteString based InputStream should not throw IOException.", e);
+ }
+ }
+ };
+
+ public abstract TestMessagesProto3.TestAllTypes parse(ByteString bytes)
+ throws InvalidProtocolBufferException;
+ }
+
+ private TestMessagesProto3.TestAllTypes parseBinary(ByteString bytes)
+ throws InvalidProtocolBufferException {
+ TestMessagesProto3.TestAllTypes[] messages =
+ new TestMessagesProto3.TestAllTypes[BinaryDecoder.values().length];
+ InvalidProtocolBufferException[] exceptions =
+ new InvalidProtocolBufferException[BinaryDecoder.values().length];
+
+ boolean hasMessage = false;
+ boolean hasException = false;
+ for (int i = 0; i < BinaryDecoder.values().length; ++i) {
+ try {
+ messages[i] = BinaryDecoder.values()[i].parse(bytes);
+ hasMessage = true;
+ } catch (InvalidProtocolBufferException e) {
+ exceptions[i] = e;
+ hasException = true;
+ }
+ }
+
+ if (hasMessage && hasException) {
+ StringBuilder sb =
+ new StringBuilder("Binary decoders disagreed on whether the payload was valid.\n");
+ for (int i = 0; i < BinaryDecoder.values().length; ++i) {
+ sb.append(BinaryDecoder.values()[i].name());
+ if (messages[i] != null) {
+ sb.append(" accepted the payload.\n");
+ } else {
+ sb.append(" rejected the payload.\n");
+ }
+ }
+ throw new RuntimeException(sb.toString());
+ }
+
+ if (hasException) {
+ // We do not check if exceptions are equal. Different implementations may return different
+ // exception messages. Throw an arbitrary one out instead.
+ throw exceptions[0];
+ }
+
+ // Fast path comparing all the messages with the first message, assuming equality being
+ // symmetric and transitive.
+ boolean allEqual = true;
+ for (int i = 1; i < messages.length; ++i) {
+ if (!messages[0].equals(messages[i])) {
+ allEqual = false;
+ break;
+ }
+ }
+
+ // Slow path: compare and find out all unequal pairs.
+ if (!allEqual) {
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < messages.length - 1; ++i) {
+ for (int j = i + 1; j < messages.length; ++j) {
+ if (!messages[i].equals(messages[j])) {
+ sb.append(BinaryDecoder.values()[i].name())
+ .append(" and ")
+ .append(BinaryDecoder.values()[j].name())
+ .append(" parsed the payload differently.\n");
+ }
+ }
+ }
+ throw new RuntimeException(sb.toString());
+ }
+
+ return messages[0];
+ }
+
private Conformance.ConformanceResponse doTest(Conformance.ConformanceRequest request) {
- Conformance.TestAllTypes testMessage;
+ TestMessagesProto3.TestAllTypes testMessage;
switch (request.getPayloadCase()) {
case PROTOBUF_PAYLOAD: {
try {
- testMessage = Conformance.TestAllTypes.parseFrom(request.getProtobufPayload());
+ testMessage = parseBinary(request.getProtobufPayload());
} catch (InvalidProtocolBufferException e) {
return Conformance.ConformanceResponse.newBuilder().setParseError(e.getMessage()).build();
}
@@ -61,7 +234,7 @@ class ConformanceJava {
}
case JSON_PAYLOAD: {
try {
- Conformance.TestAllTypes.Builder builder = Conformance.TestAllTypes.newBuilder();
+ TestMessagesProto3.TestAllTypes.Builder builder = TestMessagesProto3.TestAllTypes.newBuilder();
JsonFormat.parser().usingTypeRegistry(typeRegistry)
.merge(request.getJsonPayload(), builder);
testMessage = builder.build();
@@ -127,7 +300,7 @@ class ConformanceJava {
public void run() throws Exception {
typeRegistry = TypeRegistry.newBuilder().add(
- Conformance.TestAllTypes.getDescriptor()).build();
+ TestMessagesProto3.TestAllTypes.getDescriptor()).build();
while (doTestIo()) {
this.testCount++;
}
diff --git a/conformance/Makefile.am b/conformance/Makefile.am
index 5985e1d9..cf7eee3a 100644
--- a/conformance/Makefile.am
+++ b/conformance/Makefile.am
@@ -1,7 +1,8 @@
## Process this file with automake to produce Makefile.in
conformance_protoc_inputs = \
- conformance.proto
+ conformance.proto \
+ $(top_srcdir)/src/google/protobuf/test_messages_proto3.proto
well_known_type_protoc_inputs = \
$(top_srcdir)/src/google/protobuf/any.proto \
@@ -61,6 +62,7 @@ other_language_protoc_outputs = \
com/google/protobuf/Value.java \
com/google/protobuf/ValueOrBuilder.java \
com/google/protobuf/WrappersProto.java \
+ com/google/protobuf_test_messages/proto3/TestMessagesProto3.java \
google/protobuf/any.pb.cc \
google/protobuf/any.pb.h \
google/protobuf/any.rb \
@@ -77,6 +79,12 @@ other_language_protoc_outputs = \
google/protobuf/struct.pb.h \
google/protobuf/struct.rb \
google/protobuf/struct_pb2.py \
+ google/protobuf/TestMessagesProto3.pbobjc.h \
+ google/protobuf/TestMessagesProto3.pbobjc.m \
+ google/protobuf/test_messages_proto3.pb.cc \
+ google/protobuf/test_messages_proto3.pb.h \
+ google/protobuf/test_messages_proto3_pb.rb \
+ google/protobuf/test_messages_proto3_pb2.py \
google/protobuf/timestamp.pb.cc \
google/protobuf/timestamp.pb.h \
google/protobuf/timestamp.rb \
@@ -84,7 +92,40 @@ other_language_protoc_outputs = \
google/protobuf/wrappers.pb.cc \
google/protobuf/wrappers.pb.h \
google/protobuf/wrappers.rb \
- google/protobuf/wrappers_pb2.py
+ google/protobuf/wrappers_pb2.py \
+ Conformance/ConformanceRequest.php \
+ Conformance/ConformanceResponse.php \
+ Conformance/WireFormat.php \
+ GPBMetadata/Conformance.php \
+ GPBMetadata/Google/Protobuf/Any.php \
+ GPBMetadata/Google/Protobuf/Duration.php \
+ GPBMetadata/Google/Protobuf/FieldMask.php \
+ GPBMetadata/Google/Protobuf/Struct.php \
+ GPBMetadata/Google/Protobuf/TestMessagesProto3.php \
+ GPBMetadata/Google/Protobuf/Timestamp.php \
+ GPBMetadata/Google/Protobuf/Wrappers.php \
+ Google/Protobuf/Any.php \
+ Google/Protobuf/BoolValue.php \
+ Google/Protobuf/BytesValue.php \
+ Google/Protobuf/DoubleValue.php \
+ Google/Protobuf/Duration.php \
+ Google/Protobuf/FieldMask.php \
+ Google/Protobuf/FloatValue.php \
+ Google/Protobuf/Int32Value.php \
+ Google/Protobuf/Int64Value.php \
+ Google/Protobuf/ListValue.php \
+ Google/Protobuf/NullValue.php \
+ Google/Protobuf/StringValue.php \
+ Google/Protobuf/Struct.php \
+ Google/Protobuf/Timestamp.php \
+ Google/Protobuf/UInt32Value.php \
+ Google/Protobuf/UInt64Value.php \
+ Google/Protobuf/Value.php \
+ Protobuf_test_messages/Proto3/ForeignEnum.php \
+ Protobuf_test_messages/Proto3/ForeignMessage.php \
+ Protobuf_test_messages/Proto3/TestAllTypes_NestedEnum.php \
+ Protobuf_test_messages/Proto3/TestAllTypes_NestedMessage.php \
+ Protobuf_test_messages/Proto3/TestAllTypes.php
# lite/com/google/protobuf/Any.java \
# lite/com/google/protobuf/AnyOrBuilder.java \
# lite/com/google/protobuf/AnyProto.java \
@@ -138,6 +179,7 @@ EXTRA_DIST = \
conformance.proto \
conformance_python.py \
conformance_ruby.rb \
+ conformance_php.php \
failure_list_cpp.txt \
failure_list_csharp.txt \
failure_list_java.txt \
@@ -145,14 +187,16 @@ EXTRA_DIST = \
failure_list_python.txt \
failure_list_python_cpp.txt \
failure_list_python-post26.txt \
- failure_list_ruby.txt
+ failure_list_ruby.txt \
+ failure_list_php.txt \
+ failure_list_php_c.txt
conformance_test_runner_LDADD = $(top_srcdir)/src/libprotobuf.la
conformance_test_runner_SOURCES = conformance_test.h conformance_test.cc \
conformance_test_runner.cc \
third_party/jsoncpp/json.h \
third_party/jsoncpp/jsoncpp.cpp
-nodist_conformance_test_runner_SOURCES = conformance.pb.cc
+nodist_conformance_test_runner_SOURCES = conformance.pb.cc google/protobuf/test_messages_proto3.pb.cc
conformance_test_runner_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir)
conformance_test_runner_CXXFLAGS = -std=c++11
# Explicit deps beacuse BUILT_SOURCES are only done before a "make all/check"
@@ -162,7 +206,7 @@ conformance_test_runner-conformance_test_runner.$(OBJEXT): conformance.pb.h
conformance_cpp_LDADD = $(top_srcdir)/src/libprotobuf.la
conformance_cpp_SOURCES = conformance_cpp.cc
-nodist_conformance_cpp_SOURCES = conformance.pb.cc
+nodist_conformance_cpp_SOURCES = conformance.pb.cc google/protobuf/test_messages_proto3.pb.cc
conformance_cpp_CPPFLAGS = -I$(top_srcdir)/src
# Explicit dep beacuse BUILT_SOURCES are only done before a "make all/check"
# so a direct "make test_cpp" could fail if parallel enough.
@@ -173,7 +217,7 @@ if OBJC_CONFORMANCE_TEST
bin_PROGRAMS += conformance-objc
conformance_objc_SOURCES = conformance_objc.m ../objectivec/GPBProtocolBuffers.m
-nodist_conformance_objc_SOURCES = Conformance.pbobjc.m
+nodist_conformance_objc_SOURCES = Conformance.pbobjc.m google/protobuf/TestMessagesProto3.pbobjc.m
# On travis, the build fails without the isysroot because whatever system
# headers are being found don't include generics support for
# NSArray/NSDictionary, the only guess is their image at one time had an odd
@@ -182,7 +226,7 @@ conformance_objc_CPPFLAGS = -I$(top_srcdir)/objectivec -isysroot `xcrun --sdk ma
conformance_objc_LDFLAGS = -framework Foundation
# Explicit dep beacuse BUILT_SOURCES are only done before a "make all/check"
# so a direct "make test_objc" could fail if parallel enough.
-conformance_objc-conformance_objc.$(OBJEXT): Conformance.pbobjc.h
+conformance_objc-conformance_objc.$(OBJEXT): Conformance.pbobjc.h google/protobuf/TestMessagesProto3.pbobjc.h
endif
@@ -190,8 +234,8 @@ if USE_EXTERNAL_PROTOC
# Some implementations include pre-generated versions of well-known types.
protoc_middleman: $(conformance_protoc_inputs) $(well_known_type_protoc_inputs)
- $(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --objc_out=. --python_out=. $(conformance_protoc_inputs)
- $(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --python_out=. $(well_known_type_protoc_inputs)
+ $(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --objc_out=. --python_out=. --php_out=. $(conformance_protoc_inputs)
+ $(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --python_out=. --php_out=. $(well_known_type_protoc_inputs)
## $(PROTOC) -I$(srcdir) -I$(top_srcdir) --java_out=lite:lite $(conformance_protoc_inputs) $(well_known_type_protoc_inputs)
touch protoc_middleman
@@ -201,8 +245,8 @@ else
# relative to srcdir, which may not be the same as the current directory when
# building out-of-tree.
protoc_middleman: $(top_srcdir)/src/protoc$(EXEEXT) $(conformance_protoc_inputs) $(well_known_type_protoc_inputs)
- oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --objc_out=$$oldpwd --python_out=$$oldpwd $(conformance_protoc_inputs) )
- oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --python_out=$$oldpwd $(well_known_type_protoc_inputs) )
+ oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --objc_out=$$oldpwd --python_out=$$oldpwd --php_out=$$oldpwd $(conformance_protoc_inputs) )
+ oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --python_out=$$oldpwd --php_out=$$oldpwd $(well_known_type_protoc_inputs) )
## @mkdir -p lite
## oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --java_out=lite:$$oldpwd/lite $(conformance_protoc_inputs) $(well_known_type_protoc_inputs) )
touch protoc_middleman
@@ -215,13 +259,13 @@ $(other_language_protoc_outputs): protoc_middleman
BUILT_SOURCES = $(protoc_outputs) $(other_language_protoc_outputs)
-CLEANFILES = $(protoc_outputs) protoc_middleman javac_middleman conformance-java javac_middleman_lite conformance-java-lite conformance-csharp $(other_language_protoc_outputs)
+CLEANFILES = $(protoc_outputs) protoc_middleman javac_middleman conformance-java javac_middleman_lite conformance-java-lite conformance-csharp conformance-php conformance-php-c $(other_language_protoc_outputs)
MAINTAINERCLEANFILES = \
Makefile.in
javac_middleman: ConformanceJava.java protoc_middleman $(other_language_protoc_outputs)
- jar=`ls ../java/util/target/*jar-with-dependencies.jar` && javac -classpath ../java/target/classes:$$jar ConformanceJava.java com/google/protobuf/conformance/Conformance.java
+ jar=`ls ../java/util/target/*jar-with-dependencies.jar` && javac -classpath ../java/target/classes:$$jar ConformanceJava.java com/google/protobuf/conformance/Conformance.java com/google/protobuf_test_messages/proto3/TestMessagesProto3.java
@touch javac_middleman
conformance-java: javac_middleman
@@ -249,6 +293,18 @@ conformance-csharp: $(other_language_protoc_outputs)
@echo 'dotnet ../csharp/src/Google.Protobuf.Conformance/bin/Release/netcoreapp1.0/Google.Protobuf.Conformance.dll "$$@"' >> conformance-csharp
@chmod +x conformance-csharp
+conformance-php:
+ @echo "Writing shortcut script conformance-php..."
+ @echo '#! /bin/sh' > conformance-php
+ @echo 'php ./conformance_php.php' >> conformance-php
+ @chmod +x conformance-php
+
+conformance-php-c:
+ @echo "Writing shortcut script conformance-php-c..."
+ @echo '#! /bin/sh' > conformance-php-c
+ @echo 'php -dextension=../php/ext/google/protobuf/modules/protobuf.so ./conformance_php.php' >> conformance-php-c
+ @chmod +x conformance-php-c
+
# Targets for actually running tests.
test_cpp: protoc_middleman conformance-test-runner conformance-cpp
./conformance-test-runner --enforce_recommended --failure_list failure_list_cpp.txt ./conformance-cpp
@@ -265,6 +321,12 @@ test_csharp: protoc_middleman conformance-test-runner conformance-csharp
test_ruby: protoc_middleman conformance-test-runner $(other_language_protoc_outputs)
RUBYLIB=../ruby/lib:. ./conformance-test-runner --enforce_recommended --failure_list failure_list_ruby.txt ./conformance_ruby.rb
+test_php: protoc_middleman conformance-test-runner conformance-php $(other_language_protoc_outputs)
+ ./conformance-test-runner --enforce_recommended --failure_list failure_list_php.txt ./conformance-php
+
+test_php_c: protoc_middleman conformance-test-runner conformance-php-c $(other_language_protoc_outputs)
+ ./conformance-test-runner --enforce_recommended --failure_list failure_list_php_c.txt ./conformance-php-c
+
# These depend on library paths being properly set up. The easiest way to
# run them is to just use "tox" from the python dir.
test_python: protoc_middleman conformance-test-runner
diff --git a/conformance/conformance.proto b/conformance/conformance.proto
index 95a8fd13..18e4b7bc 100644
--- a/conformance/conformance.proto
+++ b/conformance/conformance.proto
@@ -32,13 +32,6 @@ syntax = "proto3";
package conformance;
option java_package = "com.google.protobuf.conformance";
-import "google/protobuf/any.proto";
-import "google/protobuf/duration.proto";
-import "google/protobuf/field_mask.proto";
-import "google/protobuf/struct.proto";
-import "google/protobuf/timestamp.proto";
-import "google/protobuf/wrappers.proto";
-
// This defines the conformance testing protocol. This protocol exists between
// the conformance test suite itself and the code being tested. For each test,
// the suite will send a ConformanceRequest message and expect a
@@ -70,8 +63,13 @@ enum WireFormat {
// 2. parse the protobuf or JSON payload in "payload" (which may fail)
// 3. if the parse succeeded, serialize the message in the requested format.
message ConformanceRequest {
- // The payload (whether protobuf of JSON) is always for a TestAllTypes proto
- // (see below).
+ // The payload (whether protobuf of JSON) is always for a
+ // protobuf_test_messages.proto3.TestAllTypes proto (as defined in
+ // src/google/protobuf/proto3_test_messages.proto).
+ //
+ // TODO(haberman): if/when we expand the conformance tests to support proto2,
+ // we will want to include a field that lets the payload/response be a
+ // protobuf_test_messages.proto2.TestAllTypes message instead.
oneof payload {
bytes protobuf_payload = 1;
string json_payload = 2;
@@ -114,172 +112,3 @@ message ConformanceResponse {
string skipped = 5;
}
}
-
-// This proto includes every type of field in both singular and repeated
-// forms.
-message TestAllTypes {
- message NestedMessage {
- int32 a = 1;
- TestAllTypes corecursive = 2;
- }
-
- enum NestedEnum {
- FOO = 0;
- BAR = 1;
- BAZ = 2;
- NEG = -1; // Intentionally negative.
- }
-
- // Singular
- int32 optional_int32 = 1;
- int64 optional_int64 = 2;
- uint32 optional_uint32 = 3;
- uint64 optional_uint64 = 4;
- sint32 optional_sint32 = 5;
- sint64 optional_sint64 = 6;
- fixed32 optional_fixed32 = 7;
- fixed64 optional_fixed64 = 8;
- sfixed32 optional_sfixed32 = 9;
- sfixed64 optional_sfixed64 = 10;
- float optional_float = 11;
- double optional_double = 12;
- bool optional_bool = 13;
- string optional_string = 14;
- bytes optional_bytes = 15;
-
- NestedMessage optional_nested_message = 18;
- ForeignMessage optional_foreign_message = 19;
-
- NestedEnum optional_nested_enum = 21;
- ForeignEnum optional_foreign_enum = 22;
-
- string optional_string_piece = 24 [ctype=STRING_PIECE];
- string optional_cord = 25 [ctype=CORD];
-
- TestAllTypes recursive_message = 27;
-
- // Repeated
- repeated int32 repeated_int32 = 31;
- repeated int64 repeated_int64 = 32;
- repeated uint32 repeated_uint32 = 33;
- repeated uint64 repeated_uint64 = 34;
- repeated sint32 repeated_sint32 = 35;
- repeated sint64 repeated_sint64 = 36;
- repeated fixed32 repeated_fixed32 = 37;
- repeated fixed64 repeated_fixed64 = 38;
- repeated sfixed32 repeated_sfixed32 = 39;
- repeated sfixed64 repeated_sfixed64 = 40;
- repeated float repeated_float = 41;
- repeated double repeated_double = 42;
- repeated bool repeated_bool = 43;
- repeated string repeated_string = 44;
- repeated bytes repeated_bytes = 45;
-
- repeated NestedMessage repeated_nested_message = 48;
- repeated ForeignMessage repeated_foreign_message = 49;
-
- repeated NestedEnum repeated_nested_enum = 51;
- repeated ForeignEnum repeated_foreign_enum = 52;
-
- repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
- repeated string repeated_cord = 55 [ctype=CORD];
-
- // Map
- map < int32, int32> map_int32_int32 = 56;
- map < int64, int64> map_int64_int64 = 57;
- map < uint32, uint32> map_uint32_uint32 = 58;
- map < uint64, uint64> map_uint64_uint64 = 59;
- map < sint32, sint32> map_sint32_sint32 = 60;
- map < sint64, sint64> map_sint64_sint64 = 61;
- map < fixed32, fixed32> map_fixed32_fixed32 = 62;
- map < fixed64, fixed64> map_fixed64_fixed64 = 63;
- map <sfixed32, sfixed32> map_sfixed32_sfixed32 = 64;
- map <sfixed64, sfixed64> map_sfixed64_sfixed64 = 65;
- map < int32, float> map_int32_float = 66;
- map < int32, double> map_int32_double = 67;
- map < bool, bool> map_bool_bool = 68;
- map < string, string> map_string_string = 69;
- map < string, bytes> map_string_bytes = 70;
- map < string, NestedMessage> map_string_nested_message = 71;
- map < string, ForeignMessage> map_string_foreign_message = 72;
- map < string, NestedEnum> map_string_nested_enum = 73;
- map < string, ForeignEnum> map_string_foreign_enum = 74;
-
- oneof oneof_field {
- uint32 oneof_uint32 = 111;
- NestedMessage oneof_nested_message = 112;
- string oneof_string = 113;
- bytes oneof_bytes = 114;
- bool oneof_bool = 115;
- uint64 oneof_uint64 = 116;
- float oneof_float = 117;
- double oneof_double = 118;
- NestedEnum oneof_enum = 119;
- }
-
- // Well-known types
- google.protobuf.BoolValue optional_bool_wrapper = 201;
- google.protobuf.Int32Value optional_int32_wrapper = 202;
- google.protobuf.Int64Value optional_int64_wrapper = 203;
- google.protobuf.UInt32Value optional_uint32_wrapper = 204;
- google.protobuf.UInt64Value optional_uint64_wrapper = 205;
- google.protobuf.FloatValue optional_float_wrapper = 206;
- google.protobuf.DoubleValue optional_double_wrapper = 207;
- google.protobuf.StringValue optional_string_wrapper = 208;
- google.protobuf.BytesValue optional_bytes_wrapper = 209;
-
- repeated google.protobuf.BoolValue repeated_bool_wrapper = 211;
- repeated google.protobuf.Int32Value repeated_int32_wrapper = 212;
- repeated google.protobuf.Int64Value repeated_int64_wrapper = 213;
- repeated google.protobuf.UInt32Value repeated_uint32_wrapper = 214;
- repeated google.protobuf.UInt64Value repeated_uint64_wrapper = 215;
- repeated google.protobuf.FloatValue repeated_float_wrapper = 216;
- repeated google.protobuf.DoubleValue repeated_double_wrapper = 217;
- repeated google.protobuf.StringValue repeated_string_wrapper = 218;
- repeated google.protobuf.BytesValue repeated_bytes_wrapper = 219;
-
- google.protobuf.Duration optional_duration = 301;
- google.protobuf.Timestamp optional_timestamp = 302;
- google.protobuf.FieldMask optional_field_mask = 303;
- google.protobuf.Struct optional_struct = 304;
- google.protobuf.Any optional_any = 305;
- google.protobuf.Value optional_value = 306;
-
- repeated google.protobuf.Duration repeated_duration = 311;
- repeated google.protobuf.Timestamp repeated_timestamp = 312;
- repeated google.protobuf.FieldMask repeated_fieldmask = 313;
- repeated google.protobuf.Struct repeated_struct = 324;
- repeated google.protobuf.Any repeated_any = 315;
- repeated google.protobuf.Value repeated_value = 316;
-
- // Test field-name-to-JSON-name convention.
- // (protobuf says names can be any valid C/C++ identifier.)
- int32 fieldname1 = 401;
- int32 field_name2 = 402;
- int32 _field_name3 = 403;
- int32 field__name4_ = 404;
- int32 field0name5 = 405;
- int32 field_0_name6 = 406;
- int32 fieldName7 = 407;
- int32 FieldName8 = 408;
- int32 field_Name9 = 409;
- int32 Field_Name10 = 410;
- int32 FIELD_NAME11 = 411;
- int32 FIELD_name12 = 412;
- int32 __field_name13 = 413;
- int32 __Field_name14 = 414;
- int32 field__name15 = 415;
- int32 field__Name16 = 416;
- int32 field_name17__ = 417;
- int32 Field_name18__ = 418;
-}
-
-message ForeignMessage {
- int32 c = 1;
-}
-
-enum ForeignEnum {
- FOREIGN_FOO = 0;
- FOREIGN_BAR = 1;
- FOREIGN_BAZ = 2;
-}
diff --git a/conformance/conformance_cpp.cc b/conformance/conformance_cpp.cc
index 1a265493..b865cd93 100644
--- a/conformance/conformance_cpp.cc
+++ b/conformance/conformance_cpp.cc
@@ -33,12 +33,12 @@
#include <unistd.h>
#include "conformance.pb.h"
+#include <google/protobuf/test_messages_proto3.pb.h>
#include <google/protobuf/util/json_util.h>
#include <google/protobuf/util/type_resolver_util.h>
using conformance::ConformanceRequest;
using conformance::ConformanceResponse;
-using conformance::TestAllTypes;
using google::protobuf::Descriptor;
using google::protobuf::DescriptorPool;
using google::protobuf::internal::scoped_ptr;
@@ -47,6 +47,7 @@ using google::protobuf::util::JsonToBinaryString;
using google::protobuf::util::NewTypeResolverForDescriptorPool;
using google::protobuf::util::Status;
using google::protobuf::util::TypeResolver;
+using protobuf_test_messages::proto3::TestAllTypes;
using std::string;
static const char kTypeUrlPrefix[] = "type.googleapis.com";
diff --git a/conformance/conformance_objc.m b/conformance/conformance_objc.m
index 1124bfeb..ef037f84 100644
--- a/conformance/conformance_objc.m
+++ b/conformance/conformance_objc.m
@@ -31,6 +31,7 @@
#import <Foundation/Foundation.h>
#import "Conformance.pbobjc.h"
+#import "google/protobuf/TestMessagesProto3.pbobjc.h"
static void Die(NSString *format, ...) __dead2;
diff --git a/conformance/conformance_php.php b/conformance/conformance_php.php
new file mode 100755
index 00000000..69001971
--- /dev/null
+++ b/conformance/conformance_php.php
@@ -0,0 +1,112 @@
+<?php
+
+require_once("Conformance/WireFormat.php");
+require_once("Conformance/ConformanceResponse.php");
+require_once("Conformance/ConformanceRequest.php");
+require_once("Google/Protobuf/Any.php");
+require_once("Google/Protobuf/Duration.php");
+require_once("Google/Protobuf/FieldMask.php");
+require_once("Google/Protobuf/Struct.php");
+require_once("Google/Protobuf/Value.php");
+require_once("Google/Protobuf/ListValue.php");
+require_once("Google/Protobuf/NullValue.php");
+require_once("Google/Protobuf/Timestamp.php");
+require_once("Google/Protobuf/DoubleValue.php");
+require_once("Google/Protobuf/BytesValue.php");
+require_once("Google/Protobuf/FloatValue.php");
+require_once("Google/Protobuf/Int64Value.php");
+require_once("Google/Protobuf/UInt32Value.php");
+require_once("Google/Protobuf/BoolValue.php");
+require_once("Google/Protobuf/DoubleValue.php");
+require_once("Google/Protobuf/Int32Value.php");
+require_once("Google/Protobuf/StringValue.php");
+require_once("Google/Protobuf/UInt64Value.php");
+require_once("Protobuf_test_messages/Proto3/ForeignMessage.php");
+require_once("Protobuf_test_messages/Proto3/ForeignEnum.php");
+require_once("Protobuf_test_messages/Proto3/TestAllTypes.php");
+require_once("Protobuf_test_messages/Proto3/TestAllTypes_NestedMessage.php");
+require_once("Protobuf_test_messages/Proto3/TestAllTypes_NestedEnum.php");
+
+require_once("GPBMetadata/Conformance.php");
+require_once("GPBMetadata/Google/Protobuf/Any.php");
+require_once("GPBMetadata/Google/Protobuf/Duration.php");
+require_once("GPBMetadata/Google/Protobuf/FieldMask.php");
+require_once("GPBMetadata/Google/Protobuf/Struct.php");
+require_once("GPBMetadata/Google/Protobuf/Timestamp.php");
+require_once("GPBMetadata/Google/Protobuf/Wrappers.php");
+require_once("GPBMetadata/Google/Protobuf/TestMessagesProto3.php");
+
+use \Conformance\WireFormat;
+
+$test_count = 0;
+
+function doTest($request)
+{
+ $test_message = new \Protobuf_test_messages\Proto3\TestAllTypes();
+ $response = new \Conformance\ConformanceResponse();
+ if ($request->getPayload() == "protobuf_payload") {
+ try {
+ $test_message->decode($request->getProtobufPayload());
+ } catch (Exception $e) {
+ $response->setParseError($e->getMessage());
+ return $response;
+ }
+ } elseif ($request->getPayload() == "json_payload") {
+ try {
+ $test_message->jsonDecode($request->getJsonPayload());
+ } catch (Exception $e) {
+ $response->setParseError($e->getMessage());
+ return $response;
+ }
+ } else {
+ trigger_error("Request didn't have payload.", E_USER_ERROR);
+ }
+
+ if ($request->getRequestedOutputFormat() == WireFormat::UNSPECIFIED) {
+ trigger_error("Unspecified output format.", E_USER_ERROR);
+ } elseif ($request->getRequestedOutputFormat() == WireFormat::PROTOBUF) {
+ $response->setProtobufPayload($test_message->encode());
+ } elseif ($request->getRequestedOutputFormat() == WireFormat::JSON) {
+ $response->setJsonPayload($test_message->jsonEncode());
+ }
+
+ return $response;
+}
+
+function doTestIO()
+{
+ $length_bytes = fread(STDIN, 4);
+ if (strlen($length_bytes) == 0) {
+ return false; # EOF
+ } elseif (strlen($length_bytes) != 4) {
+ trigger_error("I/O error", E_USER_ERROR);
+ }
+
+ $length = unpack("V", $length_bytes)[1];
+ $serialized_request = fread(STDIN, $length);
+ if (strlen($serialized_request) != $length) {
+ trigger_error("I/O error", E_USER_ERROR);
+ }
+
+ $request = new \Conformance\ConformanceRequest();
+ $request->decode($serialized_request);
+
+ $response = doTest($request);
+
+ $serialized_response = $response->encode();
+ fwrite(STDOUT, pack("V", strlen($serialized_response)));
+ fwrite(STDOUT, $serialized_response);
+
+ $GLOBALS['test_count'] += 1;
+
+ return true;
+}
+
+while(true){
+ if (!doTestIO()) {
+ fprintf(STDERR,
+ "conformance_php: received EOF from test runner " +
+ "after %d tests, exiting\n", $test_count);
+ exit;
+ }
+}
diff --git a/conformance/conformance_python.py b/conformance/conformance_python.py
index 2f4a7812..7ace9b16 100755
--- a/conformance/conformance_python.py
+++ b/conformance/conformance_python.py
@@ -38,8 +38,9 @@ See conformance.proto for more information.
import struct
import sys
import os
-from google.protobuf import message
from google.protobuf import json_format
+from google.protobuf import message
+from google.protobuf import test_messages_proto3_pb2
import conformance_pb2
sys.stdout = os.fdopen(sys.stdout.fileno(), 'wb', 0)
@@ -52,9 +53,9 @@ class ProtocolError(Exception):
pass
def do_test(request):
- test_message = conformance_pb2.TestAllTypes()
+ test_message = test_messages_proto3_pb2.TestAllTypes()
response = conformance_pb2.ConformanceResponse()
- test_message = conformance_pb2.TestAllTypes()
+ test_message = test_messages_proto3_pb2.TestAllTypes()
try:
if request.WhichOneof('payload') == 'protobuf_payload':
diff --git a/conformance/conformance_ruby.rb b/conformance/conformance_ruby.rb
index aa572144..b7b7cf1c 100755
--- a/conformance/conformance_ruby.rb
+++ b/conformance/conformance_ruby.rb
@@ -31,20 +31,21 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
require 'conformance_pb'
+require 'google/protobuf/test_messages_proto3_pb'
$test_count = 0
$verbose = false
def do_test(request)
- test_message = Conformance::TestAllTypes.new
+ test_message = ProtobufTestMessages::Proto3::TestAllTypes.new
response = Conformance::ConformanceResponse.new
begin
case request.payload
when :protobuf_payload
begin
- test_message =
- Conformance::TestAllTypes.decode(request.protobuf_payload)
+ test_message = ProtobufTestMessages::Proto3::TestAllTypes.decode(
+ request.protobuf_payload)
rescue Google::Protobuf::ParseError => err
response.parse_error = err.message.encode('utf-8')
return response
@@ -52,7 +53,8 @@ def do_test(request)
when :json_payload
begin
- test_message = Conformance::TestAllTypes.decode_json(request.json_payload)
+ test_message = ProtobufTestMessages::Proto3::TestAllTypes.decode_json(
+ request.json_payload)
rescue Google::Protobuf::ParseError => err
response.parse_error = err.message.encode('utf-8')
return response
diff --git a/conformance/conformance_test.cc b/conformance/conformance_test.cc
index b74122c6..1e5387a5 100644
--- a/conformance/conformance_test.cc
+++ b/conformance/conformance_test.cc
@@ -34,11 +34,13 @@
#include "conformance.pb.h"
#include "conformance_test.h"
+#include <google/protobuf/test_messages_proto3.pb.h>
+
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/text_format.h>
-#include <google/protobuf/util/json_util.h>
#include <google/protobuf/util/field_comparator.h>
+#include <google/protobuf/util/json_util.h>
#include <google/protobuf/util/message_differencer.h>
#include <google/protobuf/util/type_resolver_util.h>
#include <google/protobuf/wire_format_lite.h>
@@ -47,7 +49,6 @@
using conformance::ConformanceRequest;
using conformance::ConformanceResponse;
-using conformance::TestAllTypes;
using conformance::WireFormat;
using google::protobuf::Descriptor;
using google::protobuf::FieldDescriptor;
@@ -58,6 +59,7 @@ using google::protobuf::util::JsonToBinaryString;
using google::protobuf::util::MessageDifferencer;
using google::protobuf::util::NewTypeResolverForDescriptorPool;
using google::protobuf::util::Status;
+using protobuf_test_messages::proto3::TestAllTypes;
using std::string;
namespace {
@@ -107,13 +109,18 @@ string cat(const string& a, const string& b,
// The maximum number of bytes that it takes to encode a 64-bit varint.
#define VARINT_MAX_LEN 10
-size_t vencode64(uint64_t val, char *buf) {
+size_t vencode64(uint64_t val, int over_encoded_bytes, char *buf) {
if (val == 0) { buf[0] = 0; return 1; }
size_t i = 0;
while (val) {
uint8_t byte = val & 0x7fU;
val >>= 7;
- if (val) byte |= 0x80U;
+ if (val || over_encoded_bytes) byte |= 0x80U;
+ buf[i++] = byte;
+ }
+ while (over_encoded_bytes--) {
+ assert(i < 10);
+ uint8_t byte = over_encoded_bytes ? 0x80 : 0;
buf[i++] = byte;
}
return i;
@@ -121,7 +128,15 @@ size_t vencode64(uint64_t val, char *buf) {
string varint(uint64_t x) {
char buf[VARINT_MAX_LEN];
- size_t len = vencode64(x, buf);
+ size_t len = vencode64(x, 0, buf);
+ return string(buf, len);
+}
+
+// Encodes a varint that is |extra| bytes longer than it needs to be, but still
+// valid.
+string longvarint(uint64_t x, int extra) {
+ char buf[VARINT_MAX_LEN];
+ size_t len = vencode64(x, extra, buf);
return string(buf, len);
}
@@ -130,8 +145,8 @@ string fixed32(void *data) { return string(static_cast<char*>(data), 4); }
string fixed64(void *data) { return string(static_cast<char*>(data), 8); }
string delim(const string& buf) { return cat(varint(buf.size()), buf); }
-string uint32(uint32_t u32) { return fixed32(&u32); }
-string uint64(uint64_t u64) { return fixed64(&u64); }
+string u32(uint32_t u32) { return fixed32(&u32); }
+string u64(uint64_t u64) { return fixed64(&u64); }
string flt(float f) { return fixed32(&f); }
string dbl(double d) { return fixed64(&d); }
string zz32(int32_t x) { return varint(WireFormatLite::ZigZagEncode32(x)); }
@@ -147,16 +162,17 @@ string submsg(uint32_t fn, const string& buf) {
#define UNKNOWN_FIELD 666
-uint32_t GetFieldNumberForType(FieldDescriptor::Type type, bool repeated) {
+const FieldDescriptor* GetFieldForType(FieldDescriptor::Type type,
+ bool repeated) {
const Descriptor* d = TestAllTypes().GetDescriptor();
for (int i = 0; i < d->field_count(); i++) {
const FieldDescriptor* f = d->field(i);
if (f->type() == type && f->is_repeated() == repeated) {
- return f->number();
+ return f;
}
}
GOOGLE_LOG(FATAL) << "Couldn't find field with type " << (int)type;
- return 0;
+ return nullptr;
}
string UpperCase(string str) {
@@ -423,14 +439,22 @@ void ConformanceTestSuite::RunValidJsonTestWithProtobufInput(
}
void ConformanceTestSuite::RunValidProtobufTest(
+ const string& test_name, ConformanceLevel level,
+ const string& input_protobuf, const string& equivalent_text_format) {
+ RunValidInputTest(
+ ConformanceLevelToString(level) + ".ProtobufInput." + test_name +
+ ".ProtobufOutput", level, input_protobuf, conformance::PROTOBUF,
+ equivalent_text_format, conformance::PROTOBUF);
+ RunValidInputTest(
+ ConformanceLevelToString(level) + ".ProtobufInput." + test_name +
+ ".JsonOutput", level, input_protobuf, conformance::PROTOBUF,
+ equivalent_text_format, conformance::JSON);
+}
+
+void ConformanceTestSuite::RunValidProtobufTestWithMessage(
const string& test_name, ConformanceLevel level, const TestAllTypes& input,
const string& equivalent_text_format) {
- RunValidInputTest("ProtobufInput." + test_name + ".ProtobufOutput", level,
- input.SerializeAsString(), conformance::PROTOBUF,
- equivalent_text_format, conformance::PROTOBUF);
- RunValidInputTest("ProtobufInput." + test_name + ".JsonOutput", level,
- input.SerializeAsString(), conformance::PROTOBUF,
- equivalent_text_format, conformance::JSON);
+ RunValidProtobufTest(test_name, level, input.SerializeAsString(), equivalent_text_format);
}
// According to proto3 JSON specification, JSON serializers follow more strict
@@ -537,8 +561,8 @@ void ConformanceTestSuite::TestPrematureEOFForType(FieldDescriptor::Type type) {
string("abc") // 32BIT
};
- uint32_t fieldnum = GetFieldNumberForType(type, false);
- uint32_t rep_fieldnum = GetFieldNumberForType(type, true);
+ const FieldDescriptor* field = GetFieldForType(type, false);
+ const FieldDescriptor* rep_field = GetFieldForType(type, true);
WireFormatLite::WireType wire_type = WireFormatLite::WireTypeForFieldType(
static_cast<WireFormatLite::FieldType>(type));
const string& incomplete = incompletes[wire_type];
@@ -546,11 +570,11 @@ void ConformanceTestSuite::TestPrematureEOFForType(FieldDescriptor::Type type) {
UpperCase(string(".") + FieldDescriptor::TypeName(type));
ExpectParseFailureForProto(
- tag(fieldnum, wire_type),
+ tag(field->number(), wire_type),
"PrematureEofBeforeKnownNonRepeatedValue" + type_name, REQUIRED);
ExpectParseFailureForProto(
- tag(rep_fieldnum, wire_type),
+ tag(rep_field->number(), wire_type),
"PrematureEofBeforeKnownRepeatedValue" + type_name, REQUIRED);
ExpectParseFailureForProto(
@@ -558,11 +582,11 @@ void ConformanceTestSuite::TestPrematureEOFForType(FieldDescriptor::Type type) {
"PrematureEofBeforeUnknownValue" + type_name, REQUIRED);
ExpectParseFailureForProto(
- cat( tag(fieldnum, wire_type), incomplete ),
+ cat( tag(field->number(), wire_type), incomplete ),
"PrematureEofInsideKnownNonRepeatedValue" + type_name, REQUIRED);
ExpectParseFailureForProto(
- cat( tag(rep_fieldnum, wire_type), incomplete ),
+ cat( tag(rep_field->number(), wire_type), incomplete ),
"PrematureEofInsideKnownRepeatedValue" + type_name, REQUIRED);
ExpectParseFailureForProto(
@@ -571,12 +595,12 @@ void ConformanceTestSuite::TestPrematureEOFForType(FieldDescriptor::Type type) {
if (wire_type == WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
ExpectParseFailureForProto(
- cat( tag(fieldnum, wire_type), varint(1) ),
+ cat( tag(field->number(), wire_type), varint(1) ),
"PrematureEofInDelimitedDataForKnownNonRepeatedValue" + type_name,
REQUIRED);
ExpectParseFailureForProto(
- cat( tag(rep_fieldnum, wire_type), varint(1) ),
+ cat( tag(rep_field->number(), wire_type), varint(1) ),
"PrematureEofInDelimitedDataForKnownRepeatedValue" + type_name,
REQUIRED);
@@ -591,7 +615,7 @@ void ConformanceTestSuite::TestPrematureEOFForType(FieldDescriptor::Type type) {
cat( tag(WireFormatLite::TYPE_INT32, WireFormatLite::WIRETYPE_VARINT),
incompletes[WireFormatLite::WIRETYPE_VARINT] );
ExpectHardParseFailureForProto(
- cat( tag(fieldnum, WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
+ cat( tag(field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
varint(incomplete_submsg.size()),
incomplete_submsg ),
"PrematureEofInSubmessageValue" + type_name, REQUIRED);
@@ -601,19 +625,50 @@ void ConformanceTestSuite::TestPrematureEOFForType(FieldDescriptor::Type type) {
// Packed region ends in the middle of a value.
ExpectHardParseFailureForProto(
- cat( tag(rep_fieldnum, WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
- varint(incomplete.size()),
- incomplete ),
+ cat(tag(rep_field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
+ varint(incomplete.size()), incomplete),
"PrematureEofInPackedFieldValue" + type_name, REQUIRED);
// EOF in the middle of packed region.
ExpectParseFailureForProto(
- cat( tag(rep_fieldnum, WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
- varint(1) ),
+ cat(tag(rep_field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
+ varint(1)),
"PrematureEofInPackedField" + type_name, REQUIRED);
}
}
+void ConformanceTestSuite::TestValidDataForType(
+ FieldDescriptor::Type type,
+ std::vector<std::pair<std::string, std::string>> values) {
+ const string type_name =
+ UpperCase(string(".") + FieldDescriptor::TypeName(type));
+ WireFormatLite::WireType wire_type = WireFormatLite::WireTypeForFieldType(
+ static_cast<WireFormatLite::FieldType>(type));
+ const FieldDescriptor* field = GetFieldForType(type, false);
+ const FieldDescriptor* rep_field = GetFieldForType(type, true);
+
+ RunValidProtobufTest("ValidDataScalar" + type_name, REQUIRED,
+ cat(tag(field->number(), wire_type), values[0].first),
+ field->name() + ": " + values[0].second);
+
+ string proto;
+ string text = field->name() + ": " + values.back().second;
+ for (size_t i = 0; i < values.size(); i++) {
+ proto += cat(tag(field->number(), wire_type), values[i].first);
+ }
+ RunValidProtobufTest("RepeatedScalarSelectsLast" + type_name, REQUIRED,
+ proto, text);
+
+ proto.clear();
+ text.clear();
+
+ for (size_t i = 0; i < values.size(); i++) {
+ proto += cat(tag(rep_field->number(), wire_type), values[i].first);
+ text += rep_field->name() + ": " + values[i].second + " ";
+ }
+ RunValidProtobufTest("ValidDataRepeated" + type_name, REQUIRED, proto, text);
+}
+
void ConformanceTestSuite::SetFailureList(const string& filename,
const vector<string>& failure_list) {
failure_list_filename_ = filename;
@@ -673,6 +728,96 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
TestPrematureEOFForType(static_cast<FieldDescriptor::Type>(i));
}
+ int64 kInt64Min = -9223372036854775808ULL;
+ int64 kInt64Max = 9223372036854775807ULL;
+ uint64 kUint64Max = 18446744073709551615ULL;
+ int32 kInt32Max = 2147483647;
+ int32 kInt32Min = -2147483648;
+ uint32 kUint32Max = 4294967295UL;
+
+ TestValidDataForType(FieldDescriptor::TYPE_DOUBLE, {
+ {dbl(0.1), "0.1"},
+ {dbl(1.7976931348623157e+308), "1.7976931348623157e+308"},
+ {dbl(2.22507385850720138309e-308), "2.22507385850720138309e-308"}
+ });
+ TestValidDataForType(FieldDescriptor::TYPE_FLOAT, {
+ {flt(0.1), "0.1"},
+ {flt(3.402823e+38), "3.402823e+38"}, // 3.40282347e+38
+ {flt(1.17549435e-38f), "1.17549435e-38"}
+ });
+ TestValidDataForType(FieldDescriptor::TYPE_INT64, {
+ {varint(12345), "12345"},
+ {varint(kInt64Max), std::to_string(kInt64Max)},
+ {varint(kInt64Min), std::to_string(kInt64Min)}
+ });
+ TestValidDataForType(FieldDescriptor::TYPE_UINT64, {
+ {varint(12345), "12345"},
+ {varint(kUint64Max), std::to_string(kUint64Max)},
+ {varint(0), "0"}
+ });
+ TestValidDataForType(FieldDescriptor::TYPE_INT32, {
+ {varint(12345), "12345"},
+ {longvarint(12345, 2), "12345"},
+ {longvarint(12345, 7), "12345"},
+ {varint(kInt32Max), std::to_string(kInt32Max)},
+ {varint(kInt32Min), std::to_string(kInt32Min)},
+ {varint(1LL << 33), std::to_string(static_cast<int32>(1LL << 33))},
+ {varint((1LL << 33) - 1),
+ std::to_string(static_cast<int32>((1LL << 33) - 1))},
+ });
+ TestValidDataForType(FieldDescriptor::TYPE_UINT32, {
+ {varint(12345), "12345"},
+ {longvarint(12345, 2), "12345"},
+ {longvarint(12345, 7), "12345"},
+ {varint(kUint32Max), std::to_string(kUint32Max)}, // UINT32_MAX
+ {varint(0), "0"},
+ {varint(1LL << 33), std::to_string(static_cast<uint32>(1LL << 33))},
+ {varint((1LL << 33) - 1),
+ std::to_string(static_cast<uint32>((1LL << 33) - 1))},
+ });
+ TestValidDataForType(FieldDescriptor::TYPE_FIXED64, {
+ {u64(12345), "12345"},
+ {u64(kUint64Max), std::to_string(kUint64Max)},
+ {u64(0), "0"}
+ });
+ TestValidDataForType(FieldDescriptor::TYPE_FIXED32, {
+ {u32(12345), "12345"},
+ {u32(kUint32Max), std::to_string(kUint32Max)}, // UINT32_MAX
+ {u32(0), "0"}
+ });
+ TestValidDataForType(FieldDescriptor::TYPE_SFIXED64, {
+ {u64(12345), "12345"},
+ {u64(kInt64Max), std::to_string(kInt64Max)},
+ {u64(kInt64Min), std::to_string(kInt64Min)}
+ });
+ TestValidDataForType(FieldDescriptor::TYPE_SFIXED32, {
+ {u32(12345), "12345"},
+ {u32(kInt32Max), std::to_string(kInt32Max)},
+ {u32(kInt32Min), std::to_string(kInt32Min)}
+ });
+ TestValidDataForType(FieldDescriptor::TYPE_BOOL, {
+ {varint(1), "true"},
+ {varint(0), "false"},
+ {varint(12345678), "true"}
+ });
+ TestValidDataForType(FieldDescriptor::TYPE_SINT32, {
+ {zz32(12345), "12345"},
+ {zz32(kInt32Max), std::to_string(kInt32Max)},
+ {zz32(kInt32Min), std::to_string(kInt32Min)}
+ });
+ TestValidDataForType(FieldDescriptor::TYPE_SINT64, {
+ {zz64(12345), "12345"},
+ {zz64(kInt64Max), std::to_string(kInt64Max)},
+ {zz64(kInt64Min), std::to_string(kInt64Min)}
+ });
+
+ // TODO(haberman):
+ // TestValidDataForType(FieldDescriptor::TYPE_STRING
+ // TestValidDataForType(FieldDescriptor::TYPE_GROUP
+ // TestValidDataForType(FieldDescriptor::TYPE_MESSAGE
+ // TestValidDataForType(FieldDescriptor::TYPE_BYTES
+ // TestValidDataForType(FieldDescriptor::TYPE_ENUM
+
RunValidJsonTest("HelloWorld", REQUIRED,
"{\"optionalString\":\"Hello, World!\"}",
"optional_string: 'Hello, World!'");
@@ -685,7 +830,7 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
R"({
"fieldname1": 1,
"fieldName2": 2,
- "fieldName3": 3,
+ "FieldName3": 3,
"fieldName4": 4
})",
R"(
@@ -725,12 +870,12 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
RunValidJsonTest(
"FieldNameWithDoubleUnderscores", RECOMMENDED,
R"({
- "fieldName13": 13,
- "fieldName14": 14,
+ "FieldName13": 13,
+ "FieldName14": 14,
"fieldName15": 15,
"fieldName16": 16,
"fieldName17": 17,
- "fieldName18": 18
+ "FieldName18": 18
})",
R"(
__field_name13: 13
@@ -873,21 +1018,19 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
"optionalNestedMessage": {a: 1},
"optional_nested_message": {}
})");
- // NOTE: The spec for JSON support is still being sorted out, these may not
- // all be correct.
// Serializers should use lowerCamelCase by default.
RunValidJsonTestWithValidator(
"FieldNameInLowerCamelCase", REQUIRED,
R"({
"fieldname1": 1,
"fieldName2": 2,
- "fieldName3": 3,
+ "FieldName3": 3,
"fieldName4": 4
})",
[](const Json::Value& value) {
return value.isMember("fieldname1") &&
value.isMember("fieldName2") &&
- value.isMember("fieldName3") &&
+ value.isMember("FieldName3") &&
value.isMember("fieldName4");
});
RunValidJsonTestWithValidator(
@@ -921,20 +1064,20 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
RunValidJsonTestWithValidator(
"FieldNameWithDoubleUnderscores", RECOMMENDED,
R"({
- "fieldName13": 13,
- "fieldName14": 14,
+ "FieldName13": 13,
+ "FieldName14": 14,
"fieldName15": 15,
"fieldName16": 16,
"fieldName17": 17,
- "fieldName18": 18
+ "FieldName18": 18
})",
[](const Json::Value& value) {
- return value.isMember("fieldName13") &&
- value.isMember("fieldName14") &&
+ return value.isMember("FieldName13") &&
+ value.isMember("FieldName14") &&
value.isMember("fieldName15") &&
value.isMember("fieldName16") &&
value.isMember("fieldName17") &&
- value.isMember("fieldName18");
+ value.isMember("FieldName18");
});
// Integer fields.
@@ -1374,31 +1517,31 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
{
TestAllTypes message;
message.set_oneof_uint32(0);
- RunValidProtobufTest(
+ RunValidProtobufTestWithMessage(
"OneofZeroUint32", RECOMMENDED, message, "oneof_uint32: 0");
message.mutable_oneof_nested_message()->set_a(0);
- RunValidProtobufTest(
+ RunValidProtobufTestWithMessage(
"OneofZeroMessage", RECOMMENDED, message, "oneof_nested_message: {}");
message.set_oneof_string("");
- RunValidProtobufTest(
+ RunValidProtobufTestWithMessage(
"OneofZeroString", RECOMMENDED, message, "oneof_string: \"\"");
message.set_oneof_bytes("");
- RunValidProtobufTest(
+ RunValidProtobufTestWithMessage(
"OneofZeroBytes", RECOMMENDED, message, "oneof_bytes: \"\"");
message.set_oneof_bool(false);
- RunValidProtobufTest(
+ RunValidProtobufTestWithMessage(
"OneofZeroBool", RECOMMENDED, message, "oneof_bool: false");
message.set_oneof_uint64(0);
- RunValidProtobufTest(
+ RunValidProtobufTestWithMessage(
"OneofZeroUint64", RECOMMENDED, message, "oneof_uint64: 0");
message.set_oneof_float(0.0f);
- RunValidProtobufTest(
+ RunValidProtobufTestWithMessage(
"OneofZeroFloat", RECOMMENDED, message, "oneof_float: 0");
message.set_oneof_double(0.0);
- RunValidProtobufTest(
+ RunValidProtobufTestWithMessage(
"OneofZeroDouble", RECOMMENDED, message, "oneof_double: 0");
message.set_oneof_enum(TestAllTypes::FOO);
- RunValidProtobufTest(
+ RunValidProtobufTestWithMessage(
"OneofZeroEnum", RECOMMENDED, message, "oneof_enum: FOO");
}
RunValidJsonTest(
@@ -2042,13 +2185,13 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
"Any", REQUIRED,
R"({
"optionalAny": {
- "@type": "type.googleapis.com/conformance.TestAllTypes",
+ "@type": "type.googleapis.com/protobuf_test_messages.proto3.TestAllTypes",
"optionalInt32": 12345
}
})",
R"(
optional_any: {
- [type.googleapis.com/conformance.TestAllTypes] {
+ [type.googleapis.com/protobuf_test_messages.proto3.TestAllTypes] {
optional_int32: 12345
}
}
@@ -2059,7 +2202,7 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
"optionalAny": {
"@type": "type.googleapis.com/google.protobuf.Any",
"value": {
- "@type": "type.googleapis.com/conformance.TestAllTypes",
+ "@type": "type.googleapis.com/protobuf_test_messages.proto3.TestAllTypes",
"optionalInt32": 12345
}
}
@@ -2067,7 +2210,7 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
R"(
optional_any: {
[type.googleapis.com/google.protobuf.Any] {
- [type.googleapis.com/conformance.TestAllTypes] {
+ [type.googleapis.com/protobuf_test_messages.proto3.TestAllTypes] {
optional_int32: 12345
}
}
@@ -2079,12 +2222,12 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
R"({
"optionalAny": {
"optionalInt32": 12345,
- "@type": "type.googleapis.com/conformance.TestAllTypes"
+ "@type": "type.googleapis.com/protobuf_test_messages.proto3.TestAllTypes"
}
})",
R"(
optional_any: {
- [type.googleapis.com/conformance.TestAllTypes] {
+ [type.googleapis.com/protobuf_test_messages.proto3.TestAllTypes] {
optional_int32: 12345
}
}
diff --git a/conformance/conformance_test.h b/conformance/conformance_test.h
index 08f16b8f..5f05a25b 100644
--- a/conformance/conformance_test.h
+++ b/conformance/conformance_test.h
@@ -49,9 +49,14 @@
namespace conformance {
class ConformanceRequest;
class ConformanceResponse;
-class TestAllTypes;
} // namespace conformance
+namespace protobuf_test_messages {
+namespace proto3 {
+class TestAllTypes;
+} // namespace proto3
+} // namespace protobuf_test_messages
+
namespace google {
namespace protobuf {
@@ -165,14 +170,18 @@ class ConformanceTestSuite {
ConformanceLevel level,
const string& input_json,
const string& equivalent_text_format);
- void RunValidJsonTestWithProtobufInput(const string& test_name,
- ConformanceLevel level,
- const conformance::TestAllTypes& input,
- const string& equivalent_text_format);
- void RunValidProtobufTest(const string& test_name,
- ConformanceLevel level,
- const conformance::TestAllTypes& input,
+ void RunValidJsonTestWithProtobufInput(
+ const string& test_name,
+ ConformanceLevel level,
+ const protobuf_test_messages::proto3::TestAllTypes& input,
+ const string& equivalent_text_format);
+ void RunValidProtobufTest(const string& test_name, ConformanceLevel level,
+ const string& input_protobuf,
const string& equivalent_text_format);
+ void RunValidProtobufTestWithMessage(
+ const string& test_name, ConformanceLevel level,
+ const protobuf_test_messages::proto3::TestAllTypes& input,
+ const string& equivalent_text_format);
typedef std::function<bool(const Json::Value&)> Validator;
void RunValidJsonTestWithValidator(const string& test_name,
@@ -192,6 +201,9 @@ class ConformanceTestSuite {
const std::string& test_name,
ConformanceLevel level);
void TestPrematureEOFForType(google::protobuf::FieldDescriptor::Type type);
+ void TestValidDataForType(
+ google::protobuf::FieldDescriptor::Type,
+ std::vector<std::pair<std::string, std::string>> values);
bool CheckSetEmpty(const set<string>& set_to_check,
const std::string& write_to_file, const std::string& msg);
ConformanceTestRunner* runner_;
diff --git a/conformance/failure_list_cpp.txt b/conformance/failure_list_cpp.txt
index 508be506..8cfd74da 100644
--- a/conformance/failure_list_cpp.txt
+++ b/conformance/failure_list_cpp.txt
@@ -17,9 +17,6 @@ Recommended.JsonInput.FieldNameDuplicate
Recommended.JsonInput.FieldNameDuplicateDifferentCasing1
Recommended.JsonInput.FieldNameDuplicateDifferentCasing2
Recommended.JsonInput.FieldNameNotQuoted
-Recommended.JsonInput.FieldNameWithDoubleUnderscores.JsonOutput
-Recommended.JsonInput.FieldNameWithDoubleUnderscores.ProtobufOutput
-Recommended.JsonInput.FieldNameWithDoubleUnderscores.Validator
Recommended.JsonInput.MapFieldValueIsNull
Recommended.JsonInput.RepeatedFieldMessageElementIsNull
Recommended.JsonInput.RepeatedFieldPrimitiveElementIsNull
@@ -35,10 +32,6 @@ Recommended.JsonInput.TrailingCommaInAnObject
Recommended.JsonInput.TrailingCommaInAnObjectWithNewlines
Recommended.JsonInput.TrailingCommaInAnObjectWithSpace
Recommended.JsonInput.TrailingCommaInAnObjectWithSpaceCommaSpace
-Required.JsonInput.DoubleFieldTooSmall
-Required.JsonInput.FieldNameInLowerCamelCase.Validator
-Required.JsonInput.FieldNameInSnakeCase.JsonOutput
-Required.JsonInput.FieldNameInSnakeCase.ProtobufOutput
Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.MESSAGE
Required.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
Required.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
diff --git a/conformance/failure_list_csharp.txt b/conformance/failure_list_csharp.txt
index 84f46fab..e69de29b 100644
--- a/conformance/failure_list_csharp.txt
+++ b/conformance/failure_list_csharp.txt
@@ -1,2 +0,0 @@
-Recommended.JsonInput.FieldNameWithDoubleUnderscores.JsonOutput
-Required.JsonInput.FieldNameInSnakeCase.JsonOutput
diff --git a/conformance/failure_list_java.txt b/conformance/failure_list_java.txt
index c9007d68..632940ef 100644
--- a/conformance/failure_list_java.txt
+++ b/conformance/failure_list_java.txt
@@ -20,9 +20,6 @@ Recommended.JsonInput.DoubleFieldNegativeInfinityNotQuoted
Recommended.JsonInput.FieldMaskInvalidCharacter
Recommended.JsonInput.FieldNameDuplicate
Recommended.JsonInput.FieldNameNotQuoted
-Recommended.JsonInput.FieldNameWithDoubleUnderscores.JsonOutput
-Recommended.JsonInput.FieldNameWithDoubleUnderscores.ProtobufOutput
-Recommended.JsonInput.FieldNameWithDoubleUnderscores.Validator
Recommended.JsonInput.FloatFieldInfinityNotQuoted
Recommended.JsonInput.FloatFieldNanNotQuoted
Recommended.JsonInput.FloatFieldNegativeInfinityNotQuoted
@@ -38,12 +35,11 @@ Recommended.JsonInput.StringFieldUnpairedLowSurrogate
Recommended.JsonInput.Uint32MapFieldKeyNotQuoted
Recommended.JsonInput.Uint64MapFieldKeyNotQuoted
Required.JsonInput.EnumFieldNotQuoted
-Required.JsonInput.FieldNameInLowerCamelCase.Validator
-Required.JsonInput.FieldNameInSnakeCase.JsonOutput
-Required.JsonInput.FieldNameInSnakeCase.ProtobufOutput
Required.JsonInput.Int32FieldLeadingZero
Required.JsonInput.Int32FieldNegativeWithLeadingZero
Required.JsonInput.Int32FieldPlusSign
Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotBool
Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt
Required.JsonInput.StringFieldNotAString
+Required.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
+Required.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
diff --git a/conformance/failure_list_php.txt b/conformance/failure_list_php.txt
new file mode 100644
index 00000000..6dd93918
--- /dev/null
+++ b/conformance/failure_list_php.txt
@@ -0,0 +1,611 @@
+Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput
+Recommended.FieldMaskPathsDontRoundTrip.JsonOutput
+Recommended.FieldMaskTooManyUnderscore.JsonOutput
+Recommended.JsonInput.BoolFieldAllCapitalFalse
+Recommended.JsonInput.BoolFieldAllCapitalTrue
+Recommended.JsonInput.BoolFieldCamelCaseFalse
+Recommended.JsonInput.BoolFieldCamelCaseTrue
+Recommended.JsonInput.BoolFieldDoubleQuotedFalse
+Recommended.JsonInput.BoolFieldDoubleQuotedTrue
+Recommended.JsonInput.BoolFieldIntegerOne
+Recommended.JsonInput.BoolFieldIntegerZero
+Recommended.JsonInput.BoolMapFieldKeyNotQuoted
+Recommended.JsonInput.DoubleFieldInfinityNotQuoted
+Recommended.JsonInput.DoubleFieldNanNotQuoted
+Recommended.JsonInput.DoubleFieldNegativeInfinityNotQuoted
+Recommended.JsonInput.DurationHas3FractionalDigits.Validator
+Recommended.JsonInput.DurationHas6FractionalDigits.Validator
+Recommended.JsonInput.DurationHas9FractionalDigits.Validator
+Recommended.JsonInput.DurationHasZeroFractionalDigit.Validator
+Recommended.JsonInput.FieldMaskInvalidCharacter
+Recommended.JsonInput.FieldNameDuplicate
+Recommended.JsonInput.FieldNameDuplicateDifferentCasing1
+Recommended.JsonInput.FieldNameDuplicateDifferentCasing2
+Recommended.JsonInput.FieldNameNotQuoted
+Recommended.JsonInput.FieldNameWithDoubleUnderscores.JsonOutput
+Recommended.JsonInput.FieldNameWithDoubleUnderscores.ProtobufOutput
+Recommended.JsonInput.FieldNameWithDoubleUnderscores.Validator
+Recommended.JsonInput.FloatFieldInfinityNotQuoted
+Recommended.JsonInput.FloatFieldNanNotQuoted
+Recommended.JsonInput.FloatFieldNegativeInfinityNotQuoted
+Recommended.JsonInput.Int32MapFieldKeyNotQuoted
+Recommended.JsonInput.Int64FieldBeString.Validator
+Recommended.JsonInput.Int64MapFieldKeyNotQuoted
+Recommended.JsonInput.JsonWithComments
+Recommended.JsonInput.MapFieldKeyIsNull
+Recommended.JsonInput.MapFieldValueIsNull
+Recommended.JsonInput.MissingCommaMultiline
+Recommended.JsonInput.MissingCommaOneLine
+Recommended.JsonInput.MultilineNoSpaces.JsonOutput
+Recommended.JsonInput.MultilineNoSpaces.ProtobufOutput
+Recommended.JsonInput.MultilineWithSpaces.JsonOutput
+Recommended.JsonInput.MultilineWithSpaces.ProtobufOutput
+Recommended.JsonInput.OneLineNoSpaces.JsonOutput
+Recommended.JsonInput.OneLineNoSpaces.ProtobufOutput
+Recommended.JsonInput.OneLineWithSpaces.JsonOutput
+Recommended.JsonInput.OneLineWithSpaces.ProtobufOutput
+Recommended.JsonInput.OneofZeroBool.JsonOutput
+Recommended.JsonInput.OneofZeroBool.ProtobufOutput
+Recommended.JsonInput.OneofZeroBytes.JsonOutput
+Recommended.JsonInput.OneofZeroBytes.ProtobufOutput
+Recommended.JsonInput.OneofZeroDouble.JsonOutput
+Recommended.JsonInput.OneofZeroDouble.ProtobufOutput
+Recommended.JsonInput.OneofZeroEnum.JsonOutput
+Recommended.JsonInput.OneofZeroEnum.ProtobufOutput
+Recommended.JsonInput.OneofZeroFloat.JsonOutput
+Recommended.JsonInput.OneofZeroFloat.ProtobufOutput
+Recommended.JsonInput.OneofZeroMessage.JsonOutput
+Recommended.JsonInput.OneofZeroMessage.ProtobufOutput
+Recommended.JsonInput.OneofZeroString.JsonOutput
+Recommended.JsonInput.OneofZeroString.ProtobufOutput
+Recommended.JsonInput.OneofZeroUint32.JsonOutput
+Recommended.JsonInput.OneofZeroUint32.ProtobufOutput
+Recommended.JsonInput.OneofZeroUint64.JsonOutput
+Recommended.JsonInput.OneofZeroUint64.ProtobufOutput
+Recommended.JsonInput.RepeatedFieldMessageElementIsNull
+Recommended.JsonInput.RepeatedFieldPrimitiveElementIsNull
+Recommended.JsonInput.RepeatedFieldTrailingComma
+Recommended.JsonInput.RepeatedFieldTrailingCommaWithNewlines
+Recommended.JsonInput.RepeatedFieldTrailingCommaWithSpace
+Recommended.JsonInput.RepeatedFieldTrailingCommaWithSpaceCommaSpace
+Recommended.JsonInput.StringEndsWithEscapeChar
+Recommended.JsonInput.StringFieldInvalidEscape
+Recommended.JsonInput.StringFieldSingleQuoteBoth
+Recommended.JsonInput.StringFieldSingleQuoteKey
+Recommended.JsonInput.StringFieldSingleQuoteValue
+Recommended.JsonInput.StringFieldSurrogateInWrongOrder
+Recommended.JsonInput.StringFieldUnpairedHighSurrogate
+Recommended.JsonInput.StringFieldUnpairedLowSurrogate
+Recommended.JsonInput.StringFieldUnterminatedEscape
+Recommended.JsonInput.StringFieldUppercaseEscapeLetter
+Recommended.JsonInput.TimestampHas3FractionalDigits.Validator
+Recommended.JsonInput.TimestampHas6FractionalDigits.Validator
+Recommended.JsonInput.TimestampHas9FractionalDigits.Validator
+Recommended.JsonInput.TimestampHasZeroFractionalDigit.Validator
+Recommended.JsonInput.TimestampZeroNormalized.Validator
+Recommended.JsonInput.TrailingCommaInAnObject
+Recommended.JsonInput.TrailingCommaInAnObjectWithNewlines
+Recommended.JsonInput.TrailingCommaInAnObjectWithSpace
+Recommended.JsonInput.TrailingCommaInAnObjectWithSpaceCommaSpace
+Recommended.JsonInput.Uint32MapFieldKeyNotQuoted
+Recommended.JsonInput.Uint64FieldBeString.Validator
+Recommended.JsonInput.Uint64MapFieldKeyNotQuoted
+Recommended.ProtobufInput.OneofZeroBool.JsonOutput
+Recommended.ProtobufInput.OneofZeroBool.ProtobufOutput
+Recommended.ProtobufInput.OneofZeroBytes.JsonOutput
+Recommended.ProtobufInput.OneofZeroBytes.ProtobufOutput
+Recommended.ProtobufInput.OneofZeroDouble.JsonOutput
+Recommended.ProtobufInput.OneofZeroDouble.ProtobufOutput
+Recommended.ProtobufInput.OneofZeroEnum.JsonOutput
+Recommended.ProtobufInput.OneofZeroEnum.ProtobufOutput
+Recommended.ProtobufInput.OneofZeroFloat.JsonOutput
+Recommended.ProtobufInput.OneofZeroFloat.ProtobufOutput
+Recommended.ProtobufInput.OneofZeroMessage.JsonOutput
+Recommended.ProtobufInput.OneofZeroMessage.ProtobufOutput
+Recommended.ProtobufInput.OneofZeroString.JsonOutput
+Recommended.ProtobufInput.OneofZeroString.ProtobufOutput
+Recommended.ProtobufInput.OneofZeroUint32.JsonOutput
+Recommended.ProtobufInput.OneofZeroUint32.ProtobufOutput
+Recommended.ProtobufInput.OneofZeroUint64.JsonOutput
+Recommended.ProtobufInput.OneofZeroUint64.ProtobufOutput
+Required.DurationProtoInputTooLarge.JsonOutput
+Required.DurationProtoInputTooSmall.JsonOutput
+Required.JsonInput.AllFieldAcceptNull.JsonOutput
+Required.JsonInput.AllFieldAcceptNull.ProtobufOutput
+Required.JsonInput.Any.JsonOutput
+Required.JsonInput.Any.ProtobufOutput
+Required.JsonInput.AnyNested.JsonOutput
+Required.JsonInput.AnyNested.ProtobufOutput
+Required.JsonInput.AnyUnorderedTypeTag.JsonOutput
+Required.JsonInput.AnyUnorderedTypeTag.ProtobufOutput
+Required.JsonInput.AnyWithDuration.JsonOutput
+Required.JsonInput.AnyWithDuration.ProtobufOutput
+Required.JsonInput.AnyWithFieldMask.JsonOutput
+Required.JsonInput.AnyWithFieldMask.ProtobufOutput
+Required.JsonInput.AnyWithInt32ValueWrapper.JsonOutput
+Required.JsonInput.AnyWithInt32ValueWrapper.ProtobufOutput
+Required.JsonInput.AnyWithStruct.JsonOutput
+Required.JsonInput.AnyWithStruct.ProtobufOutput
+Required.JsonInput.AnyWithTimestamp.JsonOutput
+Required.JsonInput.AnyWithTimestamp.ProtobufOutput
+Required.JsonInput.AnyWithValueForInteger.JsonOutput
+Required.JsonInput.AnyWithValueForInteger.ProtobufOutput
+Required.JsonInput.AnyWithValueForJsonObject.JsonOutput
+Required.JsonInput.AnyWithValueForJsonObject.ProtobufOutput
+Required.JsonInput.BoolFieldFalse.JsonOutput
+Required.JsonInput.BoolFieldFalse.ProtobufOutput
+Required.JsonInput.BoolFieldTrue.JsonOutput
+Required.JsonInput.BoolFieldTrue.ProtobufOutput
+Required.JsonInput.BoolMapEscapedKey.JsonOutput
+Required.JsonInput.BoolMapEscapedKey.ProtobufOutput
+Required.JsonInput.BoolMapField.JsonOutput
+Required.JsonInput.BoolMapField.ProtobufOutput
+Required.JsonInput.BytesField.JsonOutput
+Required.JsonInput.BytesField.ProtobufOutput
+Required.JsonInput.BytesFieldInvalidBase64Characters
+Required.JsonInput.BytesRepeatedField.JsonOutput
+Required.JsonInput.BytesRepeatedField.ProtobufOutput
+Required.JsonInput.DoubleFieldInfinity.JsonOutput
+Required.JsonInput.DoubleFieldInfinity.ProtobufOutput
+Required.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput
+Required.JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput
+Required.JsonInput.DoubleFieldMaxPositiveValue.JsonOutput
+Required.JsonInput.DoubleFieldMaxPositiveValue.ProtobufOutput
+Required.JsonInput.DoubleFieldMinNegativeValue.JsonOutput
+Required.JsonInput.DoubleFieldMinNegativeValue.ProtobufOutput
+Required.JsonInput.DoubleFieldMinPositiveValue.JsonOutput
+Required.JsonInput.DoubleFieldMinPositiveValue.ProtobufOutput
+Required.JsonInput.DoubleFieldNan.JsonOutput
+Required.JsonInput.DoubleFieldNan.ProtobufOutput
+Required.JsonInput.DoubleFieldNegativeInfinity.JsonOutput
+Required.JsonInput.DoubleFieldNegativeInfinity.ProtobufOutput
+Required.JsonInput.DoubleFieldQuotedValue.JsonOutput
+Required.JsonInput.DoubleFieldQuotedValue.ProtobufOutput
+Required.JsonInput.DoubleFieldTooLarge
+Required.JsonInput.DoubleFieldTooSmall
+Required.JsonInput.DurationJsonInputTooLarge
+Required.JsonInput.DurationJsonInputTooSmall
+Required.JsonInput.DurationMaxValue.JsonOutput
+Required.JsonInput.DurationMaxValue.ProtobufOutput
+Required.JsonInput.DurationMinValue.JsonOutput
+Required.JsonInput.DurationMinValue.ProtobufOutput
+Required.JsonInput.DurationMissingS
+Required.JsonInput.DurationRepeatedValue.JsonOutput
+Required.JsonInput.DurationRepeatedValue.ProtobufOutput
+Required.JsonInput.EnumField.JsonOutput
+Required.JsonInput.EnumField.ProtobufOutput
+Required.JsonInput.EnumFieldNotQuoted
+Required.JsonInput.EnumFieldNumericValueNonZero.JsonOutput
+Required.JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput
+Required.JsonInput.EnumFieldNumericValueZero.JsonOutput
+Required.JsonInput.EnumFieldNumericValueZero.ProtobufOutput
+Required.JsonInput.EnumFieldUnknownValue.Validator
+Required.JsonInput.EnumRepeatedField.JsonOutput
+Required.JsonInput.EnumRepeatedField.ProtobufOutput
+Required.JsonInput.FieldMask.JsonOutput
+Required.JsonInput.FieldMask.ProtobufOutput
+Required.JsonInput.FieldNameEscaped.JsonOutput
+Required.JsonInput.FieldNameEscaped.ProtobufOutput
+Required.JsonInput.FieldNameInLowerCamelCase.Validator
+Required.JsonInput.FieldNameInSnakeCase.JsonOutput
+Required.JsonInput.FieldNameInSnakeCase.ProtobufOutput
+Required.JsonInput.FieldNameWithMixedCases.JsonOutput
+Required.JsonInput.FieldNameWithMixedCases.ProtobufOutput
+Required.JsonInput.FieldNameWithMixedCases.Validator
+Required.JsonInput.FieldNameWithNumbers.JsonOutput
+Required.JsonInput.FieldNameWithNumbers.ProtobufOutput
+Required.JsonInput.FieldNameWithNumbers.Validator
+Required.JsonInput.FloatFieldInfinity.JsonOutput
+Required.JsonInput.FloatFieldInfinity.ProtobufOutput
+Required.JsonInput.FloatFieldMaxNegativeValue.JsonOutput
+Required.JsonInput.FloatFieldMaxNegativeValue.ProtobufOutput
+Required.JsonInput.FloatFieldMaxPositiveValue.JsonOutput
+Required.JsonInput.FloatFieldMaxPositiveValue.ProtobufOutput
+Required.JsonInput.FloatFieldMinNegativeValue.JsonOutput
+Required.JsonInput.FloatFieldMinNegativeValue.ProtobufOutput
+Required.JsonInput.FloatFieldMinPositiveValue.JsonOutput
+Required.JsonInput.FloatFieldMinPositiveValue.ProtobufOutput
+Required.JsonInput.FloatFieldNan.JsonOutput
+Required.JsonInput.FloatFieldNan.ProtobufOutput
+Required.JsonInput.FloatFieldNegativeInfinity.JsonOutput
+Required.JsonInput.FloatFieldNegativeInfinity.ProtobufOutput
+Required.JsonInput.FloatFieldQuotedValue.JsonOutput
+Required.JsonInput.FloatFieldQuotedValue.ProtobufOutput
+Required.JsonInput.FloatFieldTooLarge
+Required.JsonInput.FloatFieldTooSmall
+Required.JsonInput.HelloWorld.JsonOutput
+Required.JsonInput.HelloWorld.ProtobufOutput
+Required.JsonInput.Int32FieldExponentialFormat.JsonOutput
+Required.JsonInput.Int32FieldExponentialFormat.ProtobufOutput
+Required.JsonInput.Int32FieldFloatTrailingZero.JsonOutput
+Required.JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput
+Required.JsonInput.Int32FieldLeadingSpace
+Required.JsonInput.Int32FieldLeadingZero
+Required.JsonInput.Int32FieldMaxFloatValue.JsonOutput
+Required.JsonInput.Int32FieldMaxFloatValue.ProtobufOutput
+Required.JsonInput.Int32FieldMaxValue.JsonOutput
+Required.JsonInput.Int32FieldMaxValue.ProtobufOutput
+Required.JsonInput.Int32FieldMinFloatValue.JsonOutput
+Required.JsonInput.Int32FieldMinFloatValue.ProtobufOutput
+Required.JsonInput.Int32FieldMinValue.JsonOutput
+Required.JsonInput.Int32FieldMinValue.ProtobufOutput
+Required.JsonInput.Int32FieldNegativeWithLeadingZero
+Required.JsonInput.Int32FieldNotInteger
+Required.JsonInput.Int32FieldNotNumber
+Required.JsonInput.Int32FieldPlusSign
+Required.JsonInput.Int32FieldStringValue.JsonOutput
+Required.JsonInput.Int32FieldStringValue.ProtobufOutput
+Required.JsonInput.Int32FieldStringValueEscaped.JsonOutput
+Required.JsonInput.Int32FieldStringValueEscaped.ProtobufOutput
+Required.JsonInput.Int32FieldTooLarge
+Required.JsonInput.Int32FieldTooSmall
+Required.JsonInput.Int32FieldTrailingSpace
+Required.JsonInput.Int32MapEscapedKey.JsonOutput
+Required.JsonInput.Int32MapEscapedKey.ProtobufOutput
+Required.JsonInput.Int32MapField.JsonOutput
+Required.JsonInput.Int32MapField.ProtobufOutput
+Required.JsonInput.Int64FieldMaxValue.JsonOutput
+Required.JsonInput.Int64FieldMaxValue.ProtobufOutput
+Required.JsonInput.Int64FieldMaxValueNotQuoted.JsonOutput
+Required.JsonInput.Int64FieldMaxValueNotQuoted.ProtobufOutput
+Required.JsonInput.Int64FieldMinValue.JsonOutput
+Required.JsonInput.Int64FieldMinValue.ProtobufOutput
+Required.JsonInput.Int64FieldMinValueNotQuoted.JsonOutput
+Required.JsonInput.Int64FieldMinValueNotQuoted.ProtobufOutput
+Required.JsonInput.Int64FieldNotInteger
+Required.JsonInput.Int64FieldNotNumber
+Required.JsonInput.Int64FieldTooLarge
+Required.JsonInput.Int64FieldTooSmall
+Required.JsonInput.Int64MapEscapedKey.JsonOutput
+Required.JsonInput.Int64MapEscapedKey.ProtobufOutput
+Required.JsonInput.Int64MapField.JsonOutput
+Required.JsonInput.Int64MapField.ProtobufOutput
+Required.JsonInput.MessageField.JsonOutput
+Required.JsonInput.MessageField.ProtobufOutput
+Required.JsonInput.MessageMapField.JsonOutput
+Required.JsonInput.MessageMapField.ProtobufOutput
+Required.JsonInput.MessageRepeatedField.JsonOutput
+Required.JsonInput.MessageRepeatedField.ProtobufOutput
+Required.JsonInput.OneofFieldDuplicate
+Required.JsonInput.OptionalBoolWrapper.JsonOutput
+Required.JsonInput.OptionalBoolWrapper.ProtobufOutput
+Required.JsonInput.OptionalBytesWrapper.JsonOutput
+Required.JsonInput.OptionalBytesWrapper.ProtobufOutput
+Required.JsonInput.OptionalDoubleWrapper.JsonOutput
+Required.JsonInput.OptionalDoubleWrapper.ProtobufOutput
+Required.JsonInput.OptionalFloatWrapper.JsonOutput
+Required.JsonInput.OptionalFloatWrapper.ProtobufOutput
+Required.JsonInput.OptionalInt32Wrapper.JsonOutput
+Required.JsonInput.OptionalInt32Wrapper.ProtobufOutput
+Required.JsonInput.OptionalInt64Wrapper.JsonOutput
+Required.JsonInput.OptionalInt64Wrapper.ProtobufOutput
+Required.JsonInput.OptionalStringWrapper.JsonOutput
+Required.JsonInput.OptionalStringWrapper.ProtobufOutput
+Required.JsonInput.OptionalUint32Wrapper.JsonOutput
+Required.JsonInput.OptionalUint32Wrapper.ProtobufOutput
+Required.JsonInput.OptionalUint64Wrapper.JsonOutput
+Required.JsonInput.OptionalUint64Wrapper.ProtobufOutput
+Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput
+Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput
+Required.JsonInput.OriginalProtoFieldName.JsonOutput
+Required.JsonInput.OriginalProtoFieldName.ProtobufOutput
+Required.JsonInput.PrimitiveRepeatedField.JsonOutput
+Required.JsonInput.PrimitiveRepeatedField.ProtobufOutput
+Required.JsonInput.RepeatedBoolWrapper.JsonOutput
+Required.JsonInput.RepeatedBoolWrapper.ProtobufOutput
+Required.JsonInput.RepeatedBytesWrapper.JsonOutput
+Required.JsonInput.RepeatedBytesWrapper.ProtobufOutput
+Required.JsonInput.RepeatedDoubleWrapper.JsonOutput
+Required.JsonInput.RepeatedDoubleWrapper.ProtobufOutput
+Required.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool
+Required.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotMessage
+Required.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotString
+Required.JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotBool
+Required.JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotInt
+Required.JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotString
+Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotBool
+Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt
+Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotMessage
+Required.JsonInput.RepeatedFloatWrapper.JsonOutput
+Required.JsonInput.RepeatedFloatWrapper.ProtobufOutput
+Required.JsonInput.RepeatedInt32Wrapper.JsonOutput
+Required.JsonInput.RepeatedInt32Wrapper.ProtobufOutput
+Required.JsonInput.RepeatedInt64Wrapper.JsonOutput
+Required.JsonInput.RepeatedInt64Wrapper.ProtobufOutput
+Required.JsonInput.RepeatedStringWrapper.JsonOutput
+Required.JsonInput.RepeatedStringWrapper.ProtobufOutput
+Required.JsonInput.RepeatedUint32Wrapper.JsonOutput
+Required.JsonInput.RepeatedUint32Wrapper.ProtobufOutput
+Required.JsonInput.RepeatedUint64Wrapper.JsonOutput
+Required.JsonInput.RepeatedUint64Wrapper.ProtobufOutput
+Required.JsonInput.StringField.JsonOutput
+Required.JsonInput.StringField.ProtobufOutput
+Required.JsonInput.StringFieldEscape.JsonOutput
+Required.JsonInput.StringFieldEscape.ProtobufOutput
+Required.JsonInput.StringFieldNotAString
+Required.JsonInput.StringFieldSurrogatePair.JsonOutput
+Required.JsonInput.StringFieldSurrogatePair.ProtobufOutput
+Required.JsonInput.StringFieldUnicode.JsonOutput
+Required.JsonInput.StringFieldUnicode.ProtobufOutput
+Required.JsonInput.StringFieldUnicodeEscape.JsonOutput
+Required.JsonInput.StringFieldUnicodeEscape.ProtobufOutput
+Required.JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.JsonOutput
+Required.JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.ProtobufOutput
+Required.JsonInput.StringRepeatedField.JsonOutput
+Required.JsonInput.StringRepeatedField.ProtobufOutput
+Required.JsonInput.Struct.JsonOutput
+Required.JsonInput.Struct.ProtobufOutput
+Required.JsonInput.TimestampJsonInputLowercaseT
+Required.JsonInput.TimestampJsonInputLowercaseZ
+Required.JsonInput.TimestampJsonInputMissingT
+Required.JsonInput.TimestampJsonInputMissingZ
+Required.JsonInput.TimestampJsonInputTooLarge
+Required.JsonInput.TimestampJsonInputTooSmall
+Required.JsonInput.TimestampMaxValue.JsonOutput
+Required.JsonInput.TimestampMaxValue.ProtobufOutput
+Required.JsonInput.TimestampMinValue.JsonOutput
+Required.JsonInput.TimestampMinValue.ProtobufOutput
+Required.JsonInput.TimestampRepeatedValue.JsonOutput
+Required.JsonInput.TimestampRepeatedValue.ProtobufOutput
+Required.JsonInput.TimestampWithNegativeOffset.JsonOutput
+Required.JsonInput.TimestampWithNegativeOffset.ProtobufOutput
+Required.JsonInput.TimestampWithPositiveOffset.JsonOutput
+Required.JsonInput.TimestampWithPositiveOffset.ProtobufOutput
+Required.JsonInput.Uint32FieldMaxFloatValue.JsonOutput
+Required.JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput
+Required.JsonInput.Uint32FieldMaxValue.JsonOutput
+Required.JsonInput.Uint32FieldMaxValue.ProtobufOutput
+Required.JsonInput.Uint32FieldNotInteger
+Required.JsonInput.Uint32FieldNotNumber
+Required.JsonInput.Uint32FieldTooLarge
+Required.JsonInput.Uint32MapField.JsonOutput
+Required.JsonInput.Uint32MapField.ProtobufOutput
+Required.JsonInput.Uint64FieldMaxValue.JsonOutput
+Required.JsonInput.Uint64FieldMaxValue.ProtobufOutput
+Required.JsonInput.Uint64FieldMaxValueNotQuoted.JsonOutput
+Required.JsonInput.Uint64FieldMaxValueNotQuoted.ProtobufOutput
+Required.JsonInput.Uint64FieldNotInteger
+Required.JsonInput.Uint64FieldNotNumber
+Required.JsonInput.Uint64FieldTooLarge
+Required.JsonInput.Uint64MapField.JsonOutput
+Required.JsonInput.Uint64MapField.ProtobufOutput
+Required.JsonInput.ValueAcceptBool.JsonOutput
+Required.JsonInput.ValueAcceptBool.ProtobufOutput
+Required.JsonInput.ValueAcceptFloat.JsonOutput
+Required.JsonInput.ValueAcceptFloat.ProtobufOutput
+Required.JsonInput.ValueAcceptInteger.JsonOutput
+Required.JsonInput.ValueAcceptInteger.ProtobufOutput
+Required.JsonInput.ValueAcceptList.JsonOutput
+Required.JsonInput.ValueAcceptList.ProtobufOutput
+Required.JsonInput.ValueAcceptNull.JsonOutput
+Required.JsonInput.ValueAcceptNull.ProtobufOutput
+Required.JsonInput.ValueAcceptObject.JsonOutput
+Required.JsonInput.ValueAcceptObject.ProtobufOutput
+Required.JsonInput.ValueAcceptString.JsonOutput
+Required.JsonInput.ValueAcceptString.ProtobufOutput
+Required.JsonInput.WrapperTypesWithNullValue.JsonOutput
+Required.JsonInput.WrapperTypesWithNullValue.ProtobufOutput
+Required.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput
+Required.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput
+Required.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput
+Required.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.BOOL
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.BYTES
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.DOUBLE
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.ENUM
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.FIXED32
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.FIXED64
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.FLOAT
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.INT32
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.INT64
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.MESSAGE
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.SFIXED32
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.SFIXED64
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.SINT32
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.SINT64
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.STRING
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.UINT32
+Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.UINT64
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.BOOL
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.BYTES
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.DOUBLE
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.ENUM
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.FIXED32
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.FIXED64
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.FLOAT
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.INT32
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.INT64
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.MESSAGE
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.SFIXED32
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.SFIXED64
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.SINT32
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.SINT64
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.STRING
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.UINT32
+Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.UINT64
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.BOOL
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.BYTES
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.DOUBLE
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.ENUM
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.FIXED32
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.FIXED64
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.FLOAT
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.INT32
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.INT64
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.MESSAGE
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.SFIXED32
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.SFIXED64
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.SINT32
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.SINT64
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.STRING
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.UINT32
+Required.ProtobufInput.PrematureEofBeforeUnknownValue.UINT64
+Required.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.BYTES
+Required.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
+Required.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.STRING
+Required.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.BYTES
+Required.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
+Required.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.STRING
+Required.ProtobufInput.PrematureEofInDelimitedDataForUnknownValue.BYTES
+Required.ProtobufInput.PrematureEofInDelimitedDataForUnknownValue.MESSAGE
+Required.ProtobufInput.PrematureEofInDelimitedDataForUnknownValue.STRING
+Required.ProtobufInput.PrematureEofInPackedField.BOOL
+Required.ProtobufInput.PrematureEofInPackedField.DOUBLE
+Required.ProtobufInput.PrematureEofInPackedField.ENUM
+Required.ProtobufInput.PrematureEofInPackedField.FIXED32
+Required.ProtobufInput.PrematureEofInPackedField.FIXED64
+Required.ProtobufInput.PrematureEofInPackedField.FLOAT
+Required.ProtobufInput.PrematureEofInPackedField.INT32
+Required.ProtobufInput.PrematureEofInPackedField.INT64
+Required.ProtobufInput.PrematureEofInPackedField.SFIXED32
+Required.ProtobufInput.PrematureEofInPackedField.SFIXED64
+Required.ProtobufInput.PrematureEofInPackedField.SINT32
+Required.ProtobufInput.PrematureEofInPackedField.SINT64
+Required.ProtobufInput.PrematureEofInPackedField.UINT32
+Required.ProtobufInput.PrematureEofInPackedField.UINT64
+Required.ProtobufInput.PrematureEofInPackedFieldValue.BOOL
+Required.ProtobufInput.PrematureEofInPackedFieldValue.DOUBLE
+Required.ProtobufInput.PrematureEofInPackedFieldValue.ENUM
+Required.ProtobufInput.PrematureEofInPackedFieldValue.FIXED32
+Required.ProtobufInput.PrematureEofInPackedFieldValue.FIXED64
+Required.ProtobufInput.PrematureEofInPackedFieldValue.FLOAT
+Required.ProtobufInput.PrematureEofInPackedFieldValue.INT32
+Required.ProtobufInput.PrematureEofInPackedFieldValue.INT64
+Required.ProtobufInput.PrematureEofInPackedFieldValue.SFIXED32
+Required.ProtobufInput.PrematureEofInPackedFieldValue.SFIXED64
+Required.ProtobufInput.PrematureEofInPackedFieldValue.SINT32
+Required.ProtobufInput.PrematureEofInPackedFieldValue.SINT64
+Required.ProtobufInput.PrematureEofInPackedFieldValue.UINT32
+Required.ProtobufInput.PrematureEofInPackedFieldValue.UINT64
+Required.ProtobufInput.PrematureEofInSubmessageValue.MESSAGE
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.BOOL
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.BYTES
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.DOUBLE
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.ENUM
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.FIXED32
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.FIXED64
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.FLOAT
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.INT32
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.INT64
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.MESSAGE
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.SFIXED32
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.SFIXED64
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.SINT32
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.SINT64
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.STRING
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.UINT32
+Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.UINT64
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.BOOL
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.BYTES
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.DOUBLE
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.ENUM
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.FIXED32
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.FIXED64
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.FLOAT
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.INT32
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.INT64
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.MESSAGE
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.SFIXED32
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.SFIXED64
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.SINT32
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.SINT64
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.STRING
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.UINT32
+Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.UINT64
+Required.ProtobufInput.PrematureEofInsideUnknownValue.BOOL
+Required.ProtobufInput.PrematureEofInsideUnknownValue.BYTES
+Required.ProtobufInput.PrematureEofInsideUnknownValue.DOUBLE
+Required.ProtobufInput.PrematureEofInsideUnknownValue.ENUM
+Required.ProtobufInput.PrematureEofInsideUnknownValue.FIXED32
+Required.ProtobufInput.PrematureEofInsideUnknownValue.FIXED64
+Required.ProtobufInput.PrematureEofInsideUnknownValue.FLOAT
+Required.ProtobufInput.PrematureEofInsideUnknownValue.INT32
+Required.ProtobufInput.PrematureEofInsideUnknownValue.INT64
+Required.ProtobufInput.PrematureEofInsideUnknownValue.MESSAGE
+Required.ProtobufInput.PrematureEofInsideUnknownValue.SFIXED32
+Required.ProtobufInput.PrematureEofInsideUnknownValue.SFIXED64
+Required.ProtobufInput.PrematureEofInsideUnknownValue.SINT32
+Required.ProtobufInput.PrematureEofInsideUnknownValue.SINT64
+Required.ProtobufInput.PrematureEofInsideUnknownValue.STRING
+Required.ProtobufInput.PrematureEofInsideUnknownValue.UINT32
+Required.ProtobufInput.PrematureEofInsideUnknownValue.UINT64
+Required.ProtobufInput.RepeatedScalarSelectsLast.BOOL.JsonOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.BOOL.ProtobufOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.DOUBLE.JsonOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.DOUBLE.ProtobufOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED32.JsonOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED32.ProtobufOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED64.JsonOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED64.ProtobufOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.FLOAT.JsonOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.FLOAT.ProtobufOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.INT32.JsonOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.INT32.ProtobufOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.INT64.JsonOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.INT64.ProtobufOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.SFIXED32.JsonOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.SFIXED32.ProtobufOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.SFIXED64.JsonOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.SFIXED64.ProtobufOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.SINT32.JsonOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.SINT32.ProtobufOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.SINT64.JsonOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.SINT64.ProtobufOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.UINT32.JsonOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.UINT32.ProtobufOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.UINT64.JsonOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.UINT64.ProtobufOutput
+Required.ProtobufInput.ValidDataRepeated.BOOL.JsonOutput
+Required.ProtobufInput.ValidDataRepeated.BOOL.ProtobufOutput
+Required.ProtobufInput.ValidDataRepeated.DOUBLE.JsonOutput
+Required.ProtobufInput.ValidDataRepeated.DOUBLE.ProtobufOutput
+Required.ProtobufInput.ValidDataRepeated.FIXED32.JsonOutput
+Required.ProtobufInput.ValidDataRepeated.FIXED32.ProtobufOutput
+Required.ProtobufInput.ValidDataRepeated.FIXED64.JsonOutput
+Required.ProtobufInput.ValidDataRepeated.FIXED64.ProtobufOutput
+Required.ProtobufInput.ValidDataRepeated.FLOAT.JsonOutput
+Required.ProtobufInput.ValidDataRepeated.FLOAT.ProtobufOutput
+Required.ProtobufInput.ValidDataRepeated.INT32.JsonOutput
+Required.ProtobufInput.ValidDataRepeated.INT32.ProtobufOutput
+Required.ProtobufInput.ValidDataRepeated.INT64.JsonOutput
+Required.ProtobufInput.ValidDataRepeated.INT64.ProtobufOutput
+Required.ProtobufInput.ValidDataRepeated.SFIXED32.JsonOutput
+Required.ProtobufInput.ValidDataRepeated.SFIXED32.ProtobufOutput
+Required.ProtobufInput.ValidDataRepeated.SFIXED64.JsonOutput
+Required.ProtobufInput.ValidDataRepeated.SFIXED64.ProtobufOutput
+Required.ProtobufInput.ValidDataRepeated.SINT32.JsonOutput
+Required.ProtobufInput.ValidDataRepeated.SINT32.ProtobufOutput
+Required.ProtobufInput.ValidDataRepeated.SINT64.JsonOutput
+Required.ProtobufInput.ValidDataRepeated.SINT64.ProtobufOutput
+Required.ProtobufInput.ValidDataRepeated.UINT32.JsonOutput
+Required.ProtobufInput.ValidDataRepeated.UINT32.ProtobufOutput
+Required.ProtobufInput.ValidDataRepeated.UINT64.JsonOutput
+Required.ProtobufInput.ValidDataRepeated.UINT64.ProtobufOutput
+Required.ProtobufInput.ValidDataScalar.BOOL.JsonOutput
+Required.ProtobufInput.ValidDataScalar.BOOL.ProtobufOutput
+Required.ProtobufInput.ValidDataScalar.DOUBLE.JsonOutput
+Required.ProtobufInput.ValidDataScalar.DOUBLE.ProtobufOutput
+Required.ProtobufInput.ValidDataScalar.FIXED32.JsonOutput
+Required.ProtobufInput.ValidDataScalar.FIXED32.ProtobufOutput
+Required.ProtobufInput.ValidDataScalar.FIXED64.JsonOutput
+Required.ProtobufInput.ValidDataScalar.FIXED64.ProtobufOutput
+Required.ProtobufInput.ValidDataScalar.FLOAT.JsonOutput
+Required.ProtobufInput.ValidDataScalar.FLOAT.ProtobufOutput
+Required.ProtobufInput.ValidDataScalar.INT32.JsonOutput
+Required.ProtobufInput.ValidDataScalar.INT32.ProtobufOutput
+Required.ProtobufInput.ValidDataScalar.INT64.JsonOutput
+Required.ProtobufInput.ValidDataScalar.INT64.ProtobufOutput
+Required.ProtobufInput.ValidDataScalar.SFIXED32.JsonOutput
+Required.ProtobufInput.ValidDataScalar.SFIXED32.ProtobufOutput
+Required.ProtobufInput.ValidDataScalar.SFIXED64.JsonOutput
+Required.ProtobufInput.ValidDataScalar.SFIXED64.ProtobufOutput
+Required.ProtobufInput.ValidDataScalar.SINT32.JsonOutput
+Required.ProtobufInput.ValidDataScalar.SINT32.ProtobufOutput
+Required.ProtobufInput.ValidDataScalar.SINT64.JsonOutput
+Required.ProtobufInput.ValidDataScalar.SINT64.ProtobufOutput
+Required.ProtobufInput.ValidDataScalar.UINT32.JsonOutput
+Required.ProtobufInput.ValidDataScalar.UINT32.ProtobufOutput
+Required.ProtobufInput.ValidDataScalar.UINT64.JsonOutput
+Required.ProtobufInput.ValidDataScalar.UINT64.ProtobufOutput
+Required.TimestampProtoInputTooLarge.JsonOutput
+Required.TimestampProtoInputTooSmall.JsonOutput
diff --git a/conformance/failure_list_php_c.txt b/conformance/failure_list_php_c.txt
new file mode 100644
index 00000000..05cb218a
--- /dev/null
+++ b/conformance/failure_list_php_c.txt
@@ -0,0 +1,235 @@
+Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput
+Recommended.FieldMaskPathsDontRoundTrip.JsonOutput
+Recommended.FieldMaskTooManyUnderscore.JsonOutput
+Recommended.JsonInput.BoolFieldIntegerOne
+Recommended.JsonInput.BoolFieldIntegerZero
+Recommended.JsonInput.DurationHas3FractionalDigits.Validator
+Recommended.JsonInput.DurationHas6FractionalDigits.Validator
+Recommended.JsonInput.DurationHas9FractionalDigits.Validator
+Recommended.JsonInput.DurationHasZeroFractionalDigit.Validator
+Recommended.JsonInput.Int64FieldBeString.Validator
+Recommended.JsonInput.OneofZeroBool.JsonOutput
+Recommended.JsonInput.OneofZeroBool.ProtobufOutput
+Recommended.JsonInput.OneofZeroBytes.JsonOutput
+Recommended.JsonInput.OneofZeroBytes.ProtobufOutput
+Recommended.JsonInput.OneofZeroDouble.JsonOutput
+Recommended.JsonInput.OneofZeroDouble.ProtobufOutput
+Recommended.JsonInput.OneofZeroEnum.JsonOutput
+Recommended.JsonInput.OneofZeroEnum.ProtobufOutput
+Recommended.JsonInput.OneofZeroFloat.JsonOutput
+Recommended.JsonInput.OneofZeroFloat.ProtobufOutput
+Recommended.JsonInput.OneofZeroString.JsonOutput
+Recommended.JsonInput.OneofZeroString.ProtobufOutput
+Recommended.JsonInput.OneofZeroUint32.JsonOutput
+Recommended.JsonInput.OneofZeroUint32.ProtobufOutput
+Recommended.JsonInput.OneofZeroUint64.JsonOutput
+Recommended.JsonInput.OneofZeroUint64.ProtobufOutput
+Recommended.JsonInput.StringEndsWithEscapeChar
+Recommended.JsonInput.StringFieldSurrogateInWrongOrder
+Recommended.JsonInput.StringFieldUnpairedHighSurrogate
+Recommended.JsonInput.StringFieldUnpairedLowSurrogate
+Recommended.JsonInput.TimestampHas3FractionalDigits.Validator
+Recommended.JsonInput.TimestampHas6FractionalDigits.Validator
+Recommended.JsonInput.TimestampHas9FractionalDigits.Validator
+Recommended.JsonInput.TimestampHasZeroFractionalDigit.Validator
+Recommended.JsonInput.TimestampZeroNormalized.Validator
+Recommended.JsonInput.Uint64FieldBeString.Validator
+Recommended.ProtobufInput.OneofZeroBool.JsonOutput
+Recommended.ProtobufInput.OneofZeroBool.ProtobufOutput
+Recommended.ProtobufInput.OneofZeroBytes.JsonOutput
+Recommended.ProtobufInput.OneofZeroBytes.ProtobufOutput
+Recommended.ProtobufInput.OneofZeroDouble.JsonOutput
+Recommended.ProtobufInput.OneofZeroDouble.ProtobufOutput
+Recommended.ProtobufInput.OneofZeroEnum.JsonOutput
+Recommended.ProtobufInput.OneofZeroEnum.ProtobufOutput
+Recommended.ProtobufInput.OneofZeroFloat.JsonOutput
+Recommended.ProtobufInput.OneofZeroFloat.ProtobufOutput
+Recommended.ProtobufInput.OneofZeroString.JsonOutput
+Recommended.ProtobufInput.OneofZeroString.ProtobufOutput
+Recommended.ProtobufInput.OneofZeroUint32.JsonOutput
+Recommended.ProtobufInput.OneofZeroUint32.ProtobufOutput
+Recommended.ProtobufInput.OneofZeroUint64.JsonOutput
+Recommended.ProtobufInput.OneofZeroUint64.ProtobufOutput
+Required.DurationProtoInputTooLarge.JsonOutput
+Required.DurationProtoInputTooSmall.JsonOutput
+Required.JsonInput.AllFieldAcceptNull.ProtobufOutput
+Required.JsonInput.Any.JsonOutput
+Required.JsonInput.Any.ProtobufOutput
+Required.JsonInput.AnyNested.JsonOutput
+Required.JsonInput.AnyNested.ProtobufOutput
+Required.JsonInput.AnyUnorderedTypeTag.JsonOutput
+Required.JsonInput.AnyUnorderedTypeTag.ProtobufOutput
+Required.JsonInput.AnyWithDuration.JsonOutput
+Required.JsonInput.AnyWithDuration.ProtobufOutput
+Required.JsonInput.AnyWithFieldMask.JsonOutput
+Required.JsonInput.AnyWithFieldMask.ProtobufOutput
+Required.JsonInput.AnyWithInt32ValueWrapper.JsonOutput
+Required.JsonInput.AnyWithInt32ValueWrapper.ProtobufOutput
+Required.JsonInput.AnyWithStruct.JsonOutput
+Required.JsonInput.AnyWithStruct.ProtobufOutput
+Required.JsonInput.AnyWithTimestamp.JsonOutput
+Required.JsonInput.AnyWithTimestamp.ProtobufOutput
+Required.JsonInput.AnyWithValueForInteger.JsonOutput
+Required.JsonInput.AnyWithValueForInteger.ProtobufOutput
+Required.JsonInput.AnyWithValueForJsonObject.JsonOutput
+Required.JsonInput.AnyWithValueForJsonObject.ProtobufOutput
+Required.JsonInput.BoolFieldFalse.ProtobufOutput
+Required.JsonInput.BoolMapField.JsonOutput
+Required.JsonInput.DoubleFieldInfinity.JsonOutput
+Required.JsonInput.DoubleFieldInfinity.ProtobufOutput
+Required.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput
+Required.JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput
+Required.JsonInput.DoubleFieldMaxPositiveValue.JsonOutput
+Required.JsonInput.DoubleFieldMaxPositiveValue.ProtobufOutput
+Required.JsonInput.DoubleFieldMinNegativeValue.JsonOutput
+Required.JsonInput.DoubleFieldMinNegativeValue.ProtobufOutput
+Required.JsonInput.DoubleFieldMinPositiveValue.JsonOutput
+Required.JsonInput.DoubleFieldMinPositiveValue.ProtobufOutput
+Required.JsonInput.DoubleFieldNan.JsonOutput
+Required.JsonInput.DoubleFieldNan.ProtobufOutput
+Required.JsonInput.DoubleFieldNegativeInfinity.JsonOutput
+Required.JsonInput.DoubleFieldNegativeInfinity.ProtobufOutput
+Required.JsonInput.DoubleFieldQuotedValue.JsonOutput
+Required.JsonInput.DoubleFieldQuotedValue.ProtobufOutput
+Required.JsonInput.DurationMaxValue.JsonOutput
+Required.JsonInput.DurationMaxValue.ProtobufOutput
+Required.JsonInput.DurationMinValue.JsonOutput
+Required.JsonInput.DurationMinValue.ProtobufOutput
+Required.JsonInput.DurationRepeatedValue.JsonOutput
+Required.JsonInput.DurationRepeatedValue.ProtobufOutput
+Required.JsonInput.EnumField.ProtobufOutput
+Required.JsonInput.EnumFieldNumericValueNonZero.JsonOutput
+Required.JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput
+Required.JsonInput.EnumFieldNumericValueZero.JsonOutput
+Required.JsonInput.EnumFieldNumericValueZero.ProtobufOutput
+Required.JsonInput.EnumFieldUnknownValue.Validator
+Required.JsonInput.FieldMask.JsonOutput
+Required.JsonInput.FieldMask.ProtobufOutput
+Required.JsonInput.FloatFieldInfinity.JsonOutput
+Required.JsonInput.FloatFieldInfinity.ProtobufOutput
+Required.JsonInput.FloatFieldNan.JsonOutput
+Required.JsonInput.FloatFieldNan.ProtobufOutput
+Required.JsonInput.FloatFieldNegativeInfinity.JsonOutput
+Required.JsonInput.FloatFieldNegativeInfinity.ProtobufOutput
+Required.JsonInput.FloatFieldQuotedValue.JsonOutput
+Required.JsonInput.FloatFieldQuotedValue.ProtobufOutput
+Required.JsonInput.FloatFieldTooLarge
+Required.JsonInput.FloatFieldTooSmall
+Required.JsonInput.Int32FieldExponentialFormat.JsonOutput
+Required.JsonInput.Int32FieldExponentialFormat.ProtobufOutput
+Required.JsonInput.Int32FieldFloatTrailingZero.JsonOutput
+Required.JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput
+Required.JsonInput.Int32FieldMaxFloatValue.JsonOutput
+Required.JsonInput.Int32FieldMaxFloatValue.ProtobufOutput
+Required.JsonInput.Int32FieldMinFloatValue.JsonOutput
+Required.JsonInput.Int32FieldMinFloatValue.ProtobufOutput
+Required.JsonInput.Int32FieldStringValue.JsonOutput
+Required.JsonInput.Int32FieldStringValue.ProtobufOutput
+Required.JsonInput.Int32FieldStringValueEscaped.JsonOutput
+Required.JsonInput.Int32FieldStringValueEscaped.ProtobufOutput
+Required.JsonInput.Int32MapEscapedKey.JsonOutput
+Required.JsonInput.Int32MapEscapedKey.ProtobufOutput
+Required.JsonInput.Int32MapField.JsonOutput
+Required.JsonInput.Int32MapField.ProtobufOutput
+Required.JsonInput.Int64FieldMaxValue.JsonOutput
+Required.JsonInput.Int64FieldMaxValue.ProtobufOutput
+Required.JsonInput.Int64FieldMinValue.JsonOutput
+Required.JsonInput.Int64FieldMinValue.ProtobufOutput
+Required.JsonInput.Int64MapEscapedKey.JsonOutput
+Required.JsonInput.Int64MapEscapedKey.ProtobufOutput
+Required.JsonInput.Int64MapField.JsonOutput
+Required.JsonInput.Int64MapField.ProtobufOutput
+Required.JsonInput.MessageField.JsonOutput
+Required.JsonInput.MessageField.ProtobufOutput
+Required.JsonInput.MessageMapField.JsonOutput
+Required.JsonInput.MessageMapField.ProtobufOutput
+Required.JsonInput.MessageRepeatedField.JsonOutput
+Required.JsonInput.MessageRepeatedField.ProtobufOutput
+Required.JsonInput.OptionalBoolWrapper.JsonOutput
+Required.JsonInput.OptionalBoolWrapper.ProtobufOutput
+Required.JsonInput.OptionalBytesWrapper.JsonOutput
+Required.JsonInput.OptionalBytesWrapper.ProtobufOutput
+Required.JsonInput.OptionalDoubleWrapper.JsonOutput
+Required.JsonInput.OptionalDoubleWrapper.ProtobufOutput
+Required.JsonInput.OptionalFloatWrapper.JsonOutput
+Required.JsonInput.OptionalFloatWrapper.ProtobufOutput
+Required.JsonInput.OptionalInt32Wrapper.JsonOutput
+Required.JsonInput.OptionalInt32Wrapper.ProtobufOutput
+Required.JsonInput.OptionalInt64Wrapper.JsonOutput
+Required.JsonInput.OptionalInt64Wrapper.ProtobufOutput
+Required.JsonInput.OptionalStringWrapper.JsonOutput
+Required.JsonInput.OptionalStringWrapper.ProtobufOutput
+Required.JsonInput.OptionalUint32Wrapper.JsonOutput
+Required.JsonInput.OptionalUint32Wrapper.ProtobufOutput
+Required.JsonInput.OptionalUint64Wrapper.JsonOutput
+Required.JsonInput.OptionalUint64Wrapper.ProtobufOutput
+Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput
+Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput
+Required.JsonInput.PrimitiveRepeatedField.JsonOutput
+Required.JsonInput.PrimitiveRepeatedField.ProtobufOutput
+Required.JsonInput.RepeatedBoolWrapper.JsonOutput
+Required.JsonInput.RepeatedBoolWrapper.ProtobufOutput
+Required.JsonInput.RepeatedBytesWrapper.JsonOutput
+Required.JsonInput.RepeatedBytesWrapper.ProtobufOutput
+Required.JsonInput.RepeatedDoubleWrapper.JsonOutput
+Required.JsonInput.RepeatedDoubleWrapper.ProtobufOutput
+Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt
+Required.JsonInput.RepeatedFloatWrapper.JsonOutput
+Required.JsonInput.RepeatedFloatWrapper.ProtobufOutput
+Required.JsonInput.RepeatedInt32Wrapper.JsonOutput
+Required.JsonInput.RepeatedInt32Wrapper.ProtobufOutput
+Required.JsonInput.RepeatedInt64Wrapper.JsonOutput
+Required.JsonInput.RepeatedInt64Wrapper.ProtobufOutput
+Required.JsonInput.RepeatedStringWrapper.JsonOutput
+Required.JsonInput.RepeatedStringWrapper.ProtobufOutput
+Required.JsonInput.RepeatedUint32Wrapper.JsonOutput
+Required.JsonInput.RepeatedUint32Wrapper.ProtobufOutput
+Required.JsonInput.RepeatedUint64Wrapper.JsonOutput
+Required.JsonInput.RepeatedUint64Wrapper.ProtobufOutput
+Required.JsonInput.StringFieldNotAString
+Required.JsonInput.StringFieldSurrogatePair.JsonOutput
+Required.JsonInput.StringFieldSurrogatePair.ProtobufOutput
+Required.JsonInput.Struct.JsonOutput
+Required.JsonInput.Struct.ProtobufOutput
+Required.JsonInput.TimestampMaxValue.JsonOutput
+Required.JsonInput.TimestampMaxValue.ProtobufOutput
+Required.JsonInput.TimestampMinValue.JsonOutput
+Required.JsonInput.TimestampMinValue.ProtobufOutput
+Required.JsonInput.TimestampRepeatedValue.JsonOutput
+Required.JsonInput.TimestampRepeatedValue.ProtobufOutput
+Required.JsonInput.TimestampWithNegativeOffset.JsonOutput
+Required.JsonInput.TimestampWithNegativeOffset.ProtobufOutput
+Required.JsonInput.TimestampWithPositiveOffset.JsonOutput
+Required.JsonInput.TimestampWithPositiveOffset.ProtobufOutput
+Required.JsonInput.Uint32FieldMaxFloatValue.JsonOutput
+Required.JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput
+Required.JsonInput.Uint32MapField.JsonOutput
+Required.JsonInput.Uint32MapField.ProtobufOutput
+Required.JsonInput.Uint64FieldMaxValue.JsonOutput
+Required.JsonInput.Uint64FieldMaxValue.ProtobufOutput
+Required.JsonInput.Uint64MapField.JsonOutput
+Required.JsonInput.Uint64MapField.ProtobufOutput
+Required.JsonInput.ValueAcceptBool.JsonOutput
+Required.JsonInput.ValueAcceptBool.ProtobufOutput
+Required.JsonInput.ValueAcceptFloat.JsonOutput
+Required.JsonInput.ValueAcceptFloat.ProtobufOutput
+Required.JsonInput.ValueAcceptInteger.JsonOutput
+Required.JsonInput.ValueAcceptInteger.ProtobufOutput
+Required.JsonInput.ValueAcceptList.JsonOutput
+Required.JsonInput.ValueAcceptList.ProtobufOutput
+Required.JsonInput.ValueAcceptNull.JsonOutput
+Required.JsonInput.ValueAcceptNull.ProtobufOutput
+Required.JsonInput.ValueAcceptObject.JsonOutput
+Required.JsonInput.ValueAcceptObject.ProtobufOutput
+Required.JsonInput.ValueAcceptString.JsonOutput
+Required.JsonInput.ValueAcceptString.ProtobufOutput
+Required.JsonInput.WrapperTypesWithNullValue.ProtobufOutput
+Required.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput
+Required.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput
+Required.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput
+Required.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED32.ProtobufOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED64.ProtobufOutput
+Required.ProtobufInput.RepeatedScalarSelectsLast.UINT64.ProtobufOutput
+Required.TimestampProtoInputTooLarge.JsonOutput
+Required.TimestampProtoInputTooSmall.JsonOutput
diff --git a/conformance/failure_list_python.txt b/conformance/failure_list_python.txt
index 04985199..9d556a03 100644
--- a/conformance/failure_list_python.txt
+++ b/conformance/failure_list_python.txt
@@ -1,18 +1,12 @@
Recommended.JsonInput.DoubleFieldInfinityNotQuoted
Recommended.JsonInput.DoubleFieldNanNotQuoted
Recommended.JsonInput.DoubleFieldNegativeInfinityNotQuoted
-Recommended.JsonInput.FieldNameWithDoubleUnderscores.JsonOutput
-Recommended.JsonInput.FieldNameWithDoubleUnderscores.ProtobufOutput
-Recommended.JsonInput.FieldNameWithDoubleUnderscores.Validator
Recommended.JsonInput.FloatFieldInfinityNotQuoted
Recommended.JsonInput.FloatFieldNanNotQuoted
Recommended.JsonInput.FloatFieldNegativeInfinityNotQuoted
Required.JsonInput.BytesFieldInvalidBase64Characters
Required.JsonInput.DoubleFieldTooSmall
Required.JsonInput.EnumFieldUnknownValue.Validator
-Required.JsonInput.FieldNameInLowerCamelCase.Validator
-Required.JsonInput.FieldNameInSnakeCase.JsonOutput
-Required.JsonInput.FieldNameInSnakeCase.ProtobufOutput
Required.JsonInput.FloatFieldTooLarge
Required.JsonInput.FloatFieldTooSmall
Required.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool
diff --git a/conformance/failure_list_python_cpp.txt b/conformance/failure_list_python_cpp.txt
index f3958f5f..92404d2f 100644
--- a/conformance/failure_list_python_cpp.txt
+++ b/conformance/failure_list_python_cpp.txt
@@ -10,18 +10,12 @@
Recommended.JsonInput.DoubleFieldInfinityNotQuoted
Recommended.JsonInput.DoubleFieldNanNotQuoted
Recommended.JsonInput.DoubleFieldNegativeInfinityNotQuoted
-Recommended.JsonInput.FieldNameWithDoubleUnderscores.JsonOutput
-Recommended.JsonInput.FieldNameWithDoubleUnderscores.ProtobufOutput
-Recommended.JsonInput.FieldNameWithDoubleUnderscores.Validator
Recommended.JsonInput.FloatFieldInfinityNotQuoted
Recommended.JsonInput.FloatFieldNanNotQuoted
Recommended.JsonInput.FloatFieldNegativeInfinityNotQuoted
Required.JsonInput.BytesFieldInvalidBase64Characters
Required.JsonInput.DoubleFieldTooSmall
Required.JsonInput.EnumFieldUnknownValue.Validator
-Required.JsonInput.FieldNameInLowerCamelCase.Validator
-Required.JsonInput.FieldNameInSnakeCase.JsonOutput
-Required.JsonInput.FieldNameInSnakeCase.ProtobufOutput
Required.JsonInput.FloatFieldTooLarge
Required.JsonInput.FloatFieldTooSmall
Required.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool
diff --git a/conformance/failure_list_ruby.txt b/conformance/failure_list_ruby.txt
index dbd55697..1de6c439 100644
--- a/conformance/failure_list_ruby.txt
+++ b/conformance/failure_list_ruby.txt
@@ -7,9 +7,6 @@ Recommended.JsonInput.DurationHas3FractionalDigits.Validator
Recommended.JsonInput.DurationHas6FractionalDigits.Validator
Recommended.JsonInput.DurationHas9FractionalDigits.Validator
Recommended.JsonInput.DurationHasZeroFractionalDigit.Validator
-Recommended.JsonInput.FieldNameWithDoubleUnderscores.JsonOutput
-Recommended.JsonInput.FieldNameWithDoubleUnderscores.ProtobufOutput
-Recommended.JsonInput.FieldNameWithDoubleUnderscores.Validator
Recommended.JsonInput.Int64FieldBeString.Validator
Recommended.JsonInput.OneofZeroDouble.JsonOutput
Recommended.JsonInput.OneofZeroDouble.ProtobufOutput
@@ -80,9 +77,6 @@ Required.JsonInput.EnumFieldNumericValueZero.ProtobufOutput
Required.JsonInput.EnumFieldUnknownValue.Validator
Required.JsonInput.FieldMask.JsonOutput
Required.JsonInput.FieldMask.ProtobufOutput
-Required.JsonInput.FieldNameInLowerCamelCase.Validator
-Required.JsonInput.FieldNameInSnakeCase.JsonOutput
-Required.JsonInput.FieldNameInSnakeCase.ProtobufOutput
Required.JsonInput.FloatFieldInfinity.JsonOutput
Required.JsonInput.FloatFieldInfinity.ProtobufOutput
Required.JsonInput.FloatFieldNan.JsonOutput
diff --git a/csharp/Google.Protobuf.Tools.nuspec b/csharp/Google.Protobuf.Tools.nuspec
index d079c683..0b9cbcf4 100644
--- a/csharp/Google.Protobuf.Tools.nuspec
+++ b/csharp/Google.Protobuf.Tools.nuspec
@@ -5,7 +5,7 @@
<title>Google Protocol Buffers tools</title>
<summary>Tools for Protocol Buffers - Google's data interchange format.</summary>
<description>See project site for more info.</description>
- <version>3.1.0</version>
+ <version>3.2.0</version>
<authors>Google Inc.</authors>
<owners>protobuf-packages</owners>
<licenseUrl>https://github.com/google/protobuf/blob/master/LICENSE</licenseUrl>
diff --git a/csharp/README.md b/csharp/README.md
index ed5c7be7..65d2311f 100644
--- a/csharp/README.md
+++ b/csharp/README.md
@@ -32,8 +32,7 @@ Building
========
Open the `src/Google.Protobuf.sln` solution in Visual Studio 2015 or
-later. You should be able to run the NUnit test from Test Explorer
-(you might need to install NUnit Visual Studio add-in).
+later.
Although *users* of this project are only expected to have Visual
Studio 2012 or later, *developers* of the library are required to
@@ -42,6 +41,57 @@ in its implementation. These features have no impact when using the
compiled code - they're only relevant when building the
`Google.Protobuf` assembly.
+Testing
+=======
+
+The unit tests use [NUnit 3](https://github.com/nunit/nunit). Vanilla NUnit doesn't
+support .NET Core, so to run the tests you'll need to use
+[dotnet-test-nunit](https://github.com/nunit/dotnet-test-nunit).
+`dotnet-test-nunit` can also run tests for .NET 4.5+, so to run the tests
+for both .NET Core and .NET 4.5, you can simply open the
+`Package Manager Console` in Visual Studio and execute:
+```
+dotnet test Google.Protobuf.Test
+```
+
+.NET 3.5
+========
+
+We don't officially support .NET 3.5. However, there has been some effort
+to make enabling .NET 3.5 support relatively painless in case you require it.
+There's no guarantee that this will continue in the future, so rely on .NET
+3.5 support at your peril.
+
+To enable .NET 3.5 support:
+
+1. Modify [src/Google.Protobuf/project.json](src/Google.Protobuf/project.json) to add `"net35": {}` to `"frameworks"`.
+2. Modify [src/Google.Protobuf.Test/project.json](src/Google.Protobuf/project.json):
+ 1. Add `"net35": {}` to `"frameworks"`.
+ 2. `dotnet-test-nunit` doesn't support .NET 3.5, so remove it from
+ the project-wide `"dependencies"` and add it to the framework-specific
+ dependencies under `"net451"` and `"netcoreapp1.0"`.
+
+Note that `dotnet-test-nunit` doesn't support .NET 3.5. You can instead run the
+tests with [NUnit 3 console](https://github.com/nunit/nunit-console)
+by running something like:
+```
+nunit3-console.exe "Google.Protobuf.Test\bin\Debug\net35\win7-x64\Google.Protobuf.Test.dll" --inprocess
+```
+
+The exact path may differ depending on your environment (e.g., the `win7-x64`
+directory may be called something else). The `--inprocess` flag seems to be a
+necessary workaround for a bug in NUnit; otherwise, you'll receive
+an error "Exception has been thrown by the target of an invocation"
+([possibly related issue](https://github.com/nunit/nunit/issues/1480)).
+
+If you still want to run the .NET 4.5 and .NET Core tests, you can do so by
+specifying the framework when using `dotnet-test-nunit`, i.e. from
+`Package Manager Console` in Visual Studio:
+```
+dotnet test Google.Protobuf.Test --framework netcoreapp1.0
+dotnet test Google.Protobuf.Test --framework net451
+```
+
History of C# protobufs
=======================
diff --git a/csharp/compatibility_tests/v3.0.0/protos/csharp/protos/unittest_issues.proto b/csharp/compatibility_tests/v3.0.0/protos/csharp/protos/unittest_issues.proto
new file mode 100644
index 00000000..6c9f7634
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/protos/csharp/protos/unittest_issues.proto
@@ -0,0 +1,126 @@
+syntax = "proto3";
+
+// These proto descriptors have at one time been reported as an issue or defect.
+// They are kept here to replicate the issue, and continue to verify the fix.
+
+// Issue: Non-"Google.Protobuffers" namespace will ensure that protobuffer library types are qualified
+option csharp_namespace = "UnitTest.Issues.TestProtos";
+
+package unittest_issues;
+option optimize_for = SPEED;
+
+// Issue 307: when generating doubly-nested types, any references
+// should be of the form A.Types.B.Types.C.
+message Issue307 {
+ message NestedOnce {
+ message NestedTwice {
+ }
+ }
+}
+
+// Old issue 13: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=13
+// New issue 309: https://github.com/google/protobuf/issues/309
+
+// message A {
+// optional int32 _A = 1;
+// }
+
+// message B {
+// optional int32 B_ = 1;
+// }
+
+//message AB {
+// optional int32 a_b = 1;
+//}
+
+// Similar issue with numeric names
+// Java code failed too, so probably best for this to be a restriction.
+// See https://github.com/google/protobuf/issues/308
+// message NumberField {
+// optional int32 _01 = 1;
+// }
+
+// issue 19 - negative enum values
+
+enum NegativeEnum {
+ NEGATIVE_ENUM_ZERO = 0;
+ FiveBelow = -5;
+ MinusOne = -1;
+}
+
+message NegativeEnumMessage {
+ NegativeEnum value = 1;
+ repeated NegativeEnum values = 2 [packed = false];
+ repeated NegativeEnum packed_values = 3 [packed=true];
+}
+
+// Issue 21: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=21
+// Decorate fields with [deprecated=true] as [System.Obsolete]
+
+message DeprecatedChild {
+}
+
+enum DeprecatedEnum {
+ DEPRECATED_ZERO = 0;
+ one = 1;
+}
+
+message DeprecatedFieldsMessage {
+ int32 PrimitiveValue = 1 [deprecated = true];
+ repeated int32 PrimitiveArray = 2 [deprecated = true];
+
+ DeprecatedChild MessageValue = 3 [deprecated = true];
+ repeated DeprecatedChild MessageArray = 4 [deprecated = true];
+
+ DeprecatedEnum EnumValue = 5 [deprecated = true];
+ repeated DeprecatedEnum EnumArray = 6 [deprecated = true];
+}
+
+// Issue 45: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=45
+message ItemField {
+ int32 item = 1;
+}
+
+message ReservedNames {
+ // Force a nested type called Types
+ message SomeNestedType {
+ }
+
+ int32 types = 1;
+ int32 descriptor = 2;
+}
+
+message TestJsonFieldOrdering {
+ // These fields are deliberately not declared in numeric
+ // order, and the oneof fields aren't contiguous either.
+ // This allows for reasonably robust tests of JSON output
+ // ordering.
+ // TestFieldOrderings in unittest_proto3.proto is similar,
+ // but doesn't include oneofs.
+ // TODO: Consider adding oneofs to TestFieldOrderings, although
+ // that will require fixing other tests in multiple platforms.
+ // Alternatively, consider just adding this to
+ // unittest_proto3.proto if multiple platforms want it.
+
+ int32 plain_int32 = 4;
+
+ oneof o1 {
+ string o1_string = 2;
+ int32 o1_int32 = 5;
+ }
+
+ string plain_string = 1;
+
+ oneof o2 {
+ int32 o2_int32 = 6;
+ string o2_string = 3;
+ }
+
+}
+
+message TestJsonName {
+ // Message for testing the effects for of the json_name option
+ string name = 1;
+ string description = 2 [json_name = "desc"];
+ string guid = 3 [json_name = "exid"];
+}
diff --git a/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/map_unittest_proto3.proto b/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/map_unittest_proto3.proto
new file mode 100644
index 00000000..16be2773
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/map_unittest_proto3.proto
@@ -0,0 +1,120 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// This file is mostly equivalent to map_unittest.proto, but imports
+// unittest_proto3.proto instead of unittest.proto, so that it only
+// uses proto3 messages. This makes it suitable for testing
+// implementations which only support proto3.
+// The TestRequiredMessageMap message has been removed as there are no
+// required fields in proto3.
+syntax = "proto3";
+
+option cc_enable_arenas = true;
+option csharp_namespace = "Google.Protobuf.TestProtos";
+
+import "google/protobuf/unittest_proto3.proto";
+
+// We don't put this in a package within proto2 because we need to make sure
+// that the generated code doesn't depend on being in the proto2 namespace.
+// In map_test_util.h we do "using namespace unittest = protobuf_unittest".
+package protobuf_unittest;
+
+// Tests maps.
+message TestMap {
+ map<int32 , int32 > map_int32_int32 = 1;
+ map<int64 , int64 > map_int64_int64 = 2;
+ map<uint32 , uint32 > map_uint32_uint32 = 3;
+ map<uint64 , uint64 > map_uint64_uint64 = 4;
+ map<sint32 , sint32 > map_sint32_sint32 = 5;
+ map<sint64 , sint64 > map_sint64_sint64 = 6;
+ map<fixed32 , fixed32 > map_fixed32_fixed32 = 7;
+ map<fixed64 , fixed64 > map_fixed64_fixed64 = 8;
+ map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 9;
+ map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 10;
+ map<int32 , float > map_int32_float = 11;
+ map<int32 , double > map_int32_double = 12;
+ map<bool , bool > map_bool_bool = 13;
+ map<string , string > map_string_string = 14;
+ map<int32 , bytes > map_int32_bytes = 15;
+ map<int32 , MapEnum > map_int32_enum = 16;
+ map<int32 , ForeignMessage> map_int32_foreign_message = 17;
+}
+
+message TestMapSubmessage {
+ TestMap test_map = 1;
+}
+
+message TestMessageMap {
+ map<int32, TestAllTypes> map_int32_message = 1;
+}
+
+// Two map fields share the same entry default instance.
+message TestSameTypeMap {
+ map<int32, int32> map1 = 1;
+ map<int32, int32> map2 = 2;
+}
+
+enum MapEnum {
+ MAP_ENUM_FOO = 0;
+ MAP_ENUM_BAR = 1;
+ MAP_ENUM_BAZ = 2;
+}
+
+message TestArenaMap {
+ map<int32 , int32 > map_int32_int32 = 1;
+ map<int64 , int64 > map_int64_int64 = 2;
+ map<uint32 , uint32 > map_uint32_uint32 = 3;
+ map<uint64 , uint64 > map_uint64_uint64 = 4;
+ map<sint32 , sint32 > map_sint32_sint32 = 5;
+ map<sint64 , sint64 > map_sint64_sint64 = 6;
+ map<fixed32 , fixed32 > map_fixed32_fixed32 = 7;
+ map<fixed64 , fixed64 > map_fixed64_fixed64 = 8;
+ map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 9;
+ map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 10;
+ map<int32 , float > map_int32_float = 11;
+ map<int32 , double > map_int32_double = 12;
+ map<bool , bool > map_bool_bool = 13;
+ map<int32 , MapEnum > map_int32_enum = 14;
+ map<int32 , ForeignMessage> map_int32_foreign_message = 15;
+}
+
+// Previously, message containing enum called Type cannot be used as value of
+// map field.
+message MessageContainingEnumCalledType {
+ enum Type {
+ TYPE_FOO = 0;
+ }
+ map<int32, MessageContainingEnumCalledType> type = 1;
+}
+
+// Previously, message cannot contain map field called "entry".
+message MessageContainingMapCalledEntry {
+ map<int32, int32> entry = 1;
+}
diff --git a/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_import_proto3.proto b/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_import_proto3.proto
new file mode 100644
index 00000000..59673eaf
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_import_proto3.proto
@@ -0,0 +1,68 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Author: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+//
+// A proto file which is imported by unittest_proto3.proto to test importing.
+
+syntax = "proto3";
+
+// We don't put this in a package within proto2 because we need to make sure
+// that the generated code doesn't depend on being in the proto2 namespace.
+// In test_util.h we do
+// "using namespace unittest_import = protobuf_unittest_import".
+package protobuf_unittest_import;
+
+option optimize_for = SPEED;
+option cc_enable_arenas = true;
+
+// Exercise the java_package option.
+option java_package = "com.google.protobuf.test";
+option csharp_namespace = "Google.Protobuf.TestProtos";
+
+// Do not set a java_outer_classname here to verify that Proto2 works without
+// one.
+
+// Test public import
+import public "google/protobuf/unittest_import_public_proto3.proto";
+
+message ImportMessage {
+ int32 d = 1;
+}
+
+enum ImportEnum {
+ IMPORT_ENUM_UNSPECIFIED = 0;
+ IMPORT_FOO = 7;
+ IMPORT_BAR = 8;
+ IMPORT_BAZ = 9;
+}
+
diff --git a/src/google/protobuf/arena_nc.cc b/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_import_public_proto3.proto
index f2f08427..d6f11e28 100644
--- a/src/google/protobuf/arena_nc.cc
+++ b/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_import_public_proto3.proto
@@ -28,18 +28,15 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Negative compilation test for arena usage.
+// Author: liujisi@google.com (Pherl Liu)
-#include <google/protobuf/arena.h>
-#include <google/protobuf/unittest.pb.h>
+syntax = "proto3";
-#ifdef TEST_ARENA_PRIVATE_CONSTRUCTOR
+package protobuf_unittest_import;
-namespace google {
-void ArenaPrivateConstructor() {
- google::protobuf::Arena arena;
- protobuf_unittest::TestAllTypes message(&arena);
-}
+option java_package = "com.google.protobuf.test";
+option csharp_namespace = "Google.Protobuf.TestProtos";
-#endif
-} // namespace google
+message PublicImportMessage {
+ int32 e = 1;
+}
diff --git a/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_proto3.proto b/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_proto3.proto
new file mode 100644
index 00000000..f59d2178
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_proto3.proto
@@ -0,0 +1,388 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Author: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+//
+// A proto file we will use for unit testing.
+
+syntax = "proto3";
+
+// Some generic_services option(s) added automatically.
+// See: http://go/proto2-generic-services-default
+option cc_generic_services = true; // auto-added
+option java_generic_services = true; // auto-added
+option py_generic_services = true; // auto-added
+option cc_enable_arenas = true;
+option csharp_namespace = "Google.Protobuf.TestProtos";
+
+import "google/protobuf/unittest_import_proto3.proto";
+
+// We don't put this in a package within proto2 because we need to make sure
+// that the generated code doesn't depend on being in the proto2 namespace.
+// In test_util.h we do "using namespace unittest = protobuf_unittest".
+package protobuf_unittest;
+
+// Protos optimized for SPEED use a strict superset of the generated code
+// of equivalent ones optimized for CODE_SIZE, so we should optimize all our
+// tests for speed unless explicitly testing code size optimization.
+option optimize_for = SPEED;
+
+option java_outer_classname = "UnittestProto";
+
+// This proto includes every type of field in both singular and repeated
+// forms.
+message TestAllTypes {
+ message NestedMessage {
+ // The field name "b" fails to compile in proto1 because it conflicts with
+ // a local variable named "b" in one of the generated methods. Doh.
+ // This file needs to compile in proto1 to test backwards-compatibility.
+ int32 bb = 1;
+ }
+
+ enum NestedEnum {
+ NESTED_ENUM_UNSPECIFIED = 0;
+ FOO = 1;
+ BAR = 2;
+ BAZ = 3;
+ NEG = -1; // Intentionally negative.
+ }
+
+ // Singular
+ int32 single_int32 = 1;
+ int64 single_int64 = 2;
+ uint32 single_uint32 = 3;
+ uint64 single_uint64 = 4;
+ sint32 single_sint32 = 5;
+ sint64 single_sint64 = 6;
+ fixed32 single_fixed32 = 7;
+ fixed64 single_fixed64 = 8;
+ sfixed32 single_sfixed32 = 9;
+ sfixed64 single_sfixed64 = 10;
+ float single_float = 11;
+ double single_double = 12;
+ bool single_bool = 13;
+ string single_string = 14;
+ bytes single_bytes = 15;
+
+ NestedMessage single_nested_message = 18;
+ ForeignMessage single_foreign_message = 19;
+ protobuf_unittest_import.ImportMessage single_import_message = 20;
+
+ NestedEnum single_nested_enum = 21;
+ ForeignEnum single_foreign_enum = 22;
+ protobuf_unittest_import.ImportEnum single_import_enum = 23;
+
+ // Defined in unittest_import_public.proto
+ protobuf_unittest_import.PublicImportMessage
+ single_public_import_message = 26;
+
+ // Repeated
+ repeated int32 repeated_int32 = 31;
+ repeated int64 repeated_int64 = 32;
+ repeated uint32 repeated_uint32 = 33;
+ repeated uint64 repeated_uint64 = 34;
+ repeated sint32 repeated_sint32 = 35;
+ repeated sint64 repeated_sint64 = 36;
+ repeated fixed32 repeated_fixed32 = 37;
+ repeated fixed64 repeated_fixed64 = 38;
+ repeated sfixed32 repeated_sfixed32 = 39;
+ repeated sfixed64 repeated_sfixed64 = 40;
+ repeated float repeated_float = 41;
+ repeated double repeated_double = 42;
+ repeated bool repeated_bool = 43;
+ repeated string repeated_string = 44;
+ repeated bytes repeated_bytes = 45;
+
+ repeated NestedMessage repeated_nested_message = 48;
+ repeated ForeignMessage repeated_foreign_message = 49;
+ repeated protobuf_unittest_import.ImportMessage repeated_import_message = 50;
+
+ repeated NestedEnum repeated_nested_enum = 51;
+ repeated ForeignEnum repeated_foreign_enum = 52;
+ repeated protobuf_unittest_import.ImportEnum repeated_import_enum = 53;
+ // Defined in unittest_import_public.proto
+ repeated protobuf_unittest_import.PublicImportMessage
+ repeated_public_import_message = 54;
+
+ // For oneof test
+ oneof oneof_field {
+ uint32 oneof_uint32 = 111;
+ NestedMessage oneof_nested_message = 112;
+ string oneof_string = 113;
+ bytes oneof_bytes = 114;
+ }
+}
+
+// This proto includes a recusively nested message.
+message NestedTestAllTypes {
+ NestedTestAllTypes child = 1;
+ TestAllTypes payload = 2;
+ repeated NestedTestAllTypes repeated_child = 3;
+}
+
+message TestDeprecatedFields {
+ int32 deprecated_int32 = 1 [deprecated=true];
+}
+
+// Define these after TestAllTypes to make sure the compiler can handle
+// that.
+message ForeignMessage {
+ int32 c = 1;
+}
+
+enum ForeignEnum {
+ FOREIGN_UNSPECIFIED = 0;
+ FOREIGN_FOO = 4;
+ FOREIGN_BAR = 5;
+ FOREIGN_BAZ = 6;
+}
+
+message TestReservedFields {
+ reserved 2, 15, 9 to 11;
+ reserved "bar", "baz";
+}
+
+
+// Test that we can use NestedMessage from outside TestAllTypes.
+message TestForeignNested {
+ TestAllTypes.NestedMessage foreign_nested = 1;
+}
+
+// Test that really large tag numbers don't break anything.
+message TestReallyLargeTagNumber {
+ // The largest possible tag number is 2^28 - 1, since the wire format uses
+ // three bits to communicate wire type.
+ int32 a = 1;
+ int32 bb = 268435455;
+}
+
+message TestRecursiveMessage {
+ TestRecursiveMessage a = 1;
+ int32 i = 2;
+}
+
+// Test that mutual recursion works.
+message TestMutualRecursionA {
+ TestMutualRecursionB bb = 1;
+}
+
+message TestMutualRecursionB {
+ TestMutualRecursionA a = 1;
+ int32 optional_int32 = 2;
+}
+
+
+// Test an enum that has multiple values with the same number.
+enum TestEnumWithDupValue {
+ TEST_ENUM_WITH_DUP_VALUE_UNSPECIFIED = 0;
+ option allow_alias = true;
+
+ FOO1 = 1;
+ BAR1 = 2;
+ BAZ = 3;
+ FOO2 = 1;
+ BAR2 = 2;
+}
+
+// Test an enum with large, unordered values.
+enum TestSparseEnum {
+ TEST_SPARSE_ENUM_UNSPECIFIED = 0;
+ SPARSE_A = 123;
+ SPARSE_B = 62374;
+ SPARSE_C = 12589234;
+ SPARSE_D = -15;
+ SPARSE_E = -53452;
+ // In proto3, value 0 must be the first one specified
+ // SPARSE_F = 0;
+ SPARSE_G = 2;
+}
+
+// Test message with CamelCase field names. This violates Protocol Buffer
+// standard style.
+message TestCamelCaseFieldNames {
+ int32 PrimitiveField = 1;
+ string StringField = 2;
+ ForeignEnum EnumField = 3;
+ ForeignMessage MessageField = 4;
+
+ repeated int32 RepeatedPrimitiveField = 7;
+ repeated string RepeatedStringField = 8;
+ repeated ForeignEnum RepeatedEnumField = 9;
+ repeated ForeignMessage RepeatedMessageField = 10;
+}
+
+
+// We list fields out of order, to ensure that we're using field number and not
+// field index to determine serialization order.
+message TestFieldOrderings {
+ string my_string = 11;
+ int64 my_int = 1;
+ float my_float = 101;
+ message NestedMessage {
+ int64 oo = 2;
+ // The field name "b" fails to compile in proto1 because it conflicts with
+ // a local variable named "b" in one of the generated methods. Doh.
+ // This file needs to compile in proto1 to test backwards-compatibility.
+ int32 bb = 1;
+ }
+
+ NestedMessage single_nested_message = 200;
+}
+
+message SparseEnumMessage {
+ TestSparseEnum sparse_enum = 1;
+}
+
+// Test String and Bytes: string is for valid UTF-8 strings
+message OneString {
+ string data = 1;
+}
+
+message MoreString {
+ repeated string data = 1;
+}
+
+message OneBytes {
+ bytes data = 1;
+}
+
+message MoreBytes {
+ bytes data = 1;
+}
+
+// Test int32, uint32, int64, uint64, and bool are all compatible
+message Int32Message {
+ int32 data = 1;
+}
+
+message Uint32Message {
+ uint32 data = 1;
+}
+
+message Int64Message {
+ int64 data = 1;
+}
+
+message Uint64Message {
+ uint64 data = 1;
+}
+
+message BoolMessage {
+ bool data = 1;
+}
+
+// Test oneofs.
+message TestOneof {
+ oneof foo {
+ int32 foo_int = 1;
+ string foo_string = 2;
+ TestAllTypes foo_message = 3;
+ }
+}
+
+// Test messages for packed fields
+
+message TestPackedTypes {
+ repeated int32 packed_int32 = 90 [packed = true];
+ repeated int64 packed_int64 = 91 [packed = true];
+ repeated uint32 packed_uint32 = 92 [packed = true];
+ repeated uint64 packed_uint64 = 93 [packed = true];
+ repeated sint32 packed_sint32 = 94 [packed = true];
+ repeated sint64 packed_sint64 = 95 [packed = true];
+ repeated fixed32 packed_fixed32 = 96 [packed = true];
+ repeated fixed64 packed_fixed64 = 97 [packed = true];
+ repeated sfixed32 packed_sfixed32 = 98 [packed = true];
+ repeated sfixed64 packed_sfixed64 = 99 [packed = true];
+ repeated float packed_float = 100 [packed = true];
+ repeated double packed_double = 101 [packed = true];
+ repeated bool packed_bool = 102 [packed = true];
+ repeated ForeignEnum packed_enum = 103 [packed = true];
+}
+
+// A message with the same fields as TestPackedTypes, but without packing. Used
+// to test packed <-> unpacked wire compatibility.
+message TestUnpackedTypes {
+ repeated int32 unpacked_int32 = 90 [packed = false];
+ repeated int64 unpacked_int64 = 91 [packed = false];
+ repeated uint32 unpacked_uint32 = 92 [packed = false];
+ repeated uint64 unpacked_uint64 = 93 [packed = false];
+ repeated sint32 unpacked_sint32 = 94 [packed = false];
+ repeated sint64 unpacked_sint64 = 95 [packed = false];
+ repeated fixed32 unpacked_fixed32 = 96 [packed = false];
+ repeated fixed64 unpacked_fixed64 = 97 [packed = false];
+ repeated sfixed32 unpacked_sfixed32 = 98 [packed = false];
+ repeated sfixed64 unpacked_sfixed64 = 99 [packed = false];
+ repeated float unpacked_float = 100 [packed = false];
+ repeated double unpacked_double = 101 [packed = false];
+ repeated bool unpacked_bool = 102 [packed = false];
+ repeated ForeignEnum unpacked_enum = 103 [packed = false];
+}
+
+message TestRepeatedScalarDifferentTagSizes {
+ // Parsing repeated fixed size values used to fail. This message needs to be
+ // used in order to get a tag of the right size; all of the repeated fields
+ // in TestAllTypes didn't trigger the check.
+ repeated fixed32 repeated_fixed32 = 12;
+ // Check for a varint type, just for good measure.
+ repeated int32 repeated_int32 = 13;
+
+ // These have two-byte tags.
+ repeated fixed64 repeated_fixed64 = 2046;
+ repeated int64 repeated_int64 = 2047;
+
+ // Three byte tags.
+ repeated float repeated_float = 262142;
+ repeated uint64 repeated_uint64 = 262143;
+}
+
+message TestCommentInjectionMessage {
+ // */ <- This should not close the generated doc comment
+ string a = 1;
+}
+
+
+// Test that RPC services work.
+message FooRequest {}
+message FooResponse {}
+
+message FooClientMessage {}
+message FooServerMessage{}
+
+service TestService {
+ rpc Foo(FooRequest) returns (FooResponse);
+ rpc Bar(BarRequest) returns (BarResponse);
+}
+
+
+message BarRequest {}
+message BarResponse {}
+
diff --git a/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_well_known_types.proto b/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_well_known_types.proto
new file mode 100644
index 00000000..c9075244
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_well_known_types.proto
@@ -0,0 +1,114 @@
+syntax = "proto3";
+
+package protobuf_unittest;
+
+option csharp_namespace = "Google.Protobuf.TestProtos";
+option java_multiple_files = true;
+option java_package = "com.google.protobuf.test";
+
+import "google/protobuf/any.proto";
+import "google/protobuf/api.proto";
+import "google/protobuf/duration.proto";
+import "google/protobuf/empty.proto";
+import "google/protobuf/field_mask.proto";
+import "google/protobuf/source_context.proto";
+import "google/protobuf/struct.proto";
+import "google/protobuf/timestamp.proto";
+import "google/protobuf/type.proto";
+import "google/protobuf/wrappers.proto";
+
+// Test that we can include all well-known types.
+// Each wrapper type is included separately, as languages
+// map handle different wrappers in different ways.
+message TestWellKnownTypes {
+ google.protobuf.Any any_field = 1;
+ google.protobuf.Api api_field = 2;
+ google.protobuf.Duration duration_field = 3;
+ google.protobuf.Empty empty_field = 4;
+ google.protobuf.FieldMask field_mask_field = 5;
+ google.protobuf.SourceContext source_context_field = 6;
+ google.protobuf.Struct struct_field = 7;
+ google.protobuf.Timestamp timestamp_field = 8;
+ google.protobuf.Type type_field = 9;
+ google.protobuf.DoubleValue double_field = 10;
+ google.protobuf.FloatValue float_field = 11;
+ google.protobuf.Int64Value int64_field = 12;
+ google.protobuf.UInt64Value uint64_field = 13;
+ google.protobuf.Int32Value int32_field = 14;
+ google.protobuf.UInt32Value uint32_field = 15;
+ google.protobuf.BoolValue bool_field = 16;
+ google.protobuf.StringValue string_field = 17;
+ google.protobuf.BytesValue bytes_field = 18;
+ // Part of struct, but useful to be able to test separately
+ google.protobuf.Value value_field = 19;
+}
+
+// A repeated field for each well-known type.
+message RepeatedWellKnownTypes {
+ repeated google.protobuf.Any any_field = 1;
+ repeated google.protobuf.Api api_field = 2;
+ repeated google.protobuf.Duration duration_field = 3;
+ repeated google.protobuf.Empty empty_field = 4;
+ repeated google.protobuf.FieldMask field_mask_field = 5;
+ repeated google.protobuf.SourceContext source_context_field = 6;
+ repeated google.protobuf.Struct struct_field = 7;
+ repeated google.protobuf.Timestamp timestamp_field = 8;
+ repeated google.protobuf.Type type_field = 9;
+ // These don't actually make a lot of sense, but they're not prohibited...
+ repeated google.protobuf.DoubleValue double_field = 10;
+ repeated google.protobuf.FloatValue float_field = 11;
+ repeated google.protobuf.Int64Value int64_field = 12;
+ repeated google.protobuf.UInt64Value uint64_field = 13;
+ repeated google.protobuf.Int32Value int32_field = 14;
+ repeated google.protobuf.UInt32Value uint32_field = 15;
+ repeated google.protobuf.BoolValue bool_field = 16;
+ repeated google.protobuf.StringValue string_field = 17;
+ repeated google.protobuf.BytesValue bytes_field = 18;
+}
+
+message OneofWellKnownTypes {
+ oneof oneof_field {
+ google.protobuf.Any any_field = 1;
+ google.protobuf.Api api_field = 2;
+ google.protobuf.Duration duration_field = 3;
+ google.protobuf.Empty empty_field = 4;
+ google.protobuf.FieldMask field_mask_field = 5;
+ google.protobuf.SourceContext source_context_field = 6;
+ google.protobuf.Struct struct_field = 7;
+ google.protobuf.Timestamp timestamp_field = 8;
+ google.protobuf.Type type_field = 9;
+ google.protobuf.DoubleValue double_field = 10;
+ google.protobuf.FloatValue float_field = 11;
+ google.protobuf.Int64Value int64_field = 12;
+ google.protobuf.UInt64Value uint64_field = 13;
+ google.protobuf.Int32Value int32_field = 14;
+ google.protobuf.UInt32Value uint32_field = 15;
+ google.protobuf.BoolValue bool_field = 16;
+ google.protobuf.StringValue string_field = 17;
+ google.protobuf.BytesValue bytes_field = 18;
+ }
+}
+
+// A map field for each well-known type. We only
+// need to worry about the value part of the map being the
+// well-known types, as messages can't be map keys.
+message MapWellKnownTypes {
+ map<int32,google.protobuf.Any> any_field = 1;
+ map<int32,google.protobuf.Api> api_field = 2;
+ map<int32,google.protobuf.Duration> duration_field = 3;
+ map<int32,google.protobuf.Empty> empty_field = 4;
+ map<int32,google.protobuf.FieldMask> field_mask_field = 5;
+ map<int32,google.protobuf.SourceContext> source_context_field = 6;
+ map<int32,google.protobuf.Struct> struct_field = 7;
+ map<int32,google.protobuf.Timestamp> timestamp_field = 8;
+ map<int32,google.protobuf.Type> type_field = 9;
+ map<int32,google.protobuf.DoubleValue> double_field = 10;
+ map<int32,google.protobuf.FloatValue> float_field = 11;
+ map<int32,google.protobuf.Int64Value> int64_field = 12;
+ map<int32,google.protobuf.UInt64Value> uint64_field = 13;
+ map<int32,google.protobuf.Int32Value> int32_field = 14;
+ map<int32,google.protobuf.UInt32Value> uint32_field = 15;
+ map<int32,google.protobuf.BoolValue> bool_field = 16;
+ map<int32,google.protobuf.StringValue> string_field = 17;
+ map<int32,google.protobuf.BytesValue> bytes_field = 18;
+}
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/ByteStringTest.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/ByteStringTest.cs
new file mode 100644
index 00000000..685e130a
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/ByteStringTest.cs
@@ -0,0 +1,171 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using System;
+using System.Text;
+using NUnit.Framework;
+
+namespace Google.Protobuf
+{
+ public class ByteStringTest
+ {
+ [Test]
+ public void Equality()
+ {
+ ByteString b1 = ByteString.CopyFrom(1, 2, 3);
+ ByteString b2 = ByteString.CopyFrom(1, 2, 3);
+ ByteString b3 = ByteString.CopyFrom(1, 2, 4);
+ ByteString b4 = ByteString.CopyFrom(1, 2, 3, 4);
+ EqualityTester.AssertEquality(b1, b1);
+ EqualityTester.AssertEquality(b1, b2);
+ EqualityTester.AssertInequality(b1, b3);
+ EqualityTester.AssertInequality(b1, b4);
+ EqualityTester.AssertInequality(b1, null);
+#pragma warning disable 1718 // Deliberately calling ==(b1, b1) and !=(b1, b1)
+ Assert.IsTrue(b1 == b1);
+ Assert.IsTrue(b1 == b2);
+ Assert.IsFalse(b1 == b3);
+ Assert.IsFalse(b1 == b4);
+ Assert.IsFalse(b1 == null);
+ Assert.IsTrue((ByteString) null == null);
+ Assert.IsFalse(b1 != b1);
+ Assert.IsFalse(b1 != b2);
+#pragma warning disable 1718
+ Assert.IsTrue(b1 != b3);
+ Assert.IsTrue(b1 != b4);
+ Assert.IsTrue(b1 != null);
+ Assert.IsFalse((ByteString) null != null);
+ }
+
+ [Test]
+ public void EmptyByteStringHasZeroSize()
+ {
+ Assert.AreEqual(0, ByteString.Empty.Length);
+ }
+
+ [Test]
+ public void CopyFromStringWithExplicitEncoding()
+ {
+ ByteString bs = ByteString.CopyFrom("AB", Encoding.Unicode);
+ Assert.AreEqual(4, bs.Length);
+ Assert.AreEqual(65, bs[0]);
+ Assert.AreEqual(0, bs[1]);
+ Assert.AreEqual(66, bs[2]);
+ Assert.AreEqual(0, bs[3]);
+ }
+
+ [Test]
+ public void IsEmptyWhenEmpty()
+ {
+ Assert.IsTrue(ByteString.CopyFromUtf8("").IsEmpty);
+ }
+
+ [Test]
+ public void IsEmptyWhenNotEmpty()
+ {
+ Assert.IsFalse(ByteString.CopyFromUtf8("X").IsEmpty);
+ }
+
+ [Test]
+ public void CopyFromByteArrayCopiesContents()
+ {
+ byte[] data = new byte[1];
+ data[0] = 10;
+ ByteString bs = ByteString.CopyFrom(data);
+ Assert.AreEqual(10, bs[0]);
+ data[0] = 5;
+ Assert.AreEqual(10, bs[0]);
+ }
+
+ [Test]
+ public void ToByteArrayCopiesContents()
+ {
+ ByteString bs = ByteString.CopyFromUtf8("Hello");
+ byte[] data = bs.ToByteArray();
+ Assert.AreEqual((byte)'H', data[0]);
+ Assert.AreEqual((byte)'H', bs[0]);
+ data[0] = 0;
+ Assert.AreEqual(0, data[0]);
+ Assert.AreEqual((byte)'H', bs[0]);
+ }
+
+ [Test]
+ public void CopyFromUtf8UsesUtf8()
+ {
+ ByteString bs = ByteString.CopyFromUtf8("\u20ac");
+ Assert.AreEqual(3, bs.Length);
+ Assert.AreEqual(0xe2, bs[0]);
+ Assert.AreEqual(0x82, bs[1]);
+ Assert.AreEqual(0xac, bs[2]);
+ }
+
+ [Test]
+ public void CopyFromPortion()
+ {
+ byte[] data = new byte[] {0, 1, 2, 3, 4, 5, 6};
+ ByteString bs = ByteString.CopyFrom(data, 2, 3);
+ Assert.AreEqual(3, bs.Length);
+ Assert.AreEqual(2, bs[0]);
+ Assert.AreEqual(3, bs[1]);
+ }
+
+ [Test]
+ public void ToStringUtf8()
+ {
+ ByteString bs = ByteString.CopyFromUtf8("\u20ac");
+ Assert.AreEqual("\u20ac", bs.ToStringUtf8());
+ }
+
+ [Test]
+ public void ToStringWithExplicitEncoding()
+ {
+ ByteString bs = ByteString.CopyFrom("\u20ac", Encoding.Unicode);
+ Assert.AreEqual("\u20ac", bs.ToString(Encoding.Unicode));
+ }
+
+ [Test]
+ public void FromBase64_WithText()
+ {
+ byte[] data = new byte[] {0, 1, 2, 3, 4, 5, 6};
+ string base64 = Convert.ToBase64String(data);
+ ByteString bs = ByteString.FromBase64(base64);
+ Assert.AreEqual(data, bs.ToByteArray());
+ }
+
+ [Test]
+ public void FromBase64_Empty()
+ {
+ // Optimization which also fixes issue 61.
+ Assert.AreSame(ByteString.Empty, ByteString.FromBase64(""));
+ }
+ }
+} \ No newline at end of file
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedInputStreamExtensions.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedInputStreamExtensions.cs
new file mode 100644
index 00000000..23af2887
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedInputStreamExtensions.cs
@@ -0,0 +1,53 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2015 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using NUnit.Framework;
+
+namespace Google.Protobuf
+{
+ internal static class CodedInputStreamExtensions
+ {
+ public static void AssertNextTag(this CodedInputStream input, uint expectedTag)
+ {
+ uint tag = input.ReadTag();
+ Assert.AreEqual(expectedTag, tag);
+ }
+
+ public static T ReadMessage<T>(this CodedInputStream stream, MessageParser<T> parser)
+ where T : IMessage<T>
+ {
+ var message = parser.CreateTemplate();
+ stream.ReadMessage(message);
+ return message;
+ }
+ }
+}
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedInputStreamTest.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedInputStreamTest.cs
new file mode 100644
index 00000000..c0a9ffd1
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedInputStreamTest.cs
@@ -0,0 +1,598 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using System;
+using System.IO;
+using Google.Protobuf.TestProtos;
+using NUnit.Framework;
+
+namespace Google.Protobuf
+{
+ public class CodedInputStreamTest
+ {
+ /// <summary>
+ /// Helper to construct a byte array from a bunch of bytes. The inputs are
+ /// actually ints so that I can use hex notation and not get stupid errors
+ /// about precision.
+ /// </summary>
+ private static byte[] Bytes(params int[] bytesAsInts)
+ {
+ byte[] bytes = new byte[bytesAsInts.Length];
+ for (int i = 0; i < bytesAsInts.Length; i++)
+ {
+ bytes[i] = (byte) bytesAsInts[i];
+ }
+ return bytes;
+ }
+
+ /// <summary>
+ /// Parses the given bytes using ReadRawVarint32() and ReadRawVarint64()
+ /// </summary>
+ private static void AssertReadVarint(byte[] data, ulong value)
+ {
+ CodedInputStream input = new CodedInputStream(data);
+ Assert.AreEqual((uint) value, input.ReadRawVarint32());
+
+ input = new CodedInputStream(data);
+ Assert.AreEqual(value, input.ReadRawVarint64());
+ Assert.IsTrue(input.IsAtEnd);
+
+ // Try different block sizes.
+ for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2)
+ {
+ input = new CodedInputStream(new SmallBlockInputStream(data, bufferSize));
+ Assert.AreEqual((uint) value, input.ReadRawVarint32());
+
+ input = new CodedInputStream(new SmallBlockInputStream(data, bufferSize));
+ Assert.AreEqual(value, input.ReadRawVarint64());
+ Assert.IsTrue(input.IsAtEnd);
+ }
+
+ // Try reading directly from a MemoryStream. We want to verify that it
+ // doesn't read past the end of the input, so write an extra byte - this
+ // lets us test the position at the end.
+ MemoryStream memoryStream = new MemoryStream();
+ memoryStream.Write(data, 0, data.Length);
+ memoryStream.WriteByte(0);
+ memoryStream.Position = 0;
+ Assert.AreEqual((uint) value, CodedInputStream.ReadRawVarint32(memoryStream));
+ Assert.AreEqual(data.Length, memoryStream.Position);
+ }
+
+ /// <summary>
+ /// Parses the given bytes using ReadRawVarint32() and ReadRawVarint64() and
+ /// expects them to fail with an InvalidProtocolBufferException whose
+ /// description matches the given one.
+ /// </summary>
+ private static void AssertReadVarintFailure(InvalidProtocolBufferException expected, byte[] data)
+ {
+ CodedInputStream input = new CodedInputStream(data);
+ var exception = Assert.Throws<InvalidProtocolBufferException>(() => input.ReadRawVarint32());
+ Assert.AreEqual(expected.Message, exception.Message);
+
+ input = new CodedInputStream(data);
+ exception = Assert.Throws<InvalidProtocolBufferException>(() => input.ReadRawVarint64());
+ Assert.AreEqual(expected.Message, exception.Message);
+
+ // Make sure we get the same error when reading directly from a Stream.
+ exception = Assert.Throws<InvalidProtocolBufferException>(() => CodedInputStream.ReadRawVarint32(new MemoryStream(data)));
+ Assert.AreEqual(expected.Message, exception.Message);
+ }
+
+ [Test]
+ public void ReadVarint()
+ {
+ AssertReadVarint(Bytes(0x00), 0);
+ AssertReadVarint(Bytes(0x01), 1);
+ AssertReadVarint(Bytes(0x7f), 127);
+ // 14882
+ AssertReadVarint(Bytes(0xa2, 0x74), (0x22 << 0) | (0x74 << 7));
+ // 2961488830
+ AssertReadVarint(Bytes(0xbe, 0xf7, 0x92, 0x84, 0x0b),
+ (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) |
+ (0x0bL << 28));
+
+ // 64-bit
+ // 7256456126
+ AssertReadVarint(Bytes(0xbe, 0xf7, 0x92, 0x84, 0x1b),
+ (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) |
+ (0x1bL << 28));
+ // 41256202580718336
+ AssertReadVarint(Bytes(0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49),
+ (0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) |
+ (0x43L << 28) | (0x49L << 35) | (0x24L << 42) | (0x49L << 49));
+ // 11964378330978735131
+ AssertReadVarint(Bytes(0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01),
+ (0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) |
+ (0x3bUL << 28) | (0x56UL << 35) | (0x00UL << 42) |
+ (0x05UL << 49) | (0x26UL << 56) | (0x01UL << 63));
+
+ // Failures
+ AssertReadVarintFailure(
+ InvalidProtocolBufferException.MalformedVarint(),
+ Bytes(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
+ 0x00));
+ AssertReadVarintFailure(
+ InvalidProtocolBufferException.TruncatedMessage(),
+ Bytes(0x80));
+ }
+
+ /// <summary>
+ /// Parses the given bytes using ReadRawLittleEndian32() and checks
+ /// that the result matches the given value.
+ /// </summary>
+ private static void AssertReadLittleEndian32(byte[] data, uint value)
+ {
+ CodedInputStream input = new CodedInputStream(data);
+ Assert.AreEqual(value, input.ReadRawLittleEndian32());
+ Assert.IsTrue(input.IsAtEnd);
+
+ // Try different block sizes.
+ for (int blockSize = 1; blockSize <= 16; blockSize *= 2)
+ {
+ input = new CodedInputStream(
+ new SmallBlockInputStream(data, blockSize));
+ Assert.AreEqual(value, input.ReadRawLittleEndian32());
+ Assert.IsTrue(input.IsAtEnd);
+ }
+ }
+
+ /// <summary>
+ /// Parses the given bytes using ReadRawLittleEndian64() and checks
+ /// that the result matches the given value.
+ /// </summary>
+ private static void AssertReadLittleEndian64(byte[] data, ulong value)
+ {
+ CodedInputStream input = new CodedInputStream(data);
+ Assert.AreEqual(value, input.ReadRawLittleEndian64());
+ Assert.IsTrue(input.IsAtEnd);
+
+ // Try different block sizes.
+ for (int blockSize = 1; blockSize <= 16; blockSize *= 2)
+ {
+ input = new CodedInputStream(
+ new SmallBlockInputStream(data, blockSize));
+ Assert.AreEqual(value, input.ReadRawLittleEndian64());
+ Assert.IsTrue(input.IsAtEnd);
+ }
+ }
+
+ [Test]
+ public void ReadLittleEndian()
+ {
+ AssertReadLittleEndian32(Bytes(0x78, 0x56, 0x34, 0x12), 0x12345678);
+ AssertReadLittleEndian32(Bytes(0xf0, 0xde, 0xbc, 0x9a), 0x9abcdef0);
+
+ AssertReadLittleEndian64(Bytes(0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12),
+ 0x123456789abcdef0L);
+ AssertReadLittleEndian64(
+ Bytes(0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc, 0x9a), 0x9abcdef012345678UL);
+ }
+
+ [Test]
+ public void DecodeZigZag32()
+ {
+ Assert.AreEqual(0, CodedInputStream.DecodeZigZag32(0));
+ Assert.AreEqual(-1, CodedInputStream.DecodeZigZag32(1));
+ Assert.AreEqual(1, CodedInputStream.DecodeZigZag32(2));
+ Assert.AreEqual(-2, CodedInputStream.DecodeZigZag32(3));
+ Assert.AreEqual(0x3FFFFFFF, CodedInputStream.DecodeZigZag32(0x7FFFFFFE));
+ Assert.AreEqual(unchecked((int) 0xC0000000), CodedInputStream.DecodeZigZag32(0x7FFFFFFF));
+ Assert.AreEqual(0x7FFFFFFF, CodedInputStream.DecodeZigZag32(0xFFFFFFFE));
+ Assert.AreEqual(unchecked((int) 0x80000000), CodedInputStream.DecodeZigZag32(0xFFFFFFFF));
+ }
+
+ [Test]
+ public void DecodeZigZag64()
+ {
+ Assert.AreEqual(0, CodedInputStream.DecodeZigZag64(0));
+ Assert.AreEqual(-1, CodedInputStream.DecodeZigZag64(1));
+ Assert.AreEqual(1, CodedInputStream.DecodeZigZag64(2));
+ Assert.AreEqual(-2, CodedInputStream.DecodeZigZag64(3));
+ Assert.AreEqual(0x000000003FFFFFFFL, CodedInputStream.DecodeZigZag64(0x000000007FFFFFFEL));
+ Assert.AreEqual(unchecked((long) 0xFFFFFFFFC0000000L), CodedInputStream.DecodeZigZag64(0x000000007FFFFFFFL));
+ Assert.AreEqual(0x000000007FFFFFFFL, CodedInputStream.DecodeZigZag64(0x00000000FFFFFFFEL));
+ Assert.AreEqual(unchecked((long) 0xFFFFFFFF80000000L), CodedInputStream.DecodeZigZag64(0x00000000FFFFFFFFL));
+ Assert.AreEqual(0x7FFFFFFFFFFFFFFFL, CodedInputStream.DecodeZigZag64(0xFFFFFFFFFFFFFFFEL));
+ Assert.AreEqual(unchecked((long) 0x8000000000000000L), CodedInputStream.DecodeZigZag64(0xFFFFFFFFFFFFFFFFL));
+ }
+
+ [Test]
+ public void ReadWholeMessage_VaryingBlockSizes()
+ {
+ TestAllTypes message = SampleMessages.CreateFullTestAllTypes();
+
+ byte[] rawBytes = message.ToByteArray();
+ Assert.AreEqual(rawBytes.Length, message.CalculateSize());
+ TestAllTypes message2 = TestAllTypes.Parser.ParseFrom(rawBytes);
+ Assert.AreEqual(message, message2);
+
+ // Try different block sizes.
+ for (int blockSize = 1; blockSize < 256; blockSize *= 2)
+ {
+ message2 = TestAllTypes.Parser.ParseFrom(new SmallBlockInputStream(rawBytes, blockSize));
+ Assert.AreEqual(message, message2);
+ }
+ }
+
+ [Test]
+ public void ReadHugeBlob()
+ {
+ // Allocate and initialize a 1MB blob.
+ byte[] blob = new byte[1 << 20];
+ for (int i = 0; i < blob.Length; i++)
+ {
+ blob[i] = (byte) i;
+ }
+
+ // Make a message containing it.
+ var message = new TestAllTypes { SingleBytes = ByteString.CopyFrom(blob) };
+
+ // Serialize and parse it. Make sure to parse from an InputStream, not
+ // directly from a ByteString, so that CodedInputStream uses buffered
+ // reading.
+ TestAllTypes message2 = TestAllTypes.Parser.ParseFrom(message.ToByteString());
+
+ Assert.AreEqual(message, message2);
+ }
+
+ [Test]
+ public void ReadMaliciouslyLargeBlob()
+ {
+ MemoryStream ms = new MemoryStream();
+ CodedOutputStream output = new CodedOutputStream(ms);
+
+ uint tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited);
+ output.WriteRawVarint32(tag);
+ output.WriteRawVarint32(0x7FFFFFFF);
+ output.WriteRawBytes(new byte[32]); // Pad with a few random bytes.
+ output.Flush();
+ ms.Position = 0;
+
+ CodedInputStream input = new CodedInputStream(ms);
+ Assert.AreEqual(tag, input.ReadTag());
+
+ Assert.Throws<InvalidProtocolBufferException>(() => input.ReadBytes());
+ }
+
+ internal static TestRecursiveMessage MakeRecursiveMessage(int depth)
+ {
+ if (depth == 0)
+ {
+ return new TestRecursiveMessage { I = 5 };
+ }
+ else
+ {
+ return new TestRecursiveMessage { A = MakeRecursiveMessage(depth - 1) };
+ }
+ }
+
+ internal static void AssertMessageDepth(TestRecursiveMessage message, int depth)
+ {
+ if (depth == 0)
+ {
+ Assert.IsNull(message.A);
+ Assert.AreEqual(5, message.I);
+ }
+ else
+ {
+ Assert.IsNotNull(message.A);
+ AssertMessageDepth(message.A, depth - 1);
+ }
+ }
+
+ [Test]
+ public void MaliciousRecursion()
+ {
+ ByteString data64 = MakeRecursiveMessage(64).ToByteString();
+ ByteString data65 = MakeRecursiveMessage(65).ToByteString();
+
+ AssertMessageDepth(TestRecursiveMessage.Parser.ParseFrom(data64), 64);
+
+ Assert.Throws<InvalidProtocolBufferException>(() => TestRecursiveMessage.Parser.ParseFrom(data65));
+
+ CodedInputStream input = CodedInputStream.CreateWithLimits(new MemoryStream(data64.ToByteArray()), 1000000, 63);
+ Assert.Throws<InvalidProtocolBufferException>(() => TestRecursiveMessage.Parser.ParseFrom(input));
+ }
+
+ [Test]
+ public void SizeLimit()
+ {
+ // Have to use a Stream rather than ByteString.CreateCodedInput as SizeLimit doesn't
+ // apply to the latter case.
+ MemoryStream ms = new MemoryStream(SampleMessages.CreateFullTestAllTypes().ToByteArray());
+ CodedInputStream input = CodedInputStream.CreateWithLimits(ms, 16, 100);
+ Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseFrom(input));
+ }
+
+ /// <summary>
+ /// Tests that if we read an string that contains invalid UTF-8, no exception
+ /// is thrown. Instead, the invalid bytes are replaced with the Unicode
+ /// "replacement character" U+FFFD.
+ /// </summary>
+ [Test]
+ public void ReadInvalidUtf8()
+ {
+ MemoryStream ms = new MemoryStream();
+ CodedOutputStream output = new CodedOutputStream(ms);
+
+ uint tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited);
+ output.WriteRawVarint32(tag);
+ output.WriteRawVarint32(1);
+ output.WriteRawBytes(new byte[] {0x80});
+ output.Flush();
+ ms.Position = 0;
+
+ CodedInputStream input = new CodedInputStream(ms);
+
+ Assert.AreEqual(tag, input.ReadTag());
+ string text = input.ReadString();
+ Assert.AreEqual('\ufffd', text[0]);
+ }
+
+ /// <summary>
+ /// A stream which limits the number of bytes it reads at a time.
+ /// We use this to make sure that CodedInputStream doesn't screw up when
+ /// reading in small blocks.
+ /// </summary>
+ private sealed class SmallBlockInputStream : MemoryStream
+ {
+ private readonly int blockSize;
+
+ public SmallBlockInputStream(byte[] data, int blockSize)
+ : base(data)
+ {
+ this.blockSize = blockSize;
+ }
+
+ public override int Read(byte[] buffer, int offset, int count)
+ {
+ return base.Read(buffer, offset, Math.Min(count, blockSize));
+ }
+ }
+
+ [Test]
+ public void TestNegativeEnum()
+ {
+ byte[] bytes = { 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01 };
+ CodedInputStream input = new CodedInputStream(bytes);
+ Assert.AreEqual((int)SampleEnum.NegativeValue, input.ReadEnum());
+ Assert.IsTrue(input.IsAtEnd);
+ }
+
+ //Issue 71: CodedInputStream.ReadBytes go to slow path unnecessarily
+ [Test]
+ public void TestSlowPathAvoidance()
+ {
+ using (var ms = new MemoryStream())
+ {
+ CodedOutputStream output = new CodedOutputStream(ms);
+ output.WriteTag(1, WireFormat.WireType.LengthDelimited);
+ output.WriteBytes(ByteString.CopyFrom(new byte[100]));
+ output.WriteTag(2, WireFormat.WireType.LengthDelimited);
+ output.WriteBytes(ByteString.CopyFrom(new byte[100]));
+ output.Flush();
+
+ ms.Position = 0;
+ CodedInputStream input = new CodedInputStream(ms, new byte[ms.Length / 2], 0, 0);
+
+ uint tag = input.ReadTag();
+ Assert.AreEqual(1, WireFormat.GetTagFieldNumber(tag));
+ Assert.AreEqual(100, input.ReadBytes().Length);
+
+ tag = input.ReadTag();
+ Assert.AreEqual(2, WireFormat.GetTagFieldNumber(tag));
+ Assert.AreEqual(100, input.ReadBytes().Length);
+ }
+ }
+
+ [Test]
+ public void Tag0Throws()
+ {
+ var input = new CodedInputStream(new byte[] { 0 });
+ Assert.Throws<InvalidProtocolBufferException>(() => input.ReadTag());
+ }
+
+ [Test]
+ public void SkipGroup()
+ {
+ // Create an output stream with a group in:
+ // Field 1: string "field 1"
+ // Field 2: group containing:
+ // Field 1: fixed int32 value 100
+ // Field 2: string "ignore me"
+ // Field 3: nested group containing
+ // Field 1: fixed int64 value 1000
+ // Field 3: string "field 3"
+ var stream = new MemoryStream();
+ var output = new CodedOutputStream(stream);
+ output.WriteTag(1, WireFormat.WireType.LengthDelimited);
+ output.WriteString("field 1");
+
+ // The outer group...
+ output.WriteTag(2, WireFormat.WireType.StartGroup);
+ output.WriteTag(1, WireFormat.WireType.Fixed32);
+ output.WriteFixed32(100);
+ output.WriteTag(2, WireFormat.WireType.LengthDelimited);
+ output.WriteString("ignore me");
+ // The nested group...
+ output.WriteTag(3, WireFormat.WireType.StartGroup);
+ output.WriteTag(1, WireFormat.WireType.Fixed64);
+ output.WriteFixed64(1000);
+ // Note: Not sure the field number is relevant for end group...
+ output.WriteTag(3, WireFormat.WireType.EndGroup);
+
+ // End the outer group
+ output.WriteTag(2, WireFormat.WireType.EndGroup);
+
+ output.WriteTag(3, WireFormat.WireType.LengthDelimited);
+ output.WriteString("field 3");
+ output.Flush();
+ stream.Position = 0;
+
+ // Now act like a generated client
+ var input = new CodedInputStream(stream);
+ Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited), input.ReadTag());
+ Assert.AreEqual("field 1", input.ReadString());
+ Assert.AreEqual(WireFormat.MakeTag(2, WireFormat.WireType.StartGroup), input.ReadTag());
+ input.SkipLastField(); // Should consume the whole group, including the nested one.
+ Assert.AreEqual(WireFormat.MakeTag(3, WireFormat.WireType.LengthDelimited), input.ReadTag());
+ Assert.AreEqual("field 3", input.ReadString());
+ }
+
+ [Test]
+ public void SkipGroup_WrongEndGroupTag()
+ {
+ // Create an output stream with:
+ // Field 1: string "field 1"
+ // Start group 2
+ // Field 3: fixed int32
+ // End group 4 (should give an error)
+ var stream = new MemoryStream();
+ var output = new CodedOutputStream(stream);
+ output.WriteTag(1, WireFormat.WireType.LengthDelimited);
+ output.WriteString("field 1");
+
+ // The outer group...
+ output.WriteTag(2, WireFormat.WireType.StartGroup);
+ output.WriteTag(3, WireFormat.WireType.Fixed32);
+ output.WriteFixed32(100);
+ output.WriteTag(4, WireFormat.WireType.EndGroup);
+ output.Flush();
+ stream.Position = 0;
+
+ // Now act like a generated client
+ var input = new CodedInputStream(stream);
+ Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited), input.ReadTag());
+ Assert.AreEqual("field 1", input.ReadString());
+ Assert.AreEqual(WireFormat.MakeTag(2, WireFormat.WireType.StartGroup), input.ReadTag());
+ Assert.Throws<InvalidProtocolBufferException>(input.SkipLastField);
+ }
+
+ [Test]
+ public void RogueEndGroupTag()
+ {
+ // If we have an end-group tag without a leading start-group tag, generated
+ // code will just call SkipLastField... so that should fail.
+
+ var stream = new MemoryStream();
+ var output = new CodedOutputStream(stream);
+ output.WriteTag(1, WireFormat.WireType.EndGroup);
+ output.Flush();
+ stream.Position = 0;
+
+ var input = new CodedInputStream(stream);
+ Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.EndGroup), input.ReadTag());
+ Assert.Throws<InvalidProtocolBufferException>(input.SkipLastField);
+ }
+
+ [Test]
+ public void EndOfStreamReachedWhileSkippingGroup()
+ {
+ var stream = new MemoryStream();
+ var output = new CodedOutputStream(stream);
+ output.WriteTag(1, WireFormat.WireType.StartGroup);
+ output.WriteTag(2, WireFormat.WireType.StartGroup);
+ output.WriteTag(2, WireFormat.WireType.EndGroup);
+
+ output.Flush();
+ stream.Position = 0;
+
+ // Now act like a generated client
+ var input = new CodedInputStream(stream);
+ input.ReadTag();
+ Assert.Throws<InvalidProtocolBufferException>(input.SkipLastField);
+ }
+
+ [Test]
+ public void RecursionLimitAppliedWhileSkippingGroup()
+ {
+ var stream = new MemoryStream();
+ var output = new CodedOutputStream(stream);
+ for (int i = 0; i < CodedInputStream.DefaultRecursionLimit + 1; i++)
+ {
+ output.WriteTag(1, WireFormat.WireType.StartGroup);
+ }
+ for (int i = 0; i < CodedInputStream.DefaultRecursionLimit + 1; i++)
+ {
+ output.WriteTag(1, WireFormat.WireType.EndGroup);
+ }
+ output.Flush();
+ stream.Position = 0;
+
+ // Now act like a generated client
+ var input = new CodedInputStream(stream);
+ Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.StartGroup), input.ReadTag());
+ Assert.Throws<InvalidProtocolBufferException>(input.SkipLastField);
+ }
+
+ [Test]
+ public void Construction_Invalid()
+ {
+ Assert.Throws<ArgumentNullException>(() => new CodedInputStream((byte[]) null));
+ Assert.Throws<ArgumentNullException>(() => new CodedInputStream(null, 0, 0));
+ Assert.Throws<ArgumentNullException>(() => new CodedInputStream((Stream) null));
+ Assert.Throws<ArgumentOutOfRangeException>(() => new CodedInputStream(new byte[10], 100, 0));
+ Assert.Throws<ArgumentOutOfRangeException>(() => new CodedInputStream(new byte[10], 5, 10));
+ }
+
+ [Test]
+ public void CreateWithLimits_InvalidLimits()
+ {
+ var stream = new MemoryStream();
+ Assert.Throws<ArgumentOutOfRangeException>(() => CodedInputStream.CreateWithLimits(stream, 0, 1));
+ Assert.Throws<ArgumentOutOfRangeException>(() => CodedInputStream.CreateWithLimits(stream, 1, 0));
+ }
+
+ [Test]
+ public void Dispose_DisposesUnderlyingStream()
+ {
+ var memoryStream = new MemoryStream();
+ Assert.IsTrue(memoryStream.CanRead);
+ using (var cis = new CodedInputStream(memoryStream))
+ {
+ }
+ Assert.IsFalse(memoryStream.CanRead); // Disposed
+ }
+
+ [Test]
+ public void Dispose_WithLeaveOpen()
+ {
+ var memoryStream = new MemoryStream();
+ Assert.IsTrue(memoryStream.CanRead);
+ using (var cis = new CodedInputStream(memoryStream, true))
+ {
+ }
+ Assert.IsTrue(memoryStream.CanRead); // We left the stream open
+ }
+ }
+} \ No newline at end of file
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedOutputStreamTest.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedOutputStreamTest.cs
new file mode 100644
index 00000000..48bf6d60
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/CodedOutputStreamTest.cs
@@ -0,0 +1,419 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using System;
+using System.IO;
+using Google.Protobuf.TestProtos;
+using NUnit.Framework;
+
+namespace Google.Protobuf
+{
+ public class CodedOutputStreamTest
+ {
+ /// <summary>
+ /// Writes the given value using WriteRawVarint32() and WriteRawVarint64() and
+ /// checks that the result matches the given bytes
+ /// </summary>
+ private static void AssertWriteVarint(byte[] data, ulong value)
+ {
+ // Only do 32-bit write if the value fits in 32 bits.
+ if ((value >> 32) == 0)
+ {
+ MemoryStream rawOutput = new MemoryStream();
+ CodedOutputStream output = new CodedOutputStream(rawOutput);
+ output.WriteRawVarint32((uint) value);
+ output.Flush();
+ Assert.AreEqual(data, rawOutput.ToArray());
+ // Also try computing size.
+ Assert.AreEqual(data.Length, CodedOutputStream.ComputeRawVarint32Size((uint) value));
+ }
+
+ {
+ MemoryStream rawOutput = new MemoryStream();
+ CodedOutputStream output = new CodedOutputStream(rawOutput);
+ output.WriteRawVarint64(value);
+ output.Flush();
+ Assert.AreEqual(data, rawOutput.ToArray());
+
+ // Also try computing size.
+ Assert.AreEqual(data.Length, CodedOutputStream.ComputeRawVarint64Size(value));
+ }
+
+ // Try different buffer sizes.
+ for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2)
+ {
+ // Only do 32-bit write if the value fits in 32 bits.
+ if ((value >> 32) == 0)
+ {
+ MemoryStream rawOutput = new MemoryStream();
+ CodedOutputStream output =
+ new CodedOutputStream(rawOutput, bufferSize);
+ output.WriteRawVarint32((uint) value);
+ output.Flush();
+ Assert.AreEqual(data, rawOutput.ToArray());
+ }
+
+ {
+ MemoryStream rawOutput = new MemoryStream();
+ CodedOutputStream output = new CodedOutputStream(rawOutput, bufferSize);
+ output.WriteRawVarint64(value);
+ output.Flush();
+ Assert.AreEqual(data, rawOutput.ToArray());
+ }
+ }
+ }
+
+ /// <summary>
+ /// Tests WriteRawVarint32() and WriteRawVarint64()
+ /// </summary>
+ [Test]
+ public void WriteVarint()
+ {
+ AssertWriteVarint(new byte[] {0x00}, 0);
+ AssertWriteVarint(new byte[] {0x01}, 1);
+ AssertWriteVarint(new byte[] {0x7f}, 127);
+ // 14882
+ AssertWriteVarint(new byte[] {0xa2, 0x74}, (0x22 << 0) | (0x74 << 7));
+ // 2961488830
+ AssertWriteVarint(new byte[] {0xbe, 0xf7, 0x92, 0x84, 0x0b},
+ (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) |
+ (0x0bL << 28));
+
+ // 64-bit
+ // 7256456126
+ AssertWriteVarint(new byte[] {0xbe, 0xf7, 0x92, 0x84, 0x1b},
+ (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) |
+ (0x1bL << 28));
+ // 41256202580718336
+ AssertWriteVarint(
+ new byte[] {0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49},
+ (0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) |
+ (0x43UL << 28) | (0x49L << 35) | (0x24UL << 42) | (0x49UL << 49));
+ // 11964378330978735131
+ AssertWriteVarint(
+ new byte[] {0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01},
+ unchecked((ulong)
+ ((0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) |
+ (0x3bL << 28) | (0x56L << 35) | (0x00L << 42) |
+ (0x05L << 49) | (0x26L << 56) | (0x01L << 63))));
+ }
+
+ /// <summary>
+ /// Parses the given bytes using WriteRawLittleEndian32() and checks
+ /// that the result matches the given value.
+ /// </summary>
+ private static void AssertWriteLittleEndian32(byte[] data, uint value)
+ {
+ MemoryStream rawOutput = new MemoryStream();
+ CodedOutputStream output = new CodedOutputStream(rawOutput);
+ output.WriteRawLittleEndian32(value);
+ output.Flush();
+ Assert.AreEqual(data, rawOutput.ToArray());
+
+ // Try different buffer sizes.
+ for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2)
+ {
+ rawOutput = new MemoryStream();
+ output = new CodedOutputStream(rawOutput, bufferSize);
+ output.WriteRawLittleEndian32(value);
+ output.Flush();
+ Assert.AreEqual(data, rawOutput.ToArray());
+ }
+ }
+
+ /// <summary>
+ /// Parses the given bytes using WriteRawLittleEndian64() and checks
+ /// that the result matches the given value.
+ /// </summary>
+ private static void AssertWriteLittleEndian64(byte[] data, ulong value)
+ {
+ MemoryStream rawOutput = new MemoryStream();
+ CodedOutputStream output = new CodedOutputStream(rawOutput);
+ output.WriteRawLittleEndian64(value);
+ output.Flush();
+ Assert.AreEqual(data, rawOutput.ToArray());
+
+ // Try different block sizes.
+ for (int blockSize = 1; blockSize <= 16; blockSize *= 2)
+ {
+ rawOutput = new MemoryStream();
+ output = new CodedOutputStream(rawOutput, blockSize);
+ output.WriteRawLittleEndian64(value);
+ output.Flush();
+ Assert.AreEqual(data, rawOutput.ToArray());
+ }
+ }
+
+ /// <summary>
+ /// Tests writeRawLittleEndian32() and writeRawLittleEndian64().
+ /// </summary>
+ [Test]
+ public void WriteLittleEndian()
+ {
+ AssertWriteLittleEndian32(new byte[] {0x78, 0x56, 0x34, 0x12}, 0x12345678);
+ AssertWriteLittleEndian32(new byte[] {0xf0, 0xde, 0xbc, 0x9a}, 0x9abcdef0);
+
+ AssertWriteLittleEndian64(
+ new byte[] {0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12},
+ 0x123456789abcdef0L);
+ AssertWriteLittleEndian64(
+ new byte[] {0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc, 0x9a},
+ 0x9abcdef012345678UL);
+ }
+
+ [Test]
+ public void WriteWholeMessage_VaryingBlockSizes()
+ {
+ TestAllTypes message = SampleMessages.CreateFullTestAllTypes();
+
+ byte[] rawBytes = message.ToByteArray();
+
+ // Try different block sizes.
+ for (int blockSize = 1; blockSize < 256; blockSize *= 2)
+ {
+ MemoryStream rawOutput = new MemoryStream();
+ CodedOutputStream output = new CodedOutputStream(rawOutput, blockSize);
+ message.WriteTo(output);
+ output.Flush();
+ Assert.AreEqual(rawBytes, rawOutput.ToArray());
+ }
+ }
+
+ [Test]
+ public void EncodeZigZag32()
+ {
+ Assert.AreEqual(0u, CodedOutputStream.EncodeZigZag32(0));
+ Assert.AreEqual(1u, CodedOutputStream.EncodeZigZag32(-1));
+ Assert.AreEqual(2u, CodedOutputStream.EncodeZigZag32(1));
+ Assert.AreEqual(3u, CodedOutputStream.EncodeZigZag32(-2));
+ Assert.AreEqual(0x7FFFFFFEu, CodedOutputStream.EncodeZigZag32(0x3FFFFFFF));
+ Assert.AreEqual(0x7FFFFFFFu, CodedOutputStream.EncodeZigZag32(unchecked((int) 0xC0000000)));
+ Assert.AreEqual(0xFFFFFFFEu, CodedOutputStream.EncodeZigZag32(0x7FFFFFFF));
+ Assert.AreEqual(0xFFFFFFFFu, CodedOutputStream.EncodeZigZag32(unchecked((int) 0x80000000)));
+ }
+
+ [Test]
+ public void EncodeZigZag64()
+ {
+ Assert.AreEqual(0u, CodedOutputStream.EncodeZigZag64(0));
+ Assert.AreEqual(1u, CodedOutputStream.EncodeZigZag64(-1));
+ Assert.AreEqual(2u, CodedOutputStream.EncodeZigZag64(1));
+ Assert.AreEqual(3u, CodedOutputStream.EncodeZigZag64(-2));
+ Assert.AreEqual(0x000000007FFFFFFEuL,
+ CodedOutputStream.EncodeZigZag64(unchecked((long) 0x000000003FFFFFFFUL)));
+ Assert.AreEqual(0x000000007FFFFFFFuL,
+ CodedOutputStream.EncodeZigZag64(unchecked((long) 0xFFFFFFFFC0000000UL)));
+ Assert.AreEqual(0x00000000FFFFFFFEuL,
+ CodedOutputStream.EncodeZigZag64(unchecked((long) 0x000000007FFFFFFFUL)));
+ Assert.AreEqual(0x00000000FFFFFFFFuL,
+ CodedOutputStream.EncodeZigZag64(unchecked((long) 0xFFFFFFFF80000000UL)));
+ Assert.AreEqual(0xFFFFFFFFFFFFFFFEL,
+ CodedOutputStream.EncodeZigZag64(unchecked((long) 0x7FFFFFFFFFFFFFFFUL)));
+ Assert.AreEqual(0xFFFFFFFFFFFFFFFFL,
+ CodedOutputStream.EncodeZigZag64(unchecked((long) 0x8000000000000000UL)));
+ }
+
+ [Test]
+ public void RoundTripZigZag32()
+ {
+ // Some easier-to-verify round-trip tests. The inputs (other than 0, 1, -1)
+ // were chosen semi-randomly via keyboard bashing.
+ Assert.AreEqual(0, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(0)));
+ Assert.AreEqual(1, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(1)));
+ Assert.AreEqual(-1, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(-1)));
+ Assert.AreEqual(14927, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(14927)));
+ Assert.AreEqual(-3612, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(-3612)));
+ }
+
+ [Test]
+ public void RoundTripZigZag64()
+ {
+ Assert.AreEqual(0, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(0)));
+ Assert.AreEqual(1, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(1)));
+ Assert.AreEqual(-1, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-1)));
+ Assert.AreEqual(14927, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(14927)));
+ Assert.AreEqual(-3612, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-3612)));
+
+ Assert.AreEqual(856912304801416L,
+ CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(856912304801416L)));
+ Assert.AreEqual(-75123905439571256L,
+ CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-75123905439571256L)));
+ }
+
+ [Test]
+ public void TestNegativeEnumNoTag()
+ {
+ Assert.AreEqual(10, CodedOutputStream.ComputeInt32Size(-2));
+ Assert.AreEqual(10, CodedOutputStream.ComputeEnumSize((int) SampleEnum.NegativeValue));
+
+ byte[] bytes = new byte[10];
+ CodedOutputStream output = new CodedOutputStream(bytes);
+ output.WriteEnum((int) SampleEnum.NegativeValue);
+
+ Assert.AreEqual(0, output.SpaceLeft);
+ Assert.AreEqual("FE-FF-FF-FF-FF-FF-FF-FF-FF-01", BitConverter.ToString(bytes));
+ }
+
+ [Test]
+ public void TestCodedInputOutputPosition()
+ {
+ byte[] content = new byte[110];
+ for (int i = 0; i < content.Length; i++)
+ content[i] = (byte)i;
+
+ byte[] child = new byte[120];
+ {
+ MemoryStream ms = new MemoryStream(child);
+ CodedOutputStream cout = new CodedOutputStream(ms, 20);
+ // Field 11: numeric value: 500
+ cout.WriteTag(11, WireFormat.WireType.Varint);
+ Assert.AreEqual(1, cout.Position);
+ cout.WriteInt32(500);
+ Assert.AreEqual(3, cout.Position);
+ //Field 12: length delimited 120 bytes
+ cout.WriteTag(12, WireFormat.WireType.LengthDelimited);
+ Assert.AreEqual(4, cout.Position);
+ cout.WriteBytes(ByteString.CopyFrom(content));
+ Assert.AreEqual(115, cout.Position);
+ // Field 13: fixed numeric value: 501
+ cout.WriteTag(13, WireFormat.WireType.Fixed32);
+ Assert.AreEqual(116, cout.Position);
+ cout.WriteSFixed32(501);
+ Assert.AreEqual(120, cout.Position);
+ cout.Flush();
+ }
+
+ byte[] bytes = new byte[130];
+ {
+ CodedOutputStream cout = new CodedOutputStream(bytes);
+ // Field 1: numeric value: 500
+ cout.WriteTag(1, WireFormat.WireType.Varint);
+ Assert.AreEqual(1, cout.Position);
+ cout.WriteInt32(500);
+ Assert.AreEqual(3, cout.Position);
+ //Field 2: length delimited 120 bytes
+ cout.WriteTag(2, WireFormat.WireType.LengthDelimited);
+ Assert.AreEqual(4, cout.Position);
+ cout.WriteBytes(ByteString.CopyFrom(child));
+ Assert.AreEqual(125, cout.Position);
+ // Field 3: fixed numeric value: 500
+ cout.WriteTag(3, WireFormat.WireType.Fixed32);
+ Assert.AreEqual(126, cout.Position);
+ cout.WriteSFixed32(501);
+ Assert.AreEqual(130, cout.Position);
+ cout.Flush();
+ }
+ // Now test Input stream:
+ {
+ CodedInputStream cin = new CodedInputStream(new MemoryStream(bytes), new byte[50], 0, 0);
+ Assert.AreEqual(0, cin.Position);
+ // Field 1:
+ uint tag = cin.ReadTag();
+ Assert.AreEqual(1, tag >> 3);
+ Assert.AreEqual(1, cin.Position);
+ Assert.AreEqual(500, cin.ReadInt32());
+ Assert.AreEqual(3, cin.Position);
+ //Field 2:
+ tag = cin.ReadTag();
+ Assert.AreEqual(2, tag >> 3);
+ Assert.AreEqual(4, cin.Position);
+ int childlen = cin.ReadLength();
+ Assert.AreEqual(120, childlen);
+ Assert.AreEqual(5, cin.Position);
+ int oldlimit = cin.PushLimit((int)childlen);
+ Assert.AreEqual(5, cin.Position);
+ // Now we are reading child message
+ {
+ // Field 11: numeric value: 500
+ tag = cin.ReadTag();
+ Assert.AreEqual(11, tag >> 3);
+ Assert.AreEqual(6, cin.Position);
+ Assert.AreEqual(500, cin.ReadInt32());
+ Assert.AreEqual(8, cin.Position);
+ //Field 12: length delimited 120 bytes
+ tag = cin.ReadTag();
+ Assert.AreEqual(12, tag >> 3);
+ Assert.AreEqual(9, cin.Position);
+ ByteString bstr = cin.ReadBytes();
+ Assert.AreEqual(110, bstr.Length);
+ Assert.AreEqual((byte) 109, bstr[109]);
+ Assert.AreEqual(120, cin.Position);
+ // Field 13: fixed numeric value: 501
+ tag = cin.ReadTag();
+ Assert.AreEqual(13, tag >> 3);
+ // ROK - Previously broken here, this returned 126 failing to account for bufferSizeAfterLimit
+ Assert.AreEqual(121, cin.Position);
+ Assert.AreEqual(501, cin.ReadSFixed32());
+ Assert.AreEqual(125, cin.Position);
+ Assert.IsTrue(cin.IsAtEnd);
+ }
+ cin.PopLimit(oldlimit);
+ Assert.AreEqual(125, cin.Position);
+ // Field 3: fixed numeric value: 501
+ tag = cin.ReadTag();
+ Assert.AreEqual(3, tag >> 3);
+ Assert.AreEqual(126, cin.Position);
+ Assert.AreEqual(501, cin.ReadSFixed32());
+ Assert.AreEqual(130, cin.Position);
+ Assert.IsTrue(cin.IsAtEnd);
+ }
+ }
+
+ [Test]
+ public void Dispose_DisposesUnderlyingStream()
+ {
+ var memoryStream = new MemoryStream();
+ Assert.IsTrue(memoryStream.CanWrite);
+ using (var cos = new CodedOutputStream(memoryStream))
+ {
+ cos.WriteRawByte(0);
+ Assert.AreEqual(0, memoryStream.Position); // Not flushed yet
+ }
+ Assert.AreEqual(1, memoryStream.ToArray().Length); // Flushed data from CodedOutputStream to MemoryStream
+ Assert.IsFalse(memoryStream.CanWrite); // Disposed
+ }
+
+ [Test]
+ public void Dispose_WithLeaveOpen()
+ {
+ var memoryStream = new MemoryStream();
+ Assert.IsTrue(memoryStream.CanWrite);
+ using (var cos = new CodedOutputStream(memoryStream, true))
+ {
+ cos.WriteRawByte(0);
+ Assert.AreEqual(0, memoryStream.Position); // Not flushed yet
+ }
+ Assert.AreEqual(1, memoryStream.Position); // Flushed data from CodedOutputStream to MemoryStream
+ Assert.IsTrue(memoryStream.CanWrite); // We left the stream open
+ }
+ }
+} \ No newline at end of file
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Collections/MapFieldTest.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Collections/MapFieldTest.cs
new file mode 100644
index 00000000..9c845907
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Collections/MapFieldTest.cs
@@ -0,0 +1,532 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2015 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using System;
+using System.Collections.Generic;
+using Google.Protobuf.TestProtos;
+using NUnit.Framework;
+using System.Collections;
+using System.Linq;
+
+namespace Google.Protobuf.Collections
+{
+ /// <summary>
+ /// Tests for MapField which aren't reliant on the encoded format -
+ /// tests for serialization/deserialization are part of GeneratedMessageTest.
+ /// </summary>
+ public class MapFieldTest
+ {
+ [Test]
+ public void Clone_ClonesMessages()
+ {
+ var message = new ForeignMessage { C = 20 };
+ var map = new MapField<string, ForeignMessage> { { "x", message } };
+ var clone = map.Clone();
+ map["x"].C = 30;
+ Assert.AreEqual(20, clone["x"].C);
+ }
+
+ [Test]
+ public void NullValuesProhibited()
+ {
+ TestNullValues<int?>(0);
+ TestNullValues("");
+ TestNullValues(new TestAllTypes());
+ }
+
+ private void TestNullValues<T>(T nonNullValue)
+ {
+ var map = new MapField<int, T>();
+ var nullValue = (T) (object) null;
+ Assert.Throws<ArgumentNullException>(() => map.Add(0, nullValue));
+ Assert.Throws<ArgumentNullException>(() => map[0] = nullValue);
+ map.Add(1, nonNullValue);
+ map[1] = nonNullValue;
+ }
+
+ [Test]
+ public void Add_ForbidsNullKeys()
+ {
+ var map = new MapField<string, ForeignMessage>();
+ Assert.Throws<ArgumentNullException>(() => map.Add(null, new ForeignMessage()));
+ }
+
+ [Test]
+ public void Indexer_ForbidsNullKeys()
+ {
+ var map = new MapField<string, ForeignMessage>();
+ Assert.Throws<ArgumentNullException>(() => map[null] = new ForeignMessage());
+ }
+
+ [Test]
+ public void AddPreservesInsertionOrder()
+ {
+ var map = new MapField<string, string>();
+ map.Add("a", "v1");
+ map.Add("b", "v2");
+ map.Add("c", "v3");
+ map.Remove("b");
+ map.Add("d", "v4");
+ CollectionAssert.AreEqual(new[] { "a", "c", "d" }, map.Keys);
+ CollectionAssert.AreEqual(new[] { "v1", "v3", "v4" }, map.Values);
+ }
+
+ [Test]
+ public void EqualityIsOrderInsensitive()
+ {
+ var map1 = new MapField<string, string>();
+ map1.Add("a", "v1");
+ map1.Add("b", "v2");
+
+ var map2 = new MapField<string, string>();
+ map2.Add("b", "v2");
+ map2.Add("a", "v1");
+
+ EqualityTester.AssertEquality(map1, map2);
+ }
+
+ [Test]
+ public void EqualityIsKeySensitive()
+ {
+ var map1 = new MapField<string, string>();
+ map1.Add("first key", "v1");
+ map1.Add("second key", "v2");
+
+ var map2 = new MapField<string, string>();
+ map2.Add("third key", "v1");
+ map2.Add("fourth key", "v2");
+
+ EqualityTester.AssertInequality(map1, map2);
+ }
+
+ [Test]
+ public void Equality_Simple()
+ {
+ var map = new MapField<string, string>();
+ EqualityTester.AssertEquality(map, map);
+ EqualityTester.AssertInequality(map, null);
+ Assert.IsFalse(map.Equals(new object()));
+ }
+
+ [Test]
+ public void EqualityIsValueSensitive()
+ {
+ // Note: Without some care, it's a little easier than one might
+ // hope to see hash collisions, but only in some environments...
+ var map1 = new MapField<string, string>();
+ map1.Add("a", "first value");
+ map1.Add("b", "second value");
+
+ var map2 = new MapField<string, string>();
+ map2.Add("a", "third value");
+ map2.Add("b", "fourth value");
+
+ EqualityTester.AssertInequality(map1, map2);
+ }
+
+ [Test]
+ public void Add_Dictionary()
+ {
+ var map1 = new MapField<string, string>
+ {
+ { "x", "y" },
+ { "a", "b" }
+ };
+ var map2 = new MapField<string, string>
+ {
+ { "before", "" },
+ map1,
+ { "after", "" }
+ };
+ var expected = new MapField<string, string>
+ {
+ { "before", "" },
+ { "x", "y" },
+ { "a", "b" },
+ { "after", "" }
+ };
+ Assert.AreEqual(expected, map2);
+ CollectionAssert.AreEqual(new[] { "before", "x", "a", "after" }, map2.Keys);
+ }
+
+ // General IDictionary<TKey, TValue> behavior tests
+ [Test]
+ public void Add_KeyAlreadyExists()
+ {
+ var map = new MapField<string, string>();
+ map.Add("foo", "bar");
+ Assert.Throws<ArgumentException>(() => map.Add("foo", "baz"));
+ }
+
+ [Test]
+ public void Add_Pair()
+ {
+ var map = new MapField<string, string>();
+ ICollection<KeyValuePair<string, string>> collection = map;
+ collection.Add(NewKeyValuePair("x", "y"));
+ Assert.AreEqual("y", map["x"]);
+ Assert.Throws<ArgumentException>(() => collection.Add(NewKeyValuePair("x", "z")));
+ }
+
+ [Test]
+ public void Contains_Pair()
+ {
+ var map = new MapField<string, string> { { "x", "y" } };
+ ICollection<KeyValuePair<string, string>> collection = map;
+ Assert.IsTrue(collection.Contains(NewKeyValuePair("x", "y")));
+ Assert.IsFalse(collection.Contains(NewKeyValuePair("x", "z")));
+ Assert.IsFalse(collection.Contains(NewKeyValuePair("z", "y")));
+ }
+
+ [Test]
+ public void Remove_Key()
+ {
+ var map = new MapField<string, string>();
+ map.Add("foo", "bar");
+ Assert.AreEqual(1, map.Count);
+ Assert.IsFalse(map.Remove("missing"));
+ Assert.AreEqual(1, map.Count);
+ Assert.IsTrue(map.Remove("foo"));
+ Assert.AreEqual(0, map.Count);
+ Assert.Throws<ArgumentNullException>(() => map.Remove(null));
+ }
+
+ [Test]
+ public void Remove_Pair()
+ {
+ var map = new MapField<string, string>();
+ map.Add("foo", "bar");
+ ICollection<KeyValuePair<string, string>> collection = map;
+ Assert.AreEqual(1, map.Count);
+ Assert.IsFalse(collection.Remove(NewKeyValuePair("wrong key", "bar")));
+ Assert.AreEqual(1, map.Count);
+ Assert.IsFalse(collection.Remove(NewKeyValuePair("foo", "wrong value")));
+ Assert.AreEqual(1, map.Count);
+ Assert.IsTrue(collection.Remove(NewKeyValuePair("foo", "bar")));
+ Assert.AreEqual(0, map.Count);
+ Assert.Throws<ArgumentException>(() => collection.Remove(new KeyValuePair<string, string>(null, "")));
+ }
+
+ [Test]
+ public void CopyTo_Pair()
+ {
+ var map = new MapField<string, string>();
+ map.Add("foo", "bar");
+ ICollection<KeyValuePair<string, string>> collection = map;
+ KeyValuePair<string, string>[] array = new KeyValuePair<string, string>[3];
+ collection.CopyTo(array, 1);
+ Assert.AreEqual(NewKeyValuePair("foo", "bar"), array[1]);
+ }
+
+ [Test]
+ public void Clear()
+ {
+ var map = new MapField<string, string> { { "x", "y" } };
+ Assert.AreEqual(1, map.Count);
+ map.Clear();
+ Assert.AreEqual(0, map.Count);
+ map.Add("x", "y");
+ Assert.AreEqual(1, map.Count);
+ }
+
+ [Test]
+ public void Indexer_Get()
+ {
+ var map = new MapField<string, string> { { "x", "y" } };
+ Assert.AreEqual("y", map["x"]);
+ Assert.Throws<KeyNotFoundException>(() => { var ignored = map["z"]; });
+ }
+
+ [Test]
+ public void Indexer_Set()
+ {
+ var map = new MapField<string, string>();
+ map["x"] = "y";
+ Assert.AreEqual("y", map["x"]);
+ map["x"] = "z"; // This won't throw, unlike Add.
+ Assert.AreEqual("z", map["x"]);
+ }
+
+ [Test]
+ public void GetEnumerator_NonGeneric()
+ {
+ IEnumerable map = new MapField<string, string> { { "x", "y" } };
+ CollectionAssert.AreEqual(new[] { new KeyValuePair<string, string>("x", "y") },
+ map.Cast<object>().ToList());
+ }
+
+ // Test for the explicitly-implemented non-generic IDictionary interface
+ [Test]
+ public void IDictionary_GetEnumerator()
+ {
+ IDictionary map = new MapField<string, string> { { "x", "y" } };
+ var enumerator = map.GetEnumerator();
+
+ // Commented assertions show an ideal situation - it looks like
+ // the LinkedList enumerator doesn't throw when you ask for the current entry
+ // at an inappropriate time; fixing this would be more work than it's worth.
+ // Assert.Throws<InvalidOperationException>(() => enumerator.Current.GetHashCode());
+ Assert.IsTrue(enumerator.MoveNext());
+ Assert.AreEqual("x", enumerator.Key);
+ Assert.AreEqual("y", enumerator.Value);
+ Assert.AreEqual(new DictionaryEntry("x", "y"), enumerator.Current);
+ Assert.AreEqual(new DictionaryEntry("x", "y"), enumerator.Entry);
+ Assert.IsFalse(enumerator.MoveNext());
+ // Assert.Throws<InvalidOperationException>(() => enumerator.Current.GetHashCode());
+ enumerator.Reset();
+ // Assert.Throws<InvalidOperationException>(() => enumerator.Current.GetHashCode());
+ Assert.IsTrue(enumerator.MoveNext());
+ Assert.AreEqual("x", enumerator.Key); // Assume the rest are okay
+ }
+
+ [Test]
+ public void IDictionary_Add()
+ {
+ var map = new MapField<string, string> { { "x", "y" } };
+ IDictionary dictionary = map;
+ dictionary.Add("a", "b");
+ Assert.AreEqual("b", map["a"]);
+ Assert.Throws<ArgumentException>(() => dictionary.Add("a", "duplicate"));
+ Assert.Throws<InvalidCastException>(() => dictionary.Add(new object(), "key is bad"));
+ Assert.Throws<InvalidCastException>(() => dictionary.Add("value is bad", new object()));
+ }
+
+ [Test]
+ public void IDictionary_Contains()
+ {
+ var map = new MapField<string, string> { { "x", "y" } };
+ IDictionary dictionary = map;
+
+ Assert.IsFalse(dictionary.Contains("a"));
+ Assert.IsFalse(dictionary.Contains(5));
+ // Surprising, but IDictionary.Contains is only about keys.
+ Assert.IsFalse(dictionary.Contains(new DictionaryEntry("x", "y")));
+ Assert.IsTrue(dictionary.Contains("x"));
+ }
+
+ [Test]
+ public void IDictionary_Remove()
+ {
+ var map = new MapField<string, string> { { "x", "y" } };
+ IDictionary dictionary = map;
+ dictionary.Remove("a");
+ Assert.AreEqual(1, dictionary.Count);
+ dictionary.Remove(5);
+ Assert.AreEqual(1, dictionary.Count);
+ dictionary.Remove(new DictionaryEntry("x", "y"));
+ Assert.AreEqual(1, dictionary.Count);
+ dictionary.Remove("x");
+ Assert.AreEqual(0, dictionary.Count);
+ Assert.Throws<ArgumentNullException>(() => dictionary.Remove(null));
+ }
+
+ [Test]
+ public void IDictionary_CopyTo()
+ {
+ var map = new MapField<string, string> { { "x", "y" } };
+ IDictionary dictionary = map;
+ var array = new DictionaryEntry[3];
+ dictionary.CopyTo(array, 1);
+ CollectionAssert.AreEqual(new[] { default(DictionaryEntry), new DictionaryEntry("x", "y"), default(DictionaryEntry) },
+ array);
+ var objectArray = new object[3];
+ dictionary.CopyTo(objectArray, 1);
+ CollectionAssert.AreEqual(new object[] { null, new DictionaryEntry("x", "y"), null },
+ objectArray);
+ }
+
+ [Test]
+ public void IDictionary_IsFixedSize()
+ {
+ var map = new MapField<string, string> { { "x", "y" } };
+ IDictionary dictionary = map;
+ Assert.IsFalse(dictionary.IsFixedSize);
+ }
+
+ [Test]
+ public void IDictionary_Keys()
+ {
+ IDictionary dictionary = new MapField<string, string> { { "x", "y" } };
+ CollectionAssert.AreEqual(new[] { "x" }, dictionary.Keys);
+ }
+
+ [Test]
+ public void IDictionary_Values()
+ {
+ IDictionary dictionary = new MapField<string, string> { { "x", "y" } };
+ CollectionAssert.AreEqual(new[] { "y" }, dictionary.Values);
+ }
+
+ [Test]
+ public void IDictionary_IsSynchronized()
+ {
+ IDictionary dictionary = new MapField<string, string> { { "x", "y" } };
+ Assert.IsFalse(dictionary.IsSynchronized);
+ }
+
+ [Test]
+ public void IDictionary_SyncRoot()
+ {
+ IDictionary dictionary = new MapField<string, string> { { "x", "y" } };
+ Assert.AreSame(dictionary, dictionary.SyncRoot);
+ }
+
+ [Test]
+ public void IDictionary_Indexer_Get()
+ {
+ IDictionary dictionary = new MapField<string, string> { { "x", "y" } };
+ Assert.AreEqual("y", dictionary["x"]);
+ Assert.IsNull(dictionary["a"]);
+ Assert.IsNull(dictionary[5]);
+ Assert.Throws<ArgumentNullException>(() => dictionary[null].GetHashCode());
+ }
+
+ [Test]
+ public void IDictionary_Indexer_Set()
+ {
+ var map = new MapField<string, string> { { "x", "y" } };
+ IDictionary dictionary = map;
+ map["a"] = "b";
+ Assert.AreEqual("b", map["a"]);
+ map["a"] = "c";
+ Assert.AreEqual("c", map["a"]);
+ Assert.Throws<InvalidCastException>(() => dictionary[5] = "x");
+ Assert.Throws<InvalidCastException>(() => dictionary["x"] = 5);
+ Assert.Throws<ArgumentNullException>(() => dictionary[null] = "z");
+ Assert.Throws<ArgumentNullException>(() => dictionary["x"] = null);
+ }
+
+ [Test]
+ public void KeysReturnsLiveView()
+ {
+ var map = new MapField<string, string>();
+ var keys = map.Keys;
+ CollectionAssert.AreEqual(new string[0], keys);
+ map["foo"] = "bar";
+ map["x"] = "y";
+ CollectionAssert.AreEqual(new[] { "foo", "x" }, keys);
+ }
+
+ [Test]
+ public void ValuesReturnsLiveView()
+ {
+ var map = new MapField<string, string>();
+ var values = map.Values;
+ CollectionAssert.AreEqual(new string[0], values);
+ map["foo"] = "bar";
+ map["x"] = "y";
+ CollectionAssert.AreEqual(new[] { "bar", "y" }, values);
+ }
+
+ // Just test keys - we know the implementation is the same for values
+ [Test]
+ public void ViewsAreReadOnly()
+ {
+ var map = new MapField<string, string>();
+ var keys = map.Keys;
+ Assert.IsTrue(keys.IsReadOnly);
+ Assert.Throws<NotSupportedException>(() => keys.Clear());
+ Assert.Throws<NotSupportedException>(() => keys.Remove("a"));
+ Assert.Throws<NotSupportedException>(() => keys.Add("a"));
+ }
+
+ // Just test keys - we know the implementation is the same for values
+ [Test]
+ public void ViewCopyTo()
+ {
+ var map = new MapField<string, string> { { "foo", "bar" }, { "x", "y" } };
+ var keys = map.Keys;
+ var array = new string[4];
+ Assert.Throws<ArgumentException>(() => keys.CopyTo(array, 3));
+ Assert.Throws<ArgumentOutOfRangeException>(() => keys.CopyTo(array, -1));
+ keys.CopyTo(array, 1);
+ CollectionAssert.AreEqual(new[] { null, "foo", "x", null }, array);
+ }
+
+ // Just test keys - we know the implementation is the same for values
+ [Test]
+ public void NonGenericViewCopyTo()
+ {
+ IDictionary map = new MapField<string, string> { { "foo", "bar" }, { "x", "y" } };
+ ICollection keys = map.Keys;
+ // Note the use of the Array type here rather than string[]
+ Array array = new string[4];
+ Assert.Throws<ArgumentException>(() => keys.CopyTo(array, 3));
+ Assert.Throws<ArgumentOutOfRangeException>(() => keys.CopyTo(array, -1));
+ keys.CopyTo(array, 1);
+ CollectionAssert.AreEqual(new[] { null, "foo", "x", null }, array);
+ }
+
+ [Test]
+ public void KeysContains()
+ {
+ var map = new MapField<string, string> { { "foo", "bar" }, { "x", "y" } };
+ var keys = map.Keys;
+ Assert.IsTrue(keys.Contains("foo"));
+ Assert.IsFalse(keys.Contains("bar")); // It's a value!
+ Assert.IsFalse(keys.Contains("1"));
+ // Keys can't be null, so we should prevent contains check
+ Assert.Throws<ArgumentNullException>(() => keys.Contains(null));
+ }
+
+ [Test]
+ public void ValuesContains()
+ {
+ var map = new MapField<string, string> { { "foo", "bar" }, { "x", "y" } };
+ var values = map.Values;
+ Assert.IsTrue(values.Contains("bar"));
+ Assert.IsFalse(values.Contains("foo")); // It's a key!
+ Assert.IsFalse(values.Contains("1"));
+ // Values can be null, so this makes sense
+ Assert.IsFalse(values.Contains(null));
+ }
+
+ [Test]
+ public void ToString_StringToString()
+ {
+ var map = new MapField<string, string> { { "foo", "bar" }, { "x", "y" } };
+ Assert.AreEqual("{ \"foo\": \"bar\", \"x\": \"y\" }", map.ToString());
+ }
+
+ [Test]
+ public void ToString_UnsupportedKeyType()
+ {
+ var map = new MapField<byte, string> { { 10, "foo" } };
+ Assert.Throws<ArgumentException>(() => map.ToString());
+ }
+
+ private static KeyValuePair<TKey, TValue> NewKeyValuePair<TKey, TValue>(TKey key, TValue value)
+ {
+ return new KeyValuePair<TKey, TValue>(key, value);
+ }
+ }
+}
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs
new file mode 100644
index 00000000..6852f75f
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs
@@ -0,0 +1,746 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2015 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using Google.Protobuf.TestProtos;
+using Google.Protobuf.WellKnownTypes;
+using NUnit.Framework;
+
+namespace Google.Protobuf.Collections
+{
+ public class RepeatedFieldTest
+ {
+ [Test]
+ public void NullValuesRejected()
+ {
+ var list = new RepeatedField<string>();
+ Assert.Throws<ArgumentNullException>(() => list.Add((string)null));
+ Assert.Throws<ArgumentNullException>(() => list.Add((IEnumerable<string>)null));
+ Assert.Throws<ArgumentNullException>(() => list.Add((RepeatedField<string>)null));
+ Assert.Throws<ArgumentNullException>(() => list.Contains(null));
+ Assert.Throws<ArgumentNullException>(() => list.IndexOf(null));
+ }
+
+ [Test]
+ public void Add_SingleItem()
+ {
+ var list = new RepeatedField<string>();
+ list.Add("foo");
+ Assert.AreEqual(1, list.Count);
+ Assert.AreEqual("foo", list[0]);
+ }
+
+ [Test]
+ public void Add_Sequence()
+ {
+ var list = new RepeatedField<string>();
+ list.Add(new[] { "foo", "bar" });
+ Assert.AreEqual(2, list.Count);
+ Assert.AreEqual("foo", list[0]);
+ Assert.AreEqual("bar", list[1]);
+ }
+
+ [Test]
+ public void AddRange_SlowPath()
+ {
+ var list = new RepeatedField<string>();
+ list.AddRange(new[] { "foo", "bar" }.Select(x => x));
+ Assert.AreEqual(2, list.Count);
+ Assert.AreEqual("foo", list[0]);
+ Assert.AreEqual("bar", list[1]);
+ }
+
+ [Test]
+ public void AddRange_SlowPath_NullsProhibited_ReferenceType()
+ {
+ var list = new RepeatedField<string>();
+ // It's okay for this to throw ArgumentNullException if necessary.
+ // It's not ideal, but not awful.
+ Assert.Catch<ArgumentException>(() => list.AddRange(new[] { "foo", null }.Select(x => x)));
+ }
+
+ [Test]
+ public void AddRange_SlowPath_NullsProhibited_NullableValueType()
+ {
+ var list = new RepeatedField<int?>();
+ // It's okay for this to throw ArgumentNullException if necessary.
+ // It's not ideal, but not awful.
+ Assert.Catch<ArgumentException>(() => list.AddRange(new[] { 20, (int?)null }.Select(x => x)));
+ }
+
+ [Test]
+ public void AddRange_Optimized_NonNullableValueType()
+ {
+ var list = new RepeatedField<int>();
+ list.AddRange(new List<int> { 20, 30 });
+ Assert.AreEqual(2, list.Count);
+ Assert.AreEqual(20, list[0]);
+ Assert.AreEqual(30, list[1]);
+ }
+
+ [Test]
+ public void AddRange_Optimized_ReferenceType()
+ {
+ var list = new RepeatedField<string>();
+ list.AddRange(new List<string> { "foo", "bar" });
+ Assert.AreEqual(2, list.Count);
+ Assert.AreEqual("foo", list[0]);
+ Assert.AreEqual("bar", list[1]);
+ }
+
+ [Test]
+ public void AddRange_Optimized_NullableValueType()
+ {
+ var list = new RepeatedField<int?>();
+ list.AddRange(new List<int?> { 20, 30 });
+ Assert.AreEqual(2, list.Count);
+ Assert.AreEqual((int?) 20, list[0]);
+ Assert.AreEqual((int?) 30, list[1]);
+ }
+
+ [Test]
+ public void AddRange_Optimized_NullsProhibited_ReferenceType()
+ {
+ // We don't just trust that a collection with a nullable element type doesn't contain nulls
+ var list = new RepeatedField<string>();
+ // It's okay for this to throw ArgumentNullException if necessary.
+ // It's not ideal, but not awful.
+ Assert.Catch<ArgumentException>(() => list.AddRange(new List<string> { "foo", null }));
+ }
+
+ [Test]
+ public void AddRange_Optimized_NullsProhibited_NullableValueType()
+ {
+ // We don't just trust that a collection with a nullable element type doesn't contain nulls
+ var list = new RepeatedField<int?>();
+ // It's okay for this to throw ArgumentNullException if necessary.
+ // It's not ideal, but not awful.
+ Assert.Catch<ArgumentException>(() => list.AddRange(new List<int?> { 20, null }));
+ }
+
+ [Test]
+ public void AddRange_AlreadyNotEmpty()
+ {
+ var list = new RepeatedField<int> { 1, 2, 3 };
+ list.AddRange(new List<int> { 4, 5, 6 });
+ CollectionAssert.AreEqual(new[] { 1, 2, 3, 4, 5, 6 }, list);
+ }
+
+ [Test]
+ public void AddRange_RepeatedField()
+ {
+ var list = new RepeatedField<string> { "original" };
+ list.AddRange(new RepeatedField<string> { "foo", "bar" });
+ Assert.AreEqual(3, list.Count);
+ Assert.AreEqual("original", list[0]);
+ Assert.AreEqual("foo", list[1]);
+ Assert.AreEqual("bar", list[2]);
+ }
+
+ [Test]
+ public void RemoveAt_Valid()
+ {
+ var list = new RepeatedField<string> { "first", "second", "third" };
+ list.RemoveAt(1);
+ CollectionAssert.AreEqual(new[] { "first", "third" }, list);
+ // Just check that these don't throw...
+ list.RemoveAt(list.Count - 1); // Now the count will be 1...
+ list.RemoveAt(0);
+ Assert.AreEqual(0, list.Count);
+ }
+
+ [Test]
+ public void RemoveAt_Invalid()
+ {
+ var list = new RepeatedField<string> { "first", "second", "third" };
+ Assert.Throws<ArgumentOutOfRangeException>(() => list.RemoveAt(-1));
+ Assert.Throws<ArgumentOutOfRangeException>(() => list.RemoveAt(3));
+ }
+
+ [Test]
+ public void Insert_Valid()
+ {
+ var list = new RepeatedField<string> { "first", "second" };
+ list.Insert(1, "middle");
+ CollectionAssert.AreEqual(new[] { "first", "middle", "second" }, list);
+ list.Insert(3, "end");
+ CollectionAssert.AreEqual(new[] { "first", "middle", "second", "end" }, list);
+ list.Insert(0, "start");
+ CollectionAssert.AreEqual(new[] { "start", "first", "middle", "second", "end" }, list);
+ }
+
+ [Test]
+ public void Insert_Invalid()
+ {
+ var list = new RepeatedField<string> { "first", "second" };
+ Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(-1, "foo"));
+ Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(3, "foo"));
+ Assert.Throws<ArgumentNullException>(() => list.Insert(0, null));
+ }
+
+ [Test]
+ public void Equals_RepeatedField()
+ {
+ var list = new RepeatedField<string> { "first", "second" };
+ Assert.IsFalse(list.Equals((RepeatedField<string>) null));
+ Assert.IsTrue(list.Equals(list));
+ Assert.IsFalse(list.Equals(new RepeatedField<string> { "first", "third" }));
+ Assert.IsFalse(list.Equals(new RepeatedField<string> { "first" }));
+ Assert.IsTrue(list.Equals(new RepeatedField<string> { "first", "second" }));
+ }
+
+ [Test]
+ public void Equals_Object()
+ {
+ var list = new RepeatedField<string> { "first", "second" };
+ Assert.IsFalse(list.Equals((object) null));
+ Assert.IsTrue(list.Equals((object) list));
+ Assert.IsFalse(list.Equals((object) new RepeatedField<string> { "first", "third" }));
+ Assert.IsFalse(list.Equals((object) new RepeatedField<string> { "first" }));
+ Assert.IsTrue(list.Equals((object) new RepeatedField<string> { "first", "second" }));
+ Assert.IsFalse(list.Equals(new object()));
+ }
+
+ [Test]
+ public void GetEnumerator_GenericInterface()
+ {
+ IEnumerable<string> list = new RepeatedField<string> { "first", "second" };
+ // Select gets rid of the optimizations in ToList...
+ CollectionAssert.AreEqual(new[] { "first", "second" }, list.Select(x => x).ToList());
+ }
+
+ [Test]
+ public void GetEnumerator_NonGenericInterface()
+ {
+ IEnumerable list = new RepeatedField<string> { "first", "second" };
+ CollectionAssert.AreEqual(new[] { "first", "second" }, list.Cast<object>().ToList());
+ }
+
+ [Test]
+ public void CopyTo()
+ {
+ var list = new RepeatedField<string> { "first", "second" };
+ string[] stringArray = new string[4];
+ list.CopyTo(stringArray, 1);
+ CollectionAssert.AreEqual(new[] { null, "first", "second", null }, stringArray);
+ }
+
+ [Test]
+ public void Indexer_Get()
+ {
+ var list = new RepeatedField<string> { "first", "second" };
+ Assert.AreEqual("first", list[0]);
+ Assert.AreEqual("second", list[1]);
+ Assert.Throws<ArgumentOutOfRangeException>(() => list[-1].GetHashCode());
+ Assert.Throws<ArgumentOutOfRangeException>(() => list[2].GetHashCode());
+ }
+
+ [Test]
+ public void Indexer_Set()
+ {
+ var list = new RepeatedField<string> { "first", "second" };
+ list[0] = "changed";
+ Assert.AreEqual("changed", list[0]);
+ Assert.Throws<ArgumentNullException>(() => list[0] = null);
+ Assert.Throws<ArgumentOutOfRangeException>(() => list[-1] = "bad");
+ Assert.Throws<ArgumentOutOfRangeException>(() => list[2] = "bad");
+ }
+
+ [Test]
+ public void Clone_ReturnsMutable()
+ {
+ var list = new RepeatedField<int> { 0 };
+ var clone = list.Clone();
+ clone[0] = 1;
+ }
+
+ [Test]
+ public void Enumerator()
+ {
+ var list = new RepeatedField<string> { "first", "second" };
+ using (var enumerator = list.GetEnumerator())
+ {
+ Assert.IsTrue(enumerator.MoveNext());
+ Assert.AreEqual("first", enumerator.Current);
+ Assert.IsTrue(enumerator.MoveNext());
+ Assert.AreEqual("second", enumerator.Current);
+ Assert.IsFalse(enumerator.MoveNext());
+ Assert.IsFalse(enumerator.MoveNext());
+ }
+ }
+
+ [Test]
+ public void AddEntriesFrom_PackedInt32()
+ {
+ uint packedTag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited);
+ var stream = new MemoryStream();
+ var output = new CodedOutputStream(stream);
+ var length = CodedOutputStream.ComputeInt32Size(10)
+ + CodedOutputStream.ComputeInt32Size(999)
+ + CodedOutputStream.ComputeInt32Size(-1000);
+ output.WriteTag(packedTag);
+ output.WriteRawVarint32((uint) length);
+ output.WriteInt32(10);
+ output.WriteInt32(999);
+ output.WriteInt32(-1000);
+ output.Flush();
+ stream.Position = 0;
+
+ // Deliberately "expecting" a non-packed tag, but we detect that the data is
+ // actually packed.
+ uint nonPackedTag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited);
+ var field = new RepeatedField<int>();
+ var input = new CodedInputStream(stream);
+ input.AssertNextTag(packedTag);
+ field.AddEntriesFrom(input, FieldCodec.ForInt32(nonPackedTag));
+ CollectionAssert.AreEqual(new[] { 10, 999, -1000 }, field);
+ Assert.IsTrue(input.IsAtEnd);
+ }
+
+ [Test]
+ public void AddEntriesFrom_NonPackedInt32()
+ {
+ uint nonPackedTag = WireFormat.MakeTag(10, WireFormat.WireType.Varint);
+ var stream = new MemoryStream();
+ var output = new CodedOutputStream(stream);
+ output.WriteTag(nonPackedTag);
+ output.WriteInt32(10);
+ output.WriteTag(nonPackedTag);
+ output.WriteInt32(999);
+ output.WriteTag(nonPackedTag);
+ output.WriteInt32(-1000); // Just for variety...
+ output.Flush();
+ stream.Position = 0;
+
+ // Deliberately "expecting" a packed tag, but we detect that the data is
+ // actually not packed.
+ uint packedTag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited);
+ var field = new RepeatedField<int>();
+ var input = new CodedInputStream(stream);
+ input.AssertNextTag(nonPackedTag);
+ field.AddEntriesFrom(input, FieldCodec.ForInt32(packedTag));
+ CollectionAssert.AreEqual(new[] { 10, 999, -1000 }, field);
+ Assert.IsTrue(input.IsAtEnd);
+ }
+
+ [Test]
+ public void AddEntriesFrom_String()
+ {
+ uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited);
+ var stream = new MemoryStream();
+ var output = new CodedOutputStream(stream);
+ output.WriteTag(tag);
+ output.WriteString("Foo");
+ output.WriteTag(tag);
+ output.WriteString("");
+ output.WriteTag(tag);
+ output.WriteString("Bar");
+ output.Flush();
+ stream.Position = 0;
+
+ var field = new RepeatedField<string>();
+ var input = new CodedInputStream(stream);
+ input.AssertNextTag(tag);
+ field.AddEntriesFrom(input, FieldCodec.ForString(tag));
+ CollectionAssert.AreEqual(new[] { "Foo", "", "Bar" }, field);
+ Assert.IsTrue(input.IsAtEnd);
+ }
+
+ [Test]
+ public void AddEntriesFrom_Message()
+ {
+ var message1 = new ForeignMessage { C = 2000 };
+ var message2 = new ForeignMessage { C = -250 };
+
+ uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited);
+ var stream = new MemoryStream();
+ var output = new CodedOutputStream(stream);
+ output.WriteTag(tag);
+ output.WriteMessage(message1);
+ output.WriteTag(tag);
+ output.WriteMessage(message2);
+ output.Flush();
+ stream.Position = 0;
+
+ var field = new RepeatedField<ForeignMessage>();
+ var input = new CodedInputStream(stream);
+ input.AssertNextTag(tag);
+ field.AddEntriesFrom(input, FieldCodec.ForMessage(tag, ForeignMessage.Parser));
+ CollectionAssert.AreEqual(new[] { message1, message2}, field);
+ Assert.IsTrue(input.IsAtEnd);
+ }
+
+ [Test]
+ public void WriteTo_PackedInt32()
+ {
+ uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited);
+ var field = new RepeatedField<int> { 10, 1000, 1000000 };
+ var stream = new MemoryStream();
+ var output = new CodedOutputStream(stream);
+ field.WriteTo(output, FieldCodec.ForInt32(tag));
+ output.Flush();
+ stream.Position = 0;
+
+ var input = new CodedInputStream(stream);
+ input.AssertNextTag(tag);
+ var length = input.ReadLength();
+ Assert.AreEqual(10, input.ReadInt32());
+ Assert.AreEqual(1000, input.ReadInt32());
+ Assert.AreEqual(1000000, input.ReadInt32());
+ Assert.IsTrue(input.IsAtEnd);
+ Assert.AreEqual(1 + CodedOutputStream.ComputeLengthSize(length) + length, stream.Length);
+ }
+
+ [Test]
+ public void WriteTo_NonPackedInt32()
+ {
+ uint tag = WireFormat.MakeTag(10, WireFormat.WireType.Varint);
+ var field = new RepeatedField<int> { 10, 1000, 1000000};
+ var stream = new MemoryStream();
+ var output = new CodedOutputStream(stream);
+ field.WriteTo(output, FieldCodec.ForInt32(tag));
+ output.Flush();
+ stream.Position = 0;
+
+ var input = new CodedInputStream(stream);
+ input.AssertNextTag(tag);
+ Assert.AreEqual(10, input.ReadInt32());
+ input.AssertNextTag(tag);
+ Assert.AreEqual(1000, input.ReadInt32());
+ input.AssertNextTag(tag);
+ Assert.AreEqual(1000000, input.ReadInt32());
+ Assert.IsTrue(input.IsAtEnd);
+ }
+
+ [Test]
+ public void WriteTo_String()
+ {
+ uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited);
+ var field = new RepeatedField<string> { "Foo", "", "Bar" };
+ var stream = new MemoryStream();
+ var output = new CodedOutputStream(stream);
+ field.WriteTo(output, FieldCodec.ForString(tag));
+ output.Flush();
+ stream.Position = 0;
+
+ var input = new CodedInputStream(stream);
+ input.AssertNextTag(tag);
+ Assert.AreEqual("Foo", input.ReadString());
+ input.AssertNextTag(tag);
+ Assert.AreEqual("", input.ReadString());
+ input.AssertNextTag(tag);
+ Assert.AreEqual("Bar", input.ReadString());
+ Assert.IsTrue(input.IsAtEnd);
+ }
+
+ [Test]
+ public void WriteTo_Message()
+ {
+ var message1 = new ForeignMessage { C = 20 };
+ var message2 = new ForeignMessage { C = 25 };
+ uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited);
+ var field = new RepeatedField<ForeignMessage> { message1, message2 };
+ var stream = new MemoryStream();
+ var output = new CodedOutputStream(stream);
+ field.WriteTo(output, FieldCodec.ForMessage(tag, ForeignMessage.Parser));
+ output.Flush();
+ stream.Position = 0;
+
+ var input = new CodedInputStream(stream);
+ input.AssertNextTag(tag);
+ Assert.AreEqual(message1, input.ReadMessage(ForeignMessage.Parser));
+ input.AssertNextTag(tag);
+ Assert.AreEqual(message2, input.ReadMessage(ForeignMessage.Parser));
+ Assert.IsTrue(input.IsAtEnd);
+ }
+
+ [Test]
+ public void CalculateSize_VariableSizeNonPacked()
+ {
+ var list = new RepeatedField<int> { 1, 500, 1 };
+ var tag = WireFormat.MakeTag(1, WireFormat.WireType.Varint);
+ // 2 bytes for the first entry, 3 bytes for the second, 2 bytes for the third
+ Assert.AreEqual(7, list.CalculateSize(FieldCodec.ForInt32(tag)));
+ }
+
+ [Test]
+ public void CalculateSize_FixedSizeNonPacked()
+ {
+ var list = new RepeatedField<int> { 1, 500, 1 };
+ var tag = WireFormat.MakeTag(1, WireFormat.WireType.Fixed32);
+ // 5 bytes for the each entry
+ Assert.AreEqual(15, list.CalculateSize(FieldCodec.ForSFixed32(tag)));
+ }
+
+ [Test]
+ public void CalculateSize_VariableSizePacked()
+ {
+ var list = new RepeatedField<int> { 1, 500, 1};
+ var tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited);
+ // 1 byte for the tag, 1 byte for the length,
+ // 1 byte for the first entry, 2 bytes for the second, 1 byte for the third
+ Assert.AreEqual(6, list.CalculateSize(FieldCodec.ForInt32(tag)));
+ }
+
+ [Test]
+ public void CalculateSize_FixedSizePacked()
+ {
+ var list = new RepeatedField<int> { 1, 500, 1 };
+ var tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited);
+ // 1 byte for the tag, 1 byte for the length, 4 bytes per entry
+ Assert.AreEqual(14, list.CalculateSize(FieldCodec.ForSFixed32(tag)));
+ }
+
+ [Test]
+ public void TestNegativeEnumArray()
+ {
+ int arraySize = 1 + 1 + (11 * 5);
+ int msgSize = arraySize;
+ byte[] bytes = new byte[msgSize];
+ CodedOutputStream output = new CodedOutputStream(bytes);
+ uint tag = WireFormat.MakeTag(8, WireFormat.WireType.Varint);
+ for (int i = 0; i >= -5; i--)
+ {
+ output.WriteTag(tag);
+ output.WriteEnum(i);
+ }
+
+ Assert.AreEqual(0, output.SpaceLeft);
+
+ CodedInputStream input = new CodedInputStream(bytes);
+ tag = input.ReadTag();
+
+ RepeatedField<SampleEnum> values = new RepeatedField<SampleEnum>();
+ values.AddEntriesFrom(input, FieldCodec.ForEnum(tag, x => (int)x, x => (SampleEnum)x));
+
+ Assert.AreEqual(6, values.Count);
+ Assert.AreEqual(SampleEnum.None, values[0]);
+ Assert.AreEqual(((SampleEnum)(-1)), values[1]);
+ Assert.AreEqual(SampleEnum.NegativeValue, values[2]);
+ Assert.AreEqual(((SampleEnum)(-3)), values[3]);
+ Assert.AreEqual(((SampleEnum)(-4)), values[4]);
+ Assert.AreEqual(((SampleEnum)(-5)), values[5]);
+ }
+
+
+ [Test]
+ public void TestNegativeEnumPackedArray()
+ {
+ int arraySize = 1 + (10 * 5);
+ int msgSize = 1 + 1 + arraySize;
+ byte[] bytes = new byte[msgSize];
+ CodedOutputStream output = new CodedOutputStream(bytes);
+ // Length-delimited to show we want the packed representation
+ uint tag = WireFormat.MakeTag(8, WireFormat.WireType.LengthDelimited);
+ output.WriteTag(tag);
+ int size = 0;
+ for (int i = 0; i >= -5; i--)
+ {
+ size += CodedOutputStream.ComputeEnumSize(i);
+ }
+ output.WriteRawVarint32((uint)size);
+ for (int i = 0; i >= -5; i--)
+ {
+ output.WriteEnum(i);
+ }
+ Assert.AreEqual(0, output.SpaceLeft);
+
+ CodedInputStream input = new CodedInputStream(bytes);
+ tag = input.ReadTag();
+
+ RepeatedField<SampleEnum> values = new RepeatedField<SampleEnum>();
+ values.AddEntriesFrom(input, FieldCodec.ForEnum(tag, x => (int)x, x => (SampleEnum)x));
+
+ Assert.AreEqual(6, values.Count);
+ Assert.AreEqual(SampleEnum.None, values[0]);
+ Assert.AreEqual(((SampleEnum)(-1)), values[1]);
+ Assert.AreEqual(SampleEnum.NegativeValue, values[2]);
+ Assert.AreEqual(((SampleEnum)(-3)), values[3]);
+ Assert.AreEqual(((SampleEnum)(-4)), values[4]);
+ Assert.AreEqual(((SampleEnum)(-5)), values[5]);
+ }
+
+ // Fairly perfunctory tests for the non-generic IList implementation
+ [Test]
+ public void IList_Indexer()
+ {
+ var field = new RepeatedField<string> { "first", "second" };
+ IList list = field;
+ Assert.AreEqual("first", list[0]);
+ list[1] = "changed";
+ Assert.AreEqual("changed", field[1]);
+ }
+
+ [Test]
+ public void IList_Contains()
+ {
+ IList list = new RepeatedField<string> { "first", "second" };
+ Assert.IsTrue(list.Contains("second"));
+ Assert.IsFalse(list.Contains("third"));
+ Assert.IsFalse(list.Contains(new object()));
+ }
+
+ [Test]
+ public void IList_Add()
+ {
+ IList list = new RepeatedField<string> { "first", "second" };
+ list.Add("third");
+ CollectionAssert.AreEqual(new[] { "first", "second", "third" }, list);
+ }
+
+ [Test]
+ public void IList_Remove()
+ {
+ IList list = new RepeatedField<string> { "first", "second" };
+ list.Remove("third"); // No-op, no exception
+ list.Remove(new object()); // No-op, no exception
+ list.Remove("first");
+ CollectionAssert.AreEqual(new[] { "second" }, list);
+ }
+
+ [Test]
+ public void IList_IsFixedSize()
+ {
+ var field = new RepeatedField<string> { "first", "second" };
+ IList list = field;
+ Assert.IsFalse(list.IsFixedSize);
+ }
+
+ [Test]
+ public void IList_IndexOf()
+ {
+ IList list = new RepeatedField<string> { "first", "second" };
+ Assert.AreEqual(1, list.IndexOf("second"));
+ Assert.AreEqual(-1, list.IndexOf("third"));
+ Assert.AreEqual(-1, list.IndexOf(new object()));
+ }
+
+ [Test]
+ public void IList_SyncRoot()
+ {
+ IList list = new RepeatedField<string> { "first", "second" };
+ Assert.AreSame(list, list.SyncRoot);
+ }
+
+ [Test]
+ public void IList_CopyTo()
+ {
+ IList list = new RepeatedField<string> { "first", "second" };
+ string[] stringArray = new string[4];
+ list.CopyTo(stringArray, 1);
+ CollectionAssert.AreEqual(new[] { null, "first", "second", null }, stringArray);
+
+ object[] objectArray = new object[4];
+ list.CopyTo(objectArray, 1);
+ CollectionAssert.AreEqual(new[] { null, "first", "second", null }, objectArray);
+
+ Assert.Throws<ArrayTypeMismatchException>(() => list.CopyTo(new StringBuilder[4], 1));
+ Assert.Throws<ArrayTypeMismatchException>(() => list.CopyTo(new int[4], 1));
+ }
+
+ [Test]
+ public void IList_IsSynchronized()
+ {
+ IList list = new RepeatedField<string> { "first", "second" };
+ Assert.IsFalse(list.IsSynchronized);
+ }
+
+ [Test]
+ public void IList_Insert()
+ {
+ IList list = new RepeatedField<string> { "first", "second" };
+ list.Insert(1, "middle");
+ CollectionAssert.AreEqual(new[] { "first", "middle", "second" }, list);
+ }
+
+ [Test]
+ public void ToString_Integers()
+ {
+ var list = new RepeatedField<int> { 5, 10, 20 };
+ var text = list.ToString();
+ Assert.AreEqual("[ 5, 10, 20 ]", text);
+ }
+
+ [Test]
+ public void ToString_Strings()
+ {
+ var list = new RepeatedField<string> { "x", "y", "z" };
+ var text = list.ToString();
+ Assert.AreEqual("[ \"x\", \"y\", \"z\" ]", text);
+ }
+
+ [Test]
+ public void ToString_Messages()
+ {
+ var list = new RepeatedField<TestAllTypes> { new TestAllTypes { SingleDouble = 1.5 }, new TestAllTypes { SingleInt32 = 10 } };
+ var text = list.ToString();
+ Assert.AreEqual("[ { \"singleDouble\": 1.5 }, { \"singleInt32\": 10 } ]", text);
+ }
+
+ [Test]
+ public void ToString_Empty()
+ {
+ var list = new RepeatedField<TestAllTypes> { };
+ var text = list.ToString();
+ Assert.AreEqual("[ ]", text);
+ }
+
+ [Test]
+ public void ToString_InvalidElementType()
+ {
+ var list = new RepeatedField<decimal> { 15m };
+ Assert.Throws<ArgumentException>(() => list.ToString());
+ }
+
+ [Test]
+ public void ToString_Timestamp()
+ {
+ var list = new RepeatedField<Timestamp> { Timestamp.FromDateTime(new DateTime(2015, 10, 1, 12, 34, 56, DateTimeKind.Utc)) };
+ var text = list.ToString();
+ Assert.AreEqual("[ \"2015-10-01T12:34:56Z\" ]", text);
+ }
+
+ [Test]
+ public void ToString_Struct()
+ {
+ var message = new Struct { Fields = { { "foo", new Value { NumberValue = 20 } } } };
+ var list = new RepeatedField<Struct> { message };
+ var text = list.ToString();
+ Assert.AreEqual(text, "[ { \"foo\": 20 } ]", message.ToString());
+ }
+ }
+}
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Compatibility/PropertyInfoExtensionsTest.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Compatibility/PropertyInfoExtensionsTest.cs
new file mode 100644
index 00000000..df23a09c
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Compatibility/PropertyInfoExtensionsTest.cs
@@ -0,0 +1,98 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2015 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using NUnit.Framework;
+using System.Reflection;
+
+namespace Google.Protobuf.Compatibility
+{
+ public class PropertyInfoExtensionsTest
+ {
+ public string PublicReadWrite { get; set; }
+ private string PrivateReadWrite { get; set; }
+ public string PublicReadPrivateWrite { get; private set; }
+ public string PrivateReadPublicWrite { private get; set; }
+ public string PublicReadOnly { get { return null; } }
+ private string PrivateReadOnly { get { return null; } }
+ public string PublicWriteOnly { set { } }
+ private string PrivateWriteOnly { set { } }
+
+ [Test]
+ [TestCase("PublicReadWrite")]
+ [TestCase("PublicReadPrivateWrite")]
+ [TestCase("PublicReadOnly")]
+ public void GetGetMethod_Success(string name)
+ {
+ var propertyInfo = typeof(PropertyInfoExtensionsTest)
+ .GetProperty(name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
+ Assert.IsNotNull(PropertyInfoExtensions.GetGetMethod(propertyInfo));
+ }
+
+ [Test]
+ [TestCase("PrivateReadWrite")]
+ [TestCase("PrivateReadPublicWrite")]
+ [TestCase("PrivateReadOnly")]
+ [TestCase("PublicWriteOnly")]
+ [TestCase("PrivateWriteOnly")]
+ public void GetGetMethod_NoAccessibleGetter(string name)
+ {
+ var propertyInfo = typeof(PropertyInfoExtensionsTest)
+ .GetProperty(name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
+ Assert.IsNull(PropertyInfoExtensions.GetGetMethod(propertyInfo));
+ }
+
+ [Test]
+ [TestCase("PublicReadWrite")]
+ [TestCase("PrivateReadPublicWrite")]
+ [TestCase("PublicWriteOnly")]
+ public void GetSetMethod_Success(string name)
+ {
+ var propertyInfo = typeof(PropertyInfoExtensionsTest)
+ .GetProperty(name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
+ Assert.IsNotNull(PropertyInfoExtensions.GetSetMethod(propertyInfo));
+ }
+
+ [Test]
+ [TestCase("PublicReadPrivateWrite")]
+ [TestCase("PrivateReadWrite")]
+ [TestCase("PrivateReadOnly")]
+ [TestCase("PublicReadOnly")]
+ [TestCase("PrivateWriteOnly")]
+ public void GetSetMethod_NoAccessibleGetter(string name)
+ {
+ var propertyInfo = typeof(PropertyInfoExtensionsTest)
+ .GetProperty(name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
+ Assert.IsNull(PropertyInfoExtensions.GetSetMethod(propertyInfo));
+ }
+ }
+
+}
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs
new file mode 100644
index 00000000..f430b06b
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs
@@ -0,0 +1,117 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2015 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+using NUnit.Framework;
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+
+#if !DOTNET35
+namespace Google.Protobuf.Compatibility
+{
+ public class TypeExtensionsTest
+ {
+ public class DerivedList : List<string> { }
+ public string PublicProperty { get; set; }
+ private string PrivateProperty { get; set; }
+
+ public void PublicMethod()
+ {
+ }
+
+ private void PrivateMethod()
+ {
+ }
+
+ [Test]
+ [TestCase(typeof(object), typeof(string), true)]
+ [TestCase(typeof(object), typeof(int), true)]
+ [TestCase(typeof(string), typeof(string), true)]
+ [TestCase(typeof(string), typeof(object), false)]
+ [TestCase(typeof(string), typeof(int), false)]
+ [TestCase(typeof(int), typeof(int), true)]
+ [TestCase(typeof(ValueType), typeof(int), true)]
+ [TestCase(typeof(long), typeof(int), false)] //
+ public void IsAssignableFrom(Type target, Type argument, bool expected)
+ {
+ Assert.AreEqual(expected, TypeExtensions.IsAssignableFrom(target, argument));
+ }
+
+ [Test]
+ [TestCase(typeof(DerivedList), "Count")] // Go up the type hierarchy
+ [TestCase(typeof(List<string>), "Count")]
+ [TestCase(typeof(List<>), "Count")]
+ [TestCase(typeof(TypeExtensionsTest), "PublicProperty")]
+ public void GetProperty_Success(Type type, string name)
+ {
+ var property = TypeExtensions.GetProperty(type, name);
+ Assert.IsNotNull(property);
+ Assert.AreEqual(name, property.Name);
+ }
+
+ [Test]
+ [TestCase(typeof(TypeExtensionsTest), "PrivateProperty")]
+ [TestCase(typeof(TypeExtensionsTest), "Garbage")]
+ public void GetProperty_NoSuchProperty(Type type, string name)
+ {
+ var property = TypeExtensions.GetProperty(type, name);
+ Assert.IsNull(property);
+ }
+
+ [Test]
+ [TestCase(typeof(DerivedList), "RemoveAt")] // Go up the type hierarchy
+ [TestCase(typeof(List<>), "RemoveAt")]
+ [TestCase(typeof(TypeExtensionsTest), "PublicMethod")]
+ public void GetMethod_Success(Type type, string name)
+ {
+ var method = TypeExtensions.GetMethod(type, name);
+ Assert.IsNotNull(method);
+ Assert.AreEqual(name, method.Name);
+ }
+
+ [Test]
+ [TestCase(typeof(TypeExtensionsTest), "PrivateMethod")]
+ [TestCase(typeof(TypeExtensionsTest), "GarbageMethod")]
+ public void GetMethod_NoSuchMethod(Type type, string name)
+ {
+ var method = TypeExtensions.GetMethod(type, name);
+ Assert.IsNull(method);
+ }
+
+ [Test]
+ [TestCase(typeof(List<string>), "IndexOf")]
+ public void GetMethod_Ambiguous(Type type, string name)
+ {
+ Assert.Throws<AmbiguousMatchException>(() => TypeExtensions.GetMethod(type, name));
+ }
+ }
+}
+#endif
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/DeprecatedMemberTest.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/DeprecatedMemberTest.cs
new file mode 100644
index 00000000..34d5b9f9
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/DeprecatedMemberTest.cs
@@ -0,0 +1,55 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2015 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using System;
+using System.Reflection;
+using Google.Protobuf.TestProtos;
+using NUnit.Framework;
+
+namespace Google.Protobuf
+{
+ public class DeprecatedMemberTest
+ {
+ private static void AssertIsDeprecated(MemberInfo member)
+ {
+ Assert.NotNull(member);
+ Assert.IsTrue(member.IsDefined(typeof(ObsoleteAttribute), false), "Member not obsolete: " + member);
+ }
+
+ [Test]
+ public void TestDepreatedPrimitiveValue()
+ {
+ AssertIsDeprecated(typeof(TestDeprecatedFields).GetProperty("DeprecatedInt32"));
+ }
+
+ }
+}
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/EqualityTester.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/EqualityTester.cs
new file mode 100644
index 00000000..a669baba
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/EqualityTester.cs
@@ -0,0 +1,64 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2015 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using System;
+using NUnit.Framework;
+
+namespace Google.Protobuf
+{
+ /// <summary>
+ /// Helper methods when testing equality. NUnit's Assert.AreEqual and
+ /// Assert.AreNotEqual methods try to be clever with collections, which can
+ /// be annoying...
+ /// </summary>
+ internal static class EqualityTester
+ {
+ public static void AssertEquality<T>(T first, T second) where T : IEquatable<T>
+ {
+ Assert.IsTrue(first.Equals(second));
+ Assert.IsTrue(first.Equals((object) second));
+ Assert.AreEqual(first.GetHashCode(), second.GetHashCode());
+ }
+
+ public static void AssertInequality<T>(T first, T second) where T : IEquatable<T>
+ {
+ Assert.IsFalse(first.Equals(second));
+ Assert.IsFalse(first.Equals((object) second));
+ // While this isn't a requirement, the chances of this test failing due to
+ // coincidence rather than a bug are very small.
+ if (first != null && second != null)
+ {
+ Assert.AreNotEqual(first.GetHashCode(), second.GetHashCode());
+ }
+ }
+ }
+}
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/FieldCodecTest.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/FieldCodecTest.cs
new file mode 100644
index 00000000..0e2bad59
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/FieldCodecTest.cs
@@ -0,0 +1,196 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2015 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using Google.Protobuf.TestProtos;
+using NUnit.Framework;
+
+namespace Google.Protobuf
+{
+ public class FieldCodecTest
+ {
+#pragma warning disable 0414 // Used by tests via reflection - do not remove!
+ private static readonly List<ICodecTestData> Codecs = new List<ICodecTestData>
+ {
+ new FieldCodecTestData<bool>(FieldCodec.ForBool(100), true, "Bool"),
+ new FieldCodecTestData<string>(FieldCodec.ForString(100), "sample", "String"),
+ new FieldCodecTestData<ByteString>(FieldCodec.ForBytes(100), ByteString.CopyFrom(1, 2, 3), "Bytes"),
+ new FieldCodecTestData<int>(FieldCodec.ForInt32(100), -1000, "Int32"),
+ new FieldCodecTestData<int>(FieldCodec.ForSInt32(100), -1000, "SInt32"),
+ new FieldCodecTestData<int>(FieldCodec.ForSFixed32(100), -1000, "SFixed32"),
+ new FieldCodecTestData<uint>(FieldCodec.ForUInt32(100), 1234, "UInt32"),
+ new FieldCodecTestData<uint>(FieldCodec.ForFixed32(100), 1234, "Fixed32"),
+ new FieldCodecTestData<long>(FieldCodec.ForInt64(100), -1000, "Int64"),
+ new FieldCodecTestData<long>(FieldCodec.ForSInt64(100), -1000, "SInt64"),
+ new FieldCodecTestData<long>(FieldCodec.ForSFixed64(100), -1000, "SFixed64"),
+ new FieldCodecTestData<ulong>(FieldCodec.ForUInt64(100), 1234, "UInt64"),
+ new FieldCodecTestData<ulong>(FieldCodec.ForFixed64(100), 1234, "Fixed64"),
+ new FieldCodecTestData<float>(FieldCodec.ForFloat(100), 1234.5f, "Float"),
+ new FieldCodecTestData<double>(FieldCodec.ForDouble(100), 1234567890.5d, "Double"),
+ new FieldCodecTestData<ForeignEnum>(
+ FieldCodec.ForEnum(100, t => (int) t, t => (ForeignEnum) t), ForeignEnum.ForeignBaz, "Enum"),
+ new FieldCodecTestData<ForeignMessage>(
+ FieldCodec.ForMessage(100, ForeignMessage.Parser), new ForeignMessage { C = 10 }, "Message"),
+ };
+#pragma warning restore 0414
+
+ [Test, TestCaseSource("Codecs")]
+ public void RoundTripWithTag(ICodecTestData codec)
+ {
+ codec.TestRoundTripWithTag();
+ }
+
+ [Test, TestCaseSource("Codecs")]
+ public void RoundTripRaw(ICodecTestData codec)
+ {
+ codec.TestRoundTripRaw();
+ }
+
+ [Test, TestCaseSource("Codecs")]
+ public void CalculateSize(ICodecTestData codec)
+ {
+ codec.TestCalculateSizeWithTag();
+ }
+
+ [Test, TestCaseSource("Codecs")]
+ public void DefaultValue(ICodecTestData codec)
+ {
+ codec.TestDefaultValue();
+ }
+
+ [Test, TestCaseSource("Codecs")]
+ public void FixedSize(ICodecTestData codec)
+ {
+ codec.TestFixedSize();
+ }
+
+ // This is ugly, but it means we can have a non-generic interface.
+ // It feels like NUnit should support this better, but I don't know
+ // of any better ways right now.
+ public interface ICodecTestData
+ {
+ void TestRoundTripRaw();
+ void TestRoundTripWithTag();
+ void TestCalculateSizeWithTag();
+ void TestDefaultValue();
+ void TestFixedSize();
+ }
+
+ public class FieldCodecTestData<T> : ICodecTestData
+ {
+ private readonly FieldCodec<T> codec;
+ private readonly T sampleValue;
+ private readonly string name;
+
+ public FieldCodecTestData(FieldCodec<T> codec, T sampleValue, string name)
+ {
+ this.codec = codec;
+ this.sampleValue = sampleValue;
+ this.name = name;
+ }
+
+ public void TestRoundTripRaw()
+ {
+ var stream = new MemoryStream();
+ var codedOutput = new CodedOutputStream(stream);
+ codec.ValueWriter(codedOutput, sampleValue);
+ codedOutput.Flush();
+ stream.Position = 0;
+ var codedInput = new CodedInputStream(stream);
+ Assert.AreEqual(sampleValue, codec.ValueReader(codedInput));
+ Assert.IsTrue(codedInput.IsAtEnd);
+ }
+
+ public void TestRoundTripWithTag()
+ {
+ var stream = new MemoryStream();
+ var codedOutput = new CodedOutputStream(stream);
+ codec.WriteTagAndValue(codedOutput, sampleValue);
+ codedOutput.Flush();
+ stream.Position = 0;
+ var codedInput = new CodedInputStream(stream);
+ codedInput.AssertNextTag(codec.Tag);
+ Assert.AreEqual(sampleValue, codec.Read(codedInput));
+ Assert.IsTrue(codedInput.IsAtEnd);
+ }
+
+ public void TestCalculateSizeWithTag()
+ {
+ var stream = new MemoryStream();
+ var codedOutput = new CodedOutputStream(stream);
+ codec.WriteTagAndValue(codedOutput, sampleValue);
+ codedOutput.Flush();
+ Assert.AreEqual(stream.Position, codec.CalculateSizeWithTag(sampleValue));
+ }
+
+ public void TestDefaultValue()
+ {
+ // WriteTagAndValue ignores default values
+ var stream = new MemoryStream();
+ var codedOutput = new CodedOutputStream(stream);
+ codec.WriteTagAndValue(codedOutput, codec.DefaultValue);
+ codedOutput.Flush();
+ Assert.AreEqual(0, stream.Position);
+ Assert.AreEqual(0, codec.CalculateSizeWithTag(codec.DefaultValue));
+ if (typeof(T).GetTypeInfo().IsValueType)
+ {
+ Assert.AreEqual(default(T), codec.DefaultValue);
+ }
+
+ // The plain ValueWriter/ValueReader delegates don't.
+ if (codec.DefaultValue != null) // This part isn't appropriate for message types.
+ {
+ codedOutput = new CodedOutputStream(stream);
+ codec.ValueWriter(codedOutput, codec.DefaultValue);
+ codedOutput.Flush();
+ Assert.AreNotEqual(0, stream.Position);
+ Assert.AreEqual(stream.Position, codec.ValueSizeCalculator(codec.DefaultValue));
+ stream.Position = 0;
+ var codedInput = new CodedInputStream(stream);
+ Assert.AreEqual(codec.DefaultValue, codec.ValueReader(codedInput));
+ }
+ }
+
+ public void TestFixedSize()
+ {
+ Assert.AreEqual(name.Contains("Fixed"), codec.FixedSize != 0);
+ }
+
+ public override string ToString()
+ {
+ return name;
+ }
+ }
+ }
+}
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/GeneratedMessageTest.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/GeneratedMessageTest.cs
new file mode 100644
index 00000000..8b153d69
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/GeneratedMessageTest.cs
@@ -0,0 +1,723 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2015 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using System;
+using System.IO;
+using Google.Protobuf.TestProtos;
+using NUnit.Framework;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using Google.Protobuf.WellKnownTypes;
+
+namespace Google.Protobuf
+{
+ /// <summary>
+ /// Tests around the generated TestAllTypes message.
+ /// </summary>
+ public class GeneratedMessageTest
+ {
+ [Test]
+ public void EmptyMessageFieldDistinctFromMissingMessageField()
+ {
+ // This demonstrates what we're really interested in...
+ var message1 = new TestAllTypes { SingleForeignMessage = new ForeignMessage() };
+ var message2 = new TestAllTypes(); // SingleForeignMessage is null
+ EqualityTester.AssertInequality(message1, message2);
+ }
+
+ [Test]
+ public void DefaultValues()
+ {
+ // Single fields
+ var message = new TestAllTypes();
+ Assert.AreEqual(false, message.SingleBool);
+ Assert.AreEqual(ByteString.Empty, message.SingleBytes);
+ Assert.AreEqual(0.0, message.SingleDouble);
+ Assert.AreEqual(0, message.SingleFixed32);
+ Assert.AreEqual(0L, message.SingleFixed64);
+ Assert.AreEqual(0.0f, message.SingleFloat);
+ Assert.AreEqual(ForeignEnum.ForeignUnspecified, message.SingleForeignEnum);
+ Assert.IsNull(message.SingleForeignMessage);
+ Assert.AreEqual(ImportEnum.Unspecified, message.SingleImportEnum);
+ Assert.IsNull(message.SingleImportMessage);
+ Assert.AreEqual(0, message.SingleInt32);
+ Assert.AreEqual(0L, message.SingleInt64);
+ Assert.AreEqual(TestAllTypes.Types.NestedEnum.Unspecified, message.SingleNestedEnum);
+ Assert.IsNull(message.SingleNestedMessage);
+ Assert.IsNull(message.SinglePublicImportMessage);
+ Assert.AreEqual(0, message.SingleSfixed32);
+ Assert.AreEqual(0L, message.SingleSfixed64);
+ Assert.AreEqual(0, message.SingleSint32);
+ Assert.AreEqual(0L, message.SingleSint64);
+ Assert.AreEqual("", message.SingleString);
+ Assert.AreEqual(0U, message.SingleUint32);
+ Assert.AreEqual(0UL, message.SingleUint64);
+
+ // Repeated fields
+ Assert.AreEqual(0, message.RepeatedBool.Count);
+ Assert.AreEqual(0, message.RepeatedBytes.Count);
+ Assert.AreEqual(0, message.RepeatedDouble.Count);
+ Assert.AreEqual(0, message.RepeatedFixed32.Count);
+ Assert.AreEqual(0, message.RepeatedFixed64.Count);
+ Assert.AreEqual(0, message.RepeatedFloat.Count);
+ Assert.AreEqual(0, message.RepeatedForeignEnum.Count);
+ Assert.AreEqual(0, message.RepeatedForeignMessage.Count);
+ Assert.AreEqual(0, message.RepeatedImportEnum.Count);
+ Assert.AreEqual(0, message.RepeatedImportMessage.Count);
+ Assert.AreEqual(0, message.RepeatedNestedEnum.Count);
+ Assert.AreEqual(0, message.RepeatedNestedMessage.Count);
+ Assert.AreEqual(0, message.RepeatedPublicImportMessage.Count);
+ Assert.AreEqual(0, message.RepeatedSfixed32.Count);
+ Assert.AreEqual(0, message.RepeatedSfixed64.Count);
+ Assert.AreEqual(0, message.RepeatedSint32.Count);
+ Assert.AreEqual(0, message.RepeatedSint64.Count);
+ Assert.AreEqual(0, message.RepeatedString.Count);
+ Assert.AreEqual(0, message.RepeatedUint32.Count);
+ Assert.AreEqual(0, message.RepeatedUint64.Count);
+
+ // Oneof fields
+ Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase);
+ Assert.AreEqual(0, message.OneofUint32);
+ Assert.AreEqual("", message.OneofString);
+ Assert.AreEqual(ByteString.Empty, message.OneofBytes);
+ Assert.IsNull(message.OneofNestedMessage);
+ }
+
+ [Test]
+ public void NullStringAndBytesRejected()
+ {
+ var message = new TestAllTypes();
+ Assert.Throws<ArgumentNullException>(() => message.SingleString = null);
+ Assert.Throws<ArgumentNullException>(() => message.OneofString = null);
+ Assert.Throws<ArgumentNullException>(() => message.SingleBytes = null);
+ Assert.Throws<ArgumentNullException>(() => message.OneofBytes = null);
+ }
+
+ [Test]
+ public void RoundTrip_Empty()
+ {
+ var message = new TestAllTypes();
+ // Without setting any values, there's nothing to write.
+ byte[] bytes = message.ToByteArray();
+ Assert.AreEqual(0, bytes.Length);
+ TestAllTypes parsed = TestAllTypes.Parser.ParseFrom(bytes);
+ Assert.AreEqual(message, parsed);
+ }
+
+ [Test]
+ public void RoundTrip_SingleValues()
+ {
+ var message = new TestAllTypes
+ {
+ SingleBool = true,
+ SingleBytes = ByteString.CopyFrom(1, 2, 3, 4),
+ SingleDouble = 23.5,
+ SingleFixed32 = 23,
+ SingleFixed64 = 1234567890123,
+ SingleFloat = 12.25f,
+ SingleForeignEnum = ForeignEnum.ForeignBar,
+ SingleForeignMessage = new ForeignMessage { C = 10 },
+ SingleImportEnum = ImportEnum.ImportBaz,
+ SingleImportMessage = new ImportMessage { D = 20 },
+ SingleInt32 = 100,
+ SingleInt64 = 3210987654321,
+ SingleNestedEnum = TestAllTypes.Types.NestedEnum.Foo,
+ SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 35 },
+ SinglePublicImportMessage = new PublicImportMessage { E = 54 },
+ SingleSfixed32 = -123,
+ SingleSfixed64 = -12345678901234,
+ SingleSint32 = -456,
+ SingleSint64 = -12345678901235,
+ SingleString = "test",
+ SingleUint32 = uint.MaxValue,
+ SingleUint64 = ulong.MaxValue
+ };
+
+ byte[] bytes = message.ToByteArray();
+ TestAllTypes parsed = TestAllTypes.Parser.ParseFrom(bytes);
+ Assert.AreEqual(message, parsed);
+ }
+
+ [Test]
+ public void RoundTrip_RepeatedValues()
+ {
+ var message = new TestAllTypes
+ {
+ RepeatedBool = { true, false },
+ RepeatedBytes = { ByteString.CopyFrom(1, 2, 3, 4), ByteString.CopyFrom(5, 6) },
+ RepeatedDouble = { -12.25, 23.5 },
+ RepeatedFixed32 = { uint.MaxValue, 23 },
+ RepeatedFixed64 = { ulong.MaxValue, 1234567890123 },
+ RepeatedFloat = { 100f, 12.25f },
+ RepeatedForeignEnum = { ForeignEnum.ForeignFoo, ForeignEnum.ForeignBar },
+ RepeatedForeignMessage = { new ForeignMessage(), new ForeignMessage { C = 10 } },
+ RepeatedImportEnum = { ImportEnum.ImportBaz, ImportEnum.Unspecified },
+ RepeatedImportMessage = { new ImportMessage { D = 20 }, new ImportMessage { D = 25 } },
+ RepeatedInt32 = { 100, 200 },
+ RepeatedInt64 = { 3210987654321, long.MaxValue },
+ RepeatedNestedEnum = { TestAllTypes.Types.NestedEnum.Foo, TestAllTypes.Types.NestedEnum.Neg },
+ RepeatedNestedMessage = { new TestAllTypes.Types.NestedMessage { Bb = 35 }, new TestAllTypes.Types.NestedMessage { Bb = 10 } },
+ RepeatedPublicImportMessage = { new PublicImportMessage { E = 54 }, new PublicImportMessage { E = -1 } },
+ RepeatedSfixed32 = { -123, 123 },
+ RepeatedSfixed64 = { -12345678901234, 12345678901234 },
+ RepeatedSint32 = { -456, 100 },
+ RepeatedSint64 = { -12345678901235, 123 },
+ RepeatedString = { "foo", "bar" },
+ RepeatedUint32 = { uint.MaxValue, uint.MinValue },
+ RepeatedUint64 = { ulong.MaxValue, uint.MinValue }
+ };
+
+ byte[] bytes = message.ToByteArray();
+ TestAllTypes parsed = TestAllTypes.Parser.ParseFrom(bytes);
+ Assert.AreEqual(message, parsed);
+ }
+
+ // Note that not every map within map_unittest_proto3 is used. They all go through very
+ // similar code paths. The fact that all maps are present is validation that we have codecs
+ // for every type.
+ [Test]
+ public void RoundTrip_Maps()
+ {
+ var message = new TestMap
+ {
+ MapBoolBool = {
+ { false, true },
+ { true, false }
+ },
+ MapInt32Bytes = {
+ { 5, ByteString.CopyFrom(6, 7, 8) },
+ { 25, ByteString.CopyFrom(1, 2, 3, 4, 5) },
+ { 10, ByteString.Empty }
+ },
+ MapInt32ForeignMessage = {
+ { 0, new ForeignMessage { C = 10 } },
+ { 5, new ForeignMessage() },
+ },
+ MapInt32Enum = {
+ { 1, MapEnum.Bar },
+ { 2000, MapEnum.Foo }
+ }
+ };
+
+ byte[] bytes = message.ToByteArray();
+ TestMap parsed = TestMap.Parser.ParseFrom(bytes);
+ Assert.AreEqual(message, parsed);
+ }
+
+ [Test]
+ public void MapWithEmptyEntry()
+ {
+ var message = new TestMap
+ {
+ MapInt32Bytes = { { 0, ByteString.Empty } }
+ };
+
+ byte[] bytes = message.ToByteArray();
+ Assert.AreEqual(2, bytes.Length); // Tag for field entry (1 byte), length of entry (0; 1 byte)
+
+ var parsed = TestMap.Parser.ParseFrom(bytes);
+ Assert.AreEqual(1, parsed.MapInt32Bytes.Count);
+ Assert.AreEqual(ByteString.Empty, parsed.MapInt32Bytes[0]);
+ }
+
+ [Test]
+ public void MapWithOnlyValue()
+ {
+ // Hand-craft the stream to contain a single entry with just a value.
+ var memoryStream = new MemoryStream();
+ var output = new CodedOutputStream(memoryStream);
+ output.WriteTag(TestMap.MapInt32ForeignMessageFieldNumber, WireFormat.WireType.LengthDelimited);
+ var nestedMessage = new ForeignMessage { C = 20 };
+ // Size of the entry (tag, size written by WriteMessage, data written by WriteMessage)
+ output.WriteLength(2 + nestedMessage.CalculateSize());
+ output.WriteTag(2, WireFormat.WireType.LengthDelimited);
+ output.WriteMessage(nestedMessage);
+ output.Flush();
+
+ var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray());
+ Assert.AreEqual(nestedMessage, parsed.MapInt32ForeignMessage[0]);
+ }
+
+ [Test]
+ public void MapWithOnlyKey_PrimitiveValue()
+ {
+ // Hand-craft the stream to contain a single entry with just a key.
+ var memoryStream = new MemoryStream();
+ var output = new CodedOutputStream(memoryStream);
+ output.WriteTag(TestMap.MapInt32DoubleFieldNumber, WireFormat.WireType.LengthDelimited);
+ int key = 10;
+ output.WriteLength(1 + CodedOutputStream.ComputeInt32Size(key));
+ output.WriteTag(1, WireFormat.WireType.Varint);
+ output.WriteInt32(key);
+ output.Flush();
+
+ var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray());
+ Assert.AreEqual(0.0, parsed.MapInt32Double[key]);
+ }
+
+ [Test]
+ public void MapWithOnlyKey_MessageValue()
+ {
+ // Hand-craft the stream to contain a single entry with just a key.
+ var memoryStream = new MemoryStream();
+ var output = new CodedOutputStream(memoryStream);
+ output.WriteTag(TestMap.MapInt32ForeignMessageFieldNumber, WireFormat.WireType.LengthDelimited);
+ int key = 10;
+ output.WriteLength(1 + CodedOutputStream.ComputeInt32Size(key));
+ output.WriteTag(1, WireFormat.WireType.Varint);
+ output.WriteInt32(key);
+ output.Flush();
+
+ var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray());
+ Assert.AreEqual(new ForeignMessage(), parsed.MapInt32ForeignMessage[key]);
+ }
+
+ [Test]
+ public void MapIgnoresExtraFieldsWithinEntryMessages()
+ {
+ // Hand-craft the stream to contain a single entry with three fields
+ var memoryStream = new MemoryStream();
+ var output = new CodedOutputStream(memoryStream);
+
+ output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited);
+
+ var key = 10; // Field 1
+ var value = 20; // Field 2
+ var extra = 30; // Field 3
+
+ // Each field can be represented in a single byte, with a single byte tag.
+ // Total message size: 6 bytes.
+ output.WriteLength(6);
+ output.WriteTag(1, WireFormat.WireType.Varint);
+ output.WriteInt32(key);
+ output.WriteTag(2, WireFormat.WireType.Varint);
+ output.WriteInt32(value);
+ output.WriteTag(3, WireFormat.WireType.Varint);
+ output.WriteInt32(extra);
+ output.Flush();
+
+ var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray());
+ Assert.AreEqual(value, parsed.MapInt32Int32[key]);
+ }
+
+ [Test]
+ public void MapFieldOrderIsIrrelevant()
+ {
+ var memoryStream = new MemoryStream();
+ var output = new CodedOutputStream(memoryStream);
+
+ output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited);
+
+ var key = 10;
+ var value = 20;
+
+ // Each field can be represented in a single byte, with a single byte tag.
+ // Total message size: 4 bytes.
+ output.WriteLength(4);
+ output.WriteTag(2, WireFormat.WireType.Varint);
+ output.WriteInt32(value);
+ output.WriteTag(1, WireFormat.WireType.Varint);
+ output.WriteInt32(key);
+ output.Flush();
+
+ var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray());
+ Assert.AreEqual(value, parsed.MapInt32Int32[key]);
+ }
+
+ [Test]
+ public void MapNonContiguousEntries()
+ {
+ var memoryStream = new MemoryStream();
+ var output = new CodedOutputStream(memoryStream);
+
+ // Message structure:
+ // Entry for MapInt32Int32
+ // Entry for MapStringString
+ // Entry for MapInt32Int32
+
+ // First entry
+ var key1 = 10;
+ var value1 = 20;
+ output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited);
+ output.WriteLength(4);
+ output.WriteTag(1, WireFormat.WireType.Varint);
+ output.WriteInt32(key1);
+ output.WriteTag(2, WireFormat.WireType.Varint);
+ output.WriteInt32(value1);
+
+ // Second entry
+ var key2 = "a";
+ var value2 = "b";
+ output.WriteTag(TestMap.MapStringStringFieldNumber, WireFormat.WireType.LengthDelimited);
+ output.WriteLength(6); // 3 bytes per entry: tag, size, character
+ output.WriteTag(1, WireFormat.WireType.LengthDelimited);
+ output.WriteString(key2);
+ output.WriteTag(2, WireFormat.WireType.LengthDelimited);
+ output.WriteString(value2);
+
+ // Third entry
+ var key3 = 15;
+ var value3 = 25;
+ output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited);
+ output.WriteLength(4);
+ output.WriteTag(1, WireFormat.WireType.Varint);
+ output.WriteInt32(key3);
+ output.WriteTag(2, WireFormat.WireType.Varint);
+ output.WriteInt32(value3);
+
+ output.Flush();
+ var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray());
+ var expected = new TestMap
+ {
+ MapInt32Int32 = { { key1, value1 }, { key3, value3 } },
+ MapStringString = { { key2, value2 } }
+ };
+ Assert.AreEqual(expected, parsed);
+ }
+
+ [Test]
+ public void DuplicateKeys_LastEntryWins()
+ {
+ var memoryStream = new MemoryStream();
+ var output = new CodedOutputStream(memoryStream);
+
+ var key = 10;
+ var value1 = 20;
+ var value2 = 30;
+
+ // First entry
+ output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited);
+ output.WriteLength(4);
+ output.WriteTag(1, WireFormat.WireType.Varint);
+ output.WriteInt32(key);
+ output.WriteTag(2, WireFormat.WireType.Varint);
+ output.WriteInt32(value1);
+
+ // Second entry - same key, different value
+ output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited);
+ output.WriteLength(4);
+ output.WriteTag(1, WireFormat.WireType.Varint);
+ output.WriteInt32(key);
+ output.WriteTag(2, WireFormat.WireType.Varint);
+ output.WriteInt32(value2);
+ output.Flush();
+
+ var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray());
+ Assert.AreEqual(value2, parsed.MapInt32Int32[key]);
+ }
+
+ [Test]
+ public void CloneSingleNonMessageValues()
+ {
+ var original = new TestAllTypes
+ {
+ SingleBool = true,
+ SingleBytes = ByteString.CopyFrom(1, 2, 3, 4),
+ SingleDouble = 23.5,
+ SingleFixed32 = 23,
+ SingleFixed64 = 1234567890123,
+ SingleFloat = 12.25f,
+ SingleInt32 = 100,
+ SingleInt64 = 3210987654321,
+ SingleNestedEnum = TestAllTypes.Types.NestedEnum.Foo,
+ SingleSfixed32 = -123,
+ SingleSfixed64 = -12345678901234,
+ SingleSint32 = -456,
+ SingleSint64 = -12345678901235,
+ SingleString = "test",
+ SingleUint32 = uint.MaxValue,
+ SingleUint64 = ulong.MaxValue
+ };
+ var clone = original.Clone();
+ Assert.AreNotSame(original, clone);
+ Assert.AreEqual(original, clone);
+ // Just as a single example
+ clone.SingleInt32 = 150;
+ Assert.AreNotEqual(original, clone);
+ }
+
+ [Test]
+ public void CloneRepeatedNonMessageValues()
+ {
+ var original = new TestAllTypes
+ {
+ RepeatedBool = { true, false },
+ RepeatedBytes = { ByteString.CopyFrom(1, 2, 3, 4), ByteString.CopyFrom(5, 6) },
+ RepeatedDouble = { -12.25, 23.5 },
+ RepeatedFixed32 = { uint.MaxValue, 23 },
+ RepeatedFixed64 = { ulong.MaxValue, 1234567890123 },
+ RepeatedFloat = { 100f, 12.25f },
+ RepeatedInt32 = { 100, 200 },
+ RepeatedInt64 = { 3210987654321, long.MaxValue },
+ RepeatedNestedEnum = { TestAllTypes.Types.NestedEnum.Foo, TestAllTypes.Types.NestedEnum.Neg },
+ RepeatedSfixed32 = { -123, 123 },
+ RepeatedSfixed64 = { -12345678901234, 12345678901234 },
+ RepeatedSint32 = { -456, 100 },
+ RepeatedSint64 = { -12345678901235, 123 },
+ RepeatedString = { "foo", "bar" },
+ RepeatedUint32 = { uint.MaxValue, uint.MinValue },
+ RepeatedUint64 = { ulong.MaxValue, uint.MinValue }
+ };
+
+ var clone = original.Clone();
+ Assert.AreNotSame(original, clone);
+ Assert.AreEqual(original, clone);
+ // Just as a single example
+ clone.RepeatedDouble.Add(25.5);
+ Assert.AreNotEqual(original, clone);
+ }
+
+ [Test]
+ public void CloneSingleMessageField()
+ {
+ var original = new TestAllTypes
+ {
+ SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 20 }
+ };
+
+ var clone = original.Clone();
+ Assert.AreNotSame(original, clone);
+ Assert.AreNotSame(original.SingleNestedMessage, clone.SingleNestedMessage);
+ Assert.AreEqual(original, clone);
+
+ clone.SingleNestedMessage.Bb = 30;
+ Assert.AreNotEqual(original, clone);
+ }
+
+ [Test]
+ public void CloneRepeatedMessageField()
+ {
+ var original = new TestAllTypes
+ {
+ RepeatedNestedMessage = { new TestAllTypes.Types.NestedMessage { Bb = 20 } }
+ };
+
+ var clone = original.Clone();
+ Assert.AreNotSame(original, clone);
+ Assert.AreNotSame(original.RepeatedNestedMessage, clone.RepeatedNestedMessage);
+ Assert.AreNotSame(original.RepeatedNestedMessage[0], clone.RepeatedNestedMessage[0]);
+ Assert.AreEqual(original, clone);
+
+ clone.RepeatedNestedMessage[0].Bb = 30;
+ Assert.AreNotEqual(original, clone);
+ }
+
+ [Test]
+ public void CloneOneofField()
+ {
+ var original = new TestAllTypes
+ {
+ OneofNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 20 }
+ };
+
+ var clone = original.Clone();
+ Assert.AreNotSame(original, clone);
+ Assert.AreEqual(original, clone);
+
+ // We should have cloned the message
+ original.OneofNestedMessage.Bb = 30;
+ Assert.AreNotEqual(original, clone);
+ }
+
+ [Test]
+ public void OneofProperties()
+ {
+ // Switch the oneof case between each of the different options, and check everything behaves
+ // as expected in each case.
+ var message = new TestAllTypes();
+ Assert.AreEqual("", message.OneofString);
+ Assert.AreEqual(0, message.OneofUint32);
+ Assert.AreEqual(ByteString.Empty, message.OneofBytes);
+ Assert.IsNull(message.OneofNestedMessage);
+ Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase);
+
+ message.OneofString = "sample";
+ Assert.AreEqual("sample", message.OneofString);
+ Assert.AreEqual(0, message.OneofUint32);
+ Assert.AreEqual(ByteString.Empty, message.OneofBytes);
+ Assert.IsNull(message.OneofNestedMessage);
+ Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofString, message.OneofFieldCase);
+
+ var bytes = ByteString.CopyFrom(1, 2, 3);
+ message.OneofBytes = bytes;
+ Assert.AreEqual("", message.OneofString);
+ Assert.AreEqual(0, message.OneofUint32);
+ Assert.AreEqual(bytes, message.OneofBytes);
+ Assert.IsNull(message.OneofNestedMessage);
+ Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofBytes, message.OneofFieldCase);
+
+ message.OneofUint32 = 20;
+ Assert.AreEqual("", message.OneofString);
+ Assert.AreEqual(20, message.OneofUint32);
+ Assert.AreEqual(ByteString.Empty, message.OneofBytes);
+ Assert.IsNull(message.OneofNestedMessage);
+ Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message.OneofFieldCase);
+
+ var nestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 25 };
+ message.OneofNestedMessage = nestedMessage;
+ Assert.AreEqual("", message.OneofString);
+ Assert.AreEqual(0, message.OneofUint32);
+ Assert.AreEqual(ByteString.Empty, message.OneofBytes);
+ Assert.AreEqual(nestedMessage, message.OneofNestedMessage);
+ Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofNestedMessage, message.OneofFieldCase);
+
+ message.ClearOneofField();
+ Assert.AreEqual("", message.OneofString);
+ Assert.AreEqual(0, message.OneofUint32);
+ Assert.AreEqual(ByteString.Empty, message.OneofBytes);
+ Assert.IsNull(message.OneofNestedMessage);
+ Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase);
+ }
+
+ [Test]
+ public void Oneof_DefaultValuesNotEqual()
+ {
+ var message1 = new TestAllTypes { OneofString = "" };
+ var message2 = new TestAllTypes { OneofUint32 = 0 };
+ Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofString, message1.OneofFieldCase);
+ Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message2.OneofFieldCase);
+ Assert.AreNotEqual(message1, message2);
+ }
+
+ [Test]
+ public void OneofSerialization_NonDefaultValue()
+ {
+ var message = new TestAllTypes();
+ message.OneofString = "this would take a bit of space";
+ message.OneofUint32 = 10;
+ var bytes = message.ToByteArray();
+ Assert.AreEqual(3, bytes.Length); // 2 bytes for the tag + 1 for the value - no string!
+
+ var message2 = TestAllTypes.Parser.ParseFrom(bytes);
+ Assert.AreEqual(message, message2);
+ Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message2.OneofFieldCase);
+ }
+
+ [Test]
+ public void OneofSerialization_DefaultValue()
+ {
+ var message = new TestAllTypes();
+ message.OneofString = "this would take a bit of space";
+ message.OneofUint32 = 0; // This is the default value for UInt32; normally wouldn't be serialized
+ var bytes = message.ToByteArray();
+ Assert.AreEqual(3, bytes.Length); // 2 bytes for the tag + 1 for the value - it's still serialized
+
+ var message2 = TestAllTypes.Parser.ParseFrom(bytes);
+ Assert.AreEqual(message, message2);
+ Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message2.OneofFieldCase);
+ }
+
+ [Test]
+ public void IgnoreUnknownFields_RealDataStillRead()
+ {
+ var message = SampleMessages.CreateFullTestAllTypes();
+ var stream = new MemoryStream();
+ var output = new CodedOutputStream(stream);
+ var unusedFieldNumber = 23456;
+ Assert.IsFalse(TestAllTypes.Descriptor.Fields.InDeclarationOrder().Select(x => x.FieldNumber).Contains(unusedFieldNumber));
+ output.WriteTag(unusedFieldNumber, WireFormat.WireType.LengthDelimited);
+ output.WriteString("ignore me");
+ message.WriteTo(output);
+ output.Flush();
+
+ stream.Position = 0;
+ var parsed = TestAllTypes.Parser.ParseFrom(stream);
+ Assert.AreEqual(message, parsed);
+ }
+
+ [Test]
+ public void IgnoreUnknownFields_AllTypes()
+ {
+ // Simple way of ensuring we can skip all kinds of fields.
+ var data = SampleMessages.CreateFullTestAllTypes().ToByteArray();
+ var empty = Empty.Parser.ParseFrom(data);
+ Assert.AreEqual(new Empty(), empty);
+ }
+
+ // This was originally seen as a conformance test failure.
+ [Test]
+ public void TruncatedMessageFieldThrows()
+ {
+ // 130, 3 is the message tag
+ // 1 is the data length - but there's no data.
+ var data = new byte[] { 130, 3, 1 };
+ Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseFrom(data));
+ }
+
+ /// <summary>
+ /// Demonstrates current behaviour with an extraneous end group tag - see issue 688
+ /// for details; we may want to change this.
+ /// </summary>
+ [Test]
+ public void ExtraEndGroupThrows()
+ {
+ var message = SampleMessages.CreateFullTestAllTypes();
+ var stream = new MemoryStream();
+ var output = new CodedOutputStream(stream);
+
+ output.WriteTag(TestAllTypes.SingleFixed32FieldNumber, WireFormat.WireType.Fixed32);
+ output.WriteFixed32(123);
+ output.WriteTag(100, WireFormat.WireType.EndGroup);
+
+ output.Flush();
+
+ stream.Position = 0;
+ Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseFrom(stream));
+ }
+
+ [Test]
+ public void CustomDiagnosticMessage_DirectToStringCall()
+ {
+ var message = new ForeignMessage { C = 31 };
+ Assert.AreEqual("{ \"c\": 31, \"@cInHex\": \"1f\" }", message.ToString());
+ Assert.AreEqual("{ \"c\": 31 }", JsonFormatter.Default.Format(message));
+ }
+
+ [Test]
+ public void CustomDiagnosticMessage_Nested()
+ {
+ var message = new TestAllTypes { SingleForeignMessage = new ForeignMessage { C = 16 } };
+ Assert.AreEqual("{ \"singleForeignMessage\": { \"c\": 16, \"@cInHex\": \"10\" } }", message.ToString());
+ Assert.AreEqual("{ \"singleForeignMessage\": { \"c\": 16 } }", JsonFormatter.Default.Format(message));
+ }
+
+ [Test]
+ public void CustomDiagnosticMessage_DirectToTextWriterCall()
+ {
+ var message = new ForeignMessage { C = 31 };
+ var writer = new StringWriter();
+ JsonFormatter.Default.Format(message, writer);
+ Assert.AreEqual("{ \"c\": 31 }", writer.ToString());
+ }
+ }
+} \ No newline at end of file
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj
new file mode 100644
index 00000000..a9a1cc04
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
+ <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
+ </PropertyGroup>
+ <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>580eb013-d3c7-4578-b845-015f4a3b0591</ProjectGuid>
+ <RootNamespace>Google.Protobuf.Test</RootNamespace>
+ <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
+ <OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
+ </PropertyGroup>
+
+ <PropertyGroup>
+ <SchemaVersion>2.0</SchemaVersion>
+ </PropertyGroup>
+ <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
+</Project> \ No newline at end of file
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/IssuesTest.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/IssuesTest.cs
new file mode 100644
index 00000000..a38d6b08
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/IssuesTest.cs
@@ -0,0 +1,82 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using Google.Protobuf.Reflection;
+using UnitTest.Issues.TestProtos;
+using NUnit.Framework;
+
+
+namespace Google.Protobuf
+{
+ /// <summary>
+ /// Tests for issues which aren't easily compartmentalized into other unit tests.
+ /// </summary>
+ public class IssuesTest
+ {
+ // Issue 45
+ [Test]
+ public void FieldCalledItem()
+ {
+ ItemField message = new ItemField { Item = 3 };
+ FieldDescriptor field = ItemField.Descriptor.FindFieldByName("item");
+ Assert.NotNull(field);
+ Assert.AreEqual(3, (int)field.Accessor.GetValue(message));
+ }
+
+ [Test]
+ public void ReservedNames()
+ {
+ var message = new ReservedNames { Types_ = 10, Descriptor_ = 20 };
+ // Underscores aren't reflected in the JSON.
+ Assert.AreEqual("{ \"types\": 10, \"descriptor\": 20 }", message.ToString());
+ }
+
+ [Test]
+ public void JsonNameParseTest()
+ {
+ var settings = new JsonParser.Settings(10, TypeRegistry.FromFiles(UnittestIssuesReflection.Descriptor));
+ var parser = new JsonParser(settings);
+
+ // It is safe to use either original field name or explicitly specified json_name
+ Assert.AreEqual(new TestJsonName { Name = "test", Description = "test2", Guid = "test3" },
+ parser.Parse<TestJsonName>("{ \"name\": \"test\", \"desc\": \"test2\", \"guid\": \"test3\" }"));
+ }
+
+ [Test]
+ public void JsonNameFormatTest()
+ {
+ var message = new TestJsonName { Name = "test", Description = "test2", Guid = "test3" };
+ Assert.AreEqual("{ \"name\": \"test\", \"desc\": \"test2\", \"exid\": \"test3\" }",
+ JsonFormatter.Default.Format(message));
+ }
+ }
+}
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/JsonParserTest.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/JsonParserTest.cs
new file mode 100644
index 00000000..f595455a
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/JsonParserTest.cs
@@ -0,0 +1,939 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using Google.Protobuf.Reflection;
+using Google.Protobuf.TestProtos;
+using Google.Protobuf.WellKnownTypes;
+using NUnit.Framework;
+using System;
+
+namespace Google.Protobuf
+{
+ /// <summary>
+ /// Unit tests for JSON parsing.
+ /// </summary>
+ public class JsonParserTest
+ {
+ // Sanity smoke test
+ [Test]
+ public void AllTypesRoundtrip()
+ {
+ AssertRoundtrip(SampleMessages.CreateFullTestAllTypes());
+ }
+
+ [Test]
+ public void Maps()
+ {
+ AssertRoundtrip(new TestMap { MapStringString = { { "with spaces", "bar" }, { "a", "b" } } });
+ AssertRoundtrip(new TestMap { MapInt32Int32 = { { 0, 1 }, { 2, 3 } } });
+ AssertRoundtrip(new TestMap { MapBoolBool = { { false, true }, { true, false } } });
+ }
+
+ [Test]
+ [TestCase(" 1 ")]
+ [TestCase("+1")]
+ [TestCase("1,000")]
+ [TestCase("1.5")]
+ public void IntegerMapKeysAreStrict(string keyText)
+ {
+ // Test that integer parsing is strict. We assume that if this is correct for int32,
+ // it's correct for other numeric key types.
+ var json = "{ \"mapInt32Int32\": { \"" + keyText + "\" : \"1\" } }";
+ Assert.Throws<InvalidProtocolBufferException>(() => JsonParser.Default.Parse<TestMap>(json));
+ }
+
+ [Test]
+ public void OriginalFieldNameAccepted()
+ {
+ var json = "{ \"single_int32\": 10 }";
+ var expected = new TestAllTypes { SingleInt32 = 10 };
+ Assert.AreEqual(expected, TestAllTypes.Parser.ParseJson(json));
+ }
+
+ [Test]
+ public void SourceContextRoundtrip()
+ {
+ AssertRoundtrip(new SourceContext { FileName = "foo.proto" });
+ }
+
+ [Test]
+ public void SingularWrappers_DefaultNonNullValues()
+ {
+ var message = new TestWellKnownTypes
+ {
+ StringField = "",
+ BytesField = ByteString.Empty,
+ BoolField = false,
+ FloatField = 0f,
+ DoubleField = 0d,
+ Int32Field = 0,
+ Int64Field = 0,
+ Uint32Field = 0,
+ Uint64Field = 0
+ };
+ AssertRoundtrip(message);
+ }
+
+ [Test]
+ public void SingularWrappers_NonDefaultValues()
+ {
+ var message = new TestWellKnownTypes
+ {
+ StringField = "x",
+ BytesField = ByteString.CopyFrom(1, 2, 3),
+ BoolField = true,
+ FloatField = 12.5f,
+ DoubleField = 12.25d,
+ Int32Field = 1,
+ Int64Field = 2,
+ Uint32Field = 3,
+ Uint64Field = 4
+ };
+ AssertRoundtrip(message);
+ }
+
+ [Test]
+ public void SingularWrappers_ExplicitNulls()
+ {
+ // When we parse the "valueField": null part, we remember it... basically, it's one case
+ // where explicit default values don't fully roundtrip.
+ var message = new TestWellKnownTypes { ValueField = Value.ForNull() };
+ var json = new JsonFormatter(new JsonFormatter.Settings(true)).Format(message);
+ var parsed = JsonParser.Default.Parse<TestWellKnownTypes>(json);
+ Assert.AreEqual(message, parsed);
+ }
+
+ [Test]
+ [TestCase(typeof(BoolValue), "true", true)]
+ [TestCase(typeof(Int32Value), "32", 32)]
+ [TestCase(typeof(Int64Value), "32", 32L)]
+ [TestCase(typeof(Int64Value), "\"32\"", 32L)]
+ [TestCase(typeof(UInt32Value), "32", 32U)]
+ [TestCase(typeof(UInt64Value), "\"32\"", 32UL)]
+ [TestCase(typeof(UInt64Value), "32", 32UL)]
+ [TestCase(typeof(StringValue), "\"foo\"", "foo")]
+ [TestCase(typeof(FloatValue), "1.5", 1.5f)]
+ [TestCase(typeof(DoubleValue), "1.5", 1.5d)]
+ public void Wrappers_Standalone(System.Type wrapperType, string json, object expectedValue)
+ {
+ IMessage parsed = (IMessage)Activator.CreateInstance(wrapperType);
+ IMessage expected = (IMessage)Activator.CreateInstance(wrapperType);
+ JsonParser.Default.Merge(parsed, "null");
+ Assert.AreEqual(expected, parsed);
+
+ JsonParser.Default.Merge(parsed, json);
+ expected.Descriptor.Fields[WrappersReflection.WrapperValueFieldNumber].Accessor.SetValue(expected, expectedValue);
+ Assert.AreEqual(expected, parsed);
+ }
+
+ [Test]
+ public void ExplicitNullValue()
+ {
+ string json = "{\"valueField\": null}";
+ var message = JsonParser.Default.Parse<TestWellKnownTypes>(json);
+ Assert.AreEqual(new TestWellKnownTypes { ValueField = Value.ForNull() }, message);
+ }
+
+ [Test]
+ public void BytesWrapper_Standalone()
+ {
+ ByteString data = ByteString.CopyFrom(1, 2, 3);
+ // Can't do this with attributes...
+ var parsed = JsonParser.Default.Parse<BytesValue>(WrapInQuotes(data.ToBase64()));
+ var expected = new BytesValue { Value = data };
+ Assert.AreEqual(expected, parsed);
+ }
+
+ [Test]
+ public void RepeatedWrappers()
+ {
+ var message = new RepeatedWellKnownTypes
+ {
+ BoolField = { true, false },
+ BytesField = { ByteString.CopyFrom(1, 2, 3), ByteString.CopyFrom(4, 5, 6), ByteString.Empty },
+ DoubleField = { 12.5, -1.5, 0d },
+ FloatField = { 123.25f, -20f, 0f },
+ Int32Field = { int.MaxValue, int.MinValue, 0 },
+ Int64Field = { long.MaxValue, long.MinValue, 0L },
+ StringField = { "First", "Second", "" },
+ Uint32Field = { uint.MaxValue, uint.MinValue, 0U },
+ Uint64Field = { ulong.MaxValue, ulong.MinValue, 0UL },
+ };
+ AssertRoundtrip(message);
+ }
+
+ [Test]
+ public void RepeatedField_NullElementProhibited()
+ {
+ string json = "{ \"repeated_foreign_message\": [null] }";
+ Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
+ }
+
+ [Test]
+ public void RepeatedField_NullOverallValueAllowed()
+ {
+ string json = "{ \"repeated_foreign_message\": null }";
+ Assert.AreEqual(new TestAllTypes(), TestAllTypes.Parser.ParseJson(json));
+ }
+
+ [Test]
+ [TestCase("{ \"mapInt32Int32\": { \"10\": null }")]
+ [TestCase("{ \"mapStringString\": { \"abc\": null }")]
+ [TestCase("{ \"mapInt32ForeignMessage\": { \"10\": null }")]
+ public void MapField_NullValueProhibited(string json)
+ {
+ Assert.Throws<InvalidProtocolBufferException>(() => TestMap.Parser.ParseJson(json));
+ }
+
+ [Test]
+ public void MapField_NullOverallValueAllowed()
+ {
+ string json = "{ \"mapInt32Int32\": null }";
+ Assert.AreEqual(new TestMap(), TestMap.Parser.ParseJson(json));
+ }
+
+ [Test]
+ public void IndividualWrapperTypes()
+ {
+ Assert.AreEqual(new StringValue { Value = "foo" }, StringValue.Parser.ParseJson("\"foo\""));
+ Assert.AreEqual(new Int32Value { Value = 1 }, Int32Value.Parser.ParseJson("1"));
+ // Can parse strings directly too
+ Assert.AreEqual(new Int32Value { Value = 1 }, Int32Value.Parser.ParseJson("\"1\""));
+ }
+
+ private static void AssertRoundtrip<T>(T message) where T : IMessage<T>, new()
+ {
+ var clone = message.Clone();
+ var json = JsonFormatter.Default.Format(message);
+ var parsed = JsonParser.Default.Parse<T>(json);
+ Assert.AreEqual(clone, parsed);
+ }
+
+ [Test]
+ [TestCase("0", 0)]
+ [TestCase("-0", 0)] // Not entirely clear whether we intend to allow this...
+ [TestCase("1", 1)]
+ [TestCase("-1", -1)]
+ [TestCase("2147483647", 2147483647)]
+ [TestCase("-2147483648", -2147483648)]
+ public void StringToInt32_Valid(string jsonValue, int expectedParsedValue)
+ {
+ string json = "{ \"singleInt32\": \"" + jsonValue + "\"}";
+ var parsed = TestAllTypes.Parser.ParseJson(json);
+ Assert.AreEqual(expectedParsedValue, parsed.SingleInt32);
+ }
+
+ [Test]
+ [TestCase("+0")]
+ [TestCase(" 1")]
+ [TestCase("1 ")]
+ [TestCase("00")]
+ [TestCase("-00")]
+ [TestCase("--1")]
+ [TestCase("+1")]
+ [TestCase("1.5")]
+ [TestCase("1e10")]
+ [TestCase("2147483648")]
+ [TestCase("-2147483649")]
+ public void StringToInt32_Invalid(string jsonValue)
+ {
+ string json = "{ \"singleInt32\": \"" + jsonValue + "\"}";
+ Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
+ }
+
+ [Test]
+ [TestCase("0", 0U)]
+ [TestCase("1", 1U)]
+ [TestCase("4294967295", 4294967295U)]
+ public void StringToUInt32_Valid(string jsonValue, uint expectedParsedValue)
+ {
+ string json = "{ \"singleUint32\": \"" + jsonValue + "\"}";
+ var parsed = TestAllTypes.Parser.ParseJson(json);
+ Assert.AreEqual(expectedParsedValue, parsed.SingleUint32);
+ }
+
+ // Assume that anything non-bounds-related is covered in the Int32 case
+ [Test]
+ [TestCase("-1")]
+ [TestCase("4294967296")]
+ public void StringToUInt32_Invalid(string jsonValue)
+ {
+ string json = "{ \"singleUint32\": \"" + jsonValue + "\"}";
+ Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
+ }
+
+ [Test]
+ [TestCase("0", 0L)]
+ [TestCase("1", 1L)]
+ [TestCase("-1", -1L)]
+ [TestCase("9223372036854775807", 9223372036854775807)]
+ [TestCase("-9223372036854775808", -9223372036854775808)]
+ public void StringToInt64_Valid(string jsonValue, long expectedParsedValue)
+ {
+ string json = "{ \"singleInt64\": \"" + jsonValue + "\"}";
+ var parsed = TestAllTypes.Parser.ParseJson(json);
+ Assert.AreEqual(expectedParsedValue, parsed.SingleInt64);
+ }
+
+ // Assume that anything non-bounds-related is covered in the Int32 case
+ [Test]
+ [TestCase("-9223372036854775809")]
+ [TestCase("9223372036854775808")]
+ public void StringToInt64_Invalid(string jsonValue)
+ {
+ string json = "{ \"singleInt64\": \"" + jsonValue + "\"}";
+ Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
+ }
+
+ [Test]
+ [TestCase("0", 0UL)]
+ [TestCase("1", 1UL)]
+ [TestCase("18446744073709551615", 18446744073709551615)]
+ public void StringToUInt64_Valid(string jsonValue, ulong expectedParsedValue)
+ {
+ string json = "{ \"singleUint64\": \"" + jsonValue + "\"}";
+ var parsed = TestAllTypes.Parser.ParseJson(json);
+ Assert.AreEqual(expectedParsedValue, parsed.SingleUint64);
+ }
+
+ // Assume that anything non-bounds-related is covered in the Int32 case
+ [Test]
+ [TestCase("-1")]
+ [TestCase("18446744073709551616")]
+ public void StringToUInt64_Invalid(string jsonValue)
+ {
+ string json = "{ \"singleUint64\": \"" + jsonValue + "\"}";
+ Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
+ }
+
+ [Test]
+ [TestCase("0", 0d)]
+ [TestCase("1", 1d)]
+ [TestCase("1.000000", 1d)]
+ [TestCase("1.0000000000000000000000001", 1d)] // We don't notice that we haven't preserved the exact value
+ [TestCase("-1", -1d)]
+ [TestCase("1e1", 10d)]
+ [TestCase("1e01", 10d)] // Leading decimals are allowed in exponents
+ [TestCase("1E1", 10d)] // Either case is fine
+ [TestCase("-1e1", -10d)]
+ [TestCase("1.5e1", 15d)]
+ [TestCase("-1.5e1", -15d)]
+ [TestCase("15e-1", 1.5d)]
+ [TestCase("-15e-1", -1.5d)]
+ [TestCase("1.79769e308", 1.79769e308)]
+ [TestCase("-1.79769e308", -1.79769e308)]
+ [TestCase("Infinity", double.PositiveInfinity)]
+ [TestCase("-Infinity", double.NegativeInfinity)]
+ [TestCase("NaN", double.NaN)]
+ public void StringToDouble_Valid(string jsonValue, double expectedParsedValue)
+ {
+ string json = "{ \"singleDouble\": \"" + jsonValue + "\"}";
+ var parsed = TestAllTypes.Parser.ParseJson(json);
+ Assert.AreEqual(expectedParsedValue, parsed.SingleDouble);
+ }
+
+ [Test]
+ [TestCase("1.7977e308")]
+ [TestCase("-1.7977e308")]
+ [TestCase("1e309")]
+ [TestCase("1,0")]
+ [TestCase("1.0.0")]
+ [TestCase("+1")]
+ [TestCase("00")]
+ [TestCase("01")]
+ [TestCase("-00")]
+ [TestCase("-01")]
+ [TestCase("--1")]
+ [TestCase(" Infinity")]
+ [TestCase(" -Infinity")]
+ [TestCase("NaN ")]
+ [TestCase("Infinity ")]
+ [TestCase("-Infinity ")]
+ [TestCase(" NaN")]
+ [TestCase("INFINITY")]
+ [TestCase("nan")]
+ [TestCase("\u00BD")] // 1/2 as a single Unicode character. Just sanity checking...
+ public void StringToDouble_Invalid(string jsonValue)
+ {
+ string json = "{ \"singleDouble\": \"" + jsonValue + "\"}";
+ Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
+ }
+
+ [Test]
+ [TestCase("0", 0f)]
+ [TestCase("1", 1f)]
+ [TestCase("1.000000", 1f)]
+ [TestCase("-1", -1f)]
+ [TestCase("3.402823e38", 3.402823e38f)]
+ [TestCase("-3.402823e38", -3.402823e38f)]
+ [TestCase("1.5e1", 15f)]
+ [TestCase("15e-1", 1.5f)]
+ public void StringToFloat_Valid(string jsonValue, float expectedParsedValue)
+ {
+ string json = "{ \"singleFloat\": \"" + jsonValue + "\"}";
+ var parsed = TestAllTypes.Parser.ParseJson(json);
+ Assert.AreEqual(expectedParsedValue, parsed.SingleFloat);
+ }
+
+ [Test]
+ [TestCase("3.402824e38")]
+ [TestCase("-3.402824e38")]
+ [TestCase("1,0")]
+ [TestCase("1.0.0")]
+ [TestCase("+1")]
+ [TestCase("00")]
+ [TestCase("--1")]
+ public void StringToFloat_Invalid(string jsonValue)
+ {
+ string json = "{ \"singleFloat\": \"" + jsonValue + "\"}";
+ Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
+ }
+
+ [Test]
+ [TestCase("0", 0)]
+ [TestCase("-0", 0)] // Not entirely clear whether we intend to allow this...
+ [TestCase("1", 1)]
+ [TestCase("-1", -1)]
+ [TestCase("2147483647", 2147483647)]
+ [TestCase("-2147483648", -2147483648)]
+ [TestCase("1e1", 10)]
+ [TestCase("-1e1", -10)]
+ [TestCase("10.00", 10)]
+ [TestCase("-10.00", -10)]
+ public void NumberToInt32_Valid(string jsonValue, int expectedParsedValue)
+ {
+ string json = "{ \"singleInt32\": " + jsonValue + "}";
+ var parsed = TestAllTypes.Parser.ParseJson(json);
+ Assert.AreEqual(expectedParsedValue, parsed.SingleInt32);
+ }
+
+ [Test]
+ [TestCase("+0", typeof(InvalidJsonException))]
+ [TestCase("00", typeof(InvalidJsonException))]
+ [TestCase("-00", typeof(InvalidJsonException))]
+ [TestCase("--1", typeof(InvalidJsonException))]
+ [TestCase("+1", typeof(InvalidJsonException))]
+ [TestCase("1.5", typeof(InvalidProtocolBufferException))]
+ // Value is out of range
+ [TestCase("1e10", typeof(InvalidProtocolBufferException))]
+ [TestCase("2147483648", typeof(InvalidProtocolBufferException))]
+ [TestCase("-2147483649", typeof(InvalidProtocolBufferException))]
+ public void NumberToInt32_Invalid(string jsonValue, System.Type expectedExceptionType)
+ {
+ string json = "{ \"singleInt32\": " + jsonValue + "}";
+ Assert.Throws(expectedExceptionType, () => TestAllTypes.Parser.ParseJson(json));
+ }
+
+ [Test]
+ [TestCase("0", 0U)]
+ [TestCase("1", 1U)]
+ [TestCase("4294967295", 4294967295U)]
+ public void NumberToUInt32_Valid(string jsonValue, uint expectedParsedValue)
+ {
+ string json = "{ \"singleUint32\": " + jsonValue + "}";
+ var parsed = TestAllTypes.Parser.ParseJson(json);
+ Assert.AreEqual(expectedParsedValue, parsed.SingleUint32);
+ }
+
+ // Assume that anything non-bounds-related is covered in the Int32 case
+ [Test]
+ [TestCase("-1")]
+ [TestCase("4294967296")]
+ public void NumberToUInt32_Invalid(string jsonValue)
+ {
+ string json = "{ \"singleUint32\": " + jsonValue + "}";
+ Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
+ }
+
+ [Test]
+ [TestCase("0", 0L)]
+ [TestCase("1", 1L)]
+ [TestCase("-1", -1L)]
+ // long.MaxValue isn't actually representable as a double. This string value is the highest
+ // representable value which isn't greater than long.MaxValue.
+ [TestCase("9223372036854774784", 9223372036854774784)]
+ [TestCase("-9223372036854775808", -9223372036854775808)]
+ public void NumberToInt64_Valid(string jsonValue, long expectedParsedValue)
+ {
+ string json = "{ \"singleInt64\": " + jsonValue + "}";
+ var parsed = TestAllTypes.Parser.ParseJson(json);
+ Assert.AreEqual(expectedParsedValue, parsed.SingleInt64);
+ }
+
+ // Assume that anything non-bounds-related is covered in the Int32 case
+ [Test]
+ [TestCase("9223372036854775808")]
+ // Theoretical bound would be -9223372036854775809, but when that is parsed to a double
+ // we end up with the exact value of long.MinValue due to lack of precision. The value here
+ // is the "next double down".
+ [TestCase("-9223372036854780000")]
+ public void NumberToInt64_Invalid(string jsonValue)
+ {
+ string json = "{ \"singleInt64\": " + jsonValue + "}";
+ Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
+ }
+
+ [Test]
+ [TestCase("0", 0UL)]
+ [TestCase("1", 1UL)]
+ // ulong.MaxValue isn't representable as a double. This value is the largest double within
+ // the range of ulong.
+ [TestCase("18446744073709549568", 18446744073709549568UL)]
+ public void NumberToUInt64_Valid(string jsonValue, ulong expectedParsedValue)
+ {
+ string json = "{ \"singleUint64\": " + jsonValue + "}";
+ var parsed = TestAllTypes.Parser.ParseJson(json);
+ Assert.AreEqual(expectedParsedValue, parsed.SingleUint64);
+ }
+
+ // Assume that anything non-bounds-related is covered in the Int32 case
+ [Test]
+ [TestCase("-1")]
+ [TestCase("18446744073709551616")]
+ public void NumberToUInt64_Invalid(string jsonValue)
+ {
+ string json = "{ \"singleUint64\": " + jsonValue + "}";
+ Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
+ }
+
+ [Test]
+ [TestCase("0", 0d)]
+ [TestCase("1", 1d)]
+ [TestCase("1.000000", 1d)]
+ [TestCase("1.0000000000000000000000001", 1d)] // We don't notice that we haven't preserved the exact value
+ [TestCase("-1", -1d)]
+ [TestCase("1e1", 10d)]
+ [TestCase("1e01", 10d)] // Leading decimals are allowed in exponents
+ [TestCase("1E1", 10d)] // Either case is fine
+ [TestCase("-1e1", -10d)]
+ [TestCase("1.5e1", 15d)]
+ [TestCase("-1.5e1", -15d)]
+ [TestCase("15e-1", 1.5d)]
+ [TestCase("-15e-1", -1.5d)]
+ [TestCase("1.79769e308", 1.79769e308)]
+ [TestCase("-1.79769e308", -1.79769e308)]
+ public void NumberToDouble_Valid(string jsonValue, double expectedParsedValue)
+ {
+ string json = "{ \"singleDouble\": " + jsonValue + "}";
+ var parsed = TestAllTypes.Parser.ParseJson(json);
+ Assert.AreEqual(expectedParsedValue, parsed.SingleDouble);
+ }
+
+ [Test]
+ [TestCase("1.7977e308")]
+ [TestCase("-1.7977e308")]
+ [TestCase("1e309")]
+ [TestCase("1,0")]
+ [TestCase("1.0.0")]
+ [TestCase("+1")]
+ [TestCase("00")]
+ [TestCase("--1")]
+ [TestCase("\u00BD")] // 1/2 as a single Unicode character. Just sanity checking...
+ public void NumberToDouble_Invalid(string jsonValue)
+ {
+ string json = "{ \"singleDouble\": " + jsonValue + "}";
+ Assert.Throws<InvalidJsonException>(() => TestAllTypes.Parser.ParseJson(json));
+ }
+
+ [Test]
+ [TestCase("0", 0f)]
+ [TestCase("1", 1f)]
+ [TestCase("1.000000", 1f)]
+ [TestCase("-1", -1f)]
+ [TestCase("3.402823e38", 3.402823e38f)]
+ [TestCase("-3.402823e38", -3.402823e38f)]
+ [TestCase("1.5e1", 15f)]
+ [TestCase("15e-1", 1.5f)]
+ public void NumberToFloat_Valid(string jsonValue, float expectedParsedValue)
+ {
+ string json = "{ \"singleFloat\": " + jsonValue + "}";
+ var parsed = TestAllTypes.Parser.ParseJson(json);
+ Assert.AreEqual(expectedParsedValue, parsed.SingleFloat);
+ }
+
+ [Test]
+ [TestCase("3.402824e38", typeof(InvalidProtocolBufferException))]
+ [TestCase("-3.402824e38", typeof(InvalidProtocolBufferException))]
+ [TestCase("1,0", typeof(InvalidJsonException))]
+ [TestCase("1.0.0", typeof(InvalidJsonException))]
+ [TestCase("+1", typeof(InvalidJsonException))]
+ [TestCase("00", typeof(InvalidJsonException))]
+ [TestCase("--1", typeof(InvalidJsonException))]
+ public void NumberToFloat_Invalid(string jsonValue, System.Type expectedExceptionType)
+ {
+ string json = "{ \"singleFloat\": " + jsonValue + "}";
+ Assert.Throws(expectedExceptionType, () => TestAllTypes.Parser.ParseJson(json));
+ }
+
+ // The simplest way of testing that the value has parsed correctly is to reformat it,
+ // as we trust the formatting. In many cases that will give the same result as the input,
+ // so in those cases we accept an expectedFormatted value of null. Sometimes the results
+ // will be different though, due to a different number of digits being provided.
+ [Test]
+ // Z offset
+ [TestCase("2015-10-09T14:46:23.123456789Z", null)]
+ [TestCase("2015-10-09T14:46:23.123456Z", null)]
+ [TestCase("2015-10-09T14:46:23.123Z", null)]
+ [TestCase("2015-10-09T14:46:23Z", null)]
+ [TestCase("2015-10-09T14:46:23.123456000Z", "2015-10-09T14:46:23.123456Z")]
+ [TestCase("2015-10-09T14:46:23.1234560Z", "2015-10-09T14:46:23.123456Z")]
+ [TestCase("2015-10-09T14:46:23.123000000Z", "2015-10-09T14:46:23.123Z")]
+ [TestCase("2015-10-09T14:46:23.1230Z", "2015-10-09T14:46:23.123Z")]
+ [TestCase("2015-10-09T14:46:23.00Z", "2015-10-09T14:46:23Z")]
+
+ // +00:00 offset
+ [TestCase("2015-10-09T14:46:23.123456789+00:00", "2015-10-09T14:46:23.123456789Z")]
+ [TestCase("2015-10-09T14:46:23.123456+00:00", "2015-10-09T14:46:23.123456Z")]
+ [TestCase("2015-10-09T14:46:23.123+00:00", "2015-10-09T14:46:23.123Z")]
+ [TestCase("2015-10-09T14:46:23+00:00", "2015-10-09T14:46:23Z")]
+ [TestCase("2015-10-09T14:46:23.123456000+00:00", "2015-10-09T14:46:23.123456Z")]
+ [TestCase("2015-10-09T14:46:23.1234560+00:00", "2015-10-09T14:46:23.123456Z")]
+ [TestCase("2015-10-09T14:46:23.123000000+00:00", "2015-10-09T14:46:23.123Z")]
+ [TestCase("2015-10-09T14:46:23.1230+00:00", "2015-10-09T14:46:23.123Z")]
+ [TestCase("2015-10-09T14:46:23.00+00:00", "2015-10-09T14:46:23Z")]
+
+ // Other offsets (assume by now that the subsecond handling is okay)
+ [TestCase("2015-10-09T15:46:23.123456789+01:00", "2015-10-09T14:46:23.123456789Z")]
+ [TestCase("2015-10-09T13:46:23.123456789-01:00", "2015-10-09T14:46:23.123456789Z")]
+ [TestCase("2015-10-09T15:16:23.123456789+00:30", "2015-10-09T14:46:23.123456789Z")]
+ [TestCase("2015-10-09T14:16:23.123456789-00:30", "2015-10-09T14:46:23.123456789Z")]
+ [TestCase("2015-10-09T16:31:23.123456789+01:45", "2015-10-09T14:46:23.123456789Z")]
+ [TestCase("2015-10-09T13:01:23.123456789-01:45", "2015-10-09T14:46:23.123456789Z")]
+ [TestCase("2015-10-10T08:46:23.123456789+18:00", "2015-10-09T14:46:23.123456789Z")]
+ [TestCase("2015-10-08T20:46:23.123456789-18:00", "2015-10-09T14:46:23.123456789Z")]
+
+ // Leap years and min/max
+ [TestCase("2016-02-29T14:46:23.123456789Z", null)]
+ [TestCase("2000-02-29T14:46:23.123456789Z", null)]
+ [TestCase("0001-01-01T00:00:00Z", null)]
+ [TestCase("9999-12-31T23:59:59.999999999Z", null)]
+ public void Timestamp_Valid(string jsonValue, string expectedFormatted)
+ {
+ expectedFormatted = expectedFormatted ?? jsonValue;
+ string json = WrapInQuotes(jsonValue);
+ var parsed = Timestamp.Parser.ParseJson(json);
+ Assert.AreEqual(WrapInQuotes(expectedFormatted), parsed.ToString());
+ }
+
+ [Test]
+ [TestCase("2015-10-09 14:46:23.123456789Z", Description = "No T between date and time")]
+ [TestCase("2015/10/09T14:46:23.123456789Z", Description = "Wrong date separators")]
+ [TestCase("2015-10-09T14.46.23.123456789Z", Description = "Wrong time separators")]
+ [TestCase("2015-10-09T14:46:23,123456789Z", Description = "Wrong fractional second separators (valid ISO-8601 though)")]
+ [TestCase(" 2015-10-09T14:46:23.123456789Z", Description = "Whitespace at start")]
+ [TestCase("2015-10-09T14:46:23.123456789Z ", Description = "Whitespace at end")]
+ [TestCase("2015-10-09T14:46:23.1234567890", Description = "Too many digits")]
+ [TestCase("2015-10-09T14:46:23.123456789", Description = "No offset")]
+ [TestCase("2015-13-09T14:46:23.123456789Z", Description = "Invalid month")]
+ [TestCase("2015-10-32T14:46:23.123456789Z", Description = "Invalid day")]
+ [TestCase("2015-10-09T24:00:00.000000000Z", Description = "Invalid hour (valid ISO-8601 though)")]
+ [TestCase("2015-10-09T14:60:23.123456789Z", Description = "Invalid minutes")]
+ [TestCase("2015-10-09T14:46:60.123456789Z", Description = "Invalid seconds")]
+ [TestCase("2015-10-09T14:46:23.123456789+18:01", Description = "Offset too large (positive)")]
+ [TestCase("2015-10-09T14:46:23.123456789-18:01", Description = "Offset too large (negative)")]
+ [TestCase("2015-10-09T14:46:23.123456789-00:00", Description = "Local offset (-00:00) makes no sense here")]
+ [TestCase("0001-01-01T00:00:00+00:01", Description = "Value before earliest when offset applied")]
+ [TestCase("9999-12-31T23:59:59.999999999-00:01", Description = "Value after latest when offset applied")]
+ [TestCase("2100-02-29T14:46:23.123456789Z", Description = "Feb 29th on a non-leap-year")]
+ public void Timestamp_Invalid(string jsonValue)
+ {
+ string json = WrapInQuotes(jsonValue);
+ Assert.Throws<InvalidProtocolBufferException>(() => Timestamp.Parser.ParseJson(json));
+ }
+
+ [Test]
+ public void StructValue_Null()
+ {
+ Assert.AreEqual(new Value { NullValue = 0 }, Value.Parser.ParseJson("null"));
+ }
+
+ [Test]
+ public void StructValue_String()
+ {
+ Assert.AreEqual(new Value { StringValue = "hi" }, Value.Parser.ParseJson("\"hi\""));
+ }
+
+ [Test]
+ public void StructValue_Bool()
+ {
+ Assert.AreEqual(new Value { BoolValue = true }, Value.Parser.ParseJson("true"));
+ Assert.AreEqual(new Value { BoolValue = false }, Value.Parser.ParseJson("false"));
+ }
+
+ [Test]
+ public void StructValue_List()
+ {
+ Assert.AreEqual(Value.ForList(Value.ForNumber(1), Value.ForString("x")), Value.Parser.ParseJson("[1, \"x\"]"));
+ }
+
+ [Test]
+ public void ParseListValue()
+ {
+ Assert.AreEqual(new ListValue { Values = { Value.ForNumber(1), Value.ForString("x") } }, ListValue.Parser.ParseJson("[1, \"x\"]"));
+ }
+
+ [Test]
+ public void StructValue_Struct()
+ {
+ Assert.AreEqual(
+ Value.ForStruct(new Struct { Fields = { { "x", Value.ForNumber(1) }, { "y", Value.ForString("z") } } }),
+ Value.Parser.ParseJson("{ \"x\": 1, \"y\": \"z\" }"));
+ }
+
+ [Test]
+ public void ParseStruct()
+ {
+ Assert.AreEqual(new Struct { Fields = { { "x", Value.ForNumber(1) }, { "y", Value.ForString("z") } } },
+ Struct.Parser.ParseJson("{ \"x\": 1, \"y\": \"z\" }"));
+ }
+
+ // TODO for duration parsing: upper and lower bounds.
+ // +/- 315576000000 seconds
+
+ [Test]
+ [TestCase("1.123456789s", null)]
+ [TestCase("1.123456s", null)]
+ [TestCase("1.123s", null)]
+ [TestCase("1.12300s", "1.123s")]
+ [TestCase("1.12345s", "1.123450s")]
+ [TestCase("1s", null)]
+ [TestCase("-1.123456789s", null)]
+ [TestCase("-1.123456s", null)]
+ [TestCase("-1.123s", null)]
+ [TestCase("-1s", null)]
+ [TestCase("0.123s", null)]
+ [TestCase("-0.123s", null)]
+ [TestCase("123456.123s", null)]
+ [TestCase("-123456.123s", null)]
+ // Upper and lower bounds
+ [TestCase("315576000000s", null)]
+ [TestCase("-315576000000s", null)]
+ public void Duration_Valid(string jsonValue, string expectedFormatted)
+ {
+ expectedFormatted = expectedFormatted ?? jsonValue;
+ string json = WrapInQuotes(jsonValue);
+ var parsed = Duration.Parser.ParseJson(json);
+ Assert.AreEqual(WrapInQuotes(expectedFormatted), parsed.ToString());
+ }
+
+ // The simplest way of testing that the value has parsed correctly is to reformat it,
+ // as we trust the formatting. In many cases that will give the same result as the input,
+ // so in those cases we accept an expectedFormatted value of null. Sometimes the results
+ // will be different though, due to a different number of digits being provided.
+ [Test]
+ [TestCase("1.1234567890s", Description = "Too many digits")]
+ [TestCase("1.123456789", Description = "No suffix")]
+ [TestCase("1.123456789ss", Description = "Too much suffix")]
+ [TestCase("1.123456789S", Description = "Upper case suffix")]
+ [TestCase("+1.123456789s", Description = "Leading +")]
+ [TestCase(".123456789s", Description = "No integer before the fraction")]
+ [TestCase("1,123456789s", Description = "Comma as decimal separator")]
+ [TestCase("1x1.123456789s", Description = "Non-digit in integer part")]
+ [TestCase("1.1x3456789s", Description = "Non-digit in fractional part")]
+ [TestCase(" 1.123456789s", Description = "Whitespace before fraction")]
+ [TestCase("1.123456789s ", Description = "Whitespace after value")]
+ [TestCase("01.123456789s", Description = "Leading zero (positive)")]
+ [TestCase("-01.123456789s", Description = "Leading zero (negative)")]
+ [TestCase("--0.123456789s", Description = "Double minus sign")]
+ // Violate upper/lower bounds in various ways
+ [TestCase("315576000001s", Description = "Integer part too large")]
+ [TestCase("3155760000000s", Description = "Integer part too long (positive)")]
+ [TestCase("-3155760000000s", Description = "Integer part too long (negative)")]
+ public void Duration_Invalid(string jsonValue)
+ {
+ string json = WrapInQuotes(jsonValue);
+ Assert.Throws<InvalidProtocolBufferException>(() => Duration.Parser.ParseJson(json));
+ }
+
+ // Not as many tests for field masks as I'd like; more to be added when we have more
+ // detailed specifications.
+
+ [Test]
+ [TestCase("")]
+ [TestCase("foo", "foo")]
+ [TestCase("foo,bar", "foo", "bar")]
+ [TestCase("foo.bar", "foo.bar")]
+ [TestCase("fooBar", "foo_bar")]
+ [TestCase("fooBar.bazQux", "foo_bar.baz_qux")]
+ public void FieldMask_Valid(string jsonValue, params string[] expectedPaths)
+ {
+ string json = WrapInQuotes(jsonValue);
+ var parsed = FieldMask.Parser.ParseJson(json);
+ CollectionAssert.AreEqual(expectedPaths, parsed.Paths);
+ }
+
+ [Test]
+ [TestCase("foo_bar")]
+ public void FieldMask_Invalid(string jsonValue)
+ {
+ string json = WrapInQuotes(jsonValue);
+ Assert.Throws<InvalidProtocolBufferException>(() => FieldMask.Parser.ParseJson(json));
+ }
+
+ [Test]
+ public void Any_RegularMessage()
+ {
+ var registry = TypeRegistry.FromMessages(TestAllTypes.Descriptor);
+ var formatter = new JsonFormatter(new JsonFormatter.Settings(false, TypeRegistry.FromMessages(TestAllTypes.Descriptor)));
+ var message = new TestAllTypes { SingleInt32 = 10, SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 20 } };
+ var original = Any.Pack(message);
+ var json = formatter.Format(original); // This is tested in JsonFormatterTest
+ var parser = new JsonParser(new JsonParser.Settings(10, registry));
+ Assert.AreEqual(original, parser.Parse<Any>(json));
+ string valueFirstJson = "{ \"singleInt32\": 10, \"singleNestedMessage\": { \"bb\": 20 }, \"@type\": \"type.googleapis.com/protobuf_unittest.TestAllTypes\" }";
+ Assert.AreEqual(original, parser.Parse<Any>(valueFirstJson));
+ }
+
+ [Test]
+ public void Any_CustomPrefix()
+ {
+ var registry = TypeRegistry.FromMessages(TestAllTypes.Descriptor);
+ var message = new TestAllTypes { SingleInt32 = 10 };
+ var original = Any.Pack(message, "custom.prefix/middle-part");
+ var parser = new JsonParser(new JsonParser.Settings(10, registry));
+ string json = "{ \"@type\": \"custom.prefix/middle-part/protobuf_unittest.TestAllTypes\", \"singleInt32\": 10 }";
+ Assert.AreEqual(original, parser.Parse<Any>(json));
+ }
+
+ [Test]
+ public void Any_UnknownType()
+ {
+ string json = "{ \"@type\": \"type.googleapis.com/bogus\" }";
+ Assert.Throws<InvalidOperationException>(() => Any.Parser.ParseJson(json));
+ }
+
+ [Test]
+ public void Any_NoTypeUrl()
+ {
+ string json = "{ \"foo\": \"bar\" }";
+ Assert.Throws<InvalidProtocolBufferException>(() => Any.Parser.ParseJson(json));
+ }
+
+ [Test]
+ public void Any_WellKnownType()
+ {
+ var registry = TypeRegistry.FromMessages(Timestamp.Descriptor);
+ var formatter = new JsonFormatter(new JsonFormatter.Settings(false, registry));
+ var timestamp = new DateTime(1673, 6, 19, 12, 34, 56, DateTimeKind.Utc).ToTimestamp();
+ var original = Any.Pack(timestamp);
+ var json = formatter.Format(original); // This is tested in JsonFormatterTest
+ var parser = new JsonParser(new JsonParser.Settings(10, registry));
+ Assert.AreEqual(original, parser.Parse<Any>(json));
+ string valueFirstJson = "{ \"value\": \"1673-06-19T12:34:56Z\", \"@type\": \"type.googleapis.com/google.protobuf.Timestamp\" }";
+ Assert.AreEqual(original, parser.Parse<Any>(valueFirstJson));
+ }
+
+ [Test]
+ public void Any_Nested()
+ {
+ var registry = TypeRegistry.FromMessages(TestWellKnownTypes.Descriptor, TestAllTypes.Descriptor);
+ var formatter = new JsonFormatter(new JsonFormatter.Settings(false, registry));
+ var parser = new JsonParser(new JsonParser.Settings(10, registry));
+ var doubleNestedMessage = new TestAllTypes { SingleInt32 = 20 };
+ var nestedMessage = Any.Pack(doubleNestedMessage);
+ var message = new TestWellKnownTypes { AnyField = Any.Pack(nestedMessage) };
+ var json = formatter.Format(message);
+ // Use the descriptor-based parser just for a change.
+ Assert.AreEqual(message, parser.Parse(json, TestWellKnownTypes.Descriptor));
+ }
+
+ [Test]
+ public void DataAfterObject()
+ {
+ string json = "{} 10";
+ Assert.Throws<InvalidJsonException>(() => TestAllTypes.Parser.ParseJson(json));
+ }
+
+ /// <summary>
+ /// JSON equivalent to <see cref="CodedInputStreamTest.MaliciousRecursion"/>
+ /// </summary>
+ [Test]
+ public void MaliciousRecursion()
+ {
+ string data64 = CodedInputStreamTest.MakeRecursiveMessage(64).ToString();
+ string data65 = CodedInputStreamTest.MakeRecursiveMessage(65).ToString();
+
+ var parser64 = new JsonParser(new JsonParser.Settings(64));
+ CodedInputStreamTest.AssertMessageDepth(parser64.Parse<TestRecursiveMessage>(data64), 64);
+ Assert.Throws<InvalidProtocolBufferException>(() => parser64.Parse<TestRecursiveMessage>(data65));
+
+ var parser63 = new JsonParser(new JsonParser.Settings(63));
+ Assert.Throws<InvalidProtocolBufferException>(() => parser63.Parse<TestRecursiveMessage>(data64));
+ }
+
+ [Test]
+ [TestCase("AQI")]
+ [TestCase("_-==")]
+ public void Bytes_InvalidBase64(string badBase64)
+ {
+ string json = "{ \"singleBytes\": \"" + badBase64 + "\" }";
+ Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
+ }
+
+ [Test]
+ [TestCase("\"FOREIGN_BAR\"", ForeignEnum.ForeignBar)]
+ [TestCase("5", ForeignEnum.ForeignBar)]
+ [TestCase("100", (ForeignEnum)100)]
+ public void EnumValid(string value, ForeignEnum expectedValue)
+ {
+ string json = "{ \"singleForeignEnum\": " + value + " }";
+ var parsed = TestAllTypes.Parser.ParseJson(json);
+ Assert.AreEqual(new TestAllTypes { SingleForeignEnum = expectedValue }, parsed);
+ }
+
+ [Test]
+ [TestCase("\"NOT_A_VALID_VALUE\"")]
+ [TestCase("5.5")]
+ public void Enum_Invalid(string value)
+ {
+ string json = "{ \"singleForeignEnum\": " + value + " }";
+ Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
+ }
+
+ [Test]
+ public void OneofDuplicate_Invalid()
+ {
+ string json = "{ \"oneofString\": \"x\", \"oneofUint32\": 10 }";
+ Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
+ }
+
+ /// <summary>
+ /// Various tests use strings which have quotes round them for parsing or as the result
+ /// of formatting, but without those quotes being specified in the tests (for the sake of readability).
+ /// This method simply returns the input, wrapped in double quotes.
+ /// </summary>
+ internal static string WrapInQuotes(string text)
+ {
+ return '"' + text + '"';
+ }
+ }
+} \ No newline at end of file
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/JsonTokenizerTest.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/JsonTokenizerTest.cs
new file mode 100644
index 00000000..527ab336
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/JsonTokenizerTest.cs
@@ -0,0 +1,408 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+using NUnit.Framework;
+using System;
+using System.IO;
+
+namespace Google.Protobuf
+{
+ public class JsonTokenizerTest
+ {
+ [Test]
+ public void EmptyObjectValue()
+ {
+ AssertTokens("{}", JsonToken.StartObject, JsonToken.EndObject);
+ }
+
+ [Test]
+ public void EmptyArrayValue()
+ {
+ AssertTokens("[]", JsonToken.StartArray, JsonToken.EndArray);
+ }
+
+ [Test]
+ [TestCase("foo", "foo")]
+ [TestCase("tab\\t", "tab\t")]
+ [TestCase("line\\nfeed", "line\nfeed")]
+ [TestCase("carriage\\rreturn", "carriage\rreturn")]
+ [TestCase("back\\bspace", "back\bspace")]
+ [TestCase("form\\ffeed", "form\ffeed")]
+ [TestCase("escaped\\/slash", "escaped/slash")]
+ [TestCase("escaped\\\\backslash", "escaped\\backslash")]
+ [TestCase("escaped\\\"quote", "escaped\"quote")]
+ [TestCase("foo {}[] bar", "foo {}[] bar")]
+ [TestCase("foo\\u09aFbar", "foo\u09afbar")] // Digits, upper hex, lower hex
+ [TestCase("ab\ud800\udc00cd", "ab\ud800\udc00cd")]
+ [TestCase("ab\\ud800\\udc00cd", "ab\ud800\udc00cd")]
+ public void StringValue(string json, string expectedValue)
+ {
+ AssertTokensNoReplacement("\"" + json + "\"", JsonToken.Value(expectedValue));
+ }
+
+ // Valid surrogate pairs, with mixed escaping. These test cases can't be expressed
+ // using TestCase as they have no valid UTF-8 representation.
+ // It's unclear exactly how we should handle a mixture of escaped or not: that can't
+ // come from UTF-8 text, but could come from a .NET string. For the moment,
+ // treat it as valid in the obvious way.
+ [Test]
+ public void MixedSurrogatePairs()
+ {
+ string expected = "\ud800\udc00";
+ AssertTokens("'\\ud800\udc00'", JsonToken.Value(expected));
+ AssertTokens("'\ud800\\udc00'", JsonToken.Value(expected));
+ }
+
+ [Test]
+ public void ObjectDepth()
+ {
+ string json = "{ \"foo\": { \"x\": 1, \"y\": [ 0 ] } }";
+ var tokenizer = JsonTokenizer.FromTextReader(new StringReader(json));
+ // If we had more tests like this, I'd introduce a helper method... but for one test, it's not worth it.
+ Assert.AreEqual(0, tokenizer.ObjectDepth);
+ Assert.AreEqual(JsonToken.StartObject, tokenizer.Next());
+ Assert.AreEqual(1, tokenizer.ObjectDepth);
+ Assert.AreEqual(JsonToken.Name("foo"), tokenizer.Next());
+ Assert.AreEqual(1, tokenizer.ObjectDepth);
+ Assert.AreEqual(JsonToken.StartObject, tokenizer.Next());
+ Assert.AreEqual(2, tokenizer.ObjectDepth);
+ Assert.AreEqual(JsonToken.Name("x"), tokenizer.Next());
+ Assert.AreEqual(2, tokenizer.ObjectDepth);
+ Assert.AreEqual(JsonToken.Value(1), tokenizer.Next());
+ Assert.AreEqual(2, tokenizer.ObjectDepth);
+ Assert.AreEqual(JsonToken.Name("y"), tokenizer.Next());
+ Assert.AreEqual(2, tokenizer.ObjectDepth);
+ Assert.AreEqual(JsonToken.StartArray, tokenizer.Next());
+ Assert.AreEqual(2, tokenizer.ObjectDepth); // Depth hasn't changed in array
+ Assert.AreEqual(JsonToken.Value(0), tokenizer.Next());
+ Assert.AreEqual(2, tokenizer.ObjectDepth);
+ Assert.AreEqual(JsonToken.EndArray, tokenizer.Next());
+ Assert.AreEqual(2, tokenizer.ObjectDepth);
+ Assert.AreEqual(JsonToken.EndObject, tokenizer.Next());
+ Assert.AreEqual(1, tokenizer.ObjectDepth);
+ Assert.AreEqual(JsonToken.EndObject, tokenizer.Next());
+ Assert.AreEqual(0, tokenizer.ObjectDepth);
+ Assert.AreEqual(JsonToken.EndDocument, tokenizer.Next());
+ Assert.AreEqual(0, tokenizer.ObjectDepth);
+ }
+
+ [Test]
+ public void ObjectDepth_WithPushBack()
+ {
+ string json = "{}";
+ var tokenizer = JsonTokenizer.FromTextReader(new StringReader(json));
+ Assert.AreEqual(0, tokenizer.ObjectDepth);
+ var token = tokenizer.Next();
+ Assert.AreEqual(1, tokenizer.ObjectDepth);
+ // When we push back a "start object", we should effectively be back to the previous depth.
+ tokenizer.PushBack(token);
+ Assert.AreEqual(0, tokenizer.ObjectDepth);
+ // Read the same token again, and get back to depth 1
+ token = tokenizer.Next();
+ Assert.AreEqual(1, tokenizer.ObjectDepth);
+
+ // Now the same in reverse, with EndObject
+ token = tokenizer.Next();
+ Assert.AreEqual(0, tokenizer.ObjectDepth);
+ tokenizer.PushBack(token);
+ Assert.AreEqual(1, tokenizer.ObjectDepth);
+ tokenizer.Next();
+ Assert.AreEqual(0, tokenizer.ObjectDepth);
+ }
+
+ [Test]
+ [TestCase("embedded tab\t")]
+ [TestCase("embedded CR\r")]
+ [TestCase("embedded LF\n")]
+ [TestCase("embedded bell\u0007")]
+ [TestCase("bad escape\\a")]
+ [TestCase("incomplete escape\\")]
+ [TestCase("incomplete Unicode escape\\u000")]
+ [TestCase("invalid Unicode escape\\u000H")]
+ // Surrogate pair handling, both in raw .NET strings and escaped. We only need
+ // to detect this in strings, as non-ASCII characters anywhere other than in strings
+ // will already lead to parsing errors.
+ [TestCase("\\ud800")]
+ [TestCase("\\udc00")]
+ [TestCase("\\ud800x")]
+ [TestCase("\\udc00x")]
+ [TestCase("\\udc00\\ud800y")]
+ public void InvalidStringValue(string json)
+ {
+ AssertThrowsAfter("\"" + json + "\"");
+ }
+
+ // Tests for invalid strings that can't be expressed in attributes,
+ // as the constants can't be expressed as UTF-8 strings.
+ [Test]
+ public void InvalidSurrogatePairs()
+ {
+ AssertThrowsAfter("\"\ud800x\"");
+ AssertThrowsAfter("\"\udc00y\"");
+ AssertThrowsAfter("\"\udc00\ud800y\"");
+ }
+
+ [Test]
+ [TestCase("0", 0)]
+ [TestCase("-0", 0)] // We don't distinguish between positive and negative 0
+ [TestCase("1", 1)]
+ [TestCase("-1", -1)]
+ // From here on, assume leading sign is okay...
+ [TestCase("1.125", 1.125)]
+ [TestCase("1.0", 1)]
+ [TestCase("1e5", 100000)]
+ [TestCase("1e000000", 1)] // Weird, but not prohibited by the spec
+ [TestCase("1E5", 100000)]
+ [TestCase("1e+5", 100000)]
+ [TestCase("1E-5", 0.00001)]
+ [TestCase("123E-2", 1.23)]
+ [TestCase("123.45E3", 123450)]
+ [TestCase(" 1 ", 1)]
+ public void NumberValue(string json, double expectedValue)
+ {
+ AssertTokens(json, JsonToken.Value(expectedValue));
+ }
+
+ [Test]
+ [TestCase("00")]
+ [TestCase(".5")]
+ [TestCase("1.")]
+ [TestCase("1e")]
+ [TestCase("1e-")]
+ [TestCase("--")]
+ [TestCase("--1")]
+ [TestCase("-1.7977e308")]
+ [TestCase("1.7977e308")]
+ public void InvalidNumberValue(string json)
+ {
+ AssertThrowsAfter(json);
+ }
+
+ [Test]
+ [TestCase("nul")]
+ [TestCase("nothing")]
+ [TestCase("truth")]
+ [TestCase("fALSEhood")]
+ public void InvalidLiterals(string json)
+ {
+ AssertThrowsAfter(json);
+ }
+
+ [Test]
+ public void NullValue()
+ {
+ AssertTokens("null", JsonToken.Null);
+ }
+
+ [Test]
+ public void TrueValue()
+ {
+ AssertTokens("true", JsonToken.True);
+ }
+
+ [Test]
+ public void FalseValue()
+ {
+ AssertTokens("false", JsonToken.False);
+ }
+
+ [Test]
+ public void SimpleObject()
+ {
+ AssertTokens("{'x': 'y'}",
+ JsonToken.StartObject, JsonToken.Name("x"), JsonToken.Value("y"), JsonToken.EndObject);
+ }
+
+ [Test]
+ [TestCase("[10, 20", 3)]
+ [TestCase("[10,", 2)]
+ [TestCase("[10:20]", 2)]
+ [TestCase("[", 1)]
+ [TestCase("[,", 1)]
+ [TestCase("{", 1)]
+ [TestCase("{,", 1)]
+ [TestCase("{[", 1)]
+ [TestCase("{{", 1)]
+ [TestCase("{0", 1)]
+ [TestCase("{null", 1)]
+ [TestCase("{false", 1)]
+ [TestCase("{true", 1)]
+ [TestCase("}", 0)]
+ [TestCase("]", 0)]
+ [TestCase(",", 0)]
+ [TestCase("'foo' 'bar'", 1)]
+ [TestCase(":", 0)]
+ [TestCase("'foo", 0)] // Incomplete string
+ [TestCase("{ 'foo' }", 2)]
+ [TestCase("{ x:1", 1)] // Property names must be quoted
+ [TestCase("{]", 1)]
+ [TestCase("[}", 1)]
+ [TestCase("[1,", 2)]
+ [TestCase("{'x':0]", 3)]
+ [TestCase("{ 'foo': }", 2)]
+ [TestCase("{ 'foo':'bar', }", 3)]
+ public void InvalidStructure(string json, int expectedValidTokens)
+ {
+ // Note: we don't test that the earlier tokens are exactly as expected,
+ // partly because that's hard to parameterize.
+ var reader = new StringReader(json.Replace('\'', '"'));
+ var tokenizer = JsonTokenizer.FromTextReader(reader);
+ for (int i = 0; i < expectedValidTokens; i++)
+ {
+ Assert.IsNotNull(tokenizer.Next());
+ }
+ Assert.Throws<InvalidJsonException>(() => tokenizer.Next());
+ }
+
+ [Test]
+ public void ArrayMixedType()
+ {
+ AssertTokens("[1, 'foo', null, false, true, [2], {'x':'y' }]",
+ JsonToken.StartArray,
+ JsonToken.Value(1),
+ JsonToken.Value("foo"),
+ JsonToken.Null,
+ JsonToken.False,
+ JsonToken.True,
+ JsonToken.StartArray,
+ JsonToken.Value(2),
+ JsonToken.EndArray,
+ JsonToken.StartObject,
+ JsonToken.Name("x"),
+ JsonToken.Value("y"),
+ JsonToken.EndObject,
+ JsonToken.EndArray);
+ }
+
+ [Test]
+ public void ObjectMixedType()
+ {
+ AssertTokens(@"{'a': 1, 'b': 'bar', 'c': null, 'd': false, 'e': true,
+ 'f': [2], 'g': {'x':'y' }}",
+ JsonToken.StartObject,
+ JsonToken.Name("a"),
+ JsonToken.Value(1),
+ JsonToken.Name("b"),
+ JsonToken.Value("bar"),
+ JsonToken.Name("c"),
+ JsonToken.Null,
+ JsonToken.Name("d"),
+ JsonToken.False,
+ JsonToken.Name("e"),
+ JsonToken.True,
+ JsonToken.Name("f"),
+ JsonToken.StartArray,
+ JsonToken.Value(2),
+ JsonToken.EndArray,
+ JsonToken.Name("g"),
+ JsonToken.StartObject,
+ JsonToken.Name("x"),
+ JsonToken.Value("y"),
+ JsonToken.EndObject,
+ JsonToken.EndObject);
+ }
+
+ [Test]
+ public void NextAfterEndDocumentThrows()
+ {
+ var tokenizer = JsonTokenizer.FromTextReader(new StringReader("null"));
+ Assert.AreEqual(JsonToken.Null, tokenizer.Next());
+ Assert.AreEqual(JsonToken.EndDocument, tokenizer.Next());
+ Assert.Throws<InvalidOperationException>(() => tokenizer.Next());
+ }
+
+ [Test]
+ public void CanPushBackEndDocument()
+ {
+ var tokenizer = JsonTokenizer.FromTextReader(new StringReader("null"));
+ Assert.AreEqual(JsonToken.Null, tokenizer.Next());
+ Assert.AreEqual(JsonToken.EndDocument, tokenizer.Next());
+ tokenizer.PushBack(JsonToken.EndDocument);
+ Assert.AreEqual(JsonToken.EndDocument, tokenizer.Next());
+ Assert.Throws<InvalidOperationException>(() => tokenizer.Next());
+ }
+
+ /// <summary>
+ /// Asserts that the specified JSON is tokenized into the given sequence of tokens.
+ /// All apostrophes are first converted to double quotes, allowing any tests
+ /// that don't need to check actual apostrophe handling to use apostrophes in the JSON, avoiding
+ /// messy string literal escaping. The "end document" token is not specified in the list of
+ /// expected tokens, but is implicit.
+ /// </summary>
+ private static void AssertTokens(string json, params JsonToken[] expectedTokens)
+ {
+ AssertTokensNoReplacement(json.Replace('\'', '"'), expectedTokens);
+ }
+
+ /// <summary>
+ /// Asserts that the specified JSON is tokenized into the given sequence of tokens.
+ /// Unlike <see cref="AssertTokens(string, JsonToken[])"/>, this does not perform any character
+ /// replacement on the specified JSON, and should be used when the text contains apostrophes which
+ /// are expected to be used *as* apostrophes. The "end document" token is not specified in the list of
+ /// expected tokens, but is implicit.
+ /// </summary>
+ private static void AssertTokensNoReplacement(string json, params JsonToken[] expectedTokens)
+ {
+ var reader = new StringReader(json);
+ var tokenizer = JsonTokenizer.FromTextReader(reader);
+ for (int i = 0; i < expectedTokens.Length; i++)
+ {
+ var actualToken = tokenizer.Next();
+ if (actualToken == JsonToken.EndDocument)
+ {
+ Assert.Fail("Expected {0} but reached end of token stream", expectedTokens[i]);
+ }
+ Assert.AreEqual(expectedTokens[i], actualToken);
+ }
+ var finalToken = tokenizer.Next();
+ if (finalToken != JsonToken.EndDocument)
+ {
+ Assert.Fail("Expected token stream to be exhausted; received {0}", finalToken);
+ }
+ }
+
+ private static void AssertThrowsAfter(string json, params JsonToken[] expectedTokens)
+ {
+ var reader = new StringReader(json);
+ var tokenizer = JsonTokenizer.FromTextReader(reader);
+ for (int i = 0; i < expectedTokens.Length; i++)
+ {
+ var actualToken = tokenizer.Next();
+ if (actualToken == JsonToken.EndDocument)
+ {
+ Assert.Fail("Expected {0} but reached end of document", expectedTokens[i]);
+ }
+ Assert.AreEqual(expectedTokens[i], actualToken);
+ }
+ Assert.Throws<InvalidJsonException>(() => tokenizer.Next());
+ }
+ }
+}
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs
new file mode 100644
index 00000000..52d5a676
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs
@@ -0,0 +1,259 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using System.Linq;
+using Google.Protobuf.TestProtos;
+using NUnit.Framework;
+using UnitTest.Issues.TestProtos;
+
+namespace Google.Protobuf.Reflection
+{
+ /// <summary>
+ /// Tests for descriptors. (Not in its own namespace or broken up into individual classes as the
+ /// size doesn't warrant it. On the other hand, this makes me feel a bit dirty...)
+ /// </summary>
+ public class DescriptorsTest
+ {
+ [Test]
+ public void FileDescriptor()
+ {
+ FileDescriptor file = UnittestProto3Reflection.Descriptor;
+
+ Assert.AreEqual("google/protobuf/unittest_proto3.proto", file.Name);
+ Assert.AreEqual("protobuf_unittest", file.Package);
+
+ Assert.AreEqual("UnittestProto", file.Proto.Options.JavaOuterClassname);
+ Assert.AreEqual("google/protobuf/unittest_proto3.proto", file.Proto.Name);
+
+ // unittest.proto doesn't have any public imports, but unittest_import.proto does.
+ Assert.AreEqual(0, file.PublicDependencies.Count);
+ Assert.AreEqual(1, UnittestImportProto3Reflection.Descriptor.PublicDependencies.Count);
+ Assert.AreEqual(UnittestImportPublicProto3Reflection.Descriptor, UnittestImportProto3Reflection.Descriptor.PublicDependencies[0]);
+
+ Assert.AreEqual(1, file.Dependencies.Count);
+ Assert.AreEqual(UnittestImportProto3Reflection.Descriptor, file.Dependencies[0]);
+
+ MessageDescriptor messageType = TestAllTypes.Descriptor;
+ Assert.AreSame(typeof(TestAllTypes), messageType.ClrType);
+ Assert.AreSame(TestAllTypes.Parser, messageType.Parser);
+ Assert.AreEqual(messageType, file.MessageTypes[0]);
+ Assert.AreEqual(messageType, file.FindTypeByName<MessageDescriptor>("TestAllTypes"));
+ Assert.Null(file.FindTypeByName<MessageDescriptor>("NoSuchType"));
+ Assert.Null(file.FindTypeByName<MessageDescriptor>("protobuf_unittest.TestAllTypes"));
+ for (int i = 0; i < file.MessageTypes.Count; i++)
+ {
+ Assert.AreEqual(i, file.MessageTypes[i].Index);
+ }
+
+ Assert.AreEqual(file.EnumTypes[0], file.FindTypeByName<EnumDescriptor>("ForeignEnum"));
+ Assert.Null(file.FindTypeByName<EnumDescriptor>("NoSuchType"));
+ Assert.Null(file.FindTypeByName<EnumDescriptor>("protobuf_unittest.ForeignEnum"));
+ Assert.AreEqual(1, UnittestImportProto3Reflection.Descriptor.EnumTypes.Count);
+ Assert.AreEqual("ImportEnum", UnittestImportProto3Reflection.Descriptor.EnumTypes[0].Name);
+ for (int i = 0; i < file.EnumTypes.Count; i++)
+ {
+ Assert.AreEqual(i, file.EnumTypes[i].Index);
+ }
+
+ Assert.AreEqual(10, file.SerializedData[0]);
+ }
+
+ [Test]
+ public void MessageDescriptor()
+ {
+ MessageDescriptor messageType = TestAllTypes.Descriptor;
+ MessageDescriptor nestedType = TestAllTypes.Types.NestedMessage.Descriptor;
+
+ Assert.AreEqual("TestAllTypes", messageType.Name);
+ Assert.AreEqual("protobuf_unittest.TestAllTypes", messageType.FullName);
+ Assert.AreEqual(UnittestProto3Reflection.Descriptor, messageType.File);
+ Assert.IsNull(messageType.ContainingType);
+ Assert.IsNull(messageType.Proto.Options);
+
+ Assert.AreEqual("TestAllTypes", messageType.Name);
+
+ Assert.AreEqual("NestedMessage", nestedType.Name);
+ Assert.AreEqual("protobuf_unittest.TestAllTypes.NestedMessage", nestedType.FullName);
+ Assert.AreEqual(UnittestProto3Reflection.Descriptor, nestedType.File);
+ Assert.AreEqual(messageType, nestedType.ContainingType);
+
+ FieldDescriptor field = messageType.Fields.InDeclarationOrder()[0];
+ Assert.AreEqual("single_int32", field.Name);
+ Assert.AreEqual(field, messageType.FindDescriptor<FieldDescriptor>("single_int32"));
+ Assert.Null(messageType.FindDescriptor<FieldDescriptor>("no_such_field"));
+ Assert.AreEqual(field, messageType.FindFieldByNumber(1));
+ Assert.Null(messageType.FindFieldByNumber(571283));
+ var fieldsInDeclarationOrder = messageType.Fields.InDeclarationOrder();
+ for (int i = 0; i < fieldsInDeclarationOrder.Count; i++)
+ {
+ Assert.AreEqual(i, fieldsInDeclarationOrder[i].Index);
+ }
+
+ Assert.AreEqual(nestedType, messageType.NestedTypes[0]);
+ Assert.AreEqual(nestedType, messageType.FindDescriptor<MessageDescriptor>("NestedMessage"));
+ Assert.Null(messageType.FindDescriptor<MessageDescriptor>("NoSuchType"));
+ for (int i = 0; i < messageType.NestedTypes.Count; i++)
+ {
+ Assert.AreEqual(i, messageType.NestedTypes[i].Index);
+ }
+
+ Assert.AreEqual(messageType.EnumTypes[0], messageType.FindDescriptor<EnumDescriptor>("NestedEnum"));
+ Assert.Null(messageType.FindDescriptor<EnumDescriptor>("NoSuchType"));
+ for (int i = 0; i < messageType.EnumTypes.Count; i++)
+ {
+ Assert.AreEqual(i, messageType.EnumTypes[i].Index);
+ }
+ }
+
+ [Test]
+ public void FieldDescriptor()
+ {
+ MessageDescriptor messageType = TestAllTypes.Descriptor;
+ FieldDescriptor primitiveField = messageType.FindDescriptor<FieldDescriptor>("single_int32");
+ FieldDescriptor enumField = messageType.FindDescriptor<FieldDescriptor>("single_nested_enum");
+ FieldDescriptor messageField = messageType.FindDescriptor<FieldDescriptor>("single_foreign_message");
+
+ Assert.AreEqual("single_int32", primitiveField.Name);
+ Assert.AreEqual("protobuf_unittest.TestAllTypes.single_int32",
+ primitiveField.FullName);
+ Assert.AreEqual(1, primitiveField.FieldNumber);
+ Assert.AreEqual(messageType, primitiveField.ContainingType);
+ Assert.AreEqual(UnittestProto3Reflection.Descriptor, primitiveField.File);
+ Assert.AreEqual(FieldType.Int32, primitiveField.FieldType);
+ Assert.IsNull(primitiveField.Proto.Options);
+
+ Assert.AreEqual("single_nested_enum", enumField.Name);
+ Assert.AreEqual(FieldType.Enum, enumField.FieldType);
+ // Assert.AreEqual(TestAllTypes.Types.NestedEnum.DescriptorProtoFile, enumField.EnumType);
+
+ Assert.AreEqual("single_foreign_message", messageField.Name);
+ Assert.AreEqual(FieldType.Message, messageField.FieldType);
+ Assert.AreEqual(ForeignMessage.Descriptor, messageField.MessageType);
+ }
+
+ [Test]
+ public void FieldDescriptorLabel()
+ {
+ FieldDescriptor singleField =
+ TestAllTypes.Descriptor.FindDescriptor<FieldDescriptor>("single_int32");
+ FieldDescriptor repeatedField =
+ TestAllTypes.Descriptor.FindDescriptor<FieldDescriptor>("repeated_int32");
+
+ Assert.IsFalse(singleField.IsRepeated);
+ Assert.IsTrue(repeatedField.IsRepeated);
+ }
+
+ [Test]
+ public void EnumDescriptor()
+ {
+ // Note: this test is a bit different to the Java version because there's no static way of getting to the descriptor
+ EnumDescriptor enumType = UnittestProto3Reflection.Descriptor.FindTypeByName<EnumDescriptor>("ForeignEnum");
+ EnumDescriptor nestedType = TestAllTypes.Descriptor.FindDescriptor<EnumDescriptor>("NestedEnum");
+
+ Assert.AreEqual("ForeignEnum", enumType.Name);
+ Assert.AreEqual("protobuf_unittest.ForeignEnum", enumType.FullName);
+ Assert.AreEqual(UnittestProto3Reflection.Descriptor, enumType.File);
+ Assert.Null(enumType.ContainingType);
+ Assert.Null(enumType.Proto.Options);
+
+ Assert.AreEqual("NestedEnum", nestedType.Name);
+ Assert.AreEqual("protobuf_unittest.TestAllTypes.NestedEnum",
+ nestedType.FullName);
+ Assert.AreEqual(UnittestProto3Reflection.Descriptor, nestedType.File);
+ Assert.AreEqual(TestAllTypes.Descriptor, nestedType.ContainingType);
+
+ EnumValueDescriptor value = enumType.FindValueByName("FOREIGN_FOO");
+ Assert.AreEqual(value, enumType.Values[1]);
+ Assert.AreEqual("FOREIGN_FOO", value.Name);
+ Assert.AreEqual(4, value.Number);
+ Assert.AreEqual((int) ForeignEnum.ForeignFoo, value.Number);
+ Assert.AreEqual(value, enumType.FindValueByNumber(4));
+ Assert.Null(enumType.FindValueByName("NO_SUCH_VALUE"));
+ for (int i = 0; i < enumType.Values.Count; i++)
+ {
+ Assert.AreEqual(i, enumType.Values[i].Index);
+ }
+ }
+
+ [Test]
+ public void OneofDescriptor()
+ {
+ OneofDescriptor descriptor = TestAllTypes.Descriptor.FindDescriptor<OneofDescriptor>("oneof_field");
+ Assert.AreEqual("oneof_field", descriptor.Name);
+ Assert.AreEqual("protobuf_unittest.TestAllTypes.oneof_field", descriptor.FullName);
+
+ var expectedFields = new[] {
+ TestAllTypes.OneofBytesFieldNumber,
+ TestAllTypes.OneofNestedMessageFieldNumber,
+ TestAllTypes.OneofStringFieldNumber,
+ TestAllTypes.OneofUint32FieldNumber }
+ .Select(fieldNumber => TestAllTypes.Descriptor.FindFieldByNumber(fieldNumber))
+ .ToList();
+ foreach (var field in expectedFields)
+ {
+ Assert.AreSame(descriptor, field.ContainingOneof);
+ }
+
+ CollectionAssert.AreEquivalent(expectedFields, descriptor.Fields);
+ }
+
+ [Test]
+ public void MapEntryMessageDescriptor()
+ {
+ var descriptor = MapWellKnownTypes.Descriptor.NestedTypes[0];
+ Assert.IsNull(descriptor.Parser);
+ Assert.IsNull(descriptor.ClrType);
+ Assert.IsNull(descriptor.Fields[1].Accessor);
+ }
+
+ // From TestFieldOrdering:
+ // string my_string = 11;
+ // int64 my_int = 1;
+ // float my_float = 101;
+ // NestedMessage single_nested_message = 200;
+ [Test]
+ public void FieldListOrderings()
+ {
+ var fields = TestFieldOrderings.Descriptor.Fields;
+ Assert.AreEqual(new[] { 11, 1, 101, 200 }, fields.InDeclarationOrder().Select(x => x.FieldNumber));
+ Assert.AreEqual(new[] { 1, 11, 101, 200 }, fields.InFieldNumberOrder().Select(x => x.FieldNumber));
+ }
+
+
+ [Test]
+ public void DescriptorProtoFileDescriptor()
+ {
+ var descriptor = Google.Protobuf.Reflection.FileDescriptor.DescriptorProtoFileDescriptor;
+ Assert.AreEqual("google/protobuf/descriptor.proto", descriptor.Name);
+ }
+ }
+}
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs
new file mode 100644
index 00000000..a488af30
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs
@@ -0,0 +1,218 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2015 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using Google.Protobuf.TestProtos;
+using NUnit.Framework;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace Google.Protobuf.Reflection
+{
+ public class FieldAccessTest
+ {
+ [Test]
+ public void GetValue()
+ {
+ var message = SampleMessages.CreateFullTestAllTypes();
+ var fields = TestAllTypes.Descriptor.Fields;
+ Assert.AreEqual(message.SingleBool, fields[TestAllTypes.SingleBoolFieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(message.SingleBytes, fields[TestAllTypes.SingleBytesFieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(message.SingleDouble, fields[TestAllTypes.SingleDoubleFieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(message.SingleFixed32, fields[TestAllTypes.SingleFixed32FieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(message.SingleFixed64, fields[TestAllTypes.SingleFixed64FieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(message.SingleFloat, fields[TestAllTypes.SingleFloatFieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(message.SingleForeignEnum, fields[TestAllTypes.SingleForeignEnumFieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(message.SingleForeignMessage, fields[TestAllTypes.SingleForeignMessageFieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(message.SingleImportEnum, fields[TestAllTypes.SingleImportEnumFieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(message.SingleImportMessage, fields[TestAllTypes.SingleImportMessageFieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(message.SingleInt32, fields[TestAllTypes.SingleInt32FieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(message.SingleInt64, fields[TestAllTypes.SingleInt64FieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(message.SingleNestedEnum, fields[TestAllTypes.SingleNestedEnumFieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(message.SingleNestedMessage, fields[TestAllTypes.SingleNestedMessageFieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(message.SinglePublicImportMessage, fields[TestAllTypes.SinglePublicImportMessageFieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(message.SingleSint32, fields[TestAllTypes.SingleSint32FieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(message.SingleSint64, fields[TestAllTypes.SingleSint64FieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(message.SingleString, fields[TestAllTypes.SingleStringFieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(message.SingleSfixed32, fields[TestAllTypes.SingleSfixed32FieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(message.SingleSfixed64, fields[TestAllTypes.SingleSfixed64FieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(message.SingleUint32, fields[TestAllTypes.SingleUint32FieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(message.SingleUint64, fields[TestAllTypes.SingleUint64FieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(message.OneofBytes, fields[TestAllTypes.OneofBytesFieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(message.OneofString, fields[TestAllTypes.OneofStringFieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(message.OneofNestedMessage, fields[TestAllTypes.OneofNestedMessageFieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(message.OneofUint32, fields[TestAllTypes.OneofUint32FieldNumber].Accessor.GetValue(message));
+
+ // Just one example for repeated fields - they're all just returning the list
+ var list = (IList) fields[TestAllTypes.RepeatedInt32FieldNumber].Accessor.GetValue(message);
+ Assert.AreEqual(message.RepeatedInt32, list);
+ Assert.AreEqual(message.RepeatedInt32[0], list[0]); // Just in case there was any doubt...
+
+ // Just a single map field, for the same reason
+ var mapMessage = new TestMap { MapStringString = { { "key1", "value1" }, { "key2", "value2" } } };
+ fields = TestMap.Descriptor.Fields;
+ var dictionary = (IDictionary) fields[TestMap.MapStringStringFieldNumber].Accessor.GetValue(mapMessage);
+ Assert.AreEqual(mapMessage.MapStringString, dictionary);
+ Assert.AreEqual("value1", dictionary["key1"]);
+ }
+
+ [Test]
+ public void Clear()
+ {
+ var message = SampleMessages.CreateFullTestAllTypes();
+ var fields = TestAllTypes.Descriptor.Fields;
+ fields[TestAllTypes.SingleBoolFieldNumber].Accessor.Clear(message);
+ fields[TestAllTypes.SingleInt32FieldNumber].Accessor.Clear(message);
+ fields[TestAllTypes.SingleStringFieldNumber].Accessor.Clear(message);
+ fields[TestAllTypes.SingleBytesFieldNumber].Accessor.Clear(message);
+ fields[TestAllTypes.SingleForeignEnumFieldNumber].Accessor.Clear(message);
+ fields[TestAllTypes.SingleForeignMessageFieldNumber].Accessor.Clear(message);
+ fields[TestAllTypes.RepeatedDoubleFieldNumber].Accessor.Clear(message);
+
+ var expected = new TestAllTypes(SampleMessages.CreateFullTestAllTypes())
+ {
+ SingleBool = false,
+ SingleInt32 = 0,
+ SingleString = "",
+ SingleBytes = ByteString.Empty,
+ SingleForeignEnum = 0,
+ SingleForeignMessage = null,
+ };
+ expected.RepeatedDouble.Clear();
+
+ Assert.AreEqual(expected, message);
+
+ // Separately, maps.
+ var mapMessage = new TestMap { MapStringString = { { "key1", "value1" }, { "key2", "value2" } } };
+ fields = TestMap.Descriptor.Fields;
+ fields[TestMap.MapStringStringFieldNumber].Accessor.Clear(mapMessage);
+ Assert.AreEqual(0, mapMessage.MapStringString.Count);
+ }
+
+ [Test]
+ public void SetValue_SingleFields()
+ {
+ // Just a sample (primitives, messages, enums, strings, byte strings)
+ var message = SampleMessages.CreateFullTestAllTypes();
+ var fields = TestAllTypes.Descriptor.Fields;
+ fields[TestAllTypes.SingleBoolFieldNumber].Accessor.SetValue(message, false);
+ fields[TestAllTypes.SingleInt32FieldNumber].Accessor.SetValue(message, 500);
+ fields[TestAllTypes.SingleStringFieldNumber].Accessor.SetValue(message, "It's a string");
+ fields[TestAllTypes.SingleBytesFieldNumber].Accessor.SetValue(message, ByteString.CopyFrom(99, 98, 97));
+ fields[TestAllTypes.SingleForeignEnumFieldNumber].Accessor.SetValue(message, ForeignEnum.ForeignFoo);
+ fields[TestAllTypes.SingleForeignMessageFieldNumber].Accessor.SetValue(message, new ForeignMessage { C = 12345 });
+ fields[TestAllTypes.SingleDoubleFieldNumber].Accessor.SetValue(message, 20150701.5);
+
+ var expected = new TestAllTypes(SampleMessages.CreateFullTestAllTypes())
+ {
+ SingleBool = false,
+ SingleInt32 = 500,
+ SingleString = "It's a string",
+ SingleBytes = ByteString.CopyFrom(99, 98, 97),
+ SingleForeignEnum = ForeignEnum.ForeignFoo,
+ SingleForeignMessage = new ForeignMessage { C = 12345 },
+ SingleDouble = 20150701.5
+ };
+
+ Assert.AreEqual(expected, message);
+ }
+
+ [Test]
+ public void SetValue_SingleFields_WrongType()
+ {
+ IMessage message = SampleMessages.CreateFullTestAllTypes();
+ var fields = message.Descriptor.Fields;
+ Assert.Throws<InvalidCastException>(() => fields[TestAllTypes.SingleBoolFieldNumber].Accessor.SetValue(message, "This isn't a bool"));
+ }
+
+ [Test]
+ public void SetValue_MapFields()
+ {
+ IMessage message = new TestMap();
+ var fields = message.Descriptor.Fields;
+ Assert.Throws<InvalidOperationException>(() => fields[TestMap.MapStringStringFieldNumber].Accessor.SetValue(message, new Dictionary<string, string>()));
+ }
+
+ [Test]
+ public void SetValue_RepeatedFields()
+ {
+ IMessage message = SampleMessages.CreateFullTestAllTypes();
+ var fields = message.Descriptor.Fields;
+ Assert.Throws<InvalidOperationException>(() => fields[TestAllTypes.RepeatedDoubleFieldNumber].Accessor.SetValue(message, new double[10]));
+ }
+
+ [Test]
+ public void GetValue_IncorrectType()
+ {
+ IMessage message = SampleMessages.CreateFullTestAllTypes();
+ var fields = message.Descriptor.Fields;
+ Assert.Throws<InvalidCastException>(() => fields[TestAllTypes.SingleBoolFieldNumber].Accessor.GetValue(new TestMap()));
+ }
+
+ [Test]
+ public void Oneof()
+ {
+ var message = new TestAllTypes();
+ var descriptor = TestAllTypes.Descriptor;
+ Assert.AreEqual(1, descriptor.Oneofs.Count);
+ var oneof = descriptor.Oneofs[0];
+ Assert.AreEqual("oneof_field", oneof.Name);
+ Assert.IsNull(oneof.Accessor.GetCaseFieldDescriptor(message));
+
+ message.OneofString = "foo";
+ Assert.AreSame(descriptor.Fields[TestAllTypes.OneofStringFieldNumber], oneof.Accessor.GetCaseFieldDescriptor(message));
+
+ message.OneofUint32 = 10;
+ Assert.AreSame(descriptor.Fields[TestAllTypes.OneofUint32FieldNumber], oneof.Accessor.GetCaseFieldDescriptor(message));
+
+ oneof.Accessor.Clear(message);
+ Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase);
+ }
+
+ [Test]
+ public void FieldDescriptor_ByName()
+ {
+ var descriptor = TestAllTypes.Descriptor;
+ Assert.AreSame(
+ descriptor.Fields[TestAllTypes.SingleBoolFieldNumber],
+ descriptor.Fields["single_bool"]);
+ }
+
+ [Test]
+ public void FieldDescriptor_NotFound()
+ {
+ var descriptor = TestAllTypes.Descriptor;
+ Assert.Throws<KeyNotFoundException>(() => descriptor.Fields[999999].ToString());
+ Assert.Throws<KeyNotFoundException>(() => descriptor.Fields["not found"].ToString());
+ }
+ }
+}
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Reflection/TypeRegistryTest.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Reflection/TypeRegistryTest.cs
new file mode 100644
index 00000000..5be7ca23
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/Reflection/TypeRegistryTest.cs
@@ -0,0 +1,94 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2015 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using Google.Protobuf.TestProtos;
+using Google.Protobuf.WellKnownTypes;
+using NUnit.Framework;
+
+namespace Google.Protobuf.Reflection
+{
+ public class TypeRegistryTest
+ {
+ // Most of our tests use messages. Simple test that we really can use files...
+ [Test]
+ public void CreateWithFileDescriptor()
+ {
+ var registry = TypeRegistry.FromFiles(DurationReflection.Descriptor, StructReflection.Descriptor);
+ AssertDescriptorPresent(registry, Duration.Descriptor);
+ AssertDescriptorPresent(registry, ListValue.Descriptor);
+ AssertDescriptorAbsent(registry, Timestamp.Descriptor);
+ }
+
+ [Test]
+ public void TypesFromSameFile()
+ {
+ // Just for kicks, let's start with a nested type
+ var registry = TypeRegistry.FromMessages(TestAllTypes.Types.NestedMessage.Descriptor);
+ // Top-level...
+ AssertDescriptorPresent(registry, TestFieldOrderings.Descriptor);
+ // ... and nested (not the same as the original NestedMessage!)
+ AssertDescriptorPresent(registry, TestFieldOrderings.Types.NestedMessage.Descriptor);
+ }
+
+ [Test]
+ public void DependenciesAreIncluded()
+ {
+ var registry = TypeRegistry.FromMessages(TestAllTypes.Descriptor);
+ // Direct dependencies
+ AssertDescriptorPresent(registry, ImportMessage.Descriptor);
+ // Public dependencies
+ AssertDescriptorPresent(registry, PublicImportMessage.Descriptor);
+ }
+
+ [Test]
+ public void DuplicateFiles()
+ {
+ // Duplicates via dependencies and simply via repetition
+ var registry = TypeRegistry.FromFiles(
+ UnittestProto3Reflection.Descriptor, UnittestImportProto3Reflection.Descriptor,
+ TimestampReflection.Descriptor, TimestampReflection.Descriptor);
+ AssertDescriptorPresent(registry, TestAllTypes.Descriptor);
+ AssertDescriptorPresent(registry, ImportMessage.Descriptor);
+ AssertDescriptorPresent(registry, Timestamp.Descriptor);
+ }
+
+ private static void AssertDescriptorPresent(TypeRegistry registry, MessageDescriptor descriptor)
+ {
+ Assert.AreSame(descriptor, registry.Find(descriptor.FullName));
+ }
+
+ private static void AssertDescriptorAbsent(TypeRegistry registry, MessageDescriptor descriptor)
+ {
+ Assert.IsNull(registry.Find(descriptor.FullName));
+ }
+ }
+}
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/SampleEnum.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/SampleEnum.cs
new file mode 100644
index 00000000..77447afa
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/SampleEnum.cs
@@ -0,0 +1,42 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2015 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+namespace Google.Protobuf
+{
+ // Just a sample enum with positive and negative values to be used in tests.
+ internal enum SampleEnum
+ {
+ NegativeValue = -2,
+ None = 0,
+ PositiveValue = 3
+ }
+}
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/SampleMessages.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/SampleMessages.cs
new file mode 100644
index 00000000..ffa4e2a7
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/SampleMessages.cs
@@ -0,0 +1,99 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2015 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using System;
+using Google.Protobuf.TestProtos;
+
+namespace Google.Protobuf
+{
+ /// <summary>
+ /// Helper methods to create sample instances of types generated from unit test messages.
+ /// </summary>
+ public class SampleMessages
+ {
+ /// <summary>
+ /// Creates a new sample TestAllTypes message with all fields populated.
+ /// The "oneof" field is populated with the string property (OneofString).
+ /// </summary>
+ public static TestAllTypes CreateFullTestAllTypes()
+ {
+ return new TestAllTypes
+ {
+ SingleBool = true,
+ SingleBytes = ByteString.CopyFrom(1, 2, 3, 4),
+ SingleDouble = 23.5,
+ SingleFixed32 = 23,
+ SingleFixed64 = 1234567890123,
+ SingleFloat = 12.25f,
+ SingleForeignEnum = ForeignEnum.ForeignBar,
+ SingleForeignMessage = new ForeignMessage { C = 10 },
+ SingleImportEnum = ImportEnum.ImportBaz,
+ SingleImportMessage = new ImportMessage { D = 20 },
+ SingleInt32 = 100,
+ SingleInt64 = 3210987654321,
+ SingleNestedEnum = TestAllTypes.Types.NestedEnum.Foo,
+ SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 35 },
+ SinglePublicImportMessage = new PublicImportMessage { E = 54 },
+ SingleSfixed32 = -123,
+ SingleSfixed64 = -12345678901234,
+ SingleSint32 = -456,
+ SingleSint64 = -12345678901235,
+ SingleString = "test",
+ SingleUint32 = UInt32.MaxValue,
+ SingleUint64 = UInt64.MaxValue,
+ RepeatedBool = { true, false },
+ RepeatedBytes = { ByteString.CopyFrom(1, 2, 3, 4), ByteString.CopyFrom(5, 6), ByteString.CopyFrom(new byte[1000]) },
+ RepeatedDouble = { -12.25, 23.5 },
+ RepeatedFixed32 = { UInt32.MaxValue, 23 },
+ RepeatedFixed64 = { UInt64.MaxValue, 1234567890123 },
+ RepeatedFloat = { 100f, 12.25f },
+ RepeatedForeignEnum = { ForeignEnum.ForeignFoo, ForeignEnum.ForeignBar },
+ RepeatedForeignMessage = { new ForeignMessage(), new ForeignMessage { C = 10 } },
+ RepeatedImportEnum = { ImportEnum.ImportBaz, ImportEnum.Unspecified },
+ RepeatedImportMessage = { new ImportMessage { D = 20 }, new ImportMessage { D = 25 } },
+ RepeatedInt32 = { 100, 200 },
+ RepeatedInt64 = { 3210987654321, Int64.MaxValue },
+ RepeatedNestedEnum = { TestAllTypes.Types.NestedEnum.Foo, TestAllTypes.Types.NestedEnum.Neg },
+ RepeatedNestedMessage = { new TestAllTypes.Types.NestedMessage { Bb = 35 }, new TestAllTypes.Types.NestedMessage { Bb = 10 } },
+ RepeatedPublicImportMessage = { new PublicImportMessage { E = 54 }, new PublicImportMessage { E = -1 } },
+ RepeatedSfixed32 = { -123, 123 },
+ RepeatedSfixed64 = { -12345678901234, 12345678901234 },
+ RepeatedSint32 = { -456, 100 },
+ RepeatedSint64 = { -12345678901235, 123 },
+ RepeatedString = { "foo", "bar" },
+ RepeatedUint32 = { UInt32.MaxValue, UInt32.MinValue },
+ RepeatedUint64 = { UInt64.MaxValue, UInt32.MinValue },
+ OneofString = "Oneof string"
+ };
+ }
+ }
+} \ No newline at end of file
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/TestCornerCases.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/TestCornerCases.cs
new file mode 100644
index 00000000..248f5fa9
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/TestCornerCases.cs
@@ -0,0 +1,62 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using UnitTest.Issues.TestProtos;
+using NUnit.Framework;
+
+namespace Google.Protobuf
+{
+ public class TestCornerCases
+ {
+ [Test]
+ public void TestRoundTripNegativeEnums()
+ {
+ NegativeEnumMessage msg = new NegativeEnumMessage
+ {
+ Value = NegativeEnum.MinusOne,
+ Values = { NegativeEnum.Zero, NegativeEnum.MinusOne, NegativeEnum.FiveBelow },
+ PackedValues = { NegativeEnum.Zero, NegativeEnum.MinusOne, NegativeEnum.FiveBelow }
+ };
+
+ Assert.AreEqual(58, msg.CalculateSize());
+
+ byte[] bytes = new byte[58];
+ CodedOutputStream output = new CodedOutputStream(bytes);
+
+ msg.WriteTo(output);
+ Assert.AreEqual(0, output.SpaceLeft);
+
+ NegativeEnumMessage copy = NegativeEnumMessage.Parser.ParseFrom(bytes);
+ Assert.AreEqual(msg, copy);
+ }
+ }
+}
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/TestProtos/ForeignMessagePartial.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/TestProtos/ForeignMessagePartial.cs
new file mode 100644
index 00000000..5663a699
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/TestProtos/ForeignMessagePartial.cs
@@ -0,0 +1,45 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+namespace Google.Protobuf.TestProtos
+{
+ /// <summary>
+ /// A message with custom diagnostics (to test that they work).
+ /// </summary>
+ public partial class ForeignMessage : ICustomDiagnosticMessage
+ {
+ public string ToDiagnosticString()
+ {
+ return $"{{ \"c\": {C}, \"@cInHex\": \"{C:x}\" }}";
+ }
+ }
+}
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs
new file mode 100644
index 00000000..4aecc998
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs
@@ -0,0 +1,116 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2015 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using Google.Protobuf.TestProtos;
+using NUnit.Framework;
+
+namespace Google.Protobuf.WellKnownTypes
+{
+ public class AnyTest
+ {
+ [Test]
+ public void Pack()
+ {
+ var message = SampleMessages.CreateFullTestAllTypes();
+ var any = Any.Pack(message);
+ Assert.AreEqual("type.googleapis.com/protobuf_unittest.TestAllTypes", any.TypeUrl);
+ Assert.AreEqual(message.CalculateSize(), any.Value.Length);
+ }
+
+ [Test]
+ public void Pack_WithCustomPrefix()
+ {
+ var message = SampleMessages.CreateFullTestAllTypes();
+ var any = Any.Pack(message, "foo.bar/baz");
+ Assert.AreEqual("foo.bar/baz/protobuf_unittest.TestAllTypes", any.TypeUrl);
+ Assert.AreEqual(message.CalculateSize(), any.Value.Length);
+ }
+
+ [Test]
+ public void Pack_WithCustomPrefixTrailingSlash()
+ {
+ var message = SampleMessages.CreateFullTestAllTypes();
+ var any = Any.Pack(message, "foo.bar/baz/");
+ Assert.AreEqual("foo.bar/baz/protobuf_unittest.TestAllTypes", any.TypeUrl);
+ Assert.AreEqual(message.CalculateSize(), any.Value.Length);
+ }
+
+ [Test]
+ public void Unpack_WrongType()
+ {
+ var message = SampleMessages.CreateFullTestAllTypes();
+ var any = Any.Pack(message);
+ Assert.Throws<InvalidProtocolBufferException>(() => any.Unpack<TestOneof>());
+ }
+
+ [Test]
+ public void Unpack_Success()
+ {
+ var message = SampleMessages.CreateFullTestAllTypes();
+ var any = Any.Pack(message);
+ var unpacked = any.Unpack<TestAllTypes>();
+ Assert.AreEqual(message, unpacked);
+ }
+
+ [Test]
+ public void Unpack_CustomPrefix_Success()
+ {
+ var message = SampleMessages.CreateFullTestAllTypes();
+ var any = Any.Pack(message, "foo.bar/baz");
+ var unpacked = any.Unpack<TestAllTypes>();
+ Assert.AreEqual(message, unpacked);
+ }
+
+ [Test]
+ public void ToString_WithValues()
+ {
+ var message = SampleMessages.CreateFullTestAllTypes();
+ var any = Any.Pack(message);
+ var text = any.ToString();
+ Assert.That(text, Does.Contain("\"@value\": \"" + message.ToByteString().ToBase64() + "\""));
+ }
+
+ [Test]
+ public void ToString_Empty()
+ {
+ var any = new Any();
+ Assert.AreEqual("{ \"@type\": \"\", \"@value\": \"\" }", any.ToString());
+ }
+
+ [Test]
+ public void ToString_MessageContainingAny()
+ {
+ var message = new TestWellKnownTypes { AnyField = new Any() };
+ Assert.AreEqual("{ \"anyField\": { \"@type\": \"\", \"@value\": \"\" } }", message.ToString());
+ }
+ }
+}
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/DurationTest.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/DurationTest.cs
new file mode 100644
index 00000000..141faf80
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/DurationTest.cs
@@ -0,0 +1,132 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2015 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using NUnit.Framework;
+using System;
+
+namespace Google.Protobuf.WellKnownTypes
+{
+ public class DurationTest
+ {
+ [Test]
+ public void ToTimeSpan()
+ {
+ Assert.AreEqual(TimeSpan.FromSeconds(1), new Duration { Seconds = 1 }.ToTimeSpan());
+ Assert.AreEqual(TimeSpan.FromSeconds(-1), new Duration { Seconds = -1 }.ToTimeSpan());
+ Assert.AreEqual(TimeSpan.FromMilliseconds(1), new Duration { Nanos = 1000000 }.ToTimeSpan());
+ Assert.AreEqual(TimeSpan.FromMilliseconds(-1), new Duration { Nanos = -1000000 }.ToTimeSpan());
+ Assert.AreEqual(TimeSpan.FromTicks(1), new Duration { Nanos = 100 }.ToTimeSpan());
+ Assert.AreEqual(TimeSpan.FromTicks(-1), new Duration { Nanos = -100 }.ToTimeSpan());
+
+ // Rounding is towards 0
+ Assert.AreEqual(TimeSpan.FromTicks(2), new Duration { Nanos = 250 }.ToTimeSpan());
+ Assert.AreEqual(TimeSpan.FromTicks(-2), new Duration { Nanos = -250 }.ToTimeSpan());
+ }
+
+ [Test]
+ public void Addition()
+ {
+ Assert.AreEqual(new Duration { Seconds = 2, Nanos = 100000000 },
+ new Duration { Seconds = 1, Nanos = 600000000 } + new Duration { Nanos = 500000000 });
+ Assert.AreEqual(new Duration { Seconds = -2, Nanos = -100000000 },
+ new Duration { Seconds = -1, Nanos = -600000000 } + new Duration { Nanos = -500000000 });
+ Assert.AreEqual(new Duration { Seconds = 1, Nanos = 100000000 },
+ new Duration { Seconds = 1, Nanos = 600000000 } + new Duration { Nanos = -500000000 });
+
+ // Non-normalized durations, or non-normalized intermediate results
+ Assert.AreEqual(new Duration { Seconds = 1 },
+ new Duration { Seconds = 1, Nanos = -500000000 } + new Duration { Nanos = 500000000 });
+
+ Assert.AreEqual(new Duration { Nanos = -900000000 },
+ new Duration { Seconds = -1, Nanos = -100000000 } + new Duration { Nanos = 200000000 });
+ Assert.AreEqual(new Duration { Nanos = 900000000 },
+ new Duration { Seconds = 1, Nanos = 100000000 } + new Duration { Nanos = -200000000 });
+ }
+
+ [Test]
+ public void Subtraction()
+ {
+ Assert.AreEqual(new Duration { Seconds = 1, Nanos = 100000000 },
+ new Duration { Seconds = 1, Nanos = 600000000 } - new Duration { Nanos = 500000000 });
+ Assert.AreEqual(new Duration { Seconds = -1, Nanos = -100000000 },
+ new Duration { Seconds = -1, Nanos = -600000000 } - new Duration { Nanos = -500000000 });
+ Assert.AreEqual(new Duration { Seconds = 2, Nanos = 100000000 },
+ new Duration { Seconds = 1, Nanos = 600000000 } - new Duration { Nanos = -500000000 });
+
+ // Non-normalized durations
+ Assert.AreEqual(new Duration(),
+ new Duration { Seconds = 1, Nanos = -500000000 } - new Duration { Nanos = 500000000 });
+ Assert.AreEqual(new Duration { Seconds = 1 },
+ new Duration { Nanos = 2000000000 } - new Duration { Nanos = 1000000000 });
+ }
+
+ [Test]
+ public void FromTimeSpan()
+ {
+ Assert.AreEqual(new Duration { Seconds = 1 }, Duration.FromTimeSpan(TimeSpan.FromSeconds(1)));
+ Assert.AreEqual(new Duration { Nanos = Duration.NanosecondsPerTick }, Duration.FromTimeSpan(TimeSpan.FromTicks(1)));
+ }
+
+ [Test]
+ [TestCase(0, Duration.MaxNanoseconds + 1)]
+ [TestCase(0, Duration.MinNanoseconds - 1)]
+ [TestCase(Duration.MinSeconds - 1, 0)]
+ [TestCase(Duration.MaxSeconds + 1, 0)]
+ [TestCase(1, -1)]
+ [TestCase(-1, 1)]
+ public void ToTimeSpan_Invalid(long seconds, int nanoseconds)
+ {
+ var duration = new Duration { Seconds = seconds, Nanos = nanoseconds };
+ Assert.Throws<InvalidOperationException>(() => duration.ToTimeSpan());
+ }
+
+ [Test]
+ [TestCase(0, Duration.MaxNanoseconds)]
+ [TestCase(0, Duration.MinNanoseconds)]
+ [TestCase(Duration.MinSeconds, Duration.MinNanoseconds)]
+ [TestCase(Duration.MaxSeconds, Duration.MaxNanoseconds)]
+ public void ToTimeSpan_Valid(long seconds, int nanoseconds)
+ {
+ // Only testing that these values don't throw, unlike their similar tests in ToTimeSpan_Invalid
+ var duration = new Duration { Seconds = seconds, Nanos = nanoseconds };
+ duration.ToTimeSpan();
+ }
+
+ [Test]
+ public void ToString_NonNormalized()
+ {
+ // Just a single example should be sufficient...
+ var duration = new Duration { Seconds = 1, Nanos = -1 };
+ Assert.AreEqual("{ \"@warning\": \"Invalid Duration\", \"seconds\": \"1\", \"nanos\": -1 }", duration.ToString());
+ }
+ }
+}
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/FieldMaskTest.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/FieldMaskTest.cs
new file mode 100644
index 00000000..1d9908b4
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/FieldMaskTest.cs
@@ -0,0 +1,62 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+
+using NUnit.Framework;
+
+namespace Google.Protobuf.WellKnownTypes
+{
+ public class FieldMaskTest
+ {
+ [Test]
+ [TestCase("foo__bar")]
+ [TestCase("foo_3_ar")]
+ [TestCase("fooBar")]
+ public void ToString_Invalid(string input)
+ {
+ var mask = new FieldMask { Paths = { input } };
+ var text = mask.ToString();
+ // More specific test below
+ Assert.That(text, Does.Contain("@warning"));
+ Assert.That(text, Does.Contain(input));
+ }
+
+ [Test]
+ public void ToString_Invalid_Precise()
+ {
+ var mask = new FieldMask { Paths = { "x", "foo__bar", @"x\y" } };
+ Assert.AreEqual(
+ "{ \"@warning\": \"Invalid FieldMask\", \"paths\": [ \"x\", \"foo__bar\", \"x\\\\y\" ] }",
+ mask.ToString());
+ }
+ }
+}
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs
new file mode 100644
index 00000000..9ecd24c6
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs
@@ -0,0 +1,115 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2015 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using NUnit.Framework;
+using System;
+
+namespace Google.Protobuf.WellKnownTypes
+{
+ public class TimestampTest
+ {
+ [Test]
+ public void FromAndToDateTime()
+ {
+ DateTime utcMin = DateTime.SpecifyKind(DateTime.MinValue, DateTimeKind.Utc);
+ DateTime utcMax = DateTime.SpecifyKind(DateTime.MaxValue, DateTimeKind.Utc);
+ AssertRoundtrip(new Timestamp { Seconds = -62135596800 }, utcMin);
+ AssertRoundtrip(new Timestamp { Seconds = 253402300799, Nanos = 999999900 }, utcMax);
+ AssertRoundtrip(new Timestamp(), new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc));
+ AssertRoundtrip(new Timestamp { Nanos = 1000000}, new DateTime(1970, 1, 1, 0, 0, 0, 1, DateTimeKind.Utc));
+ AssertRoundtrip(new Timestamp { Seconds = -1, Nanos = 999000000 }, new DateTime(1969, 12, 31, 23, 59, 59, 999, DateTimeKind.Utc));
+ AssertRoundtrip(new Timestamp { Seconds = 3600 }, new DateTime(1970, 1, 1, 1, 0, 0, DateTimeKind.Utc));
+ AssertRoundtrip(new Timestamp { Seconds = -3600 }, new DateTime(1969, 12, 31, 23, 0, 0, DateTimeKind.Utc));
+ }
+
+ [Test]
+ public void ToDateTimeTruncation()
+ {
+ var t1 = new Timestamp { Seconds = 1, Nanos = 1000000 + Duration.NanosecondsPerTick - 1 };
+ Assert.AreEqual(new DateTime(1970, 1, 1, 0, 0, 1, DateTimeKind.Utc).AddMilliseconds(1), t1.ToDateTime());
+
+ var t2 = new Timestamp { Seconds = -1, Nanos = 1000000 + Duration.NanosecondsPerTick - 1 };
+ Assert.AreEqual(new DateTime(1969, 12, 31, 23, 59, 59).AddMilliseconds(1), t2.ToDateTime());
+ }
+
+ [Test]
+ [TestCase(Timestamp.UnixSecondsAtBclMinValue - 1, Timestamp.MaxNanos)]
+ [TestCase(Timestamp.UnixSecondsAtBclMaxValue + 1, 0)]
+ [TestCase(0, -1)]
+ [TestCase(0, Timestamp.MaxNanos + 1)]
+ public void ToDateTime_OutOfRange(long seconds, int nanoseconds)
+ {
+ var value = new Timestamp { Seconds = seconds, Nanos = nanoseconds };
+ Assert.Throws<InvalidOperationException>(() => value.ToDateTime());
+ }
+
+ // 1ns larger or smaller than the above values
+ [Test]
+ [TestCase(Timestamp.UnixSecondsAtBclMinValue, 0)]
+ [TestCase(Timestamp.UnixSecondsAtBclMaxValue, Timestamp.MaxNanos)]
+ [TestCase(0, 0)]
+ [TestCase(0, Timestamp.MaxNanos)]
+ public void ToDateTime_ValidBoundaries(long seconds, int nanoseconds)
+ {
+ var value = new Timestamp { Seconds = seconds, Nanos = nanoseconds };
+ value.ToDateTime();
+ }
+
+ private static void AssertRoundtrip(Timestamp timestamp, DateTime dateTime)
+ {
+ Assert.AreEqual(timestamp, Timestamp.FromDateTime(dateTime));
+ Assert.AreEqual(dateTime, timestamp.ToDateTime());
+ Assert.AreEqual(DateTimeKind.Utc, timestamp.ToDateTime().Kind);
+ }
+
+ [Test]
+ public void Arithmetic()
+ {
+ Timestamp t1 = new Timestamp { Seconds = 10000, Nanos = 5000 };
+ Timestamp t2 = new Timestamp { Seconds = 8000, Nanos = 10000 };
+ Duration difference = new Duration { Seconds = 1999, Nanos = Duration.NanosecondsPerSecond - 5000 };
+ Assert.AreEqual(difference, t1 - t2);
+ Assert.AreEqual(-difference, t2 - t1);
+
+ Assert.AreEqual(t1, t2 + difference);
+ Assert.AreEqual(t2, t1 - difference);
+ }
+
+ [Test]
+ public void ToString_NonNormalized()
+ {
+ // Just a single example should be sufficient...
+ var duration = new Timestamp { Seconds = 1, Nanos = -1 };
+ Assert.AreEqual("{ \"@warning\": \"Invalid Timestamp\", \"seconds\": \"1\", \"nanos\": -1 }", duration.ToString());
+ }
+ }
+}
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs
new file mode 100644
index 00000000..5b7185dc
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs
@@ -0,0 +1,421 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2015 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using System;
+using Google.Protobuf.TestProtos;
+using NUnit.Framework;
+using System.Collections;
+using System.IO;
+
+namespace Google.Protobuf.WellKnownTypes
+{
+ public class WrappersTest
+ {
+ [Test]
+ public void NullIsDefault()
+ {
+ var message = new TestWellKnownTypes();
+ Assert.IsNull(message.StringField);
+ Assert.IsNull(message.BytesField);
+ Assert.IsNull(message.BoolField);
+ Assert.IsNull(message.FloatField);
+ Assert.IsNull(message.DoubleField);
+ Assert.IsNull(message.Int32Field);
+ Assert.IsNull(message.Int64Field);
+ Assert.IsNull(message.Uint32Field);
+ Assert.IsNull(message.Uint64Field);
+ }
+
+ [Test]
+ public void NonDefaultSingleValues()
+ {
+ var message = new TestWellKnownTypes
+ {
+ StringField = "x",
+ BytesField = ByteString.CopyFrom(1, 2, 3),
+ BoolField = true,
+ FloatField = 12.5f,
+ DoubleField = 12.25d,
+ Int32Field = 1,
+ Int64Field = 2,
+ Uint32Field = 3,
+ Uint64Field = 4
+ };
+
+ var bytes = message.ToByteArray();
+ var parsed = TestWellKnownTypes.Parser.ParseFrom(bytes);
+
+ Assert.AreEqual("x", parsed.StringField);
+ Assert.AreEqual(ByteString.CopyFrom(1, 2, 3), parsed.BytesField);
+ Assert.AreEqual(true, parsed.BoolField);
+ Assert.AreEqual(12.5f, parsed.FloatField);
+ Assert.AreEqual(12.25d, parsed.DoubleField);
+ Assert.AreEqual(1, parsed.Int32Field);
+ Assert.AreEqual(2L, parsed.Int64Field);
+ Assert.AreEqual(3U, parsed.Uint32Field);
+ Assert.AreEqual(4UL, parsed.Uint64Field);
+ }
+
+ [Test]
+ public void NonNullDefaultIsPreservedThroughSerialization()
+ {
+ var message = new TestWellKnownTypes
+ {
+ StringField = "",
+ BytesField = ByteString.Empty,
+ BoolField = false,
+ FloatField = 0f,
+ DoubleField = 0d,
+ Int32Field = 0,
+ Int64Field = 0,
+ Uint32Field = 0,
+ Uint64Field = 0
+ };
+
+ var bytes = message.ToByteArray();
+ var parsed = TestWellKnownTypes.Parser.ParseFrom(bytes);
+
+ Assert.AreEqual("", parsed.StringField);
+ Assert.AreEqual(ByteString.Empty, parsed.BytesField);
+ Assert.AreEqual(false, parsed.BoolField);
+ Assert.AreEqual(0f, parsed.FloatField);
+ Assert.AreEqual(0d, parsed.DoubleField);
+ Assert.AreEqual(0, parsed.Int32Field);
+ Assert.AreEqual(0L, parsed.Int64Field);
+ Assert.AreEqual(0U, parsed.Uint32Field);
+ Assert.AreEqual(0UL, parsed.Uint64Field);
+ }
+
+ [Test]
+ public void RepeatedWrappersProhibitNullItems()
+ {
+ var message = new RepeatedWellKnownTypes();
+ Assert.Throws<ArgumentNullException>(() => message.BoolField.Add((bool?) null));
+ Assert.Throws<ArgumentNullException>(() => message.Int32Field.Add((int?) null));
+ Assert.Throws<ArgumentNullException>(() => message.StringField.Add((string) null));
+ Assert.Throws<ArgumentNullException>(() => message.BytesField.Add((ByteString) null));
+ }
+
+ [Test]
+ public void RepeatedWrappersSerializeDeserialize()
+ {
+ var message = new RepeatedWellKnownTypes
+ {
+ BoolField = { true, false },
+ BytesField = { ByteString.CopyFrom(1, 2, 3), ByteString.CopyFrom(4, 5, 6), ByteString.Empty },
+ DoubleField = { 12.5, -1.5, 0d },
+ FloatField = { 123.25f, -20f, 0f },
+ Int32Field = { int.MaxValue, int.MinValue, 0 },
+ Int64Field = { long.MaxValue, long.MinValue, 0L },
+ StringField = { "First", "Second", "" },
+ Uint32Field = { uint.MaxValue, uint.MinValue, 0U },
+ Uint64Field = { ulong.MaxValue, ulong.MinValue, 0UL },
+ };
+ var bytes = message.ToByteArray();
+ var parsed = RepeatedWellKnownTypes.Parser.ParseFrom(bytes);
+
+ Assert.AreEqual(message, parsed);
+ // Just to test a single value for sanity...
+ Assert.AreEqual("Second", message.StringField[1]);
+ }
+
+ [Test]
+ public void RepeatedWrappersBinaryFormat()
+ {
+ // At one point we accidentally used a packed format for repeated wrappers, which is wrong (and weird).
+ // This test is just to prove that we use the right format.
+
+ var rawOutput = new MemoryStream();
+ var output = new CodedOutputStream(rawOutput);
+ // Write a value of 5
+ output.WriteTag(RepeatedWellKnownTypes.Int32FieldFieldNumber, WireFormat.WireType.LengthDelimited);
+ output.WriteLength(2);
+ output.WriteTag(WrappersReflection.WrapperValueFieldNumber, WireFormat.WireType.Varint);
+ output.WriteInt32(5);
+ // Write a value of 0 (empty message)
+ output.WriteTag(RepeatedWellKnownTypes.Int32FieldFieldNumber, WireFormat.WireType.LengthDelimited);
+ output.WriteLength(0);
+ output.Flush();
+ var expectedBytes = rawOutput.ToArray();
+
+ var message = new RepeatedWellKnownTypes { Int32Field = { 5, 0 } };
+ var actualBytes = message.ToByteArray();
+ Assert.AreEqual(expectedBytes, actualBytes);
+ }
+
+ [Test]
+ public void MapWrappersSerializeDeserialize()
+ {
+ // Note: no null values here, as they are prohibited in map fields
+ // (despite being representable).
+ var message = new MapWellKnownTypes
+ {
+ BoolField = { { 10, false }, { 20, true } },
+ BytesField = {
+ { -1, ByteString.CopyFrom(1, 2, 3) },
+ { 10, ByteString.CopyFrom(4, 5, 6) },
+ { 1000, ByteString.Empty },
+ },
+ DoubleField = { { 1, 12.5 }, { 10, -1.5 }, { 20, 0d } },
+ FloatField = { { 2, 123.25f }, { 3, -20f }, { 4, 0f } },
+ Int32Field = { { 5, int.MaxValue }, { 6, int.MinValue }, { 7, 0 } },
+ Int64Field = { { 8, long.MaxValue }, { 9, long.MinValue }, { 10, 0L } },
+ StringField = { { 11, "First" }, { 12, "Second" }, { 13, "" } },
+ Uint32Field = { { 15, uint.MaxValue }, { 16, uint.MinValue }, { 17, 0U } },
+ Uint64Field = { { 18, ulong.MaxValue }, { 19, ulong.MinValue }, { 20, 0UL } },
+ };
+
+ var bytes = message.ToByteArray();
+ var parsed = MapWellKnownTypes.Parser.ParseFrom(bytes);
+
+ Assert.AreEqual(message, parsed);
+ // Just to test a single value for sanity...
+ Assert.AreEqual("Second", message.StringField[12]);
+ }
+
+ [Test]
+ public void Reflection_SingleValues()
+ {
+ var message = new TestWellKnownTypes
+ {
+ StringField = "x",
+ BytesField = ByteString.CopyFrom(1, 2, 3),
+ BoolField = true,
+ FloatField = 12.5f,
+ DoubleField = 12.25d,
+ Int32Field = 1,
+ Int64Field = 2,
+ Uint32Field = 3,
+ Uint64Field = 4
+ };
+ var fields = TestWellKnownTypes.Descriptor.Fields;
+
+ Assert.AreEqual("x", fields[TestWellKnownTypes.StringFieldFieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(ByteString.CopyFrom(1, 2, 3), fields[TestWellKnownTypes.BytesFieldFieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(true, fields[TestWellKnownTypes.BoolFieldFieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(12.5f, fields[TestWellKnownTypes.FloatFieldFieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(12.25d, fields[TestWellKnownTypes.DoubleFieldFieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(1, fields[TestWellKnownTypes.Int32FieldFieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(2L, fields[TestWellKnownTypes.Int64FieldFieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(3U, fields[TestWellKnownTypes.Uint32FieldFieldNumber].Accessor.GetValue(message));
+ Assert.AreEqual(4UL, fields[TestWellKnownTypes.Uint64FieldFieldNumber].Accessor.GetValue(message));
+
+ // And a couple of null fields...
+ message.StringField = null;
+ message.FloatField = null;
+ Assert.IsNull(fields[TestWellKnownTypes.StringFieldFieldNumber].Accessor.GetValue(message));
+ Assert.IsNull(fields[TestWellKnownTypes.FloatFieldFieldNumber].Accessor.GetValue(message));
+ }
+
+ [Test]
+ public void Reflection_RepeatedFields()
+ {
+ // Just a single example... note that we can't have a null value here
+ var message = new RepeatedWellKnownTypes { Int32Field = { 1, 2 } };
+ var fields = RepeatedWellKnownTypes.Descriptor.Fields;
+ var list = (IList) fields[RepeatedWellKnownTypes.Int32FieldFieldNumber].Accessor.GetValue(message);
+ CollectionAssert.AreEqual(new[] { 1, 2 }, list);
+ }
+
+ [Test]
+ public void Reflection_MapFields()
+ {
+ // Just a single example... note that we can't have a null value here despite the value type being int?
+ var message = new MapWellKnownTypes { Int32Field = { { 1, 2 } } };
+ var fields = MapWellKnownTypes.Descriptor.Fields;
+ var dictionary = (IDictionary) fields[MapWellKnownTypes.Int32FieldFieldNumber].Accessor.GetValue(message);
+ Assert.AreEqual(2, dictionary[1]);
+ }
+
+ [Test]
+ public void Oneof()
+ {
+ var message = new OneofWellKnownTypes { EmptyField = new Empty() };
+ // Start off with a non-wrapper
+ Assert.AreEqual(OneofWellKnownTypes.OneofFieldOneofCase.EmptyField, message.OneofFieldCase);
+ AssertOneofRoundTrip(message);
+
+ message.StringField = "foo";
+ Assert.AreEqual(OneofWellKnownTypes.OneofFieldOneofCase.StringField, message.OneofFieldCase);
+ AssertOneofRoundTrip(message);
+
+ message.StringField = "foo";
+ Assert.AreEqual(OneofWellKnownTypes.OneofFieldOneofCase.StringField, message.OneofFieldCase);
+ AssertOneofRoundTrip(message);
+
+ message.DoubleField = 0.0f;
+ Assert.AreEqual(OneofWellKnownTypes.OneofFieldOneofCase.DoubleField, message.OneofFieldCase);
+ AssertOneofRoundTrip(message);
+
+ message.DoubleField = 1.0f;
+ Assert.AreEqual(OneofWellKnownTypes.OneofFieldOneofCase.DoubleField, message.OneofFieldCase);
+ AssertOneofRoundTrip(message);
+
+ message.ClearOneofField();
+ Assert.AreEqual(OneofWellKnownTypes.OneofFieldOneofCase.None, message.OneofFieldCase);
+ AssertOneofRoundTrip(message);
+ }
+
+ private void AssertOneofRoundTrip(OneofWellKnownTypes message)
+ {
+ // Normal roundtrip, but explicitly checking the case...
+ var bytes = message.ToByteArray();
+ var parsed = OneofWellKnownTypes.Parser.ParseFrom(bytes);
+ Assert.AreEqual(message, parsed);
+ Assert.AreEqual(message.OneofFieldCase, parsed.OneofFieldCase);
+ }
+
+ [Test]
+ [TestCase("x", "y", "y")]
+ [TestCase("x", "", "x")]
+ [TestCase("x", null, "x")]
+ [TestCase("", "y", "y")]
+ [TestCase("", "", "")]
+ [TestCase("", null, "")]
+ [TestCase(null, "y", "y")]
+ [TestCase(null, "", "")]
+ [TestCase(null, null, null)]
+ public void Merging(string original, string merged, string expected)
+ {
+ var originalMessage = new TestWellKnownTypes { StringField = original };
+ var mergingMessage = new TestWellKnownTypes { StringField = merged };
+ originalMessage.MergeFrom(mergingMessage);
+ Assert.AreEqual(expected, originalMessage.StringField);
+
+ // Try it using MergeFrom(CodedInputStream) too...
+ originalMessage = new TestWellKnownTypes { StringField = original };
+ originalMessage.MergeFrom(mergingMessage.ToByteArray());
+ Assert.AreEqual(expected, originalMessage.StringField);
+ }
+
+ // Merging is odd with wrapper types, due to the way that default values aren't emitted in
+ // the binary stream. In fact we cheat a little bit - a message with an explicitly present default
+ // value will have that default value ignored. See issue 615. Fixing this would require significant upheaval to
+ // the FieldCodec side of things.
+ [Test]
+ public void MergingStreamExplicitValue()
+ {
+ var message = new TestWellKnownTypes { Int32Field = 5 };
+
+ // Create a byte array which has the data of an Int32Value explicitly containing a value of 0.
+ // This wouldn't normally happen.
+ byte[] bytes;
+ var wrapperTag = WireFormat.MakeTag(TestWellKnownTypes.Int32FieldFieldNumber, WireFormat.WireType.LengthDelimited);
+ var valueTag = WireFormat.MakeTag(Int32Value.ValueFieldNumber, WireFormat.WireType.Varint);
+ using (var stream = new MemoryStream())
+ {
+ var coded = new CodedOutputStream(stream);
+ coded.WriteTag(wrapperTag);
+ coded.WriteLength(2); // valueTag + a value 0, each one byte
+ coded.WriteTag(valueTag);
+ coded.WriteInt32(0);
+ coded.Flush();
+ bytes = stream.ToArray();
+ }
+
+ message.MergeFrom(bytes);
+ // A normal implementation would have 0 now, as the explicit default would have been overwritten the 5.
+ // With the FieldCodec for Nullable<int>, we can't tell the difference between an implicit 0 and an explicit 0.
+ Assert.AreEqual(5, message.Int32Field);
+ }
+
+ [Test]
+ public void MergingStreamNoValue()
+ {
+ var message = new TestWellKnownTypes { Int32Field = 5 };
+
+ // Create a byte array which an Int32 field, but with no value.
+ var bytes = new TestWellKnownTypes { Int32Field = 0 }.ToByteArray();
+ Assert.AreEqual(2, bytes.Length); // The tag for Int32Field is a single byte, then a byte indicating a 0-length message.
+ message.MergeFrom(bytes);
+
+ // The "implicit" 0 did *not* overwrite the value.
+ // (This is the correct behaviour.)
+ Assert.AreEqual(5, message.Int32Field);
+ }
+
+ // All permutations of origin/merging value being null, zero (default) or non-default.
+ // As this is the in-memory version, we don't need to worry about the difference between implicit and explicit 0.
+ [Test]
+ [TestCase(null, null, null)]
+ [TestCase(null, 0, 0)]
+ [TestCase(null, 5, 5)]
+ [TestCase(0, null, 0)]
+ [TestCase(0, 0, 0)]
+ [TestCase(0, 5, 5)]
+ [TestCase(5, null, 5)]
+ [TestCase(5, 0, 5)]
+ [TestCase(5, 10, 10)]
+ public void MergingMessageWithZero(int? originValue, int? mergingValue, int? expectedResult)
+ {
+ // This differs from the MergingStreamCornerCase because when we merge message *objects*,
+ // we ignore default values from the "source".
+ var message1 = new TestWellKnownTypes { Int32Field = originValue };
+ var message2 = new TestWellKnownTypes { Int32Field = mergingValue };
+ message1.MergeFrom(message2);
+ Assert.AreEqual(expectedResult, message1.Int32Field);
+ }
+
+ [Test]
+ public void UnknownFieldInWrapper()
+ {
+ var stream = new MemoryStream();
+ var output = new CodedOutputStream(stream);
+ var wrapperTag = WireFormat.MakeTag(TestWellKnownTypes.Int32FieldFieldNumber, WireFormat.WireType.LengthDelimited);
+ var unknownTag = WireFormat.MakeTag(15, WireFormat.WireType.Varint);
+ var valueTag = WireFormat.MakeTag(Int32Value.ValueFieldNumber, WireFormat.WireType.Varint);
+
+ output.WriteTag(wrapperTag);
+ output.WriteLength(4); // unknownTag + value 5 + valueType + value 6, each 1 byte
+ output.WriteTag(unknownTag);
+ output.WriteInt32((int) valueTag); // Sneakily "pretend" it's a tag when it's really a value
+ output.WriteTag(valueTag);
+ output.WriteInt32(6);
+
+ output.Flush();
+ stream.Position = 0;
+
+ var message = TestWellKnownTypes.Parser.ParseFrom(stream);
+ Assert.AreEqual(6, message.Int32Field);
+ }
+
+ [Test]
+ public void ClearWithReflection()
+ {
+ // String and Bytes are the tricky ones here, as the CLR type of the property
+ // is the same between the wrapper and non-wrapper types.
+ var message = new TestWellKnownTypes { StringField = "foo" };
+ TestWellKnownTypes.Descriptor.Fields[TestWellKnownTypes.StringFieldFieldNumber].Accessor.Clear(message);
+ Assert.IsNull(message.StringField);
+ }
+ }
+}
diff --git a/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/project.json b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/project.json
new file mode 100644
index 00000000..87b732c9
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/src/Google.Protobuf.Test/project.json
@@ -0,0 +1,44 @@
+{
+ "buildOptions": {
+ "debugType": "portable",
+ "keyFile": "../../keys/Google.Protobuf.snk"
+ },
+
+ "configurations": {
+ "Debug": {
+ "buildOptions": {
+ "define": [ "DEBUG", "TRACE" ]
+ }
+ },
+ "Release": {
+ "buildOptions": {
+ "define": [ "RELEASE", "TRACE" ],
+ "optimize": true
+ }
+ }
+ },
+
+ "dependencies": {
+ "Google.Protobuf": { "target": "project" },
+ "NUnit": "3.4.0",
+ "dotnet-test-nunit": "3.4.0-alpha-2",
+ },
+
+ "testRunner": "nunit",
+
+ "frameworks": {
+ "netcoreapp1.0": {
+ "imports" : [ "dnxcore50", "netcoreapp1.0", "portable-net45+win8" ],
+ "buildOptions": {
+ "define": [ "PCL" ]
+ },
+ "dependencies": {
+ "Microsoft.NETCore.App": {
+ "version": "1.0.0",
+ "type": "platform"
+ },
+ "System.Console": "4.0.0"
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/csharp/compatibility_tests/v3.0.0/test.sh b/csharp/compatibility_tests/v3.0.0/test.sh
new file mode 100755
index 00000000..bb04fc2c
--- /dev/null
+++ b/csharp/compatibility_tests/v3.0.0/test.sh
@@ -0,0 +1,102 @@
+#!/bin/bash
+
+function run_test() {
+ # Generate test proto files.
+ ./protoc_1 -Iprotos/src -I../../../src/ --csharp_out=src/Google.Protobuf.Test \
+ --csharp_opt=base_namespace=Google.Protobuf \
+ protos/src/google/protobuf/unittest_import_proto3.proto \
+ protos/src/google/protobuf/unittest_import_public_proto3.proto \
+ protos/src/google/protobuf/unittest_well_known_types.proto
+
+ ./protoc_1 -Iprotos/csharp --csharp_out=src/Google.Protobuf.Test \
+ --csharp_opt=base_namespace=UnitTest.Issues \
+ protos/csharp/protos/unittest_issues.proto
+
+ ./protoc_2 -Iprotos/src --csharp_out=src/Google.Protobuf.Test \
+ --csharp_opt=base_namespace=Google.Protobuf \
+ protos/src/google/protobuf/unittest_proto3.proto \
+ protos/src/google/protobuf/map_unittest_proto3.proto
+
+ # Build and test.
+ dotnet build -c release src/Google.Protobuf src/Google.Protobuf.Test
+ dotnet test -c release -f netcoreapp1.0 src/Google.Protobuf.Test
+}
+
+set -ex
+
+# Change to the script's directory.
+cd $(dirname $0)
+
+# Version of the tests (i.e., the version of protobuf from where we extracted
+# these tests).
+TEST_VERSION=3.0.0
+
+# The old version of protobuf that we are testing compatibility against. This
+# is usually the same as TEST_VERSION (i.e., we use the tests extracted from
+# that version to test compatibility of the newest runtime against it), but it
+# is also possible to use this same test set to test the compatibiilty of the
+# latest version against other versions.
+case "$1" in
+ ""|3.0.0)
+ OLD_VERSION=3.0.0
+ OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0/protoc-3.0.0-linux-x86_64.exe
+ ;;
+ 3.0.2)
+ OLD_VERSION=3.0.2
+ OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.2/protoc-3.0.2-linux-x86_64.exe
+ ;;
+ 3.1.0)
+ OLD_VERSION=3.1.0
+ OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.1.0/protoc-3.1.0-linux-x86_64.exe
+ ;;
+ *)
+ echo "[ERROR]: Unknown version number: $1"
+ exit 1
+ ;;
+esac
+
+echo "Running compatibility tests with $OLD_VERSION"
+
+# Check protoc
+[ -f ../../../src/protoc ] || {
+ echo "[ERROR]: Please build protoc first."
+ exit 1
+}
+
+# Download old version protoc compiler (for linux).
+wget $OLD_VERSION_PROTOC -O old_protoc
+chmod +x old_protoc
+
+# Test source compatibility. In these tests we recompile everything against
+# the new runtime (including old version generated code).
+# Copy the new runtime and keys.
+cp ../../src/Google.Protobuf src/Google.Protobuf -r
+cp ../../keys . -r
+dotnet restore
+
+# Test A.1:
+# proto set 1: use old version
+# proto set 2 which may import protos in set 1: use old version
+cp old_protoc protoc_1
+cp old_protoc protoc_2
+run_test
+
+# Test A.2:
+# proto set 1: use new version
+# proto set 2 which may import protos in set 1: use old version
+cp ../../../src/protoc protoc_1
+cp old_protoc protoc_2
+run_test
+
+# Test A.3:
+# proto set 1: use old version
+# proto set 2 which may import protos in set 1: use new version
+cp old_protoc protoc_1
+cp ../../../src/protoc protoc_2
+run_test
+
+rm protoc_1
+rm protoc_2
+rm old_protoc
+rm keys -r
+rm src/Google.Protobuf -r
diff --git a/csharp/generate_protos.sh b/csharp/generate_protos.sh
index d979aa52..d2f47479 100755
--- a/csharp/generate_protos.sh
+++ b/csharp/generate_protos.sh
@@ -50,9 +50,15 @@ $PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf.Test \
src/google/protobuf/unittest_well_known_types.proto
# Different base namespace to the protos above
-$PROTOC -Icsharp/protos --csharp_out=csharp/src/Google.Protobuf.Test \
+$PROTOC -Isrc -Icsharp/protos --csharp_out=csharp/src/Google.Protobuf.Test \
--csharp_opt=base_namespace=UnitTest.Issues \
- csharp/protos/unittest_issues.proto
+ csharp/protos/unittest_issues.proto \
+ csharp/protos/unittest_custom_options_proto3.proto
+
+# Don't specify a base namespace at all; we just want to make sure the
+# results end up in TestProtos.
+$PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf.Test/TestProtos \
+ src/google/protobuf/test_messages_proto3.proto
# AddressBook sample protos
$PROTOC -Iexamples --csharp_out=csharp/src/AddressBook \
diff --git a/csharp/protos/unittest_custom_options_proto3.proto b/csharp/protos/unittest_custom_options_proto3.proto
new file mode 100644
index 00000000..87bd0f7a
--- /dev/null
+++ b/csharp/protos/unittest_custom_options_proto3.proto
@@ -0,0 +1,336 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Author: benjy@google.com (Benjy Weinberger)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+//
+// A proto file used to test the "custom options" feature of google.protobuf.
+
+// This file is based on unittest_custom_options.proto in
+// src/google/protobuf, but is modified for proto3. It could
+// potentially be moved into src/google/protobuf, but currently C#
+// is the only language that really needs it, as we don't support
+// proto2 syntax. It's cut down significantly as proto3 only supports
+// extensions for options.
+
+
+syntax = "proto3";
+
+// A custom file option (defined below).
+option (file_opt1) = 9876543210;
+
+import "google/protobuf/descriptor.proto";
+
+// We don't put this in a package within proto2 because we need to make sure
+// that the generated code doesn't depend on being in the proto2 namespace.
+package protobuf_unittest;
+option csharp_namespace = "UnitTest.Issues.TestProtos";
+
+// Some simple test custom options of various types.
+
+extend google.protobuf.FileOptions {
+ uint64 file_opt1 = 7736974;
+}
+
+extend google.protobuf.MessageOptions {
+ int32 message_opt1 = 7739036;
+}
+
+extend google.protobuf.FieldOptions {
+ fixed64 field_opt1 = 7740936;
+}
+
+extend google.protobuf.OneofOptions {
+ int32 oneof_opt1 = 7740111;
+}
+
+extend google.protobuf.EnumOptions {
+ sfixed32 enum_opt1 = 7753576;
+}
+
+extend google.protobuf.EnumValueOptions {
+ int32 enum_value_opt1 = 1560678;
+}
+
+extend google.protobuf.ServiceOptions {
+ sint64 service_opt1 = 7887650;
+}
+
+enum MethodOpt1 {
+ METHODOPT1_UNSPECIFIED = 0;
+ METHODOPT1_VAL1 = 1;
+ METHODOPT1_VAL2 = 2;
+}
+
+extend google.protobuf.MethodOptions {
+ MethodOpt1 method_opt1 = 7890860;
+}
+
+// A test message with custom options at all possible locations (and also some
+// regular options, to make sure they interact nicely).
+message TestMessageWithCustomOptions {
+ option message_set_wire_format = false;
+
+ option (message_opt1) = -56;
+
+ string field1 = 1 [ctype=CORD,
+ (field_opt1)=8765432109];
+
+ oneof AnOneof {
+ option (oneof_opt1) = -99;
+ int32 oneof_field = 2;
+ }
+
+ enum AnEnum {
+ option (enum_opt1) = -789;
+ ANENUM_UNSPECIFIED = 0;
+ ANENUM_VAL1 = 1;
+ ANENUM_VAL2 = 2 [(enum_value_opt1) = 123];
+ }
+}
+
+
+// A test RPC service with custom options at all possible locations (and also
+// some regular options, to make sure they interact nicely).
+message CustomOptionFooRequest {
+}
+
+message CustomOptionFooResponse {
+}
+
+message CustomOptionFooClientMessage {
+}
+
+message CustomOptionFooServerMessage {
+}
+
+service TestServiceWithCustomOptions {
+ option (service_opt1) = -9876543210;
+
+ rpc Foo(CustomOptionFooRequest) returns (CustomOptionFooResponse) {
+ option (method_opt1) = METHODOPT1_VAL2;
+ }
+}
+
+
+
+// Options of every possible field type, so we can test them all exhaustively.
+
+message DummyMessageContainingEnum {
+ enum TestEnumType {
+ TEST_OPTION_ENUM_UNSPECIFIED = 0;
+ TEST_OPTION_ENUM_TYPE1 = 22;
+ TEST_OPTION_ENUM_TYPE2 = -23;
+ }
+}
+
+message DummyMessageInvalidAsOptionType {
+}
+
+extend google.protobuf.MessageOptions {
+ bool bool_opt = 7706090;
+ int32 int32_opt = 7705709;
+ int64 int64_opt = 7705542;
+ uint32 uint32_opt = 7704880;
+ uint64 uint64_opt = 7702367;
+ sint32 sint32_opt = 7701568;
+ sint64 sint64_opt = 7700863;
+ fixed32 fixed32_opt = 7700307;
+ fixed64 fixed64_opt = 7700194;
+ sfixed32 sfixed32_opt = 7698645;
+ sfixed64 sfixed64_opt = 7685475;
+ float float_opt = 7675390;
+ double double_opt = 7673293;
+ string string_opt = 7673285;
+ bytes bytes_opt = 7673238;
+ DummyMessageContainingEnum.TestEnumType enum_opt = 7673233;
+ DummyMessageInvalidAsOptionType message_type_opt = 7665967;
+}
+
+message CustomOptionMinIntegerValues {
+ option (bool_opt) = false;
+ option (int32_opt) = -0x80000000;
+ option (int64_opt) = -0x8000000000000000;
+ option (uint32_opt) = 0;
+ option (uint64_opt) = 0;
+ option (sint32_opt) = -0x80000000;
+ option (sint64_opt) = -0x8000000000000000;
+ option (fixed32_opt) = 0;
+ option (fixed64_opt) = 0;
+ option (sfixed32_opt) = -0x80000000;
+ option (sfixed64_opt) = -0x8000000000000000;
+}
+
+message CustomOptionMaxIntegerValues {
+ option (bool_opt) = true;
+ option (int32_opt) = 0x7FFFFFFF;
+ option (int64_opt) = 0x7FFFFFFFFFFFFFFF;
+ option (uint32_opt) = 0xFFFFFFFF;
+ option (uint64_opt) = 0xFFFFFFFFFFFFFFFF;
+ option (sint32_opt) = 0x7FFFFFFF;
+ option (sint64_opt) = 0x7FFFFFFFFFFFFFFF;
+ option (fixed32_opt) = 0xFFFFFFFF;
+ option (fixed64_opt) = 0xFFFFFFFFFFFFFFFF;
+ option (sfixed32_opt) = 0x7FFFFFFF;
+ option (sfixed64_opt) = 0x7FFFFFFFFFFFFFFF;
+}
+
+message CustomOptionOtherValues {
+ option (int32_opt) = -100; // To test sign-extension.
+ option (float_opt) = 12.3456789;
+ option (double_opt) = 1.234567890123456789;
+ option (string_opt) = "Hello, \"World\"";
+ option (bytes_opt) = "Hello\0World";
+ option (enum_opt) = TEST_OPTION_ENUM_TYPE2;
+}
+
+message SettingRealsFromPositiveInts {
+ option (float_opt) = 12;
+ option (double_opt) = 154;
+}
+
+message SettingRealsFromNegativeInts {
+ option (float_opt) = -12;
+ option (double_opt) = -154;
+}
+
+// Options of complex message types, themselves combined and extended in
+// various ways.
+
+message ComplexOptionType1 {
+ int32 foo = 1;
+ int32 foo2 = 2;
+ int32 foo3 = 3;
+ repeated int32 foo4 = 4;
+}
+
+message ComplexOptionType2 {
+ ComplexOptionType1 bar = 1;
+ int32 baz = 2;
+
+ message ComplexOptionType4 {
+ int32 waldo = 1;
+
+ extend google.protobuf.MessageOptions {
+ ComplexOptionType4 complex_opt4 = 7633546;
+ }
+ }
+
+ ComplexOptionType4 fred = 3;
+ repeated ComplexOptionType4 barney = 4;
+}
+
+message ComplexOptionType3 {
+ int32 qux = 1;
+}
+
+extend google.protobuf.MessageOptions {
+ protobuf_unittest.ComplexOptionType1 complex_opt1 = 7646756;
+ ComplexOptionType2 complex_opt2 = 7636949;
+ ComplexOptionType3 complex_opt3 = 7636463;
+}
+
+// Note that we try various different ways of naming the same extension.
+message VariousComplexOptions {
+ option (.protobuf_unittest.complex_opt1).foo = 42;
+ option (protobuf_unittest.complex_opt1).foo4 = 99;
+ option (protobuf_unittest.complex_opt1).foo4 = 88;
+ option (complex_opt2).baz = 987;
+ option (complex_opt2).bar.foo = 743;
+ option (ComplexOptionType2.ComplexOptionType4.complex_opt4).waldo = 1971;
+ option (complex_opt2).fred.waldo = 321;
+ option (complex_opt2).barney = { waldo: 101 };
+ option (complex_opt2).barney = { waldo: 212 };
+ option (protobuf_unittest.complex_opt3).qux = 9;
+}
+
+// ------------------------------------------------------
+// Definitions for testing aggregate option parsing.
+// See descriptor_unittest.cc.
+
+// A helper type used to test aggregate option parsing
+message Aggregate {
+ int32 i = 1;
+ string s = 2;
+
+ // A nested object
+ Aggregate sub = 3;
+}
+
+// Allow Aggregate to be used as an option at all possible locations
+// in the .proto grammer.
+extend google.protobuf.FileOptions { Aggregate fileopt = 15478479; }
+extend google.protobuf.MessageOptions { Aggregate msgopt = 15480088; }
+extend google.protobuf.FieldOptions { Aggregate fieldopt = 15481374; }
+extend google.protobuf.EnumOptions { Aggregate enumopt = 15483218; }
+extend google.protobuf.EnumValueOptions { Aggregate enumvalopt = 15486921; }
+extend google.protobuf.ServiceOptions { Aggregate serviceopt = 15497145; }
+extend google.protobuf.MethodOptions { Aggregate methodopt = 15512713; }
+
+// Try using AggregateOption at different points in the proto grammar
+option (fileopt) = {
+ s: 'FileAnnotation'
+ // Also test the handling of comments
+ /* of both types */ i: 100
+
+ sub { s: 'NestedFileAnnotation' }
+};
+
+message AggregateMessage {
+ option (msgopt) = { i:101 s:'MessageAnnotation' };
+ int32 fieldname = 1 [(fieldopt) = { s:'FieldAnnotation' }];
+}
+
+service AggregateService {
+ option (serviceopt) = { s:'ServiceAnnotation' };
+ rpc Method (AggregateMessage) returns (AggregateMessage) {
+ option (methodopt) = { s:'MethodAnnotation' };
+ }
+}
+
+enum AggregateEnum {
+ option (enumopt) = { s:'EnumAnnotation' };
+ UNSPECIFIED = 0;
+ VALUE = 1 [(enumvalopt) = { s:'EnumValueAnnotation' }];
+}
+
+// Test custom options for nested type.
+message NestedOptionType {
+ message NestedMessage {
+ option (message_opt1) = 1001;
+ int32 nested_field = 1 [(field_opt1) = 1002];
+ }
+ enum NestedEnum {
+ UNSPECIFIED = 0;
+ option (enum_opt1) = 1003;
+ NESTED_ENUM_VALUE = 1 [(enum_value_opt1) = 1004];
+ }
+}
diff --git a/csharp/src/AddressBook/Addressbook.cs b/csharp/src/AddressBook/Addressbook.cs
index 8e691ad4..75ed071b 100644
--- a/csharp/src/AddressBook/Addressbook.cs
+++ b/csharp/src/AddressBook/Addressbook.cs
@@ -43,7 +43,7 @@ namespace Google.Protobuf.Examples.AddressBook {
}
#region Messages
/// <summary>
- /// [START messages]
+ /// [START messages]
/// </summary>
public sealed partial class Person : pb::IMessage<Person> {
private static readonly pb::MessageParser<Person> _parser = new pb::MessageParser<Person>(() => new Person());
@@ -95,7 +95,7 @@ namespace Google.Protobuf.Examples.AddressBook {
public const int IdFieldNumber = 2;
private int id_;
/// <summary>
- /// Unique ID number for this person.
+ /// Unique ID number for this person.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int Id {
@@ -400,7 +400,7 @@ namespace Google.Protobuf.Examples.AddressBook {
}
/// <summary>
- /// Our address book file is just one of these.
+ /// Our address book file is just one of these.
/// </summary>
public sealed partial class AddressBook : pb::IMessage<AddressBook> {
private static readonly pb::MessageParser<AddressBook> _parser = new pb::MessageParser<AddressBook>(() => new AddressBook());
diff --git a/csharp/src/Google.Protobuf.Conformance/Conformance.cs b/csharp/src/Google.Protobuf.Conformance/Conformance.cs
index 431ac4fb..1a835aef 100644
--- a/csharp/src/Google.Protobuf.Conformance/Conformance.cs
+++ b/csharp/src/Google.Protobuf.Conformance/Conformance.cs
@@ -22,182 +22,22 @@ namespace Conformance {
static ConformanceReflection() {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
- "ChFjb25mb3JtYW5jZS5wcm90bxILY29uZm9ybWFuY2UaGWdvb2dsZS9wcm90",
- "b2J1Zi9hbnkucHJvdG8aHmdvb2dsZS9wcm90b2J1Zi9kdXJhdGlvbi5wcm90",
- "bxogZ29vZ2xlL3Byb3RvYnVmL2ZpZWxkX21hc2sucHJvdG8aHGdvb2dsZS9w",
- "cm90b2J1Zi9zdHJ1Y3QucHJvdG8aH2dvb2dsZS9wcm90b2J1Zi90aW1lc3Rh",
- "bXAucHJvdG8aHmdvb2dsZS9wcm90b2J1Zi93cmFwcGVycy5wcm90byKNAQoS",
- "Q29uZm9ybWFuY2VSZXF1ZXN0EhoKEHByb3RvYnVmX3BheWxvYWQYASABKAxI",
- "ABIWCgxqc29uX3BheWxvYWQYAiABKAlIABI4ChdyZXF1ZXN0ZWRfb3V0cHV0",
- "X2Zvcm1hdBgDIAEoDjIXLmNvbmZvcm1hbmNlLldpcmVGb3JtYXRCCQoHcGF5",
- "bG9hZCKxAQoTQ29uZm9ybWFuY2VSZXNwb25zZRIVCgtwYXJzZV9lcnJvchgB",
- "IAEoCUgAEhkKD3NlcmlhbGl6ZV9lcnJvchgGIAEoCUgAEhcKDXJ1bnRpbWVf",
- "ZXJyb3IYAiABKAlIABIaChBwcm90b2J1Zl9wYXlsb2FkGAMgASgMSAASFgoM",
- "anNvbl9wYXlsb2FkGAQgASgJSAASEQoHc2tpcHBlZBgFIAEoCUgAQggKBnJl",
- "c3VsdCKCNQoMVGVzdEFsbFR5cGVzEhYKDm9wdGlvbmFsX2ludDMyGAEgASgF",
- "EhYKDm9wdGlvbmFsX2ludDY0GAIgASgDEhcKD29wdGlvbmFsX3VpbnQzMhgD",
- "IAEoDRIXCg9vcHRpb25hbF91aW50NjQYBCABKAQSFwoPb3B0aW9uYWxfc2lu",
- "dDMyGAUgASgREhcKD29wdGlvbmFsX3NpbnQ2NBgGIAEoEhIYChBvcHRpb25h",
- "bF9maXhlZDMyGAcgASgHEhgKEG9wdGlvbmFsX2ZpeGVkNjQYCCABKAYSGQoR",
- "b3B0aW9uYWxfc2ZpeGVkMzIYCSABKA8SGQoRb3B0aW9uYWxfc2ZpeGVkNjQY",
- "CiABKBASFgoOb3B0aW9uYWxfZmxvYXQYCyABKAISFwoPb3B0aW9uYWxfZG91",
- "YmxlGAwgASgBEhUKDW9wdGlvbmFsX2Jvb2wYDSABKAgSFwoPb3B0aW9uYWxf",
- "c3RyaW5nGA4gASgJEhYKDm9wdGlvbmFsX2J5dGVzGA8gASgMEkgKF29wdGlv",
- "bmFsX25lc3RlZF9tZXNzYWdlGBIgASgLMicuY29uZm9ybWFuY2UuVGVzdEFs",
- "bFR5cGVzLk5lc3RlZE1lc3NhZ2USPQoYb3B0aW9uYWxfZm9yZWlnbl9tZXNz",
- "YWdlGBMgASgLMhsuY29uZm9ybWFuY2UuRm9yZWlnbk1lc3NhZ2USQgoUb3B0",
- "aW9uYWxfbmVzdGVkX2VudW0YFSABKA4yJC5jb25mb3JtYW5jZS5UZXN0QWxs",
- "VHlwZXMuTmVzdGVkRW51bRI3ChVvcHRpb25hbF9mb3JlaWduX2VudW0YFiAB",
- "KA4yGC5jb25mb3JtYW5jZS5Gb3JlaWduRW51bRIhChVvcHRpb25hbF9zdHJp",
- "bmdfcGllY2UYGCABKAlCAggCEhkKDW9wdGlvbmFsX2NvcmQYGSABKAlCAggB",
- "EjQKEXJlY3Vyc2l2ZV9tZXNzYWdlGBsgASgLMhkuY29uZm9ybWFuY2UuVGVz",
- "dEFsbFR5cGVzEhYKDnJlcGVhdGVkX2ludDMyGB8gAygFEhYKDnJlcGVhdGVk",
- "X2ludDY0GCAgAygDEhcKD3JlcGVhdGVkX3VpbnQzMhghIAMoDRIXCg9yZXBl",
- "YXRlZF91aW50NjQYIiADKAQSFwoPcmVwZWF0ZWRfc2ludDMyGCMgAygREhcK",
- "D3JlcGVhdGVkX3NpbnQ2NBgkIAMoEhIYChByZXBlYXRlZF9maXhlZDMyGCUg",
- "AygHEhgKEHJlcGVhdGVkX2ZpeGVkNjQYJiADKAYSGQoRcmVwZWF0ZWRfc2Zp",
- "eGVkMzIYJyADKA8SGQoRcmVwZWF0ZWRfc2ZpeGVkNjQYKCADKBASFgoOcmVw",
- "ZWF0ZWRfZmxvYXQYKSADKAISFwoPcmVwZWF0ZWRfZG91YmxlGCogAygBEhUK",
- "DXJlcGVhdGVkX2Jvb2wYKyADKAgSFwoPcmVwZWF0ZWRfc3RyaW5nGCwgAygJ",
- "EhYKDnJlcGVhdGVkX2J5dGVzGC0gAygMEkgKF3JlcGVhdGVkX25lc3RlZF9t",
- "ZXNzYWdlGDAgAygLMicuY29uZm9ybWFuY2UuVGVzdEFsbFR5cGVzLk5lc3Rl",
- "ZE1lc3NhZ2USPQoYcmVwZWF0ZWRfZm9yZWlnbl9tZXNzYWdlGDEgAygLMhsu",
- "Y29uZm9ybWFuY2UuRm9yZWlnbk1lc3NhZ2USQgoUcmVwZWF0ZWRfbmVzdGVk",
- "X2VudW0YMyADKA4yJC5jb25mb3JtYW5jZS5UZXN0QWxsVHlwZXMuTmVzdGVk",
- "RW51bRI3ChVyZXBlYXRlZF9mb3JlaWduX2VudW0YNCADKA4yGC5jb25mb3Jt",
- "YW5jZS5Gb3JlaWduRW51bRIhChVyZXBlYXRlZF9zdHJpbmdfcGllY2UYNiAD",
- "KAlCAggCEhkKDXJlcGVhdGVkX2NvcmQYNyADKAlCAggBEkUKD21hcF9pbnQz",
- "Ml9pbnQzMhg4IAMoCzIsLmNvbmZvcm1hbmNlLlRlc3RBbGxUeXBlcy5NYXBJ",
- "bnQzMkludDMyRW50cnkSRQoPbWFwX2ludDY0X2ludDY0GDkgAygLMiwuY29u",
- "Zm9ybWFuY2UuVGVzdEFsbFR5cGVzLk1hcEludDY0SW50NjRFbnRyeRJJChFt",
- "YXBfdWludDMyX3VpbnQzMhg6IAMoCzIuLmNvbmZvcm1hbmNlLlRlc3RBbGxU",
- "eXBlcy5NYXBVaW50MzJVaW50MzJFbnRyeRJJChFtYXBfdWludDY0X3VpbnQ2",
- "NBg7IAMoCzIuLmNvbmZvcm1hbmNlLlRlc3RBbGxUeXBlcy5NYXBVaW50NjRV",
- "aW50NjRFbnRyeRJJChFtYXBfc2ludDMyX3NpbnQzMhg8IAMoCzIuLmNvbmZv",
- "cm1hbmNlLlRlc3RBbGxUeXBlcy5NYXBTaW50MzJTaW50MzJFbnRyeRJJChFt",
- "YXBfc2ludDY0X3NpbnQ2NBg9IAMoCzIuLmNvbmZvcm1hbmNlLlRlc3RBbGxU",
- "eXBlcy5NYXBTaW50NjRTaW50NjRFbnRyeRJNChNtYXBfZml4ZWQzMl9maXhl",
- "ZDMyGD4gAygLMjAuY29uZm9ybWFuY2UuVGVzdEFsbFR5cGVzLk1hcEZpeGVk",
- "MzJGaXhlZDMyRW50cnkSTQoTbWFwX2ZpeGVkNjRfZml4ZWQ2NBg/IAMoCzIw",
- "LmNvbmZvcm1hbmNlLlRlc3RBbGxUeXBlcy5NYXBGaXhlZDY0Rml4ZWQ2NEVu",
- "dHJ5ElEKFW1hcF9zZml4ZWQzMl9zZml4ZWQzMhhAIAMoCzIyLmNvbmZvcm1h",
- "bmNlLlRlc3RBbGxUeXBlcy5NYXBTZml4ZWQzMlNmaXhlZDMyRW50cnkSUQoV",
- "bWFwX3NmaXhlZDY0X3NmaXhlZDY0GEEgAygLMjIuY29uZm9ybWFuY2UuVGVz",
- "dEFsbFR5cGVzLk1hcFNmaXhlZDY0U2ZpeGVkNjRFbnRyeRJFCg9tYXBfaW50",
- "MzJfZmxvYXQYQiADKAsyLC5jb25mb3JtYW5jZS5UZXN0QWxsVHlwZXMuTWFw",
- "SW50MzJGbG9hdEVudHJ5EkcKEG1hcF9pbnQzMl9kb3VibGUYQyADKAsyLS5j",
- "b25mb3JtYW5jZS5UZXN0QWxsVHlwZXMuTWFwSW50MzJEb3VibGVFbnRyeRJB",
- "Cg1tYXBfYm9vbF9ib29sGEQgAygLMiouY29uZm9ybWFuY2UuVGVzdEFsbFR5",
- "cGVzLk1hcEJvb2xCb29sRW50cnkSSQoRbWFwX3N0cmluZ19zdHJpbmcYRSAD",
- "KAsyLi5jb25mb3JtYW5jZS5UZXN0QWxsVHlwZXMuTWFwU3RyaW5nU3RyaW5n",
- "RW50cnkSRwoQbWFwX3N0cmluZ19ieXRlcxhGIAMoCzItLmNvbmZvcm1hbmNl",
- "LlRlc3RBbGxUeXBlcy5NYXBTdHJpbmdCeXRlc0VudHJ5ElgKGW1hcF9zdHJp",
- "bmdfbmVzdGVkX21lc3NhZ2UYRyADKAsyNS5jb25mb3JtYW5jZS5UZXN0QWxs",
- "VHlwZXMuTWFwU3RyaW5nTmVzdGVkTWVzc2FnZUVudHJ5EloKGm1hcF9zdHJp",
- "bmdfZm9yZWlnbl9tZXNzYWdlGEggAygLMjYuY29uZm9ybWFuY2UuVGVzdEFs",
- "bFR5cGVzLk1hcFN0cmluZ0ZvcmVpZ25NZXNzYWdlRW50cnkSUgoWbWFwX3N0",
- "cmluZ19uZXN0ZWRfZW51bRhJIAMoCzIyLmNvbmZvcm1hbmNlLlRlc3RBbGxU",
- "eXBlcy5NYXBTdHJpbmdOZXN0ZWRFbnVtRW50cnkSVAoXbWFwX3N0cmluZ19m",
- "b3JlaWduX2VudW0YSiADKAsyMy5jb25mb3JtYW5jZS5UZXN0QWxsVHlwZXMu",
- "TWFwU3RyaW5nRm9yZWlnbkVudW1FbnRyeRIWCgxvbmVvZl91aW50MzIYbyAB",
- "KA1IABJHChRvbmVvZl9uZXN0ZWRfbWVzc2FnZRhwIAEoCzInLmNvbmZvcm1h",
- "bmNlLlRlc3RBbGxUeXBlcy5OZXN0ZWRNZXNzYWdlSAASFgoMb25lb2Zfc3Ry",
- "aW5nGHEgASgJSAASFQoLb25lb2ZfYnl0ZXMYciABKAxIABIUCgpvbmVvZl9i",
- "b29sGHMgASgISAASFgoMb25lb2ZfdWludDY0GHQgASgESAASFQoLb25lb2Zf",
- "ZmxvYXQYdSABKAJIABIWCgxvbmVvZl9kb3VibGUYdiABKAFIABI6CgpvbmVv",
- "Zl9lbnVtGHcgASgOMiQuY29uZm9ybWFuY2UuVGVzdEFsbFR5cGVzLk5lc3Rl",
- "ZEVudW1IABI6ChVvcHRpb25hbF9ib29sX3dyYXBwZXIYyQEgASgLMhouZ29v",
- "Z2xlLnByb3RvYnVmLkJvb2xWYWx1ZRI8ChZvcHRpb25hbF9pbnQzMl93cmFw",
- "cGVyGMoBIAEoCzIbLmdvb2dsZS5wcm90b2J1Zi5JbnQzMlZhbHVlEjwKFm9w",
- "dGlvbmFsX2ludDY0X3dyYXBwZXIYywEgASgLMhsuZ29vZ2xlLnByb3RvYnVm",
- "LkludDY0VmFsdWUSPgoXb3B0aW9uYWxfdWludDMyX3dyYXBwZXIYzAEgASgL",
- "MhwuZ29vZ2xlLnByb3RvYnVmLlVJbnQzMlZhbHVlEj4KF29wdGlvbmFsX3Vp",
- "bnQ2NF93cmFwcGVyGM0BIAEoCzIcLmdvb2dsZS5wcm90b2J1Zi5VSW50NjRW",
- "YWx1ZRI8ChZvcHRpb25hbF9mbG9hdF93cmFwcGVyGM4BIAEoCzIbLmdvb2ds",
- "ZS5wcm90b2J1Zi5GbG9hdFZhbHVlEj4KF29wdGlvbmFsX2RvdWJsZV93cmFw",
- "cGVyGM8BIAEoCzIcLmdvb2dsZS5wcm90b2J1Zi5Eb3VibGVWYWx1ZRI+Chdv",
- "cHRpb25hbF9zdHJpbmdfd3JhcHBlchjQASABKAsyHC5nb29nbGUucHJvdG9i",
- "dWYuU3RyaW5nVmFsdWUSPAoWb3B0aW9uYWxfYnl0ZXNfd3JhcHBlchjRASAB",
- "KAsyGy5nb29nbGUucHJvdG9idWYuQnl0ZXNWYWx1ZRI6ChVyZXBlYXRlZF9i",
- "b29sX3dyYXBwZXIY0wEgAygLMhouZ29vZ2xlLnByb3RvYnVmLkJvb2xWYWx1",
- "ZRI8ChZyZXBlYXRlZF9pbnQzMl93cmFwcGVyGNQBIAMoCzIbLmdvb2dsZS5w",
- "cm90b2J1Zi5JbnQzMlZhbHVlEjwKFnJlcGVhdGVkX2ludDY0X3dyYXBwZXIY",
- "1QEgAygLMhsuZ29vZ2xlLnByb3RvYnVmLkludDY0VmFsdWUSPgoXcmVwZWF0",
- "ZWRfdWludDMyX3dyYXBwZXIY1gEgAygLMhwuZ29vZ2xlLnByb3RvYnVmLlVJ",
- "bnQzMlZhbHVlEj4KF3JlcGVhdGVkX3VpbnQ2NF93cmFwcGVyGNcBIAMoCzIc",
- "Lmdvb2dsZS5wcm90b2J1Zi5VSW50NjRWYWx1ZRI8ChZyZXBlYXRlZF9mbG9h",
- "dF93cmFwcGVyGNgBIAMoCzIbLmdvb2dsZS5wcm90b2J1Zi5GbG9hdFZhbHVl",
- "Ej4KF3JlcGVhdGVkX2RvdWJsZV93cmFwcGVyGNkBIAMoCzIcLmdvb2dsZS5w",
- "cm90b2J1Zi5Eb3VibGVWYWx1ZRI+ChdyZXBlYXRlZF9zdHJpbmdfd3JhcHBl",
- "chjaASADKAsyHC5nb29nbGUucHJvdG9idWYuU3RyaW5nVmFsdWUSPAoWcmVw",
- "ZWF0ZWRfYnl0ZXNfd3JhcHBlchjbASADKAsyGy5nb29nbGUucHJvdG9idWYu",
- "Qnl0ZXNWYWx1ZRI1ChFvcHRpb25hbF9kdXJhdGlvbhitAiABKAsyGS5nb29n",
- "bGUucHJvdG9idWYuRHVyYXRpb24SNwoSb3B0aW9uYWxfdGltZXN0YW1wGK4C",
- "IAEoCzIaLmdvb2dsZS5wcm90b2J1Zi5UaW1lc3RhbXASOAoTb3B0aW9uYWxf",
- "ZmllbGRfbWFzaxivAiABKAsyGi5nb29nbGUucHJvdG9idWYuRmllbGRNYXNr",
- "EjEKD29wdGlvbmFsX3N0cnVjdBiwAiABKAsyFy5nb29nbGUucHJvdG9idWYu",
- "U3RydWN0EisKDG9wdGlvbmFsX2FueRixAiABKAsyFC5nb29nbGUucHJvdG9i",
- "dWYuQW55Ei8KDm9wdGlvbmFsX3ZhbHVlGLICIAEoCzIWLmdvb2dsZS5wcm90",
- "b2J1Zi5WYWx1ZRI1ChFyZXBlYXRlZF9kdXJhdGlvbhi3AiADKAsyGS5nb29n",
- "bGUucHJvdG9idWYuRHVyYXRpb24SNwoScmVwZWF0ZWRfdGltZXN0YW1wGLgC",
- "IAMoCzIaLmdvb2dsZS5wcm90b2J1Zi5UaW1lc3RhbXASNwoScmVwZWF0ZWRf",
- "ZmllbGRtYXNrGLkCIAMoCzIaLmdvb2dsZS5wcm90b2J1Zi5GaWVsZE1hc2sS",
- "MQoPcmVwZWF0ZWRfc3RydWN0GMQCIAMoCzIXLmdvb2dsZS5wcm90b2J1Zi5T",
- "dHJ1Y3QSKwoMcmVwZWF0ZWRfYW55GLsCIAMoCzIULmdvb2dsZS5wcm90b2J1",
- "Zi5BbnkSLwoOcmVwZWF0ZWRfdmFsdWUYvAIgAygLMhYuZ29vZ2xlLnByb3Rv",
- "YnVmLlZhbHVlEhMKCmZpZWxkbmFtZTEYkQMgASgFEhQKC2ZpZWxkX25hbWUy",
- "GJIDIAEoBRIVCgxfZmllbGRfbmFtZTMYkwMgASgFEhYKDWZpZWxkX19uYW1l",
- "NF8YlAMgASgFEhQKC2ZpZWxkMG5hbWU1GJUDIAEoBRIWCg1maWVsZF8wX25h",
- "bWU2GJYDIAEoBRITCgpmaWVsZE5hbWU3GJcDIAEoBRITCgpGaWVsZE5hbWU4",
- "GJgDIAEoBRIUCgtmaWVsZF9OYW1lORiZAyABKAUSFQoMRmllbGRfTmFtZTEw",
- "GJoDIAEoBRIVCgxGSUVMRF9OQU1FMTEYmwMgASgFEhUKDEZJRUxEX25hbWUx",
- "MhicAyABKAUSFwoOX19maWVsZF9uYW1lMTMYnQMgASgFEhcKDl9fRmllbGRf",
- "bmFtZTE0GJ4DIAEoBRIWCg1maWVsZF9fbmFtZTE1GJ8DIAEoBRIWCg1maWVs",
- "ZF9fTmFtZTE2GKADIAEoBRIXCg5maWVsZF9uYW1lMTdfXxihAyABKAUSFwoO",
- "RmllbGRfbmFtZTE4X18YogMgASgFGkoKDU5lc3RlZE1lc3NhZ2USCQoBYRgB",
- "IAEoBRIuCgtjb3JlY3Vyc2l2ZRgCIAEoCzIZLmNvbmZvcm1hbmNlLlRlc3RB",
- "bGxUeXBlcxo0ChJNYXBJbnQzMkludDMyRW50cnkSCwoDa2V5GAEgASgFEg0K",
- "BXZhbHVlGAIgASgFOgI4ARo0ChJNYXBJbnQ2NEludDY0RW50cnkSCwoDa2V5",
- "GAEgASgDEg0KBXZhbHVlGAIgASgDOgI4ARo2ChRNYXBVaW50MzJVaW50MzJF",
- "bnRyeRILCgNrZXkYASABKA0SDQoFdmFsdWUYAiABKA06AjgBGjYKFE1hcFVp",
- "bnQ2NFVpbnQ2NEVudHJ5EgsKA2tleRgBIAEoBBINCgV2YWx1ZRgCIAEoBDoC",
- "OAEaNgoUTWFwU2ludDMyU2ludDMyRW50cnkSCwoDa2V5GAEgASgREg0KBXZh",
- "bHVlGAIgASgROgI4ARo2ChRNYXBTaW50NjRTaW50NjRFbnRyeRILCgNrZXkY",
- "ASABKBISDQoFdmFsdWUYAiABKBI6AjgBGjgKFk1hcEZpeGVkMzJGaXhlZDMy",
- "RW50cnkSCwoDa2V5GAEgASgHEg0KBXZhbHVlGAIgASgHOgI4ARo4ChZNYXBG",
- "aXhlZDY0Rml4ZWQ2NEVudHJ5EgsKA2tleRgBIAEoBhINCgV2YWx1ZRgCIAEo",
- "BjoCOAEaOgoYTWFwU2ZpeGVkMzJTZml4ZWQzMkVudHJ5EgsKA2tleRgBIAEo",
- "DxINCgV2YWx1ZRgCIAEoDzoCOAEaOgoYTWFwU2ZpeGVkNjRTZml4ZWQ2NEVu",
- "dHJ5EgsKA2tleRgBIAEoEBINCgV2YWx1ZRgCIAEoEDoCOAEaNAoSTWFwSW50",
- "MzJGbG9hdEVudHJ5EgsKA2tleRgBIAEoBRINCgV2YWx1ZRgCIAEoAjoCOAEa",
- "NQoTTWFwSW50MzJEb3VibGVFbnRyeRILCgNrZXkYASABKAUSDQoFdmFsdWUY",
- "AiABKAE6AjgBGjIKEE1hcEJvb2xCb29sRW50cnkSCwoDa2V5GAEgASgIEg0K",
- "BXZhbHVlGAIgASgIOgI4ARo2ChRNYXBTdHJpbmdTdHJpbmdFbnRyeRILCgNr",
- "ZXkYASABKAkSDQoFdmFsdWUYAiABKAk6AjgBGjUKE01hcFN0cmluZ0J5dGVz",
- "RW50cnkSCwoDa2V5GAEgASgJEg0KBXZhbHVlGAIgASgMOgI4ARpmChtNYXBT",
- "dHJpbmdOZXN0ZWRNZXNzYWdlRW50cnkSCwoDa2V5GAEgASgJEjYKBXZhbHVl",
- "GAIgASgLMicuY29uZm9ybWFuY2UuVGVzdEFsbFR5cGVzLk5lc3RlZE1lc3Nh",
- "Z2U6AjgBGlsKHE1hcFN0cmluZ0ZvcmVpZ25NZXNzYWdlRW50cnkSCwoDa2V5",
- "GAEgASgJEioKBXZhbHVlGAIgASgLMhsuY29uZm9ybWFuY2UuRm9yZWlnbk1l",
- "c3NhZ2U6AjgBGmAKGE1hcFN0cmluZ05lc3RlZEVudW1FbnRyeRILCgNrZXkY",
- "ASABKAkSMwoFdmFsdWUYAiABKA4yJC5jb25mb3JtYW5jZS5UZXN0QWxsVHlw",
- "ZXMuTmVzdGVkRW51bToCOAEaVQoZTWFwU3RyaW5nRm9yZWlnbkVudW1FbnRy",
- "eRILCgNrZXkYASABKAkSJwoFdmFsdWUYAiABKA4yGC5jb25mb3JtYW5jZS5G",
- "b3JlaWduRW51bToCOAEiOQoKTmVzdGVkRW51bRIHCgNGT08QABIHCgNCQVIQ",
- "ARIHCgNCQVoQAhIQCgNORUcQ////////////AUINCgtvbmVvZl9maWVsZCIb",
- "Cg5Gb3JlaWduTWVzc2FnZRIJCgFjGAEgASgFKjUKCldpcmVGb3JtYXQSDwoL",
- "VU5TUEVDSUZJRUQQABIMCghQUk9UT0JVRhABEggKBEpTT04QAipACgtGb3Jl",
- "aWduRW51bRIPCgtGT1JFSUdOX0ZPTxAAEg8KC0ZPUkVJR05fQkFSEAESDwoL",
- "Rk9SRUlHTl9CQVoQAkIhCh9jb20uZ29vZ2xlLnByb3RvYnVmLmNvbmZvcm1h",
- "bmNlYgZwcm90bzM="));
+ "ChFjb25mb3JtYW5jZS5wcm90bxILY29uZm9ybWFuY2UijQEKEkNvbmZvcm1h",
+ "bmNlUmVxdWVzdBIaChBwcm90b2J1Zl9wYXlsb2FkGAEgASgMSAASFgoManNv",
+ "bl9wYXlsb2FkGAIgASgJSAASOAoXcmVxdWVzdGVkX291dHB1dF9mb3JtYXQY",
+ "AyABKA4yFy5jb25mb3JtYW5jZS5XaXJlRm9ybWF0QgkKB3BheWxvYWQisQEK",
+ "E0NvbmZvcm1hbmNlUmVzcG9uc2USFQoLcGFyc2VfZXJyb3IYASABKAlIABIZ",
+ "Cg9zZXJpYWxpemVfZXJyb3IYBiABKAlIABIXCg1ydW50aW1lX2Vycm9yGAIg",
+ "ASgJSAASGgoQcHJvdG9idWZfcGF5bG9hZBgDIAEoDEgAEhYKDGpzb25fcGF5",
+ "bG9hZBgEIAEoCUgAEhEKB3NraXBwZWQYBSABKAlIAEIICgZyZXN1bHQqNQoK",
+ "V2lyZUZvcm1hdBIPCgtVTlNQRUNJRklFRBAAEgwKCFBST1RPQlVGEAESCAoE",
+ "SlNPThACQiEKH2NvbS5nb29nbGUucHJvdG9idWYuY29uZm9ybWFuY2ViBnBy",
+ "b3RvMw=="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
- new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.AnyReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.DurationReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.FieldMaskReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.StructReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.TimestampReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.WrappersReflection.Descriptor, },
- new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Conformance.WireFormat), typeof(global::Conformance.ForeignEnum), }, new pbr::GeneratedClrTypeInfo[] {
+ new pbr::FileDescriptor[] { },
+ new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Conformance.WireFormat), }, new pbr::GeneratedClrTypeInfo[] {
new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.ConformanceRequest), global::Conformance.ConformanceRequest.Parser, new[]{ "ProtobufPayload", "JsonPayload", "RequestedOutputFormat" }, new[]{ "Payload" }, null, null),
- new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.ConformanceResponse), global::Conformance.ConformanceResponse.Parser, new[]{ "ParseError", "SerializeError", "RuntimeError", "ProtobufPayload", "JsonPayload", "Skipped" }, new[]{ "Result" }, null, null),
- new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.TestAllTypes), global::Conformance.TestAllTypes.Parser, new[]{ "OptionalInt32", "OptionalInt64", "OptionalUint32", "OptionalUint64", "OptionalSint32", "OptionalSint64", "OptionalFixed32", "OptionalFixed64", "OptionalSfixed32", "OptionalSfixed64", "OptionalFloat", "OptionalDouble", "OptionalBool", "OptionalString", "OptionalBytes", "OptionalNestedMessage", "OptionalForeignMessage", "OptionalNestedEnum", "OptionalForeignEnum", "OptionalStringPiece", "OptionalCord", "RecursiveMessage", "RepeatedInt32", "RepeatedInt64", "RepeatedUint32", "RepeatedUint64", "RepeatedSint32", "RepeatedSint64", "RepeatedFixed32", "RepeatedFixed64", "RepeatedSfixed32", "RepeatedSfixed64", "RepeatedFloat", "RepeatedDouble", "RepeatedBool", "RepeatedString", "RepeatedBytes", "RepeatedNestedMessage", "RepeatedForeignMessage", "RepeatedNestedEnum", "RepeatedForeignEnum", "RepeatedStringPiece", "RepeatedCord", "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapStringString", "MapStringBytes", "MapStringNestedMessage", "MapStringForeignMessage", "MapStringNestedEnum", "MapStringForeignEnum", "OneofUint32", "OneofNestedMessage", "OneofString", "OneofBytes", "OneofBool", "OneofUint64", "OneofFloat", "OneofDouble", "OneofEnum", "OptionalBoolWrapper", "OptionalInt32Wrapper", "OptionalInt64Wrapper", "OptionalUint32Wrapper", "OptionalUint64Wrapper", "OptionalFloatWrapper", "OptionalDoubleWrapper", "OptionalStringWrapper", "OptionalBytesWrapper", "RepeatedBoolWrapper", "RepeatedInt32Wrapper", "RepeatedInt64Wrapper", "RepeatedUint32Wrapper", "RepeatedUint64Wrapper", "RepeatedFloatWrapper", "RepeatedDoubleWrapper", "RepeatedStringWrapper", "RepeatedBytesWrapper", "OptionalDuration", "OptionalTimestamp", "OptionalFieldMask", "OptionalStruct", "OptionalAny", "OptionalValue", "RepeatedDuration", "RepeatedTimestamp", "RepeatedFieldmask", "RepeatedStruct", "RepeatedAny", "RepeatedValue", "Fieldname1", "FieldName2", "FieldName3", "FieldName4", "Field0Name5", "Field0Name6", "FieldName7", "FieldName8", "FieldName9", "FieldName10", "FIELDNAME11", "FIELDName12", "FieldName13", "FieldName14", "FieldName15", "FieldName16", "FieldName17", "FieldName18" }, new[]{ "OneofField" }, new[]{ typeof(global::Conformance.TestAllTypes.Types.NestedEnum) }, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.TestAllTypes.Types.NestedMessage), global::Conformance.TestAllTypes.Types.NestedMessage.Parser, new[]{ "A", "Corecursive" }, null, null, null),
- null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, }),
- new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.ForeignMessage), global::Conformance.ForeignMessage.Parser, new[]{ "C" }, null, null, null)
+ new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.ConformanceResponse), global::Conformance.ConformanceResponse.Parser, new[]{ "ParseError", "SerializeError", "RuntimeError", "ProtobufPayload", "JsonPayload", "Skipped" }, new[]{ "Result" }, null, null)
}));
}
#endregion
@@ -210,21 +50,15 @@ namespace Conformance {
[pbr::OriginalName("JSON")] Json = 2,
}
- public enum ForeignEnum {
- [pbr::OriginalName("FOREIGN_FOO")] ForeignFoo = 0,
- [pbr::OriginalName("FOREIGN_BAR")] ForeignBar = 1,
- [pbr::OriginalName("FOREIGN_BAZ")] ForeignBaz = 2,
- }
-
#endregion
#region Messages
/// <summary>
- /// Represents a single test case's input. The testee should:
+ /// Represents a single test case's input. The testee should:
///
- /// 1. parse this proto (which should always succeed)
- /// 2. parse the protobuf or JSON payload in "payload" (which may fail)
- /// 3. if the parse succeeded, serialize the message in the requested format.
+ /// 1. parse this proto (which should always succeed)
+ /// 2. parse the protobuf or JSON payload in "payload" (which may fail)
+ /// 3. if the parse succeeded, serialize the message in the requested format.
/// </summary>
public sealed partial class ConformanceRequest : pb::IMessage<ConformanceRequest> {
private static readonly pb::MessageParser<ConformanceRequest> _parser = new pb::MessageParser<ConformanceRequest>(() => new ConformanceRequest());
@@ -293,7 +127,7 @@ namespace Conformance {
public const int RequestedOutputFormatFieldNumber = 3;
private global::Conformance.WireFormat requestedOutputFormat_ = 0;
/// <summary>
- /// Which format should the testee serialize its message to?
+ /// Which format should the testee serialize its message to?
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Conformance.WireFormat RequestedOutputFormat {
@@ -434,7 +268,7 @@ namespace Conformance {
}
/// <summary>
- /// Represents a single test case's output.
+ /// Represents a single test case's output.
/// </summary>
public sealed partial class ConformanceResponse : pb::IMessage<ConformanceResponse> {
private static readonly pb::MessageParser<ConformanceResponse> _parser = new pb::MessageParser<ConformanceResponse>(() => new ConformanceResponse());
@@ -491,11 +325,11 @@ namespace Conformance {
/// <summary>Field number for the "parse_error" field.</summary>
public const int ParseErrorFieldNumber = 1;
/// <summary>
- /// This string should be set to indicate parsing failed. The string can
- /// provide more information about the parse error if it is available.
+ /// This string should be set to indicate parsing failed. The string can
+ /// provide more information about the parse error if it is available.
///
- /// Setting this string does not necessarily mean the testee failed the
- /// test. Some of the test cases are intentionally invalid input.
+ /// Setting this string does not necessarily mean the testee failed the
+ /// test. Some of the test cases are intentionally invalid input.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string ParseError {
@@ -509,9 +343,9 @@ namespace Conformance {
/// <summary>Field number for the "serialize_error" field.</summary>
public const int SerializeErrorFieldNumber = 6;
/// <summary>
- /// If the input was successfully parsed but errors occurred when
- /// serializing it to the requested output format, set the error message in
- /// this field.
+ /// If the input was successfully parsed but errors occurred when
+ /// serializing it to the requested output format, set the error message in
+ /// this field.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string SerializeError {
@@ -525,9 +359,9 @@ namespace Conformance {
/// <summary>Field number for the "runtime_error" field.</summary>
public const int RuntimeErrorFieldNumber = 2;
/// <summary>
- /// This should be set if some other error occurred. This will always
- /// indicate that the test failed. The string can provide more information
- /// about the failure.
+ /// This should be set if some other error occurred. This will always
+ /// indicate that the test failed. The string can provide more information
+ /// about the failure.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string RuntimeError {
@@ -541,8 +375,8 @@ namespace Conformance {
/// <summary>Field number for the "protobuf_payload" field.</summary>
public const int ProtobufPayloadFieldNumber = 3;
/// <summary>
- /// If the input was successfully parsed and the requested output was
- /// protobuf, serialize it to protobuf and set it in this field.
+ /// If the input was successfully parsed and the requested output was
+ /// protobuf, serialize it to protobuf and set it in this field.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pb::ByteString ProtobufPayload {
@@ -556,8 +390,8 @@ namespace Conformance {
/// <summary>Field number for the "json_payload" field.</summary>
public const int JsonPayloadFieldNumber = 4;
/// <summary>
- /// If the input was successfully parsed and the requested output was JSON,
- /// serialize to JSON and set it in this field.
+ /// If the input was successfully parsed and the requested output was JSON,
+ /// serialize to JSON and set it in this field.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string JsonPayload {
@@ -571,8 +405,8 @@ namespace Conformance {
/// <summary>Field number for the "skipped" field.</summary>
public const int SkippedFieldNumber = 5;
/// <summary>
- /// For when the testee skipped the test, likely because a certain feature
- /// wasn't supported, like JSON input/output.
+ /// For when the testee skipped the test, likely because a certain feature
+ /// wasn't supported, like JSON input/output.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Skipped {
@@ -765,3464 +599,6 @@ namespace Conformance {
}
- /// <summary>
- /// This proto includes every type of field in both singular and repeated
- /// forms.
- /// </summary>
- public sealed partial class TestAllTypes : pb::IMessage<TestAllTypes> {
- private static readonly pb::MessageParser<TestAllTypes> _parser = new pb::MessageParser<TestAllTypes>(() => new TestAllTypes());
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public static pb::MessageParser<TestAllTypes> Parser { get { return _parser; } }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public static pbr::MessageDescriptor Descriptor {
- get { return global::Conformance.ConformanceReflection.Descriptor.MessageTypes[2]; }
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- pbr::MessageDescriptor pb::IMessage.Descriptor {
- get { return Descriptor; }
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public TestAllTypes() {
- OnConstruction();
- }
-
- partial void OnConstruction();
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public TestAllTypes(TestAllTypes other) : this() {
- optionalInt32_ = other.optionalInt32_;
- optionalInt64_ = other.optionalInt64_;
- optionalUint32_ = other.optionalUint32_;
- optionalUint64_ = other.optionalUint64_;
- optionalSint32_ = other.optionalSint32_;
- optionalSint64_ = other.optionalSint64_;
- optionalFixed32_ = other.optionalFixed32_;
- optionalFixed64_ = other.optionalFixed64_;
- optionalSfixed32_ = other.optionalSfixed32_;
- optionalSfixed64_ = other.optionalSfixed64_;
- optionalFloat_ = other.optionalFloat_;
- optionalDouble_ = other.optionalDouble_;
- optionalBool_ = other.optionalBool_;
- optionalString_ = other.optionalString_;
- optionalBytes_ = other.optionalBytes_;
- OptionalNestedMessage = other.optionalNestedMessage_ != null ? other.OptionalNestedMessage.Clone() : null;
- OptionalForeignMessage = other.optionalForeignMessage_ != null ? other.OptionalForeignMessage.Clone() : null;
- optionalNestedEnum_ = other.optionalNestedEnum_;
- optionalForeignEnum_ = other.optionalForeignEnum_;
- optionalStringPiece_ = other.optionalStringPiece_;
- optionalCord_ = other.optionalCord_;
- RecursiveMessage = other.recursiveMessage_ != null ? other.RecursiveMessage.Clone() : null;
- repeatedInt32_ = other.repeatedInt32_.Clone();
- repeatedInt64_ = other.repeatedInt64_.Clone();
- repeatedUint32_ = other.repeatedUint32_.Clone();
- repeatedUint64_ = other.repeatedUint64_.Clone();
- repeatedSint32_ = other.repeatedSint32_.Clone();
- repeatedSint64_ = other.repeatedSint64_.Clone();
- repeatedFixed32_ = other.repeatedFixed32_.Clone();
- repeatedFixed64_ = other.repeatedFixed64_.Clone();
- repeatedSfixed32_ = other.repeatedSfixed32_.Clone();
- repeatedSfixed64_ = other.repeatedSfixed64_.Clone();
- repeatedFloat_ = other.repeatedFloat_.Clone();
- repeatedDouble_ = other.repeatedDouble_.Clone();
- repeatedBool_ = other.repeatedBool_.Clone();
- repeatedString_ = other.repeatedString_.Clone();
- repeatedBytes_ = other.repeatedBytes_.Clone();
- repeatedNestedMessage_ = other.repeatedNestedMessage_.Clone();
- repeatedForeignMessage_ = other.repeatedForeignMessage_.Clone();
- repeatedNestedEnum_ = other.repeatedNestedEnum_.Clone();
- repeatedForeignEnum_ = other.repeatedForeignEnum_.Clone();
- repeatedStringPiece_ = other.repeatedStringPiece_.Clone();
- repeatedCord_ = other.repeatedCord_.Clone();
- mapInt32Int32_ = other.mapInt32Int32_.Clone();
- mapInt64Int64_ = other.mapInt64Int64_.Clone();
- mapUint32Uint32_ = other.mapUint32Uint32_.Clone();
- mapUint64Uint64_ = other.mapUint64Uint64_.Clone();
- mapSint32Sint32_ = other.mapSint32Sint32_.Clone();
- mapSint64Sint64_ = other.mapSint64Sint64_.Clone();
- mapFixed32Fixed32_ = other.mapFixed32Fixed32_.Clone();
- mapFixed64Fixed64_ = other.mapFixed64Fixed64_.Clone();
- mapSfixed32Sfixed32_ = other.mapSfixed32Sfixed32_.Clone();
- mapSfixed64Sfixed64_ = other.mapSfixed64Sfixed64_.Clone();
- mapInt32Float_ = other.mapInt32Float_.Clone();
- mapInt32Double_ = other.mapInt32Double_.Clone();
- mapBoolBool_ = other.mapBoolBool_.Clone();
- mapStringString_ = other.mapStringString_.Clone();
- mapStringBytes_ = other.mapStringBytes_.Clone();
- mapStringNestedMessage_ = other.mapStringNestedMessage_.Clone();
- mapStringForeignMessage_ = other.mapStringForeignMessage_.Clone();
- mapStringNestedEnum_ = other.mapStringNestedEnum_.Clone();
- mapStringForeignEnum_ = other.mapStringForeignEnum_.Clone();
- OptionalBoolWrapper = other.OptionalBoolWrapper;
- OptionalInt32Wrapper = other.OptionalInt32Wrapper;
- OptionalInt64Wrapper = other.OptionalInt64Wrapper;
- OptionalUint32Wrapper = other.OptionalUint32Wrapper;
- OptionalUint64Wrapper = other.OptionalUint64Wrapper;
- OptionalFloatWrapper = other.OptionalFloatWrapper;
- OptionalDoubleWrapper = other.OptionalDoubleWrapper;
- OptionalStringWrapper = other.OptionalStringWrapper;
- OptionalBytesWrapper = other.OptionalBytesWrapper;
- repeatedBoolWrapper_ = other.repeatedBoolWrapper_.Clone();
- repeatedInt32Wrapper_ = other.repeatedInt32Wrapper_.Clone();
- repeatedInt64Wrapper_ = other.repeatedInt64Wrapper_.Clone();
- repeatedUint32Wrapper_ = other.repeatedUint32Wrapper_.Clone();
- repeatedUint64Wrapper_ = other.repeatedUint64Wrapper_.Clone();
- repeatedFloatWrapper_ = other.repeatedFloatWrapper_.Clone();
- repeatedDoubleWrapper_ = other.repeatedDoubleWrapper_.Clone();
- repeatedStringWrapper_ = other.repeatedStringWrapper_.Clone();
- repeatedBytesWrapper_ = other.repeatedBytesWrapper_.Clone();
- OptionalDuration = other.optionalDuration_ != null ? other.OptionalDuration.Clone() : null;
- OptionalTimestamp = other.optionalTimestamp_ != null ? other.OptionalTimestamp.Clone() : null;
- OptionalFieldMask = other.optionalFieldMask_ != null ? other.OptionalFieldMask.Clone() : null;
- OptionalStruct = other.optionalStruct_ != null ? other.OptionalStruct.Clone() : null;
- OptionalAny = other.optionalAny_ != null ? other.OptionalAny.Clone() : null;
- OptionalValue = other.optionalValue_ != null ? other.OptionalValue.Clone() : null;
- repeatedDuration_ = other.repeatedDuration_.Clone();
- repeatedTimestamp_ = other.repeatedTimestamp_.Clone();
- repeatedFieldmask_ = other.repeatedFieldmask_.Clone();
- repeatedStruct_ = other.repeatedStruct_.Clone();
- repeatedAny_ = other.repeatedAny_.Clone();
- repeatedValue_ = other.repeatedValue_.Clone();
- fieldname1_ = other.fieldname1_;
- fieldName2_ = other.fieldName2_;
- FieldName3_ = other.FieldName3_;
- fieldName4_ = other.fieldName4_;
- field0Name5_ = other.field0Name5_;
- field0Name6_ = other.field0Name6_;
- fieldName7_ = other.fieldName7_;
- fieldName8_ = other.fieldName8_;
- fieldName9_ = other.fieldName9_;
- fieldName10_ = other.fieldName10_;
- fIELDNAME11_ = other.fIELDNAME11_;
- fIELDName12_ = other.fIELDName12_;
- FieldName13_ = other.FieldName13_;
- FieldName14_ = other.FieldName14_;
- fieldName15_ = other.fieldName15_;
- fieldName16_ = other.fieldName16_;
- fieldName17_ = other.fieldName17_;
- fieldName18_ = other.fieldName18_;
- switch (other.OneofFieldCase) {
- case OneofFieldOneofCase.OneofUint32:
- OneofUint32 = other.OneofUint32;
- break;
- case OneofFieldOneofCase.OneofNestedMessage:
- OneofNestedMessage = other.OneofNestedMessage.Clone();
- break;
- case OneofFieldOneofCase.OneofString:
- OneofString = other.OneofString;
- break;
- case OneofFieldOneofCase.OneofBytes:
- OneofBytes = other.OneofBytes;
- break;
- case OneofFieldOneofCase.OneofBool:
- OneofBool = other.OneofBool;
- break;
- case OneofFieldOneofCase.OneofUint64:
- OneofUint64 = other.OneofUint64;
- break;
- case OneofFieldOneofCase.OneofFloat:
- OneofFloat = other.OneofFloat;
- break;
- case OneofFieldOneofCase.OneofDouble:
- OneofDouble = other.OneofDouble;
- break;
- case OneofFieldOneofCase.OneofEnum:
- OneofEnum = other.OneofEnum;
- break;
- }
-
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public TestAllTypes Clone() {
- return new TestAllTypes(this);
- }
-
- /// <summary>Field number for the "optional_int32" field.</summary>
- public const int OptionalInt32FieldNumber = 1;
- private int optionalInt32_;
- /// <summary>
- /// Singular
- /// </summary>
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public int OptionalInt32 {
- get { return optionalInt32_; }
- set {
- optionalInt32_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_int64" field.</summary>
- public const int OptionalInt64FieldNumber = 2;
- private long optionalInt64_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public long OptionalInt64 {
- get { return optionalInt64_; }
- set {
- optionalInt64_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_uint32" field.</summary>
- public const int OptionalUint32FieldNumber = 3;
- private uint optionalUint32_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public uint OptionalUint32 {
- get { return optionalUint32_; }
- set {
- optionalUint32_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_uint64" field.</summary>
- public const int OptionalUint64FieldNumber = 4;
- private ulong optionalUint64_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public ulong OptionalUint64 {
- get { return optionalUint64_; }
- set {
- optionalUint64_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_sint32" field.</summary>
- public const int OptionalSint32FieldNumber = 5;
- private int optionalSint32_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public int OptionalSint32 {
- get { return optionalSint32_; }
- set {
- optionalSint32_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_sint64" field.</summary>
- public const int OptionalSint64FieldNumber = 6;
- private long optionalSint64_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public long OptionalSint64 {
- get { return optionalSint64_; }
- set {
- optionalSint64_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_fixed32" field.</summary>
- public const int OptionalFixed32FieldNumber = 7;
- private uint optionalFixed32_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public uint OptionalFixed32 {
- get { return optionalFixed32_; }
- set {
- optionalFixed32_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_fixed64" field.</summary>
- public const int OptionalFixed64FieldNumber = 8;
- private ulong optionalFixed64_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public ulong OptionalFixed64 {
- get { return optionalFixed64_; }
- set {
- optionalFixed64_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_sfixed32" field.</summary>
- public const int OptionalSfixed32FieldNumber = 9;
- private int optionalSfixed32_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public int OptionalSfixed32 {
- get { return optionalSfixed32_; }
- set {
- optionalSfixed32_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_sfixed64" field.</summary>
- public const int OptionalSfixed64FieldNumber = 10;
- private long optionalSfixed64_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public long OptionalSfixed64 {
- get { return optionalSfixed64_; }
- set {
- optionalSfixed64_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_float" field.</summary>
- public const int OptionalFloatFieldNumber = 11;
- private float optionalFloat_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public float OptionalFloat {
- get { return optionalFloat_; }
- set {
- optionalFloat_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_double" field.</summary>
- public const int OptionalDoubleFieldNumber = 12;
- private double optionalDouble_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public double OptionalDouble {
- get { return optionalDouble_; }
- set {
- optionalDouble_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_bool" field.</summary>
- public const int OptionalBoolFieldNumber = 13;
- private bool optionalBool_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public bool OptionalBool {
- get { return optionalBool_; }
- set {
- optionalBool_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_string" field.</summary>
- public const int OptionalStringFieldNumber = 14;
- private string optionalString_ = "";
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public string OptionalString {
- get { return optionalString_; }
- set {
- optionalString_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
- }
- }
-
- /// <summary>Field number for the "optional_bytes" field.</summary>
- public const int OptionalBytesFieldNumber = 15;
- private pb::ByteString optionalBytes_ = pb::ByteString.Empty;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pb::ByteString OptionalBytes {
- get { return optionalBytes_; }
- set {
- optionalBytes_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
- }
- }
-
- /// <summary>Field number for the "optional_nested_message" field.</summary>
- public const int OptionalNestedMessageFieldNumber = 18;
- private global::Conformance.TestAllTypes.Types.NestedMessage optionalNestedMessage_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public global::Conformance.TestAllTypes.Types.NestedMessage OptionalNestedMessage {
- get { return optionalNestedMessage_; }
- set {
- optionalNestedMessage_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_foreign_message" field.</summary>
- public const int OptionalForeignMessageFieldNumber = 19;
- private global::Conformance.ForeignMessage optionalForeignMessage_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public global::Conformance.ForeignMessage OptionalForeignMessage {
- get { return optionalForeignMessage_; }
- set {
- optionalForeignMessage_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_nested_enum" field.</summary>
- public const int OptionalNestedEnumFieldNumber = 21;
- private global::Conformance.TestAllTypes.Types.NestedEnum optionalNestedEnum_ = 0;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public global::Conformance.TestAllTypes.Types.NestedEnum OptionalNestedEnum {
- get { return optionalNestedEnum_; }
- set {
- optionalNestedEnum_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_foreign_enum" field.</summary>
- public const int OptionalForeignEnumFieldNumber = 22;
- private global::Conformance.ForeignEnum optionalForeignEnum_ = 0;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public global::Conformance.ForeignEnum OptionalForeignEnum {
- get { return optionalForeignEnum_; }
- set {
- optionalForeignEnum_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_string_piece" field.</summary>
- public const int OptionalStringPieceFieldNumber = 24;
- private string optionalStringPiece_ = "";
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public string OptionalStringPiece {
- get { return optionalStringPiece_; }
- set {
- optionalStringPiece_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
- }
- }
-
- /// <summary>Field number for the "optional_cord" field.</summary>
- public const int OptionalCordFieldNumber = 25;
- private string optionalCord_ = "";
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public string OptionalCord {
- get { return optionalCord_; }
- set {
- optionalCord_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
- }
- }
-
- /// <summary>Field number for the "recursive_message" field.</summary>
- public const int RecursiveMessageFieldNumber = 27;
- private global::Conformance.TestAllTypes recursiveMessage_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public global::Conformance.TestAllTypes RecursiveMessage {
- get { return recursiveMessage_; }
- set {
- recursiveMessage_ = value;
- }
- }
-
- /// <summary>Field number for the "repeated_int32" field.</summary>
- public const int RepeatedInt32FieldNumber = 31;
- private static readonly pb::FieldCodec<int> _repeated_repeatedInt32_codec
- = pb::FieldCodec.ForInt32(250);
- private readonly pbc::RepeatedField<int> repeatedInt32_ = new pbc::RepeatedField<int>();
- /// <summary>
- /// Repeated
- /// </summary>
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<int> RepeatedInt32 {
- get { return repeatedInt32_; }
- }
-
- /// <summary>Field number for the "repeated_int64" field.</summary>
- public const int RepeatedInt64FieldNumber = 32;
- private static readonly pb::FieldCodec<long> _repeated_repeatedInt64_codec
- = pb::FieldCodec.ForInt64(258);
- private readonly pbc::RepeatedField<long> repeatedInt64_ = new pbc::RepeatedField<long>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<long> RepeatedInt64 {
- get { return repeatedInt64_; }
- }
-
- /// <summary>Field number for the "repeated_uint32" field.</summary>
- public const int RepeatedUint32FieldNumber = 33;
- private static readonly pb::FieldCodec<uint> _repeated_repeatedUint32_codec
- = pb::FieldCodec.ForUInt32(266);
- private readonly pbc::RepeatedField<uint> repeatedUint32_ = new pbc::RepeatedField<uint>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<uint> RepeatedUint32 {
- get { return repeatedUint32_; }
- }
-
- /// <summary>Field number for the "repeated_uint64" field.</summary>
- public const int RepeatedUint64FieldNumber = 34;
- private static readonly pb::FieldCodec<ulong> _repeated_repeatedUint64_codec
- = pb::FieldCodec.ForUInt64(274);
- private readonly pbc::RepeatedField<ulong> repeatedUint64_ = new pbc::RepeatedField<ulong>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<ulong> RepeatedUint64 {
- get { return repeatedUint64_; }
- }
-
- /// <summary>Field number for the "repeated_sint32" field.</summary>
- public const int RepeatedSint32FieldNumber = 35;
- private static readonly pb::FieldCodec<int> _repeated_repeatedSint32_codec
- = pb::FieldCodec.ForSInt32(282);
- private readonly pbc::RepeatedField<int> repeatedSint32_ = new pbc::RepeatedField<int>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<int> RepeatedSint32 {
- get { return repeatedSint32_; }
- }
-
- /// <summary>Field number for the "repeated_sint64" field.</summary>
- public const int RepeatedSint64FieldNumber = 36;
- private static readonly pb::FieldCodec<long> _repeated_repeatedSint64_codec
- = pb::FieldCodec.ForSInt64(290);
- private readonly pbc::RepeatedField<long> repeatedSint64_ = new pbc::RepeatedField<long>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<long> RepeatedSint64 {
- get { return repeatedSint64_; }
- }
-
- /// <summary>Field number for the "repeated_fixed32" field.</summary>
- public const int RepeatedFixed32FieldNumber = 37;
- private static readonly pb::FieldCodec<uint> _repeated_repeatedFixed32_codec
- = pb::FieldCodec.ForFixed32(298);
- private readonly pbc::RepeatedField<uint> repeatedFixed32_ = new pbc::RepeatedField<uint>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<uint> RepeatedFixed32 {
- get { return repeatedFixed32_; }
- }
-
- /// <summary>Field number for the "repeated_fixed64" field.</summary>
- public const int RepeatedFixed64FieldNumber = 38;
- private static readonly pb::FieldCodec<ulong> _repeated_repeatedFixed64_codec
- = pb::FieldCodec.ForFixed64(306);
- private readonly pbc::RepeatedField<ulong> repeatedFixed64_ = new pbc::RepeatedField<ulong>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<ulong> RepeatedFixed64 {
- get { return repeatedFixed64_; }
- }
-
- /// <summary>Field number for the "repeated_sfixed32" field.</summary>
- public const int RepeatedSfixed32FieldNumber = 39;
- private static readonly pb::FieldCodec<int> _repeated_repeatedSfixed32_codec
- = pb::FieldCodec.ForSFixed32(314);
- private readonly pbc::RepeatedField<int> repeatedSfixed32_ = new pbc::RepeatedField<int>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<int> RepeatedSfixed32 {
- get { return repeatedSfixed32_; }
- }
-
- /// <summary>Field number for the "repeated_sfixed64" field.</summary>
- public const int RepeatedSfixed64FieldNumber = 40;
- private static readonly pb::FieldCodec<long> _repeated_repeatedSfixed64_codec
- = pb::FieldCodec.ForSFixed64(322);
- private readonly pbc::RepeatedField<long> repeatedSfixed64_ = new pbc::RepeatedField<long>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<long> RepeatedSfixed64 {
- get { return repeatedSfixed64_; }
- }
-
- /// <summary>Field number for the "repeated_float" field.</summary>
- public const int RepeatedFloatFieldNumber = 41;
- private static readonly pb::FieldCodec<float> _repeated_repeatedFloat_codec
- = pb::FieldCodec.ForFloat(330);
- private readonly pbc::RepeatedField<float> repeatedFloat_ = new pbc::RepeatedField<float>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<float> RepeatedFloat {
- get { return repeatedFloat_; }
- }
-
- /// <summary>Field number for the "repeated_double" field.</summary>
- public const int RepeatedDoubleFieldNumber = 42;
- private static readonly pb::FieldCodec<double> _repeated_repeatedDouble_codec
- = pb::FieldCodec.ForDouble(338);
- private readonly pbc::RepeatedField<double> repeatedDouble_ = new pbc::RepeatedField<double>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<double> RepeatedDouble {
- get { return repeatedDouble_; }
- }
-
- /// <summary>Field number for the "repeated_bool" field.</summary>
- public const int RepeatedBoolFieldNumber = 43;
- private static readonly pb::FieldCodec<bool> _repeated_repeatedBool_codec
- = pb::FieldCodec.ForBool(346);
- private readonly pbc::RepeatedField<bool> repeatedBool_ = new pbc::RepeatedField<bool>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<bool> RepeatedBool {
- get { return repeatedBool_; }
- }
-
- /// <summary>Field number for the "repeated_string" field.</summary>
- public const int RepeatedStringFieldNumber = 44;
- private static readonly pb::FieldCodec<string> _repeated_repeatedString_codec
- = pb::FieldCodec.ForString(354);
- private readonly pbc::RepeatedField<string> repeatedString_ = new pbc::RepeatedField<string>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<string> RepeatedString {
- get { return repeatedString_; }
- }
-
- /// <summary>Field number for the "repeated_bytes" field.</summary>
- public const int RepeatedBytesFieldNumber = 45;
- private static readonly pb::FieldCodec<pb::ByteString> _repeated_repeatedBytes_codec
- = pb::FieldCodec.ForBytes(362);
- private readonly pbc::RepeatedField<pb::ByteString> repeatedBytes_ = new pbc::RepeatedField<pb::ByteString>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<pb::ByteString> RepeatedBytes {
- get { return repeatedBytes_; }
- }
-
- /// <summary>Field number for the "repeated_nested_message" field.</summary>
- public const int RepeatedNestedMessageFieldNumber = 48;
- private static readonly pb::FieldCodec<global::Conformance.TestAllTypes.Types.NestedMessage> _repeated_repeatedNestedMessage_codec
- = pb::FieldCodec.ForMessage(386, global::Conformance.TestAllTypes.Types.NestedMessage.Parser);
- private readonly pbc::RepeatedField<global::Conformance.TestAllTypes.Types.NestedMessage> repeatedNestedMessage_ = new pbc::RepeatedField<global::Conformance.TestAllTypes.Types.NestedMessage>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<global::Conformance.TestAllTypes.Types.NestedMessage> RepeatedNestedMessage {
- get { return repeatedNestedMessage_; }
- }
-
- /// <summary>Field number for the "repeated_foreign_message" field.</summary>
- public const int RepeatedForeignMessageFieldNumber = 49;
- private static readonly pb::FieldCodec<global::Conformance.ForeignMessage> _repeated_repeatedForeignMessage_codec
- = pb::FieldCodec.ForMessage(394, global::Conformance.ForeignMessage.Parser);
- private readonly pbc::RepeatedField<global::Conformance.ForeignMessage> repeatedForeignMessage_ = new pbc::RepeatedField<global::Conformance.ForeignMessage>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<global::Conformance.ForeignMessage> RepeatedForeignMessage {
- get { return repeatedForeignMessage_; }
- }
-
- /// <summary>Field number for the "repeated_nested_enum" field.</summary>
- public const int RepeatedNestedEnumFieldNumber = 51;
- private static readonly pb::FieldCodec<global::Conformance.TestAllTypes.Types.NestedEnum> _repeated_repeatedNestedEnum_codec
- = pb::FieldCodec.ForEnum(410, x => (int) x, x => (global::Conformance.TestAllTypes.Types.NestedEnum) x);
- private readonly pbc::RepeatedField<global::Conformance.TestAllTypes.Types.NestedEnum> repeatedNestedEnum_ = new pbc::RepeatedField<global::Conformance.TestAllTypes.Types.NestedEnum>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<global::Conformance.TestAllTypes.Types.NestedEnum> RepeatedNestedEnum {
- get { return repeatedNestedEnum_; }
- }
-
- /// <summary>Field number for the "repeated_foreign_enum" field.</summary>
- public const int RepeatedForeignEnumFieldNumber = 52;
- private static readonly pb::FieldCodec<global::Conformance.ForeignEnum> _repeated_repeatedForeignEnum_codec
- = pb::FieldCodec.ForEnum(418, x => (int) x, x => (global::Conformance.ForeignEnum) x);
- private readonly pbc::RepeatedField<global::Conformance.ForeignEnum> repeatedForeignEnum_ = new pbc::RepeatedField<global::Conformance.ForeignEnum>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<global::Conformance.ForeignEnum> RepeatedForeignEnum {
- get { return repeatedForeignEnum_; }
- }
-
- /// <summary>Field number for the "repeated_string_piece" field.</summary>
- public const int RepeatedStringPieceFieldNumber = 54;
- private static readonly pb::FieldCodec<string> _repeated_repeatedStringPiece_codec
- = pb::FieldCodec.ForString(434);
- private readonly pbc::RepeatedField<string> repeatedStringPiece_ = new pbc::RepeatedField<string>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<string> RepeatedStringPiece {
- get { return repeatedStringPiece_; }
- }
-
- /// <summary>Field number for the "repeated_cord" field.</summary>
- public const int RepeatedCordFieldNumber = 55;
- private static readonly pb::FieldCodec<string> _repeated_repeatedCord_codec
- = pb::FieldCodec.ForString(442);
- private readonly pbc::RepeatedField<string> repeatedCord_ = new pbc::RepeatedField<string>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<string> RepeatedCord {
- get { return repeatedCord_; }
- }
-
- /// <summary>Field number for the "map_int32_int32" field.</summary>
- public const int MapInt32Int32FieldNumber = 56;
- private static readonly pbc::MapField<int, int>.Codec _map_mapInt32Int32_codec
- = new pbc::MapField<int, int>.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForInt32(16), 450);
- private readonly pbc::MapField<int, int> mapInt32Int32_ = new pbc::MapField<int, int>();
- /// <summary>
- /// Map
- /// </summary>
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::MapField<int, int> MapInt32Int32 {
- get { return mapInt32Int32_; }
- }
-
- /// <summary>Field number for the "map_int64_int64" field.</summary>
- public const int MapInt64Int64FieldNumber = 57;
- private static readonly pbc::MapField<long, long>.Codec _map_mapInt64Int64_codec
- = new pbc::MapField<long, long>.Codec(pb::FieldCodec.ForInt64(8), pb::FieldCodec.ForInt64(16), 458);
- private readonly pbc::MapField<long, long> mapInt64Int64_ = new pbc::MapField<long, long>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::MapField<long, long> MapInt64Int64 {
- get { return mapInt64Int64_; }
- }
-
- /// <summary>Field number for the "map_uint32_uint32" field.</summary>
- public const int MapUint32Uint32FieldNumber = 58;
- private static readonly pbc::MapField<uint, uint>.Codec _map_mapUint32Uint32_codec
- = new pbc::MapField<uint, uint>.Codec(pb::FieldCodec.ForUInt32(8), pb::FieldCodec.ForUInt32(16), 466);
- private readonly pbc::MapField<uint, uint> mapUint32Uint32_ = new pbc::MapField<uint, uint>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::MapField<uint, uint> MapUint32Uint32 {
- get { return mapUint32Uint32_; }
- }
-
- /// <summary>Field number for the "map_uint64_uint64" field.</summary>
- public const int MapUint64Uint64FieldNumber = 59;
- private static readonly pbc::MapField<ulong, ulong>.Codec _map_mapUint64Uint64_codec
- = new pbc::MapField<ulong, ulong>.Codec(pb::FieldCodec.ForUInt64(8), pb::FieldCodec.ForUInt64(16), 474);
- private readonly pbc::MapField<ulong, ulong> mapUint64Uint64_ = new pbc::MapField<ulong, ulong>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::MapField<ulong, ulong> MapUint64Uint64 {
- get { return mapUint64Uint64_; }
- }
-
- /// <summary>Field number for the "map_sint32_sint32" field.</summary>
- public const int MapSint32Sint32FieldNumber = 60;
- private static readonly pbc::MapField<int, int>.Codec _map_mapSint32Sint32_codec
- = new pbc::MapField<int, int>.Codec(pb::FieldCodec.ForSInt32(8), pb::FieldCodec.ForSInt32(16), 482);
- private readonly pbc::MapField<int, int> mapSint32Sint32_ = new pbc::MapField<int, int>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::MapField<int, int> MapSint32Sint32 {
- get { return mapSint32Sint32_; }
- }
-
- /// <summary>Field number for the "map_sint64_sint64" field.</summary>
- public const int MapSint64Sint64FieldNumber = 61;
- private static readonly pbc::MapField<long, long>.Codec _map_mapSint64Sint64_codec
- = new pbc::MapField<long, long>.Codec(pb::FieldCodec.ForSInt64(8), pb::FieldCodec.ForSInt64(16), 490);
- private readonly pbc::MapField<long, long> mapSint64Sint64_ = new pbc::MapField<long, long>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::MapField<long, long> MapSint64Sint64 {
- get { return mapSint64Sint64_; }
- }
-
- /// <summary>Field number for the "map_fixed32_fixed32" field.</summary>
- public const int MapFixed32Fixed32FieldNumber = 62;
- private static readonly pbc::MapField<uint, uint>.Codec _map_mapFixed32Fixed32_codec
- = new pbc::MapField<uint, uint>.Codec(pb::FieldCodec.ForFixed32(13), pb::FieldCodec.ForFixed32(21), 498);
- private readonly pbc::MapField<uint, uint> mapFixed32Fixed32_ = new pbc::MapField<uint, uint>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::MapField<uint, uint> MapFixed32Fixed32 {
- get { return mapFixed32Fixed32_; }
- }
-
- /// <summary>Field number for the "map_fixed64_fixed64" field.</summary>
- public const int MapFixed64Fixed64FieldNumber = 63;
- private static readonly pbc::MapField<ulong, ulong>.Codec _map_mapFixed64Fixed64_codec
- = new pbc::MapField<ulong, ulong>.Codec(pb::FieldCodec.ForFixed64(9), pb::FieldCodec.ForFixed64(17), 506);
- private readonly pbc::MapField<ulong, ulong> mapFixed64Fixed64_ = new pbc::MapField<ulong, ulong>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::MapField<ulong, ulong> MapFixed64Fixed64 {
- get { return mapFixed64Fixed64_; }
- }
-
- /// <summary>Field number for the "map_sfixed32_sfixed32" field.</summary>
- public const int MapSfixed32Sfixed32FieldNumber = 64;
- private static readonly pbc::MapField<int, int>.Codec _map_mapSfixed32Sfixed32_codec
- = new pbc::MapField<int, int>.Codec(pb::FieldCodec.ForSFixed32(13), pb::FieldCodec.ForSFixed32(21), 514);
- private readonly pbc::MapField<int, int> mapSfixed32Sfixed32_ = new pbc::MapField<int, int>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::MapField<int, int> MapSfixed32Sfixed32 {
- get { return mapSfixed32Sfixed32_; }
- }
-
- /// <summary>Field number for the "map_sfixed64_sfixed64" field.</summary>
- public const int MapSfixed64Sfixed64FieldNumber = 65;
- private static readonly pbc::MapField<long, long>.Codec _map_mapSfixed64Sfixed64_codec
- = new pbc::MapField<long, long>.Codec(pb::FieldCodec.ForSFixed64(9), pb::FieldCodec.ForSFixed64(17), 522);
- private readonly pbc::MapField<long, long> mapSfixed64Sfixed64_ = new pbc::MapField<long, long>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::MapField<long, long> MapSfixed64Sfixed64 {
- get { return mapSfixed64Sfixed64_; }
- }
-
- /// <summary>Field number for the "map_int32_float" field.</summary>
- public const int MapInt32FloatFieldNumber = 66;
- private static readonly pbc::MapField<int, float>.Codec _map_mapInt32Float_codec
- = new pbc::MapField<int, float>.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForFloat(21), 530);
- private readonly pbc::MapField<int, float> mapInt32Float_ = new pbc::MapField<int, float>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::MapField<int, float> MapInt32Float {
- get { return mapInt32Float_; }
- }
-
- /// <summary>Field number for the "map_int32_double" field.</summary>
- public const int MapInt32DoubleFieldNumber = 67;
- private static readonly pbc::MapField<int, double>.Codec _map_mapInt32Double_codec
- = new pbc::MapField<int, double>.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForDouble(17), 538);
- private readonly pbc::MapField<int, double> mapInt32Double_ = new pbc::MapField<int, double>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::MapField<int, double> MapInt32Double {
- get { return mapInt32Double_; }
- }
-
- /// <summary>Field number for the "map_bool_bool" field.</summary>
- public const int MapBoolBoolFieldNumber = 68;
- private static readonly pbc::MapField<bool, bool>.Codec _map_mapBoolBool_codec
- = new pbc::MapField<bool, bool>.Codec(pb::FieldCodec.ForBool(8), pb::FieldCodec.ForBool(16), 546);
- private readonly pbc::MapField<bool, bool> mapBoolBool_ = new pbc::MapField<bool, bool>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::MapField<bool, bool> MapBoolBool {
- get { return mapBoolBool_; }
- }
-
- /// <summary>Field number for the "map_string_string" field.</summary>
- public const int MapStringStringFieldNumber = 69;
- private static readonly pbc::MapField<string, string>.Codec _map_mapStringString_codec
- = new pbc::MapField<string, string>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForString(18), 554);
- private readonly pbc::MapField<string, string> mapStringString_ = new pbc::MapField<string, string>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::MapField<string, string> MapStringString {
- get { return mapStringString_; }
- }
-
- /// <summary>Field number for the "map_string_bytes" field.</summary>
- public const int MapStringBytesFieldNumber = 70;
- private static readonly pbc::MapField<string, pb::ByteString>.Codec _map_mapStringBytes_codec
- = new pbc::MapField<string, pb::ByteString>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForBytes(18), 562);
- private readonly pbc::MapField<string, pb::ByteString> mapStringBytes_ = new pbc::MapField<string, pb::ByteString>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::MapField<string, pb::ByteString> MapStringBytes {
- get { return mapStringBytes_; }
- }
-
- /// <summary>Field number for the "map_string_nested_message" field.</summary>
- public const int MapStringNestedMessageFieldNumber = 71;
- private static readonly pbc::MapField<string, global::Conformance.TestAllTypes.Types.NestedMessage>.Codec _map_mapStringNestedMessage_codec
- = new pbc::MapField<string, global::Conformance.TestAllTypes.Types.NestedMessage>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForMessage(18, global::Conformance.TestAllTypes.Types.NestedMessage.Parser), 570);
- private readonly pbc::MapField<string, global::Conformance.TestAllTypes.Types.NestedMessage> mapStringNestedMessage_ = new pbc::MapField<string, global::Conformance.TestAllTypes.Types.NestedMessage>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::MapField<string, global::Conformance.TestAllTypes.Types.NestedMessage> MapStringNestedMessage {
- get { return mapStringNestedMessage_; }
- }
-
- /// <summary>Field number for the "map_string_foreign_message" field.</summary>
- public const int MapStringForeignMessageFieldNumber = 72;
- private static readonly pbc::MapField<string, global::Conformance.ForeignMessage>.Codec _map_mapStringForeignMessage_codec
- = new pbc::MapField<string, global::Conformance.ForeignMessage>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForMessage(18, global::Conformance.ForeignMessage.Parser), 578);
- private readonly pbc::MapField<string, global::Conformance.ForeignMessage> mapStringForeignMessage_ = new pbc::MapField<string, global::Conformance.ForeignMessage>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::MapField<string, global::Conformance.ForeignMessage> MapStringForeignMessage {
- get { return mapStringForeignMessage_; }
- }
-
- /// <summary>Field number for the "map_string_nested_enum" field.</summary>
- public const int MapStringNestedEnumFieldNumber = 73;
- private static readonly pbc::MapField<string, global::Conformance.TestAllTypes.Types.NestedEnum>.Codec _map_mapStringNestedEnum_codec
- = new pbc::MapField<string, global::Conformance.TestAllTypes.Types.NestedEnum>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForEnum(16, x => (int) x, x => (global::Conformance.TestAllTypes.Types.NestedEnum) x), 586);
- private readonly pbc::MapField<string, global::Conformance.TestAllTypes.Types.NestedEnum> mapStringNestedEnum_ = new pbc::MapField<string, global::Conformance.TestAllTypes.Types.NestedEnum>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::MapField<string, global::Conformance.TestAllTypes.Types.NestedEnum> MapStringNestedEnum {
- get { return mapStringNestedEnum_; }
- }
-
- /// <summary>Field number for the "map_string_foreign_enum" field.</summary>
- public const int MapStringForeignEnumFieldNumber = 74;
- private static readonly pbc::MapField<string, global::Conformance.ForeignEnum>.Codec _map_mapStringForeignEnum_codec
- = new pbc::MapField<string, global::Conformance.ForeignEnum>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForEnum(16, x => (int) x, x => (global::Conformance.ForeignEnum) x), 594);
- private readonly pbc::MapField<string, global::Conformance.ForeignEnum> mapStringForeignEnum_ = new pbc::MapField<string, global::Conformance.ForeignEnum>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::MapField<string, global::Conformance.ForeignEnum> MapStringForeignEnum {
- get { return mapStringForeignEnum_; }
- }
-
- /// <summary>Field number for the "oneof_uint32" field.</summary>
- public const int OneofUint32FieldNumber = 111;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public uint OneofUint32 {
- get { return oneofFieldCase_ == OneofFieldOneofCase.OneofUint32 ? (uint) oneofField_ : 0; }
- set {
- oneofField_ = value;
- oneofFieldCase_ = OneofFieldOneofCase.OneofUint32;
- }
- }
-
- /// <summary>Field number for the "oneof_nested_message" field.</summary>
- public const int OneofNestedMessageFieldNumber = 112;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public global::Conformance.TestAllTypes.Types.NestedMessage OneofNestedMessage {
- get { return oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage ? (global::Conformance.TestAllTypes.Types.NestedMessage) oneofField_ : null; }
- set {
- oneofField_ = value;
- oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.OneofNestedMessage;
- }
- }
-
- /// <summary>Field number for the "oneof_string" field.</summary>
- public const int OneofStringFieldNumber = 113;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public string OneofString {
- get { return oneofFieldCase_ == OneofFieldOneofCase.OneofString ? (string) oneofField_ : ""; }
- set {
- oneofField_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
- oneofFieldCase_ = OneofFieldOneofCase.OneofString;
- }
- }
-
- /// <summary>Field number for the "oneof_bytes" field.</summary>
- public const int OneofBytesFieldNumber = 114;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pb::ByteString OneofBytes {
- get { return oneofFieldCase_ == OneofFieldOneofCase.OneofBytes ? (pb::ByteString) oneofField_ : pb::ByteString.Empty; }
- set {
- oneofField_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
- oneofFieldCase_ = OneofFieldOneofCase.OneofBytes;
- }
- }
-
- /// <summary>Field number for the "oneof_bool" field.</summary>
- public const int OneofBoolFieldNumber = 115;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public bool OneofBool {
- get { return oneofFieldCase_ == OneofFieldOneofCase.OneofBool ? (bool) oneofField_ : false; }
- set {
- oneofField_ = value;
- oneofFieldCase_ = OneofFieldOneofCase.OneofBool;
- }
- }
-
- /// <summary>Field number for the "oneof_uint64" field.</summary>
- public const int OneofUint64FieldNumber = 116;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public ulong OneofUint64 {
- get { return oneofFieldCase_ == OneofFieldOneofCase.OneofUint64 ? (ulong) oneofField_ : 0UL; }
- set {
- oneofField_ = value;
- oneofFieldCase_ = OneofFieldOneofCase.OneofUint64;
- }
- }
-
- /// <summary>Field number for the "oneof_float" field.</summary>
- public const int OneofFloatFieldNumber = 117;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public float OneofFloat {
- get { return oneofFieldCase_ == OneofFieldOneofCase.OneofFloat ? (float) oneofField_ : 0F; }
- set {
- oneofField_ = value;
- oneofFieldCase_ = OneofFieldOneofCase.OneofFloat;
- }
- }
-
- /// <summary>Field number for the "oneof_double" field.</summary>
- public const int OneofDoubleFieldNumber = 118;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public double OneofDouble {
- get { return oneofFieldCase_ == OneofFieldOneofCase.OneofDouble ? (double) oneofField_ : 0D; }
- set {
- oneofField_ = value;
- oneofFieldCase_ = OneofFieldOneofCase.OneofDouble;
- }
- }
-
- /// <summary>Field number for the "oneof_enum" field.</summary>
- public const int OneofEnumFieldNumber = 119;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public global::Conformance.TestAllTypes.Types.NestedEnum OneofEnum {
- get { return oneofFieldCase_ == OneofFieldOneofCase.OneofEnum ? (global::Conformance.TestAllTypes.Types.NestedEnum) oneofField_ : 0; }
- set {
- oneofField_ = value;
- oneofFieldCase_ = OneofFieldOneofCase.OneofEnum;
- }
- }
-
- /// <summary>Field number for the "optional_bool_wrapper" field.</summary>
- public const int OptionalBoolWrapperFieldNumber = 201;
- private static readonly pb::FieldCodec<bool?> _single_optionalBoolWrapper_codec = pb::FieldCodec.ForStructWrapper<bool>(1610);
- private bool? optionalBoolWrapper_;
- /// <summary>
- /// Well-known types
- /// </summary>
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public bool? OptionalBoolWrapper {
- get { return optionalBoolWrapper_; }
- set {
- optionalBoolWrapper_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_int32_wrapper" field.</summary>
- public const int OptionalInt32WrapperFieldNumber = 202;
- private static readonly pb::FieldCodec<int?> _single_optionalInt32Wrapper_codec = pb::FieldCodec.ForStructWrapper<int>(1618);
- private int? optionalInt32Wrapper_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public int? OptionalInt32Wrapper {
- get { return optionalInt32Wrapper_; }
- set {
- optionalInt32Wrapper_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_int64_wrapper" field.</summary>
- public const int OptionalInt64WrapperFieldNumber = 203;
- private static readonly pb::FieldCodec<long?> _single_optionalInt64Wrapper_codec = pb::FieldCodec.ForStructWrapper<long>(1626);
- private long? optionalInt64Wrapper_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public long? OptionalInt64Wrapper {
- get { return optionalInt64Wrapper_; }
- set {
- optionalInt64Wrapper_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_uint32_wrapper" field.</summary>
- public const int OptionalUint32WrapperFieldNumber = 204;
- private static readonly pb::FieldCodec<uint?> _single_optionalUint32Wrapper_codec = pb::FieldCodec.ForStructWrapper<uint>(1634);
- private uint? optionalUint32Wrapper_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public uint? OptionalUint32Wrapper {
- get { return optionalUint32Wrapper_; }
- set {
- optionalUint32Wrapper_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_uint64_wrapper" field.</summary>
- public const int OptionalUint64WrapperFieldNumber = 205;
- private static readonly pb::FieldCodec<ulong?> _single_optionalUint64Wrapper_codec = pb::FieldCodec.ForStructWrapper<ulong>(1642);
- private ulong? optionalUint64Wrapper_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public ulong? OptionalUint64Wrapper {
- get { return optionalUint64Wrapper_; }
- set {
- optionalUint64Wrapper_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_float_wrapper" field.</summary>
- public const int OptionalFloatWrapperFieldNumber = 206;
- private static readonly pb::FieldCodec<float?> _single_optionalFloatWrapper_codec = pb::FieldCodec.ForStructWrapper<float>(1650);
- private float? optionalFloatWrapper_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public float? OptionalFloatWrapper {
- get { return optionalFloatWrapper_; }
- set {
- optionalFloatWrapper_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_double_wrapper" field.</summary>
- public const int OptionalDoubleWrapperFieldNumber = 207;
- private static readonly pb::FieldCodec<double?> _single_optionalDoubleWrapper_codec = pb::FieldCodec.ForStructWrapper<double>(1658);
- private double? optionalDoubleWrapper_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public double? OptionalDoubleWrapper {
- get { return optionalDoubleWrapper_; }
- set {
- optionalDoubleWrapper_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_string_wrapper" field.</summary>
- public const int OptionalStringWrapperFieldNumber = 208;
- private static readonly pb::FieldCodec<string> _single_optionalStringWrapper_codec = pb::FieldCodec.ForClassWrapper<string>(1666);
- private string optionalStringWrapper_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public string OptionalStringWrapper {
- get { return optionalStringWrapper_; }
- set {
- optionalStringWrapper_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_bytes_wrapper" field.</summary>
- public const int OptionalBytesWrapperFieldNumber = 209;
- private static readonly pb::FieldCodec<pb::ByteString> _single_optionalBytesWrapper_codec = pb::FieldCodec.ForClassWrapper<pb::ByteString>(1674);
- private pb::ByteString optionalBytesWrapper_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pb::ByteString OptionalBytesWrapper {
- get { return optionalBytesWrapper_; }
- set {
- optionalBytesWrapper_ = value;
- }
- }
-
- /// <summary>Field number for the "repeated_bool_wrapper" field.</summary>
- public const int RepeatedBoolWrapperFieldNumber = 211;
- private static readonly pb::FieldCodec<bool?> _repeated_repeatedBoolWrapper_codec
- = pb::FieldCodec.ForStructWrapper<bool>(1690);
- private readonly pbc::RepeatedField<bool?> repeatedBoolWrapper_ = new pbc::RepeatedField<bool?>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<bool?> RepeatedBoolWrapper {
- get { return repeatedBoolWrapper_; }
- }
-
- /// <summary>Field number for the "repeated_int32_wrapper" field.</summary>
- public const int RepeatedInt32WrapperFieldNumber = 212;
- private static readonly pb::FieldCodec<int?> _repeated_repeatedInt32Wrapper_codec
- = pb::FieldCodec.ForStructWrapper<int>(1698);
- private readonly pbc::RepeatedField<int?> repeatedInt32Wrapper_ = new pbc::RepeatedField<int?>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<int?> RepeatedInt32Wrapper {
- get { return repeatedInt32Wrapper_; }
- }
-
- /// <summary>Field number for the "repeated_int64_wrapper" field.</summary>
- public const int RepeatedInt64WrapperFieldNumber = 213;
- private static readonly pb::FieldCodec<long?> _repeated_repeatedInt64Wrapper_codec
- = pb::FieldCodec.ForStructWrapper<long>(1706);
- private readonly pbc::RepeatedField<long?> repeatedInt64Wrapper_ = new pbc::RepeatedField<long?>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<long?> RepeatedInt64Wrapper {
- get { return repeatedInt64Wrapper_; }
- }
-
- /// <summary>Field number for the "repeated_uint32_wrapper" field.</summary>
- public const int RepeatedUint32WrapperFieldNumber = 214;
- private static readonly pb::FieldCodec<uint?> _repeated_repeatedUint32Wrapper_codec
- = pb::FieldCodec.ForStructWrapper<uint>(1714);
- private readonly pbc::RepeatedField<uint?> repeatedUint32Wrapper_ = new pbc::RepeatedField<uint?>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<uint?> RepeatedUint32Wrapper {
- get { return repeatedUint32Wrapper_; }
- }
-
- /// <summary>Field number for the "repeated_uint64_wrapper" field.</summary>
- public const int RepeatedUint64WrapperFieldNumber = 215;
- private static readonly pb::FieldCodec<ulong?> _repeated_repeatedUint64Wrapper_codec
- = pb::FieldCodec.ForStructWrapper<ulong>(1722);
- private readonly pbc::RepeatedField<ulong?> repeatedUint64Wrapper_ = new pbc::RepeatedField<ulong?>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<ulong?> RepeatedUint64Wrapper {
- get { return repeatedUint64Wrapper_; }
- }
-
- /// <summary>Field number for the "repeated_float_wrapper" field.</summary>
- public const int RepeatedFloatWrapperFieldNumber = 216;
- private static readonly pb::FieldCodec<float?> _repeated_repeatedFloatWrapper_codec
- = pb::FieldCodec.ForStructWrapper<float>(1730);
- private readonly pbc::RepeatedField<float?> repeatedFloatWrapper_ = new pbc::RepeatedField<float?>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<float?> RepeatedFloatWrapper {
- get { return repeatedFloatWrapper_; }
- }
-
- /// <summary>Field number for the "repeated_double_wrapper" field.</summary>
- public const int RepeatedDoubleWrapperFieldNumber = 217;
- private static readonly pb::FieldCodec<double?> _repeated_repeatedDoubleWrapper_codec
- = pb::FieldCodec.ForStructWrapper<double>(1738);
- private readonly pbc::RepeatedField<double?> repeatedDoubleWrapper_ = new pbc::RepeatedField<double?>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<double?> RepeatedDoubleWrapper {
- get { return repeatedDoubleWrapper_; }
- }
-
- /// <summary>Field number for the "repeated_string_wrapper" field.</summary>
- public const int RepeatedStringWrapperFieldNumber = 218;
- private static readonly pb::FieldCodec<string> _repeated_repeatedStringWrapper_codec
- = pb::FieldCodec.ForClassWrapper<string>(1746);
- private readonly pbc::RepeatedField<string> repeatedStringWrapper_ = new pbc::RepeatedField<string>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<string> RepeatedStringWrapper {
- get { return repeatedStringWrapper_; }
- }
-
- /// <summary>Field number for the "repeated_bytes_wrapper" field.</summary>
- public const int RepeatedBytesWrapperFieldNumber = 219;
- private static readonly pb::FieldCodec<pb::ByteString> _repeated_repeatedBytesWrapper_codec
- = pb::FieldCodec.ForClassWrapper<pb::ByteString>(1754);
- private readonly pbc::RepeatedField<pb::ByteString> repeatedBytesWrapper_ = new pbc::RepeatedField<pb::ByteString>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<pb::ByteString> RepeatedBytesWrapper {
- get { return repeatedBytesWrapper_; }
- }
-
- /// <summary>Field number for the "optional_duration" field.</summary>
- public const int OptionalDurationFieldNumber = 301;
- private global::Google.Protobuf.WellKnownTypes.Duration optionalDuration_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public global::Google.Protobuf.WellKnownTypes.Duration OptionalDuration {
- get { return optionalDuration_; }
- set {
- optionalDuration_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_timestamp" field.</summary>
- public const int OptionalTimestampFieldNumber = 302;
- private global::Google.Protobuf.WellKnownTypes.Timestamp optionalTimestamp_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public global::Google.Protobuf.WellKnownTypes.Timestamp OptionalTimestamp {
- get { return optionalTimestamp_; }
- set {
- optionalTimestamp_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_field_mask" field.</summary>
- public const int OptionalFieldMaskFieldNumber = 303;
- private global::Google.Protobuf.WellKnownTypes.FieldMask optionalFieldMask_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public global::Google.Protobuf.WellKnownTypes.FieldMask OptionalFieldMask {
- get { return optionalFieldMask_; }
- set {
- optionalFieldMask_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_struct" field.</summary>
- public const int OptionalStructFieldNumber = 304;
- private global::Google.Protobuf.WellKnownTypes.Struct optionalStruct_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public global::Google.Protobuf.WellKnownTypes.Struct OptionalStruct {
- get { return optionalStruct_; }
- set {
- optionalStruct_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_any" field.</summary>
- public const int OptionalAnyFieldNumber = 305;
- private global::Google.Protobuf.WellKnownTypes.Any optionalAny_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public global::Google.Protobuf.WellKnownTypes.Any OptionalAny {
- get { return optionalAny_; }
- set {
- optionalAny_ = value;
- }
- }
-
- /// <summary>Field number for the "optional_value" field.</summary>
- public const int OptionalValueFieldNumber = 306;
- private global::Google.Protobuf.WellKnownTypes.Value optionalValue_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public global::Google.Protobuf.WellKnownTypes.Value OptionalValue {
- get { return optionalValue_; }
- set {
- optionalValue_ = value;
- }
- }
-
- /// <summary>Field number for the "repeated_duration" field.</summary>
- public const int RepeatedDurationFieldNumber = 311;
- private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Duration> _repeated_repeatedDuration_codec
- = pb::FieldCodec.ForMessage(2490, global::Google.Protobuf.WellKnownTypes.Duration.Parser);
- private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Duration> repeatedDuration_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Duration>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Duration> RepeatedDuration {
- get { return repeatedDuration_; }
- }
-
- /// <summary>Field number for the "repeated_timestamp" field.</summary>
- public const int RepeatedTimestampFieldNumber = 312;
- private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Timestamp> _repeated_repeatedTimestamp_codec
- = pb::FieldCodec.ForMessage(2498, global::Google.Protobuf.WellKnownTypes.Timestamp.Parser);
- private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Timestamp> repeatedTimestamp_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Timestamp>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Timestamp> RepeatedTimestamp {
- get { return repeatedTimestamp_; }
- }
-
- /// <summary>Field number for the "repeated_fieldmask" field.</summary>
- public const int RepeatedFieldmaskFieldNumber = 313;
- private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.FieldMask> _repeated_repeatedFieldmask_codec
- = pb::FieldCodec.ForMessage(2506, global::Google.Protobuf.WellKnownTypes.FieldMask.Parser);
- private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.FieldMask> repeatedFieldmask_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.FieldMask>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.FieldMask> RepeatedFieldmask {
- get { return repeatedFieldmask_; }
- }
-
- /// <summary>Field number for the "repeated_struct" field.</summary>
- public const int RepeatedStructFieldNumber = 324;
- private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Struct> _repeated_repeatedStruct_codec
- = pb::FieldCodec.ForMessage(2594, global::Google.Protobuf.WellKnownTypes.Struct.Parser);
- private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Struct> repeatedStruct_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Struct>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Struct> RepeatedStruct {
- get { return repeatedStruct_; }
- }
-
- /// <summary>Field number for the "repeated_any" field.</summary>
- public const int RepeatedAnyFieldNumber = 315;
- private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Any> _repeated_repeatedAny_codec
- = pb::FieldCodec.ForMessage(2522, global::Google.Protobuf.WellKnownTypes.Any.Parser);
- private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Any> repeatedAny_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Any>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Any> RepeatedAny {
- get { return repeatedAny_; }
- }
-
- /// <summary>Field number for the "repeated_value" field.</summary>
- public const int RepeatedValueFieldNumber = 316;
- private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Value> _repeated_repeatedValue_codec
- = pb::FieldCodec.ForMessage(2530, global::Google.Protobuf.WellKnownTypes.Value.Parser);
- private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Value> repeatedValue_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Value>();
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Value> RepeatedValue {
- get { return repeatedValue_; }
- }
-
- /// <summary>Field number for the "fieldname1" field.</summary>
- public const int Fieldname1FieldNumber = 401;
- private int fieldname1_;
- /// <summary>
- /// Test field-name-to-JSON-name convention.
- /// (protobuf says names can be any valid C/C++ identifier.)
- /// </summary>
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public int Fieldname1 {
- get { return fieldname1_; }
- set {
- fieldname1_ = value;
- }
- }
-
- /// <summary>Field number for the "field_name2" field.</summary>
- public const int FieldName2FieldNumber = 402;
- private int fieldName2_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public int FieldName2 {
- get { return fieldName2_; }
- set {
- fieldName2_ = value;
- }
- }
-
- /// <summary>Field number for the "_field_name3" field.</summary>
- public const int FieldName3FieldNumber = 403;
- private int FieldName3_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public int FieldName3 {
- get { return FieldName3_; }
- set {
- FieldName3_ = value;
- }
- }
-
- /// <summary>Field number for the "field__name4_" field.</summary>
- public const int FieldName4FieldNumber = 404;
- private int fieldName4_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public int FieldName4 {
- get { return fieldName4_; }
- set {
- fieldName4_ = value;
- }
- }
-
- /// <summary>Field number for the "field0name5" field.</summary>
- public const int Field0Name5FieldNumber = 405;
- private int field0Name5_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public int Field0Name5 {
- get { return field0Name5_; }
- set {
- field0Name5_ = value;
- }
- }
-
- /// <summary>Field number for the "field_0_name6" field.</summary>
- public const int Field0Name6FieldNumber = 406;
- private int field0Name6_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public int Field0Name6 {
- get { return field0Name6_; }
- set {
- field0Name6_ = value;
- }
- }
-
- /// <summary>Field number for the "fieldName7" field.</summary>
- public const int FieldName7FieldNumber = 407;
- private int fieldName7_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public int FieldName7 {
- get { return fieldName7_; }
- set {
- fieldName7_ = value;
- }
- }
-
- /// <summary>Field number for the "FieldName8" field.</summary>
- public const int FieldName8FieldNumber = 408;
- private int fieldName8_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public int FieldName8 {
- get { return fieldName8_; }
- set {
- fieldName8_ = value;
- }
- }
-
- /// <summary>Field number for the "field_Name9" field.</summary>
- public const int FieldName9FieldNumber = 409;
- private int fieldName9_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public int FieldName9 {
- get { return fieldName9_; }
- set {
- fieldName9_ = value;
- }
- }
-
- /// <summary>Field number for the "Field_Name10" field.</summary>
- public const int FieldName10FieldNumber = 410;
- private int fieldName10_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public int FieldName10 {
- get { return fieldName10_; }
- set {
- fieldName10_ = value;
- }
- }
-
- /// <summary>Field number for the "FIELD_NAME11" field.</summary>
- public const int FIELDNAME11FieldNumber = 411;
- private int fIELDNAME11_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public int FIELDNAME11 {
- get { return fIELDNAME11_; }
- set {
- fIELDNAME11_ = value;
- }
- }
-
- /// <summary>Field number for the "FIELD_name12" field.</summary>
- public const int FIELDName12FieldNumber = 412;
- private int fIELDName12_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public int FIELDName12 {
- get { return fIELDName12_; }
- set {
- fIELDName12_ = value;
- }
- }
-
- /// <summary>Field number for the "__field_name13" field.</summary>
- public const int FieldName13FieldNumber = 413;
- private int FieldName13_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public int FieldName13 {
- get { return FieldName13_; }
- set {
- FieldName13_ = value;
- }
- }
-
- /// <summary>Field number for the "__Field_name14" field.</summary>
- public const int FieldName14FieldNumber = 414;
- private int FieldName14_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public int FieldName14 {
- get { return FieldName14_; }
- set {
- FieldName14_ = value;
- }
- }
-
- /// <summary>Field number for the "field__name15" field.</summary>
- public const int FieldName15FieldNumber = 415;
- private int fieldName15_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public int FieldName15 {
- get { return fieldName15_; }
- set {
- fieldName15_ = value;
- }
- }
-
- /// <summary>Field number for the "field__Name16" field.</summary>
- public const int FieldName16FieldNumber = 416;
- private int fieldName16_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public int FieldName16 {
- get { return fieldName16_; }
- set {
- fieldName16_ = value;
- }
- }
-
- /// <summary>Field number for the "field_name17__" field.</summary>
- public const int FieldName17FieldNumber = 417;
- private int fieldName17_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public int FieldName17 {
- get { return fieldName17_; }
- set {
- fieldName17_ = value;
- }
- }
-
- /// <summary>Field number for the "Field_name18__" field.</summary>
- public const int FieldName18FieldNumber = 418;
- private int fieldName18_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public int FieldName18 {
- get { return fieldName18_; }
- set {
- fieldName18_ = value;
- }
- }
-
- private object oneofField_;
- /// <summary>Enum of possible cases for the "oneof_field" oneof.</summary>
- public enum OneofFieldOneofCase {
- None = 0,
- OneofUint32 = 111,
- OneofNestedMessage = 112,
- OneofString = 113,
- OneofBytes = 114,
- OneofBool = 115,
- OneofUint64 = 116,
- OneofFloat = 117,
- OneofDouble = 118,
- OneofEnum = 119,
- }
- private OneofFieldOneofCase oneofFieldCase_ = OneofFieldOneofCase.None;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public OneofFieldOneofCase OneofFieldCase {
- get { return oneofFieldCase_; }
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public void ClearOneofField() {
- oneofFieldCase_ = OneofFieldOneofCase.None;
- oneofField_ = null;
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public override bool Equals(object other) {
- return Equals(other as TestAllTypes);
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public bool Equals(TestAllTypes other) {
- if (ReferenceEquals(other, null)) {
- return false;
- }
- if (ReferenceEquals(other, this)) {
- return true;
- }
- if (OptionalInt32 != other.OptionalInt32) return false;
- if (OptionalInt64 != other.OptionalInt64) return false;
- if (OptionalUint32 != other.OptionalUint32) return false;
- if (OptionalUint64 != other.OptionalUint64) return false;
- if (OptionalSint32 != other.OptionalSint32) return false;
- if (OptionalSint64 != other.OptionalSint64) return false;
- if (OptionalFixed32 != other.OptionalFixed32) return false;
- if (OptionalFixed64 != other.OptionalFixed64) return false;
- if (OptionalSfixed32 != other.OptionalSfixed32) return false;
- if (OptionalSfixed64 != other.OptionalSfixed64) return false;
- if (OptionalFloat != other.OptionalFloat) return false;
- if (OptionalDouble != other.OptionalDouble) return false;
- if (OptionalBool != other.OptionalBool) return false;
- if (OptionalString != other.OptionalString) return false;
- if (OptionalBytes != other.OptionalBytes) return false;
- if (!object.Equals(OptionalNestedMessage, other.OptionalNestedMessage)) return false;
- if (!object.Equals(OptionalForeignMessage, other.OptionalForeignMessage)) return false;
- if (OptionalNestedEnum != other.OptionalNestedEnum) return false;
- if (OptionalForeignEnum != other.OptionalForeignEnum) return false;
- if (OptionalStringPiece != other.OptionalStringPiece) return false;
- if (OptionalCord != other.OptionalCord) return false;
- if (!object.Equals(RecursiveMessage, other.RecursiveMessage)) return false;
- if(!repeatedInt32_.Equals(other.repeatedInt32_)) return false;
- if(!repeatedInt64_.Equals(other.repeatedInt64_)) return false;
- if(!repeatedUint32_.Equals(other.repeatedUint32_)) return false;
- if(!repeatedUint64_.Equals(other.repeatedUint64_)) return false;
- if(!repeatedSint32_.Equals(other.repeatedSint32_)) return false;
- if(!repeatedSint64_.Equals(other.repeatedSint64_)) return false;
- if(!repeatedFixed32_.Equals(other.repeatedFixed32_)) return false;
- if(!repeatedFixed64_.Equals(other.repeatedFixed64_)) return false;
- if(!repeatedSfixed32_.Equals(other.repeatedSfixed32_)) return false;
- if(!repeatedSfixed64_.Equals(other.repeatedSfixed64_)) return false;
- if(!repeatedFloat_.Equals(other.repeatedFloat_)) return false;
- if(!repeatedDouble_.Equals(other.repeatedDouble_)) return false;
- if(!repeatedBool_.Equals(other.repeatedBool_)) return false;
- if(!repeatedString_.Equals(other.repeatedString_)) return false;
- if(!repeatedBytes_.Equals(other.repeatedBytes_)) return false;
- if(!repeatedNestedMessage_.Equals(other.repeatedNestedMessage_)) return false;
- if(!repeatedForeignMessage_.Equals(other.repeatedForeignMessage_)) return false;
- if(!repeatedNestedEnum_.Equals(other.repeatedNestedEnum_)) return false;
- if(!repeatedForeignEnum_.Equals(other.repeatedForeignEnum_)) return false;
- if(!repeatedStringPiece_.Equals(other.repeatedStringPiece_)) return false;
- if(!repeatedCord_.Equals(other.repeatedCord_)) return false;
- if (!MapInt32Int32.Equals(other.MapInt32Int32)) return false;
- if (!MapInt64Int64.Equals(other.MapInt64Int64)) return false;
- if (!MapUint32Uint32.Equals(other.MapUint32Uint32)) return false;
- if (!MapUint64Uint64.Equals(other.MapUint64Uint64)) return false;
- if (!MapSint32Sint32.Equals(other.MapSint32Sint32)) return false;
- if (!MapSint64Sint64.Equals(other.MapSint64Sint64)) return false;
- if (!MapFixed32Fixed32.Equals(other.MapFixed32Fixed32)) return false;
- if (!MapFixed64Fixed64.Equals(other.MapFixed64Fixed64)) return false;
- if (!MapSfixed32Sfixed32.Equals(other.MapSfixed32Sfixed32)) return false;
- if (!MapSfixed64Sfixed64.Equals(other.MapSfixed64Sfixed64)) return false;
- if (!MapInt32Float.Equals(other.MapInt32Float)) return false;
- if (!MapInt32Double.Equals(other.MapInt32Double)) return false;
- if (!MapBoolBool.Equals(other.MapBoolBool)) return false;
- if (!MapStringString.Equals(other.MapStringString)) return false;
- if (!MapStringBytes.Equals(other.MapStringBytes)) return false;
- if (!MapStringNestedMessage.Equals(other.MapStringNestedMessage)) return false;
- if (!MapStringForeignMessage.Equals(other.MapStringForeignMessage)) return false;
- if (!MapStringNestedEnum.Equals(other.MapStringNestedEnum)) return false;
- if (!MapStringForeignEnum.Equals(other.MapStringForeignEnum)) return false;
- if (OneofUint32 != other.OneofUint32) return false;
- if (!object.Equals(OneofNestedMessage, other.OneofNestedMessage)) return false;
- if (OneofString != other.OneofString) return false;
- if (OneofBytes != other.OneofBytes) return false;
- if (OneofBool != other.OneofBool) return false;
- if (OneofUint64 != other.OneofUint64) return false;
- if (OneofFloat != other.OneofFloat) return false;
- if (OneofDouble != other.OneofDouble) return false;
- if (OneofEnum != other.OneofEnum) return false;
- if (OptionalBoolWrapper != other.OptionalBoolWrapper) return false;
- if (OptionalInt32Wrapper != other.OptionalInt32Wrapper) return false;
- if (OptionalInt64Wrapper != other.OptionalInt64Wrapper) return false;
- if (OptionalUint32Wrapper != other.OptionalUint32Wrapper) return false;
- if (OptionalUint64Wrapper != other.OptionalUint64Wrapper) return false;
- if (OptionalFloatWrapper != other.OptionalFloatWrapper) return false;
- if (OptionalDoubleWrapper != other.OptionalDoubleWrapper) return false;
- if (OptionalStringWrapper != other.OptionalStringWrapper) return false;
- if (OptionalBytesWrapper != other.OptionalBytesWrapper) return false;
- if(!repeatedBoolWrapper_.Equals(other.repeatedBoolWrapper_)) return false;
- if(!repeatedInt32Wrapper_.Equals(other.repeatedInt32Wrapper_)) return false;
- if(!repeatedInt64Wrapper_.Equals(other.repeatedInt64Wrapper_)) return false;
- if(!repeatedUint32Wrapper_.Equals(other.repeatedUint32Wrapper_)) return false;
- if(!repeatedUint64Wrapper_.Equals(other.repeatedUint64Wrapper_)) return false;
- if(!repeatedFloatWrapper_.Equals(other.repeatedFloatWrapper_)) return false;
- if(!repeatedDoubleWrapper_.Equals(other.repeatedDoubleWrapper_)) return false;
- if(!repeatedStringWrapper_.Equals(other.repeatedStringWrapper_)) return false;
- if(!repeatedBytesWrapper_.Equals(other.repeatedBytesWrapper_)) return false;
- if (!object.Equals(OptionalDuration, other.OptionalDuration)) return false;
- if (!object.Equals(OptionalTimestamp, other.OptionalTimestamp)) return false;
- if (!object.Equals(OptionalFieldMask, other.OptionalFieldMask)) return false;
- if (!object.Equals(OptionalStruct, other.OptionalStruct)) return false;
- if (!object.Equals(OptionalAny, other.OptionalAny)) return false;
- if (!object.Equals(OptionalValue, other.OptionalValue)) return false;
- if(!repeatedDuration_.Equals(other.repeatedDuration_)) return false;
- if(!repeatedTimestamp_.Equals(other.repeatedTimestamp_)) return false;
- if(!repeatedFieldmask_.Equals(other.repeatedFieldmask_)) return false;
- if(!repeatedStruct_.Equals(other.repeatedStruct_)) return false;
- if(!repeatedAny_.Equals(other.repeatedAny_)) return false;
- if(!repeatedValue_.Equals(other.repeatedValue_)) return false;
- if (Fieldname1 != other.Fieldname1) return false;
- if (FieldName2 != other.FieldName2) return false;
- if (FieldName3 != other.FieldName3) return false;
- if (FieldName4 != other.FieldName4) return false;
- if (Field0Name5 != other.Field0Name5) return false;
- if (Field0Name6 != other.Field0Name6) return false;
- if (FieldName7 != other.FieldName7) return false;
- if (FieldName8 != other.FieldName8) return false;
- if (FieldName9 != other.FieldName9) return false;
- if (FieldName10 != other.FieldName10) return false;
- if (FIELDNAME11 != other.FIELDNAME11) return false;
- if (FIELDName12 != other.FIELDName12) return false;
- if (FieldName13 != other.FieldName13) return false;
- if (FieldName14 != other.FieldName14) return false;
- if (FieldName15 != other.FieldName15) return false;
- if (FieldName16 != other.FieldName16) return false;
- if (FieldName17 != other.FieldName17) return false;
- if (FieldName18 != other.FieldName18) return false;
- if (OneofFieldCase != other.OneofFieldCase) return false;
- return true;
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public override int GetHashCode() {
- int hash = 1;
- if (OptionalInt32 != 0) hash ^= OptionalInt32.GetHashCode();
- if (OptionalInt64 != 0L) hash ^= OptionalInt64.GetHashCode();
- if (OptionalUint32 != 0) hash ^= OptionalUint32.GetHashCode();
- if (OptionalUint64 != 0UL) hash ^= OptionalUint64.GetHashCode();
- if (OptionalSint32 != 0) hash ^= OptionalSint32.GetHashCode();
- if (OptionalSint64 != 0L) hash ^= OptionalSint64.GetHashCode();
- if (OptionalFixed32 != 0) hash ^= OptionalFixed32.GetHashCode();
- if (OptionalFixed64 != 0UL) hash ^= OptionalFixed64.GetHashCode();
- if (OptionalSfixed32 != 0) hash ^= OptionalSfixed32.GetHashCode();
- if (OptionalSfixed64 != 0L) hash ^= OptionalSfixed64.GetHashCode();
- if (OptionalFloat != 0F) hash ^= OptionalFloat.GetHashCode();
- if (OptionalDouble != 0D) hash ^= OptionalDouble.GetHashCode();
- if (OptionalBool != false) hash ^= OptionalBool.GetHashCode();
- if (OptionalString.Length != 0) hash ^= OptionalString.GetHashCode();
- if (OptionalBytes.Length != 0) hash ^= OptionalBytes.GetHashCode();
- if (optionalNestedMessage_ != null) hash ^= OptionalNestedMessage.GetHashCode();
- if (optionalForeignMessage_ != null) hash ^= OptionalForeignMessage.GetHashCode();
- if (OptionalNestedEnum != 0) hash ^= OptionalNestedEnum.GetHashCode();
- if (OptionalForeignEnum != 0) hash ^= OptionalForeignEnum.GetHashCode();
- if (OptionalStringPiece.Length != 0) hash ^= OptionalStringPiece.GetHashCode();
- if (OptionalCord.Length != 0) hash ^= OptionalCord.GetHashCode();
- if (recursiveMessage_ != null) hash ^= RecursiveMessage.GetHashCode();
- hash ^= repeatedInt32_.GetHashCode();
- hash ^= repeatedInt64_.GetHashCode();
- hash ^= repeatedUint32_.GetHashCode();
- hash ^= repeatedUint64_.GetHashCode();
- hash ^= repeatedSint32_.GetHashCode();
- hash ^= repeatedSint64_.GetHashCode();
- hash ^= repeatedFixed32_.GetHashCode();
- hash ^= repeatedFixed64_.GetHashCode();
- hash ^= repeatedSfixed32_.GetHashCode();
- hash ^= repeatedSfixed64_.GetHashCode();
- hash ^= repeatedFloat_.GetHashCode();
- hash ^= repeatedDouble_.GetHashCode();
- hash ^= repeatedBool_.GetHashCode();
- hash ^= repeatedString_.GetHashCode();
- hash ^= repeatedBytes_.GetHashCode();
- hash ^= repeatedNestedMessage_.GetHashCode();
- hash ^= repeatedForeignMessage_.GetHashCode();
- hash ^= repeatedNestedEnum_.GetHashCode();
- hash ^= repeatedForeignEnum_.GetHashCode();
- hash ^= repeatedStringPiece_.GetHashCode();
- hash ^= repeatedCord_.GetHashCode();
- hash ^= MapInt32Int32.GetHashCode();
- hash ^= MapInt64Int64.GetHashCode();
- hash ^= MapUint32Uint32.GetHashCode();
- hash ^= MapUint64Uint64.GetHashCode();
- hash ^= MapSint32Sint32.GetHashCode();
- hash ^= MapSint64Sint64.GetHashCode();
- hash ^= MapFixed32Fixed32.GetHashCode();
- hash ^= MapFixed64Fixed64.GetHashCode();
- hash ^= MapSfixed32Sfixed32.GetHashCode();
- hash ^= MapSfixed64Sfixed64.GetHashCode();
- hash ^= MapInt32Float.GetHashCode();
- hash ^= MapInt32Double.GetHashCode();
- hash ^= MapBoolBool.GetHashCode();
- hash ^= MapStringString.GetHashCode();
- hash ^= MapStringBytes.GetHashCode();
- hash ^= MapStringNestedMessage.GetHashCode();
- hash ^= MapStringForeignMessage.GetHashCode();
- hash ^= MapStringNestedEnum.GetHashCode();
- hash ^= MapStringForeignEnum.GetHashCode();
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) hash ^= OneofUint32.GetHashCode();
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) hash ^= OneofNestedMessage.GetHashCode();
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) hash ^= OneofString.GetHashCode();
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) hash ^= OneofBytes.GetHashCode();
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofBool) hash ^= OneofBool.GetHashCode();
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint64) hash ^= OneofUint64.GetHashCode();
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofFloat) hash ^= OneofFloat.GetHashCode();
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofDouble) hash ^= OneofDouble.GetHashCode();
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofEnum) hash ^= OneofEnum.GetHashCode();
- if (optionalBoolWrapper_ != null) hash ^= OptionalBoolWrapper.GetHashCode();
- if (optionalInt32Wrapper_ != null) hash ^= OptionalInt32Wrapper.GetHashCode();
- if (optionalInt64Wrapper_ != null) hash ^= OptionalInt64Wrapper.GetHashCode();
- if (optionalUint32Wrapper_ != null) hash ^= OptionalUint32Wrapper.GetHashCode();
- if (optionalUint64Wrapper_ != null) hash ^= OptionalUint64Wrapper.GetHashCode();
- if (optionalFloatWrapper_ != null) hash ^= OptionalFloatWrapper.GetHashCode();
- if (optionalDoubleWrapper_ != null) hash ^= OptionalDoubleWrapper.GetHashCode();
- if (optionalStringWrapper_ != null) hash ^= OptionalStringWrapper.GetHashCode();
- if (optionalBytesWrapper_ != null) hash ^= OptionalBytesWrapper.GetHashCode();
- hash ^= repeatedBoolWrapper_.GetHashCode();
- hash ^= repeatedInt32Wrapper_.GetHashCode();
- hash ^= repeatedInt64Wrapper_.GetHashCode();
- hash ^= repeatedUint32Wrapper_.GetHashCode();
- hash ^= repeatedUint64Wrapper_.GetHashCode();
- hash ^= repeatedFloatWrapper_.GetHashCode();
- hash ^= repeatedDoubleWrapper_.GetHashCode();
- hash ^= repeatedStringWrapper_.GetHashCode();
- hash ^= repeatedBytesWrapper_.GetHashCode();
- if (optionalDuration_ != null) hash ^= OptionalDuration.GetHashCode();
- if (optionalTimestamp_ != null) hash ^= OptionalTimestamp.GetHashCode();
- if (optionalFieldMask_ != null) hash ^= OptionalFieldMask.GetHashCode();
- if (optionalStruct_ != null) hash ^= OptionalStruct.GetHashCode();
- if (optionalAny_ != null) hash ^= OptionalAny.GetHashCode();
- if (optionalValue_ != null) hash ^= OptionalValue.GetHashCode();
- hash ^= repeatedDuration_.GetHashCode();
- hash ^= repeatedTimestamp_.GetHashCode();
- hash ^= repeatedFieldmask_.GetHashCode();
- hash ^= repeatedStruct_.GetHashCode();
- hash ^= repeatedAny_.GetHashCode();
- hash ^= repeatedValue_.GetHashCode();
- if (Fieldname1 != 0) hash ^= Fieldname1.GetHashCode();
- if (FieldName2 != 0) hash ^= FieldName2.GetHashCode();
- if (FieldName3 != 0) hash ^= FieldName3.GetHashCode();
- if (FieldName4 != 0) hash ^= FieldName4.GetHashCode();
- if (Field0Name5 != 0) hash ^= Field0Name5.GetHashCode();
- if (Field0Name6 != 0) hash ^= Field0Name6.GetHashCode();
- if (FieldName7 != 0) hash ^= FieldName7.GetHashCode();
- if (FieldName8 != 0) hash ^= FieldName8.GetHashCode();
- if (FieldName9 != 0) hash ^= FieldName9.GetHashCode();
- if (FieldName10 != 0) hash ^= FieldName10.GetHashCode();
- if (FIELDNAME11 != 0) hash ^= FIELDNAME11.GetHashCode();
- if (FIELDName12 != 0) hash ^= FIELDName12.GetHashCode();
- if (FieldName13 != 0) hash ^= FieldName13.GetHashCode();
- if (FieldName14 != 0) hash ^= FieldName14.GetHashCode();
- if (FieldName15 != 0) hash ^= FieldName15.GetHashCode();
- if (FieldName16 != 0) hash ^= FieldName16.GetHashCode();
- if (FieldName17 != 0) hash ^= FieldName17.GetHashCode();
- if (FieldName18 != 0) hash ^= FieldName18.GetHashCode();
- hash ^= (int) oneofFieldCase_;
- return hash;
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public override string ToString() {
- return pb::JsonFormatter.ToDiagnosticString(this);
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public void WriteTo(pb::CodedOutputStream output) {
- if (OptionalInt32 != 0) {
- output.WriteRawTag(8);
- output.WriteInt32(OptionalInt32);
- }
- if (OptionalInt64 != 0L) {
- output.WriteRawTag(16);
- output.WriteInt64(OptionalInt64);
- }
- if (OptionalUint32 != 0) {
- output.WriteRawTag(24);
- output.WriteUInt32(OptionalUint32);
- }
- if (OptionalUint64 != 0UL) {
- output.WriteRawTag(32);
- output.WriteUInt64(OptionalUint64);
- }
- if (OptionalSint32 != 0) {
- output.WriteRawTag(40);
- output.WriteSInt32(OptionalSint32);
- }
- if (OptionalSint64 != 0L) {
- output.WriteRawTag(48);
- output.WriteSInt64(OptionalSint64);
- }
- if (OptionalFixed32 != 0) {
- output.WriteRawTag(61);
- output.WriteFixed32(OptionalFixed32);
- }
- if (OptionalFixed64 != 0UL) {
- output.WriteRawTag(65);
- output.WriteFixed64(OptionalFixed64);
- }
- if (OptionalSfixed32 != 0) {
- output.WriteRawTag(77);
- output.WriteSFixed32(OptionalSfixed32);
- }
- if (OptionalSfixed64 != 0L) {
- output.WriteRawTag(81);
- output.WriteSFixed64(OptionalSfixed64);
- }
- if (OptionalFloat != 0F) {
- output.WriteRawTag(93);
- output.WriteFloat(OptionalFloat);
- }
- if (OptionalDouble != 0D) {
- output.WriteRawTag(97);
- output.WriteDouble(OptionalDouble);
- }
- if (OptionalBool != false) {
- output.WriteRawTag(104);
- output.WriteBool(OptionalBool);
- }
- if (OptionalString.Length != 0) {
- output.WriteRawTag(114);
- output.WriteString(OptionalString);
- }
- if (OptionalBytes.Length != 0) {
- output.WriteRawTag(122);
- output.WriteBytes(OptionalBytes);
- }
- if (optionalNestedMessage_ != null) {
- output.WriteRawTag(146, 1);
- output.WriteMessage(OptionalNestedMessage);
- }
- if (optionalForeignMessage_ != null) {
- output.WriteRawTag(154, 1);
- output.WriteMessage(OptionalForeignMessage);
- }
- if (OptionalNestedEnum != 0) {
- output.WriteRawTag(168, 1);
- output.WriteEnum((int) OptionalNestedEnum);
- }
- if (OptionalForeignEnum != 0) {
- output.WriteRawTag(176, 1);
- output.WriteEnum((int) OptionalForeignEnum);
- }
- if (OptionalStringPiece.Length != 0) {
- output.WriteRawTag(194, 1);
- output.WriteString(OptionalStringPiece);
- }
- if (OptionalCord.Length != 0) {
- output.WriteRawTag(202, 1);
- output.WriteString(OptionalCord);
- }
- if (recursiveMessage_ != null) {
- output.WriteRawTag(218, 1);
- output.WriteMessage(RecursiveMessage);
- }
- repeatedInt32_.WriteTo(output, _repeated_repeatedInt32_codec);
- repeatedInt64_.WriteTo(output, _repeated_repeatedInt64_codec);
- repeatedUint32_.WriteTo(output, _repeated_repeatedUint32_codec);
- repeatedUint64_.WriteTo(output, _repeated_repeatedUint64_codec);
- repeatedSint32_.WriteTo(output, _repeated_repeatedSint32_codec);
- repeatedSint64_.WriteTo(output, _repeated_repeatedSint64_codec);
- repeatedFixed32_.WriteTo(output, _repeated_repeatedFixed32_codec);
- repeatedFixed64_.WriteTo(output, _repeated_repeatedFixed64_codec);
- repeatedSfixed32_.WriteTo(output, _repeated_repeatedSfixed32_codec);
- repeatedSfixed64_.WriteTo(output, _repeated_repeatedSfixed64_codec);
- repeatedFloat_.WriteTo(output, _repeated_repeatedFloat_codec);
- repeatedDouble_.WriteTo(output, _repeated_repeatedDouble_codec);
- repeatedBool_.WriteTo(output, _repeated_repeatedBool_codec);
- repeatedString_.WriteTo(output, _repeated_repeatedString_codec);
- repeatedBytes_.WriteTo(output, _repeated_repeatedBytes_codec);
- repeatedNestedMessage_.WriteTo(output, _repeated_repeatedNestedMessage_codec);
- repeatedForeignMessage_.WriteTo(output, _repeated_repeatedForeignMessage_codec);
- repeatedNestedEnum_.WriteTo(output, _repeated_repeatedNestedEnum_codec);
- repeatedForeignEnum_.WriteTo(output, _repeated_repeatedForeignEnum_codec);
- repeatedStringPiece_.WriteTo(output, _repeated_repeatedStringPiece_codec);
- repeatedCord_.WriteTo(output, _repeated_repeatedCord_codec);
- mapInt32Int32_.WriteTo(output, _map_mapInt32Int32_codec);
- mapInt64Int64_.WriteTo(output, _map_mapInt64Int64_codec);
- mapUint32Uint32_.WriteTo(output, _map_mapUint32Uint32_codec);
- mapUint64Uint64_.WriteTo(output, _map_mapUint64Uint64_codec);
- mapSint32Sint32_.WriteTo(output, _map_mapSint32Sint32_codec);
- mapSint64Sint64_.WriteTo(output, _map_mapSint64Sint64_codec);
- mapFixed32Fixed32_.WriteTo(output, _map_mapFixed32Fixed32_codec);
- mapFixed64Fixed64_.WriteTo(output, _map_mapFixed64Fixed64_codec);
- mapSfixed32Sfixed32_.WriteTo(output, _map_mapSfixed32Sfixed32_codec);
- mapSfixed64Sfixed64_.WriteTo(output, _map_mapSfixed64Sfixed64_codec);
- mapInt32Float_.WriteTo(output, _map_mapInt32Float_codec);
- mapInt32Double_.WriteTo(output, _map_mapInt32Double_codec);
- mapBoolBool_.WriteTo(output, _map_mapBoolBool_codec);
- mapStringString_.WriteTo(output, _map_mapStringString_codec);
- mapStringBytes_.WriteTo(output, _map_mapStringBytes_codec);
- mapStringNestedMessage_.WriteTo(output, _map_mapStringNestedMessage_codec);
- mapStringForeignMessage_.WriteTo(output, _map_mapStringForeignMessage_codec);
- mapStringNestedEnum_.WriteTo(output, _map_mapStringNestedEnum_codec);
- mapStringForeignEnum_.WriteTo(output, _map_mapStringForeignEnum_codec);
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) {
- output.WriteRawTag(248, 6);
- output.WriteUInt32(OneofUint32);
- }
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) {
- output.WriteRawTag(130, 7);
- output.WriteMessage(OneofNestedMessage);
- }
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) {
- output.WriteRawTag(138, 7);
- output.WriteString(OneofString);
- }
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) {
- output.WriteRawTag(146, 7);
- output.WriteBytes(OneofBytes);
- }
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofBool) {
- output.WriteRawTag(152, 7);
- output.WriteBool(OneofBool);
- }
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint64) {
- output.WriteRawTag(160, 7);
- output.WriteUInt64(OneofUint64);
- }
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofFloat) {
- output.WriteRawTag(173, 7);
- output.WriteFloat(OneofFloat);
- }
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofDouble) {
- output.WriteRawTag(177, 7);
- output.WriteDouble(OneofDouble);
- }
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofEnum) {
- output.WriteRawTag(184, 7);
- output.WriteEnum((int) OneofEnum);
- }
- if (optionalBoolWrapper_ != null) {
- _single_optionalBoolWrapper_codec.WriteTagAndValue(output, OptionalBoolWrapper);
- }
- if (optionalInt32Wrapper_ != null) {
- _single_optionalInt32Wrapper_codec.WriteTagAndValue(output, OptionalInt32Wrapper);
- }
- if (optionalInt64Wrapper_ != null) {
- _single_optionalInt64Wrapper_codec.WriteTagAndValue(output, OptionalInt64Wrapper);
- }
- if (optionalUint32Wrapper_ != null) {
- _single_optionalUint32Wrapper_codec.WriteTagAndValue(output, OptionalUint32Wrapper);
- }
- if (optionalUint64Wrapper_ != null) {
- _single_optionalUint64Wrapper_codec.WriteTagAndValue(output, OptionalUint64Wrapper);
- }
- if (optionalFloatWrapper_ != null) {
- _single_optionalFloatWrapper_codec.WriteTagAndValue(output, OptionalFloatWrapper);
- }
- if (optionalDoubleWrapper_ != null) {
- _single_optionalDoubleWrapper_codec.WriteTagAndValue(output, OptionalDoubleWrapper);
- }
- if (optionalStringWrapper_ != null) {
- _single_optionalStringWrapper_codec.WriteTagAndValue(output, OptionalStringWrapper);
- }
- if (optionalBytesWrapper_ != null) {
- _single_optionalBytesWrapper_codec.WriteTagAndValue(output, OptionalBytesWrapper);
- }
- repeatedBoolWrapper_.WriteTo(output, _repeated_repeatedBoolWrapper_codec);
- repeatedInt32Wrapper_.WriteTo(output, _repeated_repeatedInt32Wrapper_codec);
- repeatedInt64Wrapper_.WriteTo(output, _repeated_repeatedInt64Wrapper_codec);
- repeatedUint32Wrapper_.WriteTo(output, _repeated_repeatedUint32Wrapper_codec);
- repeatedUint64Wrapper_.WriteTo(output, _repeated_repeatedUint64Wrapper_codec);
- repeatedFloatWrapper_.WriteTo(output, _repeated_repeatedFloatWrapper_codec);
- repeatedDoubleWrapper_.WriteTo(output, _repeated_repeatedDoubleWrapper_codec);
- repeatedStringWrapper_.WriteTo(output, _repeated_repeatedStringWrapper_codec);
- repeatedBytesWrapper_.WriteTo(output, _repeated_repeatedBytesWrapper_codec);
- if (optionalDuration_ != null) {
- output.WriteRawTag(234, 18);
- output.WriteMessage(OptionalDuration);
- }
- if (optionalTimestamp_ != null) {
- output.WriteRawTag(242, 18);
- output.WriteMessage(OptionalTimestamp);
- }
- if (optionalFieldMask_ != null) {
- output.WriteRawTag(250, 18);
- output.WriteMessage(OptionalFieldMask);
- }
- if (optionalStruct_ != null) {
- output.WriteRawTag(130, 19);
- output.WriteMessage(OptionalStruct);
- }
- if (optionalAny_ != null) {
- output.WriteRawTag(138, 19);
- output.WriteMessage(OptionalAny);
- }
- if (optionalValue_ != null) {
- output.WriteRawTag(146, 19);
- output.WriteMessage(OptionalValue);
- }
- repeatedDuration_.WriteTo(output, _repeated_repeatedDuration_codec);
- repeatedTimestamp_.WriteTo(output, _repeated_repeatedTimestamp_codec);
- repeatedFieldmask_.WriteTo(output, _repeated_repeatedFieldmask_codec);
- repeatedAny_.WriteTo(output, _repeated_repeatedAny_codec);
- repeatedValue_.WriteTo(output, _repeated_repeatedValue_codec);
- repeatedStruct_.WriteTo(output, _repeated_repeatedStruct_codec);
- if (Fieldname1 != 0) {
- output.WriteRawTag(136, 25);
- output.WriteInt32(Fieldname1);
- }
- if (FieldName2 != 0) {
- output.WriteRawTag(144, 25);
- output.WriteInt32(FieldName2);
- }
- if (FieldName3 != 0) {
- output.WriteRawTag(152, 25);
- output.WriteInt32(FieldName3);
- }
- if (FieldName4 != 0) {
- output.WriteRawTag(160, 25);
- output.WriteInt32(FieldName4);
- }
- if (Field0Name5 != 0) {
- output.WriteRawTag(168, 25);
- output.WriteInt32(Field0Name5);
- }
- if (Field0Name6 != 0) {
- output.WriteRawTag(176, 25);
- output.WriteInt32(Field0Name6);
- }
- if (FieldName7 != 0) {
- output.WriteRawTag(184, 25);
- output.WriteInt32(FieldName7);
- }
- if (FieldName8 != 0) {
- output.WriteRawTag(192, 25);
- output.WriteInt32(FieldName8);
- }
- if (FieldName9 != 0) {
- output.WriteRawTag(200, 25);
- output.WriteInt32(FieldName9);
- }
- if (FieldName10 != 0) {
- output.WriteRawTag(208, 25);
- output.WriteInt32(FieldName10);
- }
- if (FIELDNAME11 != 0) {
- output.WriteRawTag(216, 25);
- output.WriteInt32(FIELDNAME11);
- }
- if (FIELDName12 != 0) {
- output.WriteRawTag(224, 25);
- output.WriteInt32(FIELDName12);
- }
- if (FieldName13 != 0) {
- output.WriteRawTag(232, 25);
- output.WriteInt32(FieldName13);
- }
- if (FieldName14 != 0) {
- output.WriteRawTag(240, 25);
- output.WriteInt32(FieldName14);
- }
- if (FieldName15 != 0) {
- output.WriteRawTag(248, 25);
- output.WriteInt32(FieldName15);
- }
- if (FieldName16 != 0) {
- output.WriteRawTag(128, 26);
- output.WriteInt32(FieldName16);
- }
- if (FieldName17 != 0) {
- output.WriteRawTag(136, 26);
- output.WriteInt32(FieldName17);
- }
- if (FieldName18 != 0) {
- output.WriteRawTag(144, 26);
- output.WriteInt32(FieldName18);
- }
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public int CalculateSize() {
- int size = 0;
- if (OptionalInt32 != 0) {
- size += 1 + pb::CodedOutputStream.ComputeInt32Size(OptionalInt32);
- }
- if (OptionalInt64 != 0L) {
- size += 1 + pb::CodedOutputStream.ComputeInt64Size(OptionalInt64);
- }
- if (OptionalUint32 != 0) {
- size += 1 + pb::CodedOutputStream.ComputeUInt32Size(OptionalUint32);
- }
- if (OptionalUint64 != 0UL) {
- size += 1 + pb::CodedOutputStream.ComputeUInt64Size(OptionalUint64);
- }
- if (OptionalSint32 != 0) {
- size += 1 + pb::CodedOutputStream.ComputeSInt32Size(OptionalSint32);
- }
- if (OptionalSint64 != 0L) {
- size += 1 + pb::CodedOutputStream.ComputeSInt64Size(OptionalSint64);
- }
- if (OptionalFixed32 != 0) {
- size += 1 + 4;
- }
- if (OptionalFixed64 != 0UL) {
- size += 1 + 8;
- }
- if (OptionalSfixed32 != 0) {
- size += 1 + 4;
- }
- if (OptionalSfixed64 != 0L) {
- size += 1 + 8;
- }
- if (OptionalFloat != 0F) {
- size += 1 + 4;
- }
- if (OptionalDouble != 0D) {
- size += 1 + 8;
- }
- if (OptionalBool != false) {
- size += 1 + 1;
- }
- if (OptionalString.Length != 0) {
- size += 1 + pb::CodedOutputStream.ComputeStringSize(OptionalString);
- }
- if (OptionalBytes.Length != 0) {
- size += 1 + pb::CodedOutputStream.ComputeBytesSize(OptionalBytes);
- }
- if (optionalNestedMessage_ != null) {
- size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalNestedMessage);
- }
- if (optionalForeignMessage_ != null) {
- size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalForeignMessage);
- }
- if (OptionalNestedEnum != 0) {
- size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) OptionalNestedEnum);
- }
- if (OptionalForeignEnum != 0) {
- size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) OptionalForeignEnum);
- }
- if (OptionalStringPiece.Length != 0) {
- size += 2 + pb::CodedOutputStream.ComputeStringSize(OptionalStringPiece);
- }
- if (OptionalCord.Length != 0) {
- size += 2 + pb::CodedOutputStream.ComputeStringSize(OptionalCord);
- }
- if (recursiveMessage_ != null) {
- size += 2 + pb::CodedOutputStream.ComputeMessageSize(RecursiveMessage);
- }
- size += repeatedInt32_.CalculateSize(_repeated_repeatedInt32_codec);
- size += repeatedInt64_.CalculateSize(_repeated_repeatedInt64_codec);
- size += repeatedUint32_.CalculateSize(_repeated_repeatedUint32_codec);
- size += repeatedUint64_.CalculateSize(_repeated_repeatedUint64_codec);
- size += repeatedSint32_.CalculateSize(_repeated_repeatedSint32_codec);
- size += repeatedSint64_.CalculateSize(_repeated_repeatedSint64_codec);
- size += repeatedFixed32_.CalculateSize(_repeated_repeatedFixed32_codec);
- size += repeatedFixed64_.CalculateSize(_repeated_repeatedFixed64_codec);
- size += repeatedSfixed32_.CalculateSize(_repeated_repeatedSfixed32_codec);
- size += repeatedSfixed64_.CalculateSize(_repeated_repeatedSfixed64_codec);
- size += repeatedFloat_.CalculateSize(_repeated_repeatedFloat_codec);
- size += repeatedDouble_.CalculateSize(_repeated_repeatedDouble_codec);
- size += repeatedBool_.CalculateSize(_repeated_repeatedBool_codec);
- size += repeatedString_.CalculateSize(_repeated_repeatedString_codec);
- size += repeatedBytes_.CalculateSize(_repeated_repeatedBytes_codec);
- size += repeatedNestedMessage_.CalculateSize(_repeated_repeatedNestedMessage_codec);
- size += repeatedForeignMessage_.CalculateSize(_repeated_repeatedForeignMessage_codec);
- size += repeatedNestedEnum_.CalculateSize(_repeated_repeatedNestedEnum_codec);
- size += repeatedForeignEnum_.CalculateSize(_repeated_repeatedForeignEnum_codec);
- size += repeatedStringPiece_.CalculateSize(_repeated_repeatedStringPiece_codec);
- size += repeatedCord_.CalculateSize(_repeated_repeatedCord_codec);
- size += mapInt32Int32_.CalculateSize(_map_mapInt32Int32_codec);
- size += mapInt64Int64_.CalculateSize(_map_mapInt64Int64_codec);
- size += mapUint32Uint32_.CalculateSize(_map_mapUint32Uint32_codec);
- size += mapUint64Uint64_.CalculateSize(_map_mapUint64Uint64_codec);
- size += mapSint32Sint32_.CalculateSize(_map_mapSint32Sint32_codec);
- size += mapSint64Sint64_.CalculateSize(_map_mapSint64Sint64_codec);
- size += mapFixed32Fixed32_.CalculateSize(_map_mapFixed32Fixed32_codec);
- size += mapFixed64Fixed64_.CalculateSize(_map_mapFixed64Fixed64_codec);
- size += mapSfixed32Sfixed32_.CalculateSize(_map_mapSfixed32Sfixed32_codec);
- size += mapSfixed64Sfixed64_.CalculateSize(_map_mapSfixed64Sfixed64_codec);
- size += mapInt32Float_.CalculateSize(_map_mapInt32Float_codec);
- size += mapInt32Double_.CalculateSize(_map_mapInt32Double_codec);
- size += mapBoolBool_.CalculateSize(_map_mapBoolBool_codec);
- size += mapStringString_.CalculateSize(_map_mapStringString_codec);
- size += mapStringBytes_.CalculateSize(_map_mapStringBytes_codec);
- size += mapStringNestedMessage_.CalculateSize(_map_mapStringNestedMessage_codec);
- size += mapStringForeignMessage_.CalculateSize(_map_mapStringForeignMessage_codec);
- size += mapStringNestedEnum_.CalculateSize(_map_mapStringNestedEnum_codec);
- size += mapStringForeignEnum_.CalculateSize(_map_mapStringForeignEnum_codec);
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) {
- size += 2 + pb::CodedOutputStream.ComputeUInt32Size(OneofUint32);
- }
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) {
- size += 2 + pb::CodedOutputStream.ComputeMessageSize(OneofNestedMessage);
- }
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) {
- size += 2 + pb::CodedOutputStream.ComputeStringSize(OneofString);
- }
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) {
- size += 2 + pb::CodedOutputStream.ComputeBytesSize(OneofBytes);
- }
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofBool) {
- size += 2 + 1;
- }
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint64) {
- size += 2 + pb::CodedOutputStream.ComputeUInt64Size(OneofUint64);
- }
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofFloat) {
- size += 2 + 4;
- }
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofDouble) {
- size += 2 + 8;
- }
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofEnum) {
- size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) OneofEnum);
- }
- if (optionalBoolWrapper_ != null) {
- size += _single_optionalBoolWrapper_codec.CalculateSizeWithTag(OptionalBoolWrapper);
- }
- if (optionalInt32Wrapper_ != null) {
- size += _single_optionalInt32Wrapper_codec.CalculateSizeWithTag(OptionalInt32Wrapper);
- }
- if (optionalInt64Wrapper_ != null) {
- size += _single_optionalInt64Wrapper_codec.CalculateSizeWithTag(OptionalInt64Wrapper);
- }
- if (optionalUint32Wrapper_ != null) {
- size += _single_optionalUint32Wrapper_codec.CalculateSizeWithTag(OptionalUint32Wrapper);
- }
- if (optionalUint64Wrapper_ != null) {
- size += _single_optionalUint64Wrapper_codec.CalculateSizeWithTag(OptionalUint64Wrapper);
- }
- if (optionalFloatWrapper_ != null) {
- size += _single_optionalFloatWrapper_codec.CalculateSizeWithTag(OptionalFloatWrapper);
- }
- if (optionalDoubleWrapper_ != null) {
- size += _single_optionalDoubleWrapper_codec.CalculateSizeWithTag(OptionalDoubleWrapper);
- }
- if (optionalStringWrapper_ != null) {
- size += _single_optionalStringWrapper_codec.CalculateSizeWithTag(OptionalStringWrapper);
- }
- if (optionalBytesWrapper_ != null) {
- size += _single_optionalBytesWrapper_codec.CalculateSizeWithTag(OptionalBytesWrapper);
- }
- size += repeatedBoolWrapper_.CalculateSize(_repeated_repeatedBoolWrapper_codec);
- size += repeatedInt32Wrapper_.CalculateSize(_repeated_repeatedInt32Wrapper_codec);
- size += repeatedInt64Wrapper_.CalculateSize(_repeated_repeatedInt64Wrapper_codec);
- size += repeatedUint32Wrapper_.CalculateSize(_repeated_repeatedUint32Wrapper_codec);
- size += repeatedUint64Wrapper_.CalculateSize(_repeated_repeatedUint64Wrapper_codec);
- size += repeatedFloatWrapper_.CalculateSize(_repeated_repeatedFloatWrapper_codec);
- size += repeatedDoubleWrapper_.CalculateSize(_repeated_repeatedDoubleWrapper_codec);
- size += repeatedStringWrapper_.CalculateSize(_repeated_repeatedStringWrapper_codec);
- size += repeatedBytesWrapper_.CalculateSize(_repeated_repeatedBytesWrapper_codec);
- if (optionalDuration_ != null) {
- size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalDuration);
- }
- if (optionalTimestamp_ != null) {
- size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalTimestamp);
- }
- if (optionalFieldMask_ != null) {
- size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalFieldMask);
- }
- if (optionalStruct_ != null) {
- size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalStruct);
- }
- if (optionalAny_ != null) {
- size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalAny);
- }
- if (optionalValue_ != null) {
- size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalValue);
- }
- size += repeatedDuration_.CalculateSize(_repeated_repeatedDuration_codec);
- size += repeatedTimestamp_.CalculateSize(_repeated_repeatedTimestamp_codec);
- size += repeatedFieldmask_.CalculateSize(_repeated_repeatedFieldmask_codec);
- size += repeatedStruct_.CalculateSize(_repeated_repeatedStruct_codec);
- size += repeatedAny_.CalculateSize(_repeated_repeatedAny_codec);
- size += repeatedValue_.CalculateSize(_repeated_repeatedValue_codec);
- if (Fieldname1 != 0) {
- size += 2 + pb::CodedOutputStream.ComputeInt32Size(Fieldname1);
- }
- if (FieldName2 != 0) {
- size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName2);
- }
- if (FieldName3 != 0) {
- size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName3);
- }
- if (FieldName4 != 0) {
- size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName4);
- }
- if (Field0Name5 != 0) {
- size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field0Name5);
- }
- if (Field0Name6 != 0) {
- size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field0Name6);
- }
- if (FieldName7 != 0) {
- size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName7);
- }
- if (FieldName8 != 0) {
- size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName8);
- }
- if (FieldName9 != 0) {
- size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName9);
- }
- if (FieldName10 != 0) {
- size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName10);
- }
- if (FIELDNAME11 != 0) {
- size += 2 + pb::CodedOutputStream.ComputeInt32Size(FIELDNAME11);
- }
- if (FIELDName12 != 0) {
- size += 2 + pb::CodedOutputStream.ComputeInt32Size(FIELDName12);
- }
- if (FieldName13 != 0) {
- size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName13);
- }
- if (FieldName14 != 0) {
- size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName14);
- }
- if (FieldName15 != 0) {
- size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName15);
- }
- if (FieldName16 != 0) {
- size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName16);
- }
- if (FieldName17 != 0) {
- size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName17);
- }
- if (FieldName18 != 0) {
- size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName18);
- }
- return size;
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public void MergeFrom(TestAllTypes other) {
- if (other == null) {
- return;
- }
- if (other.OptionalInt32 != 0) {
- OptionalInt32 = other.OptionalInt32;
- }
- if (other.OptionalInt64 != 0L) {
- OptionalInt64 = other.OptionalInt64;
- }
- if (other.OptionalUint32 != 0) {
- OptionalUint32 = other.OptionalUint32;
- }
- if (other.OptionalUint64 != 0UL) {
- OptionalUint64 = other.OptionalUint64;
- }
- if (other.OptionalSint32 != 0) {
- OptionalSint32 = other.OptionalSint32;
- }
- if (other.OptionalSint64 != 0L) {
- OptionalSint64 = other.OptionalSint64;
- }
- if (other.OptionalFixed32 != 0) {
- OptionalFixed32 = other.OptionalFixed32;
- }
- if (other.OptionalFixed64 != 0UL) {
- OptionalFixed64 = other.OptionalFixed64;
- }
- if (other.OptionalSfixed32 != 0) {
- OptionalSfixed32 = other.OptionalSfixed32;
- }
- if (other.OptionalSfixed64 != 0L) {
- OptionalSfixed64 = other.OptionalSfixed64;
- }
- if (other.OptionalFloat != 0F) {
- OptionalFloat = other.OptionalFloat;
- }
- if (other.OptionalDouble != 0D) {
- OptionalDouble = other.OptionalDouble;
- }
- if (other.OptionalBool != false) {
- OptionalBool = other.OptionalBool;
- }
- if (other.OptionalString.Length != 0) {
- OptionalString = other.OptionalString;
- }
- if (other.OptionalBytes.Length != 0) {
- OptionalBytes = other.OptionalBytes;
- }
- if (other.optionalNestedMessage_ != null) {
- if (optionalNestedMessage_ == null) {
- optionalNestedMessage_ = new global::Conformance.TestAllTypes.Types.NestedMessage();
- }
- OptionalNestedMessage.MergeFrom(other.OptionalNestedMessage);
- }
- if (other.optionalForeignMessage_ != null) {
- if (optionalForeignMessage_ == null) {
- optionalForeignMessage_ = new global::Conformance.ForeignMessage();
- }
- OptionalForeignMessage.MergeFrom(other.OptionalForeignMessage);
- }
- if (other.OptionalNestedEnum != 0) {
- OptionalNestedEnum = other.OptionalNestedEnum;
- }
- if (other.OptionalForeignEnum != 0) {
- OptionalForeignEnum = other.OptionalForeignEnum;
- }
- if (other.OptionalStringPiece.Length != 0) {
- OptionalStringPiece = other.OptionalStringPiece;
- }
- if (other.OptionalCord.Length != 0) {
- OptionalCord = other.OptionalCord;
- }
- if (other.recursiveMessage_ != null) {
- if (recursiveMessage_ == null) {
- recursiveMessage_ = new global::Conformance.TestAllTypes();
- }
- RecursiveMessage.MergeFrom(other.RecursiveMessage);
- }
- repeatedInt32_.Add(other.repeatedInt32_);
- repeatedInt64_.Add(other.repeatedInt64_);
- repeatedUint32_.Add(other.repeatedUint32_);
- repeatedUint64_.Add(other.repeatedUint64_);
- repeatedSint32_.Add(other.repeatedSint32_);
- repeatedSint64_.Add(other.repeatedSint64_);
- repeatedFixed32_.Add(other.repeatedFixed32_);
- repeatedFixed64_.Add(other.repeatedFixed64_);
- repeatedSfixed32_.Add(other.repeatedSfixed32_);
- repeatedSfixed64_.Add(other.repeatedSfixed64_);
- repeatedFloat_.Add(other.repeatedFloat_);
- repeatedDouble_.Add(other.repeatedDouble_);
- repeatedBool_.Add(other.repeatedBool_);
- repeatedString_.Add(other.repeatedString_);
- repeatedBytes_.Add(other.repeatedBytes_);
- repeatedNestedMessage_.Add(other.repeatedNestedMessage_);
- repeatedForeignMessage_.Add(other.repeatedForeignMessage_);
- repeatedNestedEnum_.Add(other.repeatedNestedEnum_);
- repeatedForeignEnum_.Add(other.repeatedForeignEnum_);
- repeatedStringPiece_.Add(other.repeatedStringPiece_);
- repeatedCord_.Add(other.repeatedCord_);
- mapInt32Int32_.Add(other.mapInt32Int32_);
- mapInt64Int64_.Add(other.mapInt64Int64_);
- mapUint32Uint32_.Add(other.mapUint32Uint32_);
- mapUint64Uint64_.Add(other.mapUint64Uint64_);
- mapSint32Sint32_.Add(other.mapSint32Sint32_);
- mapSint64Sint64_.Add(other.mapSint64Sint64_);
- mapFixed32Fixed32_.Add(other.mapFixed32Fixed32_);
- mapFixed64Fixed64_.Add(other.mapFixed64Fixed64_);
- mapSfixed32Sfixed32_.Add(other.mapSfixed32Sfixed32_);
- mapSfixed64Sfixed64_.Add(other.mapSfixed64Sfixed64_);
- mapInt32Float_.Add(other.mapInt32Float_);
- mapInt32Double_.Add(other.mapInt32Double_);
- mapBoolBool_.Add(other.mapBoolBool_);
- mapStringString_.Add(other.mapStringString_);
- mapStringBytes_.Add(other.mapStringBytes_);
- mapStringNestedMessage_.Add(other.mapStringNestedMessage_);
- mapStringForeignMessage_.Add(other.mapStringForeignMessage_);
- mapStringNestedEnum_.Add(other.mapStringNestedEnum_);
- mapStringForeignEnum_.Add(other.mapStringForeignEnum_);
- if (other.optionalBoolWrapper_ != null) {
- if (optionalBoolWrapper_ == null || other.OptionalBoolWrapper != false) {
- OptionalBoolWrapper = other.OptionalBoolWrapper;
- }
- }
- if (other.optionalInt32Wrapper_ != null) {
- if (optionalInt32Wrapper_ == null || other.OptionalInt32Wrapper != 0) {
- OptionalInt32Wrapper = other.OptionalInt32Wrapper;
- }
- }
- if (other.optionalInt64Wrapper_ != null) {
- if (optionalInt64Wrapper_ == null || other.OptionalInt64Wrapper != 0L) {
- OptionalInt64Wrapper = other.OptionalInt64Wrapper;
- }
- }
- if (other.optionalUint32Wrapper_ != null) {
- if (optionalUint32Wrapper_ == null || other.OptionalUint32Wrapper != 0) {
- OptionalUint32Wrapper = other.OptionalUint32Wrapper;
- }
- }
- if (other.optionalUint64Wrapper_ != null) {
- if (optionalUint64Wrapper_ == null || other.OptionalUint64Wrapper != 0UL) {
- OptionalUint64Wrapper = other.OptionalUint64Wrapper;
- }
- }
- if (other.optionalFloatWrapper_ != null) {
- if (optionalFloatWrapper_ == null || other.OptionalFloatWrapper != 0F) {
- OptionalFloatWrapper = other.OptionalFloatWrapper;
- }
- }
- if (other.optionalDoubleWrapper_ != null) {
- if (optionalDoubleWrapper_ == null || other.OptionalDoubleWrapper != 0D) {
- OptionalDoubleWrapper = other.OptionalDoubleWrapper;
- }
- }
- if (other.optionalStringWrapper_ != null) {
- if (optionalStringWrapper_ == null || other.OptionalStringWrapper != "") {
- OptionalStringWrapper = other.OptionalStringWrapper;
- }
- }
- if (other.optionalBytesWrapper_ != null) {
- if (optionalBytesWrapper_ == null || other.OptionalBytesWrapper != pb::ByteString.Empty) {
- OptionalBytesWrapper = other.OptionalBytesWrapper;
- }
- }
- repeatedBoolWrapper_.Add(other.repeatedBoolWrapper_);
- repeatedInt32Wrapper_.Add(other.repeatedInt32Wrapper_);
- repeatedInt64Wrapper_.Add(other.repeatedInt64Wrapper_);
- repeatedUint32Wrapper_.Add(other.repeatedUint32Wrapper_);
- repeatedUint64Wrapper_.Add(other.repeatedUint64Wrapper_);
- repeatedFloatWrapper_.Add(other.repeatedFloatWrapper_);
- repeatedDoubleWrapper_.Add(other.repeatedDoubleWrapper_);
- repeatedStringWrapper_.Add(other.repeatedStringWrapper_);
- repeatedBytesWrapper_.Add(other.repeatedBytesWrapper_);
- if (other.optionalDuration_ != null) {
- if (optionalDuration_ == null) {
- optionalDuration_ = new global::Google.Protobuf.WellKnownTypes.Duration();
- }
- OptionalDuration.MergeFrom(other.OptionalDuration);
- }
- if (other.optionalTimestamp_ != null) {
- if (optionalTimestamp_ == null) {
- optionalTimestamp_ = new global::Google.Protobuf.WellKnownTypes.Timestamp();
- }
- OptionalTimestamp.MergeFrom(other.OptionalTimestamp);
- }
- if (other.optionalFieldMask_ != null) {
- if (optionalFieldMask_ == null) {
- optionalFieldMask_ = new global::Google.Protobuf.WellKnownTypes.FieldMask();
- }
- OptionalFieldMask.MergeFrom(other.OptionalFieldMask);
- }
- if (other.optionalStruct_ != null) {
- if (optionalStruct_ == null) {
- optionalStruct_ = new global::Google.Protobuf.WellKnownTypes.Struct();
- }
- OptionalStruct.MergeFrom(other.OptionalStruct);
- }
- if (other.optionalAny_ != null) {
- if (optionalAny_ == null) {
- optionalAny_ = new global::Google.Protobuf.WellKnownTypes.Any();
- }
- OptionalAny.MergeFrom(other.OptionalAny);
- }
- if (other.optionalValue_ != null) {
- if (optionalValue_ == null) {
- optionalValue_ = new global::Google.Protobuf.WellKnownTypes.Value();
- }
- OptionalValue.MergeFrom(other.OptionalValue);
- }
- repeatedDuration_.Add(other.repeatedDuration_);
- repeatedTimestamp_.Add(other.repeatedTimestamp_);
- repeatedFieldmask_.Add(other.repeatedFieldmask_);
- repeatedStruct_.Add(other.repeatedStruct_);
- repeatedAny_.Add(other.repeatedAny_);
- repeatedValue_.Add(other.repeatedValue_);
- if (other.Fieldname1 != 0) {
- Fieldname1 = other.Fieldname1;
- }
- if (other.FieldName2 != 0) {
- FieldName2 = other.FieldName2;
- }
- if (other.FieldName3 != 0) {
- FieldName3 = other.FieldName3;
- }
- if (other.FieldName4 != 0) {
- FieldName4 = other.FieldName4;
- }
- if (other.Field0Name5 != 0) {
- Field0Name5 = other.Field0Name5;
- }
- if (other.Field0Name6 != 0) {
- Field0Name6 = other.Field0Name6;
- }
- if (other.FieldName7 != 0) {
- FieldName7 = other.FieldName7;
- }
- if (other.FieldName8 != 0) {
- FieldName8 = other.FieldName8;
- }
- if (other.FieldName9 != 0) {
- FieldName9 = other.FieldName9;
- }
- if (other.FieldName10 != 0) {
- FieldName10 = other.FieldName10;
- }
- if (other.FIELDNAME11 != 0) {
- FIELDNAME11 = other.FIELDNAME11;
- }
- if (other.FIELDName12 != 0) {
- FIELDName12 = other.FIELDName12;
- }
- if (other.FieldName13 != 0) {
- FieldName13 = other.FieldName13;
- }
- if (other.FieldName14 != 0) {
- FieldName14 = other.FieldName14;
- }
- if (other.FieldName15 != 0) {
- FieldName15 = other.FieldName15;
- }
- if (other.FieldName16 != 0) {
- FieldName16 = other.FieldName16;
- }
- if (other.FieldName17 != 0) {
- FieldName17 = other.FieldName17;
- }
- if (other.FieldName18 != 0) {
- FieldName18 = other.FieldName18;
- }
- switch (other.OneofFieldCase) {
- case OneofFieldOneofCase.OneofUint32:
- OneofUint32 = other.OneofUint32;
- break;
- case OneofFieldOneofCase.OneofNestedMessage:
- OneofNestedMessage = other.OneofNestedMessage;
- break;
- case OneofFieldOneofCase.OneofString:
- OneofString = other.OneofString;
- break;
- case OneofFieldOneofCase.OneofBytes:
- OneofBytes = other.OneofBytes;
- break;
- case OneofFieldOneofCase.OneofBool:
- OneofBool = other.OneofBool;
- break;
- case OneofFieldOneofCase.OneofUint64:
- OneofUint64 = other.OneofUint64;
- break;
- case OneofFieldOneofCase.OneofFloat:
- OneofFloat = other.OneofFloat;
- break;
- case OneofFieldOneofCase.OneofDouble:
- OneofDouble = other.OneofDouble;
- break;
- case OneofFieldOneofCase.OneofEnum:
- OneofEnum = other.OneofEnum;
- break;
- }
-
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public void MergeFrom(pb::CodedInputStream input) {
- uint tag;
- while ((tag = input.ReadTag()) != 0) {
- switch(tag) {
- default:
- input.SkipLastField();
- break;
- case 8: {
- OptionalInt32 = input.ReadInt32();
- break;
- }
- case 16: {
- OptionalInt64 = input.ReadInt64();
- break;
- }
- case 24: {
- OptionalUint32 = input.ReadUInt32();
- break;
- }
- case 32: {
- OptionalUint64 = input.ReadUInt64();
- break;
- }
- case 40: {
- OptionalSint32 = input.ReadSInt32();
- break;
- }
- case 48: {
- OptionalSint64 = input.ReadSInt64();
- break;
- }
- case 61: {
- OptionalFixed32 = input.ReadFixed32();
- break;
- }
- case 65: {
- OptionalFixed64 = input.ReadFixed64();
- break;
- }
- case 77: {
- OptionalSfixed32 = input.ReadSFixed32();
- break;
- }
- case 81: {
- OptionalSfixed64 = input.ReadSFixed64();
- break;
- }
- case 93: {
- OptionalFloat = input.ReadFloat();
- break;
- }
- case 97: {
- OptionalDouble = input.ReadDouble();
- break;
- }
- case 104: {
- OptionalBool = input.ReadBool();
- break;
- }
- case 114: {
- OptionalString = input.ReadString();
- break;
- }
- case 122: {
- OptionalBytes = input.ReadBytes();
- break;
- }
- case 146: {
- if (optionalNestedMessage_ == null) {
- optionalNestedMessage_ = new global::Conformance.TestAllTypes.Types.NestedMessage();
- }
- input.ReadMessage(optionalNestedMessage_);
- break;
- }
- case 154: {
- if (optionalForeignMessage_ == null) {
- optionalForeignMessage_ = new global::Conformance.ForeignMessage();
- }
- input.ReadMessage(optionalForeignMessage_);
- break;
- }
- case 168: {
- optionalNestedEnum_ = (global::Conformance.TestAllTypes.Types.NestedEnum) input.ReadEnum();
- break;
- }
- case 176: {
- optionalForeignEnum_ = (global::Conformance.ForeignEnum) input.ReadEnum();
- break;
- }
- case 194: {
- OptionalStringPiece = input.ReadString();
- break;
- }
- case 202: {
- OptionalCord = input.ReadString();
- break;
- }
- case 218: {
- if (recursiveMessage_ == null) {
- recursiveMessage_ = new global::Conformance.TestAllTypes();
- }
- input.ReadMessage(recursiveMessage_);
- break;
- }
- case 250:
- case 248: {
- repeatedInt32_.AddEntriesFrom(input, _repeated_repeatedInt32_codec);
- break;
- }
- case 258:
- case 256: {
- repeatedInt64_.AddEntriesFrom(input, _repeated_repeatedInt64_codec);
- break;
- }
- case 266:
- case 264: {
- repeatedUint32_.AddEntriesFrom(input, _repeated_repeatedUint32_codec);
- break;
- }
- case 274:
- case 272: {
- repeatedUint64_.AddEntriesFrom(input, _repeated_repeatedUint64_codec);
- break;
- }
- case 282:
- case 280: {
- repeatedSint32_.AddEntriesFrom(input, _repeated_repeatedSint32_codec);
- break;
- }
- case 290:
- case 288: {
- repeatedSint64_.AddEntriesFrom(input, _repeated_repeatedSint64_codec);
- break;
- }
- case 298:
- case 301: {
- repeatedFixed32_.AddEntriesFrom(input, _repeated_repeatedFixed32_codec);
- break;
- }
- case 306:
- case 305: {
- repeatedFixed64_.AddEntriesFrom(input, _repeated_repeatedFixed64_codec);
- break;
- }
- case 314:
- case 317: {
- repeatedSfixed32_.AddEntriesFrom(input, _repeated_repeatedSfixed32_codec);
- break;
- }
- case 322:
- case 321: {
- repeatedSfixed64_.AddEntriesFrom(input, _repeated_repeatedSfixed64_codec);
- break;
- }
- case 330:
- case 333: {
- repeatedFloat_.AddEntriesFrom(input, _repeated_repeatedFloat_codec);
- break;
- }
- case 338:
- case 337: {
- repeatedDouble_.AddEntriesFrom(input, _repeated_repeatedDouble_codec);
- break;
- }
- case 346:
- case 344: {
- repeatedBool_.AddEntriesFrom(input, _repeated_repeatedBool_codec);
- break;
- }
- case 354: {
- repeatedString_.AddEntriesFrom(input, _repeated_repeatedString_codec);
- break;
- }
- case 362: {
- repeatedBytes_.AddEntriesFrom(input, _repeated_repeatedBytes_codec);
- break;
- }
- case 386: {
- repeatedNestedMessage_.AddEntriesFrom(input, _repeated_repeatedNestedMessage_codec);
- break;
- }
- case 394: {
- repeatedForeignMessage_.AddEntriesFrom(input, _repeated_repeatedForeignMessage_codec);
- break;
- }
- case 410:
- case 408: {
- repeatedNestedEnum_.AddEntriesFrom(input, _repeated_repeatedNestedEnum_codec);
- break;
- }
- case 418:
- case 416: {
- repeatedForeignEnum_.AddEntriesFrom(input, _repeated_repeatedForeignEnum_codec);
- break;
- }
- case 434: {
- repeatedStringPiece_.AddEntriesFrom(input, _repeated_repeatedStringPiece_codec);
- break;
- }
- case 442: {
- repeatedCord_.AddEntriesFrom(input, _repeated_repeatedCord_codec);
- break;
- }
- case 450: {
- mapInt32Int32_.AddEntriesFrom(input, _map_mapInt32Int32_codec);
- break;
- }
- case 458: {
- mapInt64Int64_.AddEntriesFrom(input, _map_mapInt64Int64_codec);
- break;
- }
- case 466: {
- mapUint32Uint32_.AddEntriesFrom(input, _map_mapUint32Uint32_codec);
- break;
- }
- case 474: {
- mapUint64Uint64_.AddEntriesFrom(input, _map_mapUint64Uint64_codec);
- break;
- }
- case 482: {
- mapSint32Sint32_.AddEntriesFrom(input, _map_mapSint32Sint32_codec);
- break;
- }
- case 490: {
- mapSint64Sint64_.AddEntriesFrom(input, _map_mapSint64Sint64_codec);
- break;
- }
- case 498: {
- mapFixed32Fixed32_.AddEntriesFrom(input, _map_mapFixed32Fixed32_codec);
- break;
- }
- case 506: {
- mapFixed64Fixed64_.AddEntriesFrom(input, _map_mapFixed64Fixed64_codec);
- break;
- }
- case 514: {
- mapSfixed32Sfixed32_.AddEntriesFrom(input, _map_mapSfixed32Sfixed32_codec);
- break;
- }
- case 522: {
- mapSfixed64Sfixed64_.AddEntriesFrom(input, _map_mapSfixed64Sfixed64_codec);
- break;
- }
- case 530: {
- mapInt32Float_.AddEntriesFrom(input, _map_mapInt32Float_codec);
- break;
- }
- case 538: {
- mapInt32Double_.AddEntriesFrom(input, _map_mapInt32Double_codec);
- break;
- }
- case 546: {
- mapBoolBool_.AddEntriesFrom(input, _map_mapBoolBool_codec);
- break;
- }
- case 554: {
- mapStringString_.AddEntriesFrom(input, _map_mapStringString_codec);
- break;
- }
- case 562: {
- mapStringBytes_.AddEntriesFrom(input, _map_mapStringBytes_codec);
- break;
- }
- case 570: {
- mapStringNestedMessage_.AddEntriesFrom(input, _map_mapStringNestedMessage_codec);
- break;
- }
- case 578: {
- mapStringForeignMessage_.AddEntriesFrom(input, _map_mapStringForeignMessage_codec);
- break;
- }
- case 586: {
- mapStringNestedEnum_.AddEntriesFrom(input, _map_mapStringNestedEnum_codec);
- break;
- }
- case 594: {
- mapStringForeignEnum_.AddEntriesFrom(input, _map_mapStringForeignEnum_codec);
- break;
- }
- case 888: {
- OneofUint32 = input.ReadUInt32();
- break;
- }
- case 898: {
- global::Conformance.TestAllTypes.Types.NestedMessage subBuilder = new global::Conformance.TestAllTypes.Types.NestedMessage();
- if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) {
- subBuilder.MergeFrom(OneofNestedMessage);
- }
- input.ReadMessage(subBuilder);
- OneofNestedMessage = subBuilder;
- break;
- }
- case 906: {
- OneofString = input.ReadString();
- break;
- }
- case 914: {
- OneofBytes = input.ReadBytes();
- break;
- }
- case 920: {
- OneofBool = input.ReadBool();
- break;
- }
- case 928: {
- OneofUint64 = input.ReadUInt64();
- break;
- }
- case 941: {
- OneofFloat = input.ReadFloat();
- break;
- }
- case 945: {
- OneofDouble = input.ReadDouble();
- break;
- }
- case 952: {
- oneofField_ = input.ReadEnum();
- oneofFieldCase_ = OneofFieldOneofCase.OneofEnum;
- break;
- }
- case 1610: {
- bool? value = _single_optionalBoolWrapper_codec.Read(input);
- if (optionalBoolWrapper_ == null || value != false) {
- OptionalBoolWrapper = value;
- }
- break;
- }
- case 1618: {
- int? value = _single_optionalInt32Wrapper_codec.Read(input);
- if (optionalInt32Wrapper_ == null || value != 0) {
- OptionalInt32Wrapper = value;
- }
- break;
- }
- case 1626: {
- long? value = _single_optionalInt64Wrapper_codec.Read(input);
- if (optionalInt64Wrapper_ == null || value != 0L) {
- OptionalInt64Wrapper = value;
- }
- break;
- }
- case 1634: {
- uint? value = _single_optionalUint32Wrapper_codec.Read(input);
- if (optionalUint32Wrapper_ == null || value != 0) {
- OptionalUint32Wrapper = value;
- }
- break;
- }
- case 1642: {
- ulong? value = _single_optionalUint64Wrapper_codec.Read(input);
- if (optionalUint64Wrapper_ == null || value != 0UL) {
- OptionalUint64Wrapper = value;
- }
- break;
- }
- case 1650: {
- float? value = _single_optionalFloatWrapper_codec.Read(input);
- if (optionalFloatWrapper_ == null || value != 0F) {
- OptionalFloatWrapper = value;
- }
- break;
- }
- case 1658: {
- double? value = _single_optionalDoubleWrapper_codec.Read(input);
- if (optionalDoubleWrapper_ == null || value != 0D) {
- OptionalDoubleWrapper = value;
- }
- break;
- }
- case 1666: {
- string value = _single_optionalStringWrapper_codec.Read(input);
- if (optionalStringWrapper_ == null || value != "") {
- OptionalStringWrapper = value;
- }
- break;
- }
- case 1674: {
- pb::ByteString value = _single_optionalBytesWrapper_codec.Read(input);
- if (optionalBytesWrapper_ == null || value != pb::ByteString.Empty) {
- OptionalBytesWrapper = value;
- }
- break;
- }
- case 1690: {
- repeatedBoolWrapper_.AddEntriesFrom(input, _repeated_repeatedBoolWrapper_codec);
- break;
- }
- case 1698: {
- repeatedInt32Wrapper_.AddEntriesFrom(input, _repeated_repeatedInt32Wrapper_codec);
- break;
- }
- case 1706: {
- repeatedInt64Wrapper_.AddEntriesFrom(input, _repeated_repeatedInt64Wrapper_codec);
- break;
- }
- case 1714: {
- repeatedUint32Wrapper_.AddEntriesFrom(input, _repeated_repeatedUint32Wrapper_codec);
- break;
- }
- case 1722: {
- repeatedUint64Wrapper_.AddEntriesFrom(input, _repeated_repeatedUint64Wrapper_codec);
- break;
- }
- case 1730: {
- repeatedFloatWrapper_.AddEntriesFrom(input, _repeated_repeatedFloatWrapper_codec);
- break;
- }
- case 1738: {
- repeatedDoubleWrapper_.AddEntriesFrom(input, _repeated_repeatedDoubleWrapper_codec);
- break;
- }
- case 1746: {
- repeatedStringWrapper_.AddEntriesFrom(input, _repeated_repeatedStringWrapper_codec);
- break;
- }
- case 1754: {
- repeatedBytesWrapper_.AddEntriesFrom(input, _repeated_repeatedBytesWrapper_codec);
- break;
- }
- case 2410: {
- if (optionalDuration_ == null) {
- optionalDuration_ = new global::Google.Protobuf.WellKnownTypes.Duration();
- }
- input.ReadMessage(optionalDuration_);
- break;
- }
- case 2418: {
- if (optionalTimestamp_ == null) {
- optionalTimestamp_ = new global::Google.Protobuf.WellKnownTypes.Timestamp();
- }
- input.ReadMessage(optionalTimestamp_);
- break;
- }
- case 2426: {
- if (optionalFieldMask_ == null) {
- optionalFieldMask_ = new global::Google.Protobuf.WellKnownTypes.FieldMask();
- }
- input.ReadMessage(optionalFieldMask_);
- break;
- }
- case 2434: {
- if (optionalStruct_ == null) {
- optionalStruct_ = new global::Google.Protobuf.WellKnownTypes.Struct();
- }
- input.ReadMessage(optionalStruct_);
- break;
- }
- case 2442: {
- if (optionalAny_ == null) {
- optionalAny_ = new global::Google.Protobuf.WellKnownTypes.Any();
- }
- input.ReadMessage(optionalAny_);
- break;
- }
- case 2450: {
- if (optionalValue_ == null) {
- optionalValue_ = new global::Google.Protobuf.WellKnownTypes.Value();
- }
- input.ReadMessage(optionalValue_);
- break;
- }
- case 2490: {
- repeatedDuration_.AddEntriesFrom(input, _repeated_repeatedDuration_codec);
- break;
- }
- case 2498: {
- repeatedTimestamp_.AddEntriesFrom(input, _repeated_repeatedTimestamp_codec);
- break;
- }
- case 2506: {
- repeatedFieldmask_.AddEntriesFrom(input, _repeated_repeatedFieldmask_codec);
- break;
- }
- case 2522: {
- repeatedAny_.AddEntriesFrom(input, _repeated_repeatedAny_codec);
- break;
- }
- case 2530: {
- repeatedValue_.AddEntriesFrom(input, _repeated_repeatedValue_codec);
- break;
- }
- case 2594: {
- repeatedStruct_.AddEntriesFrom(input, _repeated_repeatedStruct_codec);
- break;
- }
- case 3208: {
- Fieldname1 = input.ReadInt32();
- break;
- }
- case 3216: {
- FieldName2 = input.ReadInt32();
- break;
- }
- case 3224: {
- FieldName3 = input.ReadInt32();
- break;
- }
- case 3232: {
- FieldName4 = input.ReadInt32();
- break;
- }
- case 3240: {
- Field0Name5 = input.ReadInt32();
- break;
- }
- case 3248: {
- Field0Name6 = input.ReadInt32();
- break;
- }
- case 3256: {
- FieldName7 = input.ReadInt32();
- break;
- }
- case 3264: {
- FieldName8 = input.ReadInt32();
- break;
- }
- case 3272: {
- FieldName9 = input.ReadInt32();
- break;
- }
- case 3280: {
- FieldName10 = input.ReadInt32();
- break;
- }
- case 3288: {
- FIELDNAME11 = input.ReadInt32();
- break;
- }
- case 3296: {
- FIELDName12 = input.ReadInt32();
- break;
- }
- case 3304: {
- FieldName13 = input.ReadInt32();
- break;
- }
- case 3312: {
- FieldName14 = input.ReadInt32();
- break;
- }
- case 3320: {
- FieldName15 = input.ReadInt32();
- break;
- }
- case 3328: {
- FieldName16 = input.ReadInt32();
- break;
- }
- case 3336: {
- FieldName17 = input.ReadInt32();
- break;
- }
- case 3344: {
- FieldName18 = input.ReadInt32();
- break;
- }
- }
- }
- }
-
- #region Nested types
- /// <summary>Container for nested types declared in the TestAllTypes message type.</summary>
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public static partial class Types {
- public enum NestedEnum {
- [pbr::OriginalName("FOO")] Foo = 0,
- [pbr::OriginalName("BAR")] Bar = 1,
- [pbr::OriginalName("BAZ")] Baz = 2,
- /// <summary>
- /// Intentionally negative.
- /// </summary>
- [pbr::OriginalName("NEG")] Neg = -1,
- }
-
- public sealed partial class NestedMessage : pb::IMessage<NestedMessage> {
- private static readonly pb::MessageParser<NestedMessage> _parser = new pb::MessageParser<NestedMessage>(() => new NestedMessage());
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public static pb::MessageParser<NestedMessage> Parser { get { return _parser; } }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public static pbr::MessageDescriptor Descriptor {
- get { return global::Conformance.TestAllTypes.Descriptor.NestedTypes[0]; }
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- pbr::MessageDescriptor pb::IMessage.Descriptor {
- get { return Descriptor; }
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public NestedMessage() {
- OnConstruction();
- }
-
- partial void OnConstruction();
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public NestedMessage(NestedMessage other) : this() {
- a_ = other.a_;
- Corecursive = other.corecursive_ != null ? other.Corecursive.Clone() : null;
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public NestedMessage Clone() {
- return new NestedMessage(this);
- }
-
- /// <summary>Field number for the "a" field.</summary>
- public const int AFieldNumber = 1;
- private int a_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public int A {
- get { return a_; }
- set {
- a_ = value;
- }
- }
-
- /// <summary>Field number for the "corecursive" field.</summary>
- public const int CorecursiveFieldNumber = 2;
- private global::Conformance.TestAllTypes corecursive_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public global::Conformance.TestAllTypes Corecursive {
- get { return corecursive_; }
- set {
- corecursive_ = value;
- }
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public override bool Equals(object other) {
- return Equals(other as NestedMessage);
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public bool Equals(NestedMessage other) {
- if (ReferenceEquals(other, null)) {
- return false;
- }
- if (ReferenceEquals(other, this)) {
- return true;
- }
- if (A != other.A) return false;
- if (!object.Equals(Corecursive, other.Corecursive)) return false;
- return true;
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public override int GetHashCode() {
- int hash = 1;
- if (A != 0) hash ^= A.GetHashCode();
- if (corecursive_ != null) hash ^= Corecursive.GetHashCode();
- return hash;
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public override string ToString() {
- return pb::JsonFormatter.ToDiagnosticString(this);
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public void WriteTo(pb::CodedOutputStream output) {
- if (A != 0) {
- output.WriteRawTag(8);
- output.WriteInt32(A);
- }
- if (corecursive_ != null) {
- output.WriteRawTag(18);
- output.WriteMessage(Corecursive);
- }
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public int CalculateSize() {
- int size = 0;
- if (A != 0) {
- size += 1 + pb::CodedOutputStream.ComputeInt32Size(A);
- }
- if (corecursive_ != null) {
- size += 1 + pb::CodedOutputStream.ComputeMessageSize(Corecursive);
- }
- return size;
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public void MergeFrom(NestedMessage other) {
- if (other == null) {
- return;
- }
- if (other.A != 0) {
- A = other.A;
- }
- if (other.corecursive_ != null) {
- if (corecursive_ == null) {
- corecursive_ = new global::Conformance.TestAllTypes();
- }
- Corecursive.MergeFrom(other.Corecursive);
- }
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public void MergeFrom(pb::CodedInputStream input) {
- uint tag;
- while ((tag = input.ReadTag()) != 0) {
- switch(tag) {
- default:
- input.SkipLastField();
- break;
- case 8: {
- A = input.ReadInt32();
- break;
- }
- case 18: {
- if (corecursive_ == null) {
- corecursive_ = new global::Conformance.TestAllTypes();
- }
- input.ReadMessage(corecursive_);
- break;
- }
- }
- }
- }
-
- }
-
- }
- #endregion
-
- }
-
- public sealed partial class ForeignMessage : pb::IMessage<ForeignMessage> {
- private static readonly pb::MessageParser<ForeignMessage> _parser = new pb::MessageParser<ForeignMessage>(() => new ForeignMessage());
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public static pb::MessageParser<ForeignMessage> Parser { get { return _parser; } }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public static pbr::MessageDescriptor Descriptor {
- get { return global::Conformance.ConformanceReflection.Descriptor.MessageTypes[3]; }
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- pbr::MessageDescriptor pb::IMessage.Descriptor {
- get { return Descriptor; }
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public ForeignMessage() {
- OnConstruction();
- }
-
- partial void OnConstruction();
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public ForeignMessage(ForeignMessage other) : this() {
- c_ = other.c_;
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public ForeignMessage Clone() {
- return new ForeignMessage(this);
- }
-
- /// <summary>Field number for the "c" field.</summary>
- public const int CFieldNumber = 1;
- private int c_;
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public int C {
- get { return c_; }
- set {
- c_ = value;
- }
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public override bool Equals(object other) {
- return Equals(other as ForeignMessage);
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public bool Equals(ForeignMessage other) {
- if (ReferenceEquals(other, null)) {
- return false;
- }
- if (ReferenceEquals(other, this)) {
- return true;
- }
- if (C != other.C) return false;
- return true;
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public override int GetHashCode() {
- int hash = 1;
- if (C != 0) hash ^= C.GetHashCode();
- return hash;
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public override string ToString() {
- return pb::JsonFormatter.ToDiagnosticString(this);
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public void WriteTo(pb::CodedOutputStream output) {
- if (C != 0) {
- output.WriteRawTag(8);
- output.WriteInt32(C);
- }
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public int CalculateSize() {
- int size = 0;
- if (C != 0) {
- size += 1 + pb::CodedOutputStream.ComputeInt32Size(C);
- }
- return size;
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public void MergeFrom(ForeignMessage other) {
- if (other == null) {
- return;
- }
- if (other.C != 0) {
- C = other.C;
- }
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
- public void MergeFrom(pb::CodedInputStream input) {
- uint tag;
- while ((tag = input.ReadTag()) != 0) {
- switch(tag) {
- default:
- input.SkipLastField();
- break;
- case 8: {
- C = input.ReadInt32();
- break;
- }
- }
- }
- }
-
- }
-
#endregion
}
diff --git a/csharp/src/Google.Protobuf.Conformance/Program.cs b/csharp/src/Google.Protobuf.Conformance/Program.cs
index 19827c48..00ee64f8 100644
--- a/csharp/src/Google.Protobuf.Conformance/Program.cs
+++ b/csharp/src/Google.Protobuf.Conformance/Program.cs
@@ -48,7 +48,7 @@ namespace Google.Protobuf.Conformance
// This way we get the binary streams instead of readers/writers.
var input = new BinaryReader(Console.OpenStandardInput());
var output = new BinaryWriter(Console.OpenStandardOutput());
- var typeRegistry = TypeRegistry.FromMessages(TestAllTypes.Descriptor);
+ var typeRegistry = TypeRegistry.FromMessages(ProtobufTestMessages.Proto3.TestAllTypes.Descriptor);
int count = 0;
while (RunTest(input, output, typeRegistry))
@@ -81,17 +81,17 @@ namespace Google.Protobuf.Conformance
private static ConformanceResponse PerformRequest(ConformanceRequest request, TypeRegistry typeRegistry)
{
- TestAllTypes message;
+ ProtobufTestMessages.Proto3.TestAllTypes message;
try
{
switch (request.PayloadCase)
{
case ConformanceRequest.PayloadOneofCase.JsonPayload:
var parser = new JsonParser(new JsonParser.Settings(20, typeRegistry));
- message = parser.Parse<TestAllTypes>(request.JsonPayload);
+ message = parser.Parse<ProtobufTestMessages.Proto3.TestAllTypes>(request.JsonPayload);
break;
case ConformanceRequest.PayloadOneofCase.ProtobufPayload:
- message = TestAllTypes.Parser.ParseFrom(request.ProtobufPayload);
+ message = ProtobufTestMessages.Proto3.TestAllTypes.Parser.ParseFrom(request.ProtobufPayload);
break;
default:
throw new Exception("Unsupported request payload: " + request.PayloadCase);
diff --git a/csharp/src/Google.Protobuf.Conformance/project.json b/csharp/src/Google.Protobuf.Conformance/project.json
index 84b23c45..4cf05231 100644
--- a/csharp/src/Google.Protobuf.Conformance/project.json
+++ b/csharp/src/Google.Protobuf.Conformance/project.json
@@ -4,10 +4,12 @@
"emitEntryPoint": true
},
"dependencies": {
- "Google.Protobuf": { "target": "project" }
+ "Google.Protobuf": { "target": "project" },
+ "Google.Protobuf.Test": { "target": "project" }
},
"frameworks": {
"netcoreapp1.0": {
+ "imports": [ "dnxcore50", "netcoreapp1.0", "portable-net45+win8" ],
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
diff --git a/csharp/src/Google.Protobuf.Test/ByteStringTest.cs b/csharp/src/Google.Protobuf.Test/ByteStringTest.cs
index 685e130a..afdd491f 100644..100755
--- a/csharp/src/Google.Protobuf.Test/ByteStringTest.cs
+++ b/csharp/src/Google.Protobuf.Test/ByteStringTest.cs
@@ -33,6 +33,10 @@
using System;
using System.Text;
using NUnit.Framework;
+using System.IO;
+#if !NET35
+using System.Threading.Tasks;
+#endif
namespace Google.Protobuf
{
@@ -167,5 +171,67 @@ namespace Google.Protobuf
// Optimization which also fixes issue 61.
Assert.AreSame(ByteString.Empty, ByteString.FromBase64(""));
}
+
+ [Test]
+ public void FromStream_Seekable()
+ {
+ var stream = new MemoryStream(new byte[] { 1, 2, 3, 4, 5 });
+ // Consume the first byte, just to test that it's "from current position"
+ stream.ReadByte();
+ var actual = ByteString.FromStream(stream);
+ ByteString expected = ByteString.CopyFrom(2, 3, 4, 5);
+ Assert.AreEqual(expected, actual, $"{expected.ToBase64()} != {actual.ToBase64()}");
+ }
+
+ [Test]
+ public void FromStream_NotSeekable()
+ {
+ var stream = new MemoryStream(new byte[] { 1, 2, 3, 4, 5 });
+ // Consume the first byte, just to test that it's "from current position"
+ stream.ReadByte();
+ // Wrap the original stream in LimitedInputStream, which has CanSeek=false
+ var limitedStream = new LimitedInputStream(stream, 3);
+ var actual = ByteString.FromStream(limitedStream);
+ ByteString expected = ByteString.CopyFrom(2, 3, 4);
+ Assert.AreEqual(expected, actual, $"{expected.ToBase64()} != {actual.ToBase64()}");
+ }
+
+#if !NET35
+ [Test]
+ public async Task FromStreamAsync_Seekable()
+ {
+ var stream = new MemoryStream(new byte[] { 1, 2, 3, 4, 5 });
+ // Consume the first byte, just to test that it's "from current position"
+ stream.ReadByte();
+ var actual = await ByteString.FromStreamAsync(stream);
+ ByteString expected = ByteString.CopyFrom(2, 3, 4, 5);
+ Assert.AreEqual(expected, actual, $"{expected.ToBase64()} != {actual.ToBase64()}");
+ }
+
+ [Test]
+ public async Task FromStreamAsync_NotSeekable()
+ {
+ var stream = new MemoryStream(new byte[] { 1, 2, 3, 4, 5 });
+ // Consume the first byte, just to test that it's "from current position"
+ stream.ReadByte();
+ // Wrap the original stream in LimitedInputStream, which has CanSeek=false
+ var limitedStream = new LimitedInputStream(stream, 3);
+ var actual = await ByteString.FromStreamAsync(limitedStream);
+ ByteString expected = ByteString.CopyFrom(2, 3, 4);
+ Assert.AreEqual(expected, actual, $"{expected.ToBase64()} != {actual.ToBase64()}");
+ }
+#endif
+
+ [Test]
+ public void GetHashCode_Regression()
+ {
+ // We used to have an awful hash algorithm where only the last four
+ // bytes were relevant. This is a regression test for
+ // https://github.com/google/protobuf/issues/2511
+
+ ByteString b1 = ByteString.CopyFrom(100, 1, 2, 3, 4);
+ ByteString b2 = ByteString.CopyFrom(200, 1, 2, 3, 4);
+ Assert.AreNotEqual(b1.GetHashCode(), b2.GetHashCode());
+ }
}
} \ No newline at end of file
diff --git a/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs b/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs
index 9c845907..9d3d69af 100644
--- a/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs
+++ b/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs
@@ -499,6 +499,14 @@ namespace Google.Protobuf.Collections
}
[Test]
+ public void KeysCopyTo()
+ {
+ var map = new MapField<string, string> { { "foo", "bar" }, { "x", "y" } };
+ var keys = map.Keys.ToArray(); // Uses CopyTo internally
+ CollectionAssert.AreEquivalent(new[] { "foo", "x" }, keys);
+ }
+
+ [Test]
public void ValuesContains()
{
var map = new MapField<string, string> { { "foo", "bar" }, { "x", "y" } };
@@ -511,6 +519,14 @@ namespace Google.Protobuf.Collections
}
[Test]
+ public void ValuesCopyTo()
+ {
+ var map = new MapField<string, string> { { "foo", "bar" }, { "x", "y" } };
+ var values = map.Values.ToArray(); // Uses CopyTo internally
+ CollectionAssert.AreEquivalent(new[] { "bar", "y" }, values);
+ }
+
+ [Test]
public void ToString_StringToString()
{
var map = new MapField<string, string> { { "foo", "bar" }, { "x", "y" } };
diff --git a/csharp/src/Google.Protobuf.Test/Compatibility/StreamExtensionsTest.cs b/csharp/src/Google.Protobuf.Test/Compatibility/StreamExtensionsTest.cs
new file mode 100755
index 00000000..48c0725f
--- /dev/null
+++ b/csharp/src/Google.Protobuf.Test/Compatibility/StreamExtensionsTest.cs
@@ -0,0 +1,67 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2015 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+#if NET35
+using System;
+using System.IO;
+using NUnit.Framework;
+using Google.Protobuf.Compatibility;
+
+namespace Google.Protobuf.Test.Compatibility
+{
+ public class StreamExtensionsTest
+ {
+ [Test]
+ public void CopyToNullArgument()
+ {
+ var memoryStream = new MemoryStream();
+ Assert.Throws<ArgumentNullException>(() => memoryStream.CopyTo(null));
+ }
+
+ [Test]
+ public void CopyToTest()
+ {
+ byte[] bytesToStream = new byte[] { 0x31, 0x08, 0xFF, 0x00 };
+ Stream source = new MemoryStream(bytesToStream);
+ Stream destination = new MemoryStream((int)source.Length);
+ source.CopyTo(destination);
+ destination.Seek(0, SeekOrigin.Begin);
+
+ Assert.AreEqual(0x31, destination.ReadByte());
+ Assert.AreEqual(0x08, destination.ReadByte());
+ Assert.AreEqual(0xFF, destination.ReadByte());
+ Assert.AreEqual(0x00, destination.ReadByte());
+ Assert.AreEqual(-1, destination.ReadByte());
+ }
+ }
+}
+#endif
diff --git a/csharp/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs b/csharp/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs
index f430b06b..abbe3c95 100644..100755
--- a/csharp/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs
+++ b/csharp/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs
@@ -34,7 +34,7 @@ using System;
using System.Collections.Generic;
using System.Reflection;
-#if !DOTNET35
+#if !NET35
namespace Google.Protobuf.Compatibility
{
public class TypeExtensionsTest
diff --git a/csharp/src/Google.Protobuf.Test/FieldCodecTest.cs b/csharp/src/Google.Protobuf.Test/FieldCodecTest.cs
index 0e2bad59..77641163 100644..100755
--- a/csharp/src/Google.Protobuf.Test/FieldCodecTest.cs
+++ b/csharp/src/Google.Protobuf.Test/FieldCodecTest.cs
@@ -158,7 +158,9 @@ namespace Google.Protobuf
{
// WriteTagAndValue ignores default values
var stream = new MemoryStream();
- var codedOutput = new CodedOutputStream(stream);
+ CodedOutputStream codedOutput;
+#if !NET35
+ codedOutput = new CodedOutputStream(stream);
codec.WriteTagAndValue(codedOutput, codec.DefaultValue);
codedOutput.Flush();
Assert.AreEqual(0, stream.Position);
@@ -167,6 +169,7 @@ namespace Google.Protobuf
{
Assert.AreEqual(default(T), codec.DefaultValue);
}
+#endif
// The plain ValueWriter/ValueReader delegates don't.
if (codec.DefaultValue != null) // This part isn't appropriate for message types.
diff --git a/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj b/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj
index a9a1cc04..6370441e 100644
--- a/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj
+++ b/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj
@@ -11,9 +11,11 @@
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
</PropertyGroup>
-
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
+ <ItemGroup>
+ <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
+ </ItemGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project> \ No newline at end of file
diff --git a/csharp/src/Google.Protobuf.Test/Reflection/CustomOptionsTest.cs b/csharp/src/Google.Protobuf.Test/Reflection/CustomOptionsTest.cs
new file mode 100644
index 00000000..68b4d6af
--- /dev/null
+++ b/csharp/src/Google.Protobuf.Test/Reflection/CustomOptionsTest.cs
@@ -0,0 +1,271 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2017 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using Google.Protobuf.Reflection;
+using Google.Protobuf.WellKnownTypes;
+using NUnit.Framework;
+using System.IO;
+using System.Linq;
+using UnitTest.Issues.TestProtos;
+using static Google.Protobuf.WireFormat;
+using static UnitTest.Issues.TestProtos.ComplexOptionType2.Types;
+using static UnitTest.Issues.TestProtos.DummyMessageContainingEnum.Types;
+using static Google.Protobuf.Test.Reflection.CustomOptionNumber;
+
+namespace Google.Protobuf.Test.Reflection
+{
+ // Internal enum to allow us to use "using static" for convenience.
+ // These are the options defined in unittest_custom_options_proto3.proto
+ internal enum CustomOptionNumber
+ {
+ FileOpt1 = 7736974,
+ MessageOpt1 = 7739036,
+ FieldOpt1 = 7740936,
+ OneofOpt1 = 7740111,
+ EnumOpt1 = 7753576,
+ EnumValueOpt1 = 1560678,
+ ServiceOpt1 = 7887650,
+ MethodOpt1 = 7890860,
+
+ // All message options...
+ BoolOpt = 7706090,
+ Int32Opt = 7705709,
+ Int64Opt = 7705542,
+ UInt32Opt = 7704880,
+ UInt64Opt = 7702367,
+ SInt32Opt = 7701568,
+ SInt64Opt = 7700863,
+ Fixed32Opt = 7700307,
+ Fixed64Opt = 7700194,
+ SFixed32Opt = 7698645,
+ SFixed64Opt = 7685475,
+ FloatOpt = 7675390,
+ DoubleOpt = 7673293,
+ StringOpt = 7673285,
+ BytesOpt = 7673238,
+ EnumOpt = 7673233,
+ MessageTypeOpt = 7665967,
+
+ // Miscellaneous
+ ComplexOpt4 = 7633546,
+ ComplexOpt1 = 7646756,
+ ComplexOpt2 = 7636949,
+ ComplexOpt3 = 7636463,
+
+ // Aggregates
+ AggregateFileOpt = 15478479,
+ AggregateMsgOpt = 15480088,
+ AggregateFieldOpt = 15481374,
+ AggregateEnumOpt = 15483218,
+ AggregateEnumValueOpt = 15486921,
+ AggregateServiceOpt = 15497145,
+ AggregateMethodOpt = 15512713,
+ }
+
+ /// <summary>
+ /// The majority of the testing here is done via parsed descriptors. That's simpler to
+ /// achieve (and more important) than constructing a CodedInputStream manually.
+ /// </summary>
+ public class CustomOptionsTest
+ {
+ delegate bool OptionFetcher<T>(int field, out T value);
+
+ [Test]
+ public void EmptyOptionsIsShared()
+ {
+ var structOptions = Struct.Descriptor.CustomOptions;
+ var timestampOptions = Struct.Descriptor.CustomOptions;
+ Assert.AreSame(structOptions, timestampOptions);
+ }
+
+ [Test]
+ public void SimpleIntegerTest()
+ {
+ var stream = new MemoryStream();
+ var output = new CodedOutputStream(stream);
+ output.WriteTag(MakeTag(1, WireType.Varint));
+ output.WriteInt32(1234567);
+ output.Flush();
+ stream.Position = 0;
+ var input = new CodedInputStream(stream);
+ input.ReadTag();
+
+ var options = CustomOptions.Empty;
+ options = options.ReadOrSkipUnknownField(input);
+
+ int intValue;
+ Assert.True(options.TryGetInt32(1, out intValue));
+ Assert.AreEqual(1234567, intValue);
+
+ string stringValue;
+ // No ByteString stored values
+ Assert.False(options.TryGetString(1, out stringValue));
+ // Nothing stored for field 2
+ Assert.False(options.TryGetInt32(2, out intValue));
+ }
+
+ [Test]
+ public void SimpleStringTest()
+ {
+ var stream = new MemoryStream();
+ var output = new CodedOutputStream(stream);
+ output.WriteTag(MakeTag(1, WireType.LengthDelimited));
+ output.WriteString("value");
+ output.Flush();
+ stream.Position = 0;
+ var input = new CodedInputStream(stream);
+ input.ReadTag();
+
+ var options = CustomOptions.Empty;
+ options = options.ReadOrSkipUnknownField(input);
+
+ string stringValue;
+ Assert.True(options.TryGetString(1, out stringValue));
+ Assert.AreEqual("value", stringValue);
+
+ int intValue;
+ // No numeric stored values
+ Assert.False(options.TryGetInt32(1, out intValue));
+ // Nothing stored for field 2
+ Assert.False(options.TryGetString(2, out stringValue));
+ }
+
+ [Test]
+ public void ScalarOptions()
+ {
+ var options = CustomOptionOtherValues.Descriptor.CustomOptions;
+ AssertOption(-100, options.TryGetInt32, Int32Opt);
+ AssertOption(12.3456789f, options.TryGetFloat, FloatOpt);
+ AssertOption(1.234567890123456789d, options.TryGetDouble, DoubleOpt);
+ AssertOption("Hello, \"World\"", options.TryGetString, StringOpt);
+ AssertOption(ByteString.CopyFromUtf8("Hello\0World"), options.TryGetBytes, BytesOpt);
+ AssertOption((int) TestEnumType.TestOptionEnumType2, options.TryGetInt32, EnumOpt);
+ }
+
+ [Test]
+ public void MessageOptions()
+ {
+ var options = VariousComplexOptions.Descriptor.CustomOptions;
+ AssertOption(new ComplexOptionType1 { Foo = 42, Foo4 = { 99, 88 } }, options.TryGetMessage, ComplexOpt1);
+ AssertOption(new ComplexOptionType2
+ {
+ Baz = 987, Bar = new ComplexOptionType1 { Foo = 743 },
+ Fred = new ComplexOptionType4 { Waldo = 321 },
+ Barney = { new ComplexOptionType4 { Waldo = 101 }, new ComplexOptionType4 { Waldo = 212 } }
+ },
+ options.TryGetMessage, ComplexOpt2);
+ AssertOption(new ComplexOptionType3 { Qux = 9 }, options.TryGetMessage, ComplexOpt3);
+ }
+
+ [Test]
+ public void OptionLocations()
+ {
+ var fileOptions = UnittestCustomOptionsProto3Reflection.Descriptor.CustomOptions;
+ AssertOption(9876543210UL, fileOptions.TryGetUInt64, FileOpt1);
+
+ var messageOptions = TestMessageWithCustomOptions.Descriptor.CustomOptions;
+ AssertOption(-56, messageOptions.TryGetInt32, MessageOpt1);
+
+ var fieldOptions = TestMessageWithCustomOptions.Descriptor.Fields["field1"] .CustomOptions;
+ AssertOption(8765432109UL, fieldOptions.TryGetFixed64, FieldOpt1);
+
+ var oneofOptions = TestMessageWithCustomOptions.Descriptor.Oneofs[0].CustomOptions;
+ AssertOption(-99, oneofOptions.TryGetInt32, OneofOpt1);
+
+ var enumOptions = TestMessageWithCustomOptions.Descriptor.EnumTypes[0].CustomOptions;
+ AssertOption(-789, enumOptions.TryGetSFixed32, EnumOpt1);
+
+ var enumValueOptions = TestMessageWithCustomOptions.Descriptor.EnumTypes[0].FindValueByNumber(2).CustomOptions;
+ AssertOption(123, enumValueOptions.TryGetInt32, EnumValueOpt1);
+
+ var service = UnittestCustomOptionsProto3Reflection.Descriptor.Services
+ .Single(s => s.Name == "TestServiceWithCustomOptions");
+ var serviceOptions = service.CustomOptions;
+ AssertOption(-9876543210, serviceOptions.TryGetSInt64, ServiceOpt1);
+
+ var methodOptions = service.Methods[0].CustomOptions;
+ AssertOption((int) UnitTest.Issues.TestProtos.MethodOpt1.Val2, methodOptions.TryGetInt32, CustomOptionNumber.MethodOpt1);
+ }
+
+ [Test]
+ public void MinValues()
+ {
+ var options = CustomOptionMinIntegerValues.Descriptor.CustomOptions;
+ AssertOption(false, options.TryGetBool, BoolOpt);
+ AssertOption(int.MinValue, options.TryGetInt32, Int32Opt);
+ AssertOption(long.MinValue, options.TryGetInt64, Int64Opt);
+ AssertOption(uint.MinValue, options.TryGetUInt32, UInt32Opt);
+ AssertOption(ulong.MinValue, options.TryGetUInt64, UInt64Opt);
+ AssertOption(int.MinValue, options.TryGetSInt32, SInt32Opt);
+ AssertOption(long.MinValue, options.TryGetSInt64, SInt64Opt);
+ AssertOption(uint.MinValue, options.TryGetUInt32, Fixed32Opt);
+ AssertOption(ulong.MinValue, options.TryGetUInt64, Fixed64Opt);
+ AssertOption(int.MinValue, options.TryGetInt32, SFixed32Opt);
+ AssertOption(long.MinValue, options.TryGetInt64, SFixed64Opt);
+ }
+
+ [Test]
+ public void MaxValues()
+ {
+ var options = CustomOptionMaxIntegerValues.Descriptor.CustomOptions;
+ AssertOption(true, options.TryGetBool, BoolOpt);
+ AssertOption(int.MaxValue, options.TryGetInt32, Int32Opt);
+ AssertOption(long.MaxValue, options.TryGetInt64, Int64Opt);
+ AssertOption(uint.MaxValue, options.TryGetUInt32, UInt32Opt);
+ AssertOption(ulong.MaxValue, options.TryGetUInt64, UInt64Opt);
+ AssertOption(int.MaxValue, options.TryGetSInt32, SInt32Opt);
+ AssertOption(long.MaxValue, options.TryGetSInt64, SInt64Opt);
+ AssertOption(uint.MaxValue, options.TryGetFixed32, Fixed32Opt);
+ AssertOption(ulong.MaxValue, options.TryGetFixed64, Fixed64Opt);
+ AssertOption(int.MaxValue, options.TryGetSFixed32, SFixed32Opt);
+ AssertOption(long.MaxValue, options.TryGetSFixed64, SFixed64Opt);
+ }
+
+ [Test]
+ public void AggregateOptions()
+ {
+ // Just two examples
+ var messageOptions = AggregateMessage.Descriptor.CustomOptions;
+ AssertOption(new Aggregate { I = 101, S = "MessageAnnotation" }, messageOptions.TryGetMessage, AggregateMsgOpt);
+
+ var fieldOptions = AggregateMessage.Descriptor.Fields["fieldname"].CustomOptions;
+ AssertOption(new Aggregate { S = "FieldAnnotation" }, fieldOptions.TryGetMessage, AggregateFieldOpt);
+ }
+
+ private void AssertOption<T>(T expected, OptionFetcher<T> fetcher, CustomOptionNumber field)
+ {
+ T actual;
+ Assert.IsTrue(fetcher((int) field, out actual));
+ Assert.AreEqual(expected, actual);
+ }
+ }
+}
diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs b/csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs
index 0a299fd7..9c0518a3 100644
--- a/csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs
+++ b/csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs
@@ -172,7 +172,7 @@ namespace Google.Protobuf.TestProtos {
#region Messages
/// <summary>
- /// Tests maps.
+ /// Tests maps.
/// </summary>
public sealed partial class TestMap : pb::IMessage<TestMap> {
private static readonly pb::MessageParser<TestMap> _parser = new pb::MessageParser<TestMap>(() => new TestMap());
@@ -836,7 +836,7 @@ namespace Google.Protobuf.TestProtos {
}
/// <summary>
- /// Two map fields share the same entry default instance.
+ /// Two map fields share the same entry default instance.
/// </summary>
public sealed partial class TestSameTypeMap : pb::IMessage<TestSameTypeMap> {
private static readonly pb::MessageParser<TestSameTypeMap> _parser = new pb::MessageParser<TestSameTypeMap>(() => new TestSameTypeMap());
@@ -1357,8 +1357,8 @@ namespace Google.Protobuf.TestProtos {
}
/// <summary>
- /// Previously, message containing enum called Type cannot be used as value of
- /// map field.
+ /// Previously, message containing enum called Type cannot be used as value of
+ /// map field.
/// </summary>
public sealed partial class MessageContainingEnumCalledType : pb::IMessage<MessageContainingEnumCalledType> {
private static readonly pb::MessageParser<MessageContainingEnumCalledType> _parser = new pb::MessageParser<MessageContainingEnumCalledType>(() => new MessageContainingEnumCalledType());
@@ -1481,7 +1481,7 @@ namespace Google.Protobuf.TestProtos {
}
/// <summary>
- /// Previously, message cannot contain map field called "entry".
+ /// Previously, message cannot contain map field called "entry".
/// </summary>
public sealed partial class MessageContainingMapCalledEntry : pb::IMessage<MessageContainingMapCalledEntry> {
private static readonly pb::MessageParser<MessageContainingMapCalledEntry> _parser = new pb::MessageParser<MessageContainingMapCalledEntry>(() => new MessageContainingMapCalledEntry());
diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs b/csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs
new file mode 100644
index 00000000..fbeb512a
--- /dev/null
+++ b/csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs
@@ -0,0 +1,3688 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: google/protobuf/test_messages_proto3.proto
+#pragma warning disable 1591, 0612, 3021
+#region Designer generated code
+
+using pb = global::Google.Protobuf;
+using pbc = global::Google.Protobuf.Collections;
+using pbr = global::Google.Protobuf.Reflection;
+using scg = global::System.Collections.Generic;
+namespace ProtobufTestMessages.Proto3 {
+
+ /// <summary>Holder for reflection information generated from google/protobuf/test_messages_proto3.proto</summary>
+ public static partial class TestMessagesProto3Reflection {
+
+ #region Descriptor
+ /// <summary>File descriptor for google/protobuf/test_messages_proto3.proto</summary>
+ public static pbr::FileDescriptor Descriptor {
+ get { return descriptor; }
+ }
+ private static pbr::FileDescriptor descriptor;
+
+ static TestMessagesProto3Reflection() {
+ byte[] descriptorData = global::System.Convert.FromBase64String(
+ string.Concat(
+ "Cipnb29nbGUvcHJvdG9idWYvdGVzdF9tZXNzYWdlc19wcm90bzMucHJvdG8S",
+ "HXByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zGhlnb29nbGUvcHJvdG9i",
+ "dWYvYW55LnByb3RvGh5nb29nbGUvcHJvdG9idWYvZHVyYXRpb24ucHJvdG8a",
+ "IGdvb2dsZS9wcm90b2J1Zi9maWVsZF9tYXNrLnByb3RvGhxnb29nbGUvcHJv",
+ "dG9idWYvc3RydWN0LnByb3RvGh9nb29nbGUvcHJvdG9idWYvdGltZXN0YW1w",
+ "LnByb3RvGh5nb29nbGUvcHJvdG9idWYvd3JhcHBlcnMucHJvdG8i+DkKDFRl",
+ "c3RBbGxUeXBlcxIWCg5vcHRpb25hbF9pbnQzMhgBIAEoBRIWCg5vcHRpb25h",
+ "bF9pbnQ2NBgCIAEoAxIXCg9vcHRpb25hbF91aW50MzIYAyABKA0SFwoPb3B0",
+ "aW9uYWxfdWludDY0GAQgASgEEhcKD29wdGlvbmFsX3NpbnQzMhgFIAEoERIX",
+ "Cg9vcHRpb25hbF9zaW50NjQYBiABKBISGAoQb3B0aW9uYWxfZml4ZWQzMhgH",
+ "IAEoBxIYChBvcHRpb25hbF9maXhlZDY0GAggASgGEhkKEW9wdGlvbmFsX3Nm",
+ "aXhlZDMyGAkgASgPEhkKEW9wdGlvbmFsX3NmaXhlZDY0GAogASgQEhYKDm9w",
+ "dGlvbmFsX2Zsb2F0GAsgASgCEhcKD29wdGlvbmFsX2RvdWJsZRgMIAEoARIV",
+ "Cg1vcHRpb25hbF9ib29sGA0gASgIEhcKD29wdGlvbmFsX3N0cmluZxgOIAEo",
+ "CRIWCg5vcHRpb25hbF9ieXRlcxgPIAEoDBJaChdvcHRpb25hbF9uZXN0ZWRf",
+ "bWVzc2FnZRgSIAEoCzI5LnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8z",
+ "LlRlc3RBbGxUeXBlcy5OZXN0ZWRNZXNzYWdlEk8KGG9wdGlvbmFsX2ZvcmVp",
+ "Z25fbWVzc2FnZRgTIAEoCzItLnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJv",
+ "dG8zLkZvcmVpZ25NZXNzYWdlElQKFG9wdGlvbmFsX25lc3RlZF9lbnVtGBUg",
+ "ASgOMjYucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzMuVGVzdEFsbFR5",
+ "cGVzLk5lc3RlZEVudW0SSQoVb3B0aW9uYWxfZm9yZWlnbl9lbnVtGBYgASgO",
+ "MioucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzMuRm9yZWlnbkVudW0S",
+ "IQoVb3B0aW9uYWxfc3RyaW5nX3BpZWNlGBggASgJQgIIAhIZCg1vcHRpb25h",
+ "bF9jb3JkGBkgASgJQgIIARJGChFyZWN1cnNpdmVfbWVzc2FnZRgbIAEoCzIr",
+ "LnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zLlRlc3RBbGxUeXBlcxIW",
+ "Cg5yZXBlYXRlZF9pbnQzMhgfIAMoBRIWCg5yZXBlYXRlZF9pbnQ2NBggIAMo",
+ "AxIXCg9yZXBlYXRlZF91aW50MzIYISADKA0SFwoPcmVwZWF0ZWRfdWludDY0",
+ "GCIgAygEEhcKD3JlcGVhdGVkX3NpbnQzMhgjIAMoERIXCg9yZXBlYXRlZF9z",
+ "aW50NjQYJCADKBISGAoQcmVwZWF0ZWRfZml4ZWQzMhglIAMoBxIYChByZXBl",
+ "YXRlZF9maXhlZDY0GCYgAygGEhkKEXJlcGVhdGVkX3NmaXhlZDMyGCcgAygP",
+ "EhkKEXJlcGVhdGVkX3NmaXhlZDY0GCggAygQEhYKDnJlcGVhdGVkX2Zsb2F0",
+ "GCkgAygCEhcKD3JlcGVhdGVkX2RvdWJsZRgqIAMoARIVCg1yZXBlYXRlZF9i",
+ "b29sGCsgAygIEhcKD3JlcGVhdGVkX3N0cmluZxgsIAMoCRIWCg5yZXBlYXRl",
+ "ZF9ieXRlcxgtIAMoDBJaChdyZXBlYXRlZF9uZXN0ZWRfbWVzc2FnZRgwIAMo",
+ "CzI5LnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zLlRlc3RBbGxUeXBl",
+ "cy5OZXN0ZWRNZXNzYWdlEk8KGHJlcGVhdGVkX2ZvcmVpZ25fbWVzc2FnZRgx",
+ "IAMoCzItLnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zLkZvcmVpZ25N",
+ "ZXNzYWdlElQKFHJlcGVhdGVkX25lc3RlZF9lbnVtGDMgAygOMjYucHJvdG9i",
+ "dWZfdGVzdF9tZXNzYWdlcy5wcm90bzMuVGVzdEFsbFR5cGVzLk5lc3RlZEVu",
+ "dW0SSQoVcmVwZWF0ZWRfZm9yZWlnbl9lbnVtGDQgAygOMioucHJvdG9idWZf",
+ "dGVzdF9tZXNzYWdlcy5wcm90bzMuRm9yZWlnbkVudW0SIQoVcmVwZWF0ZWRf",
+ "c3RyaW5nX3BpZWNlGDYgAygJQgIIAhIZCg1yZXBlYXRlZF9jb3JkGDcgAygJ",
+ "QgIIARJXCg9tYXBfaW50MzJfaW50MzIYOCADKAsyPi5wcm90b2J1Zl90ZXN0",
+ "X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXMuTWFwSW50MzJJbnQzMkVu",
+ "dHJ5ElcKD21hcF9pbnQ2NF9pbnQ2NBg5IAMoCzI+LnByb3RvYnVmX3Rlc3Rf",
+ "bWVzc2FnZXMucHJvdG8zLlRlc3RBbGxUeXBlcy5NYXBJbnQ2NEludDY0RW50",
+ "cnkSWwoRbWFwX3VpbnQzMl91aW50MzIYOiADKAsyQC5wcm90b2J1Zl90ZXN0",
+ "X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXMuTWFwVWludDMyVWludDMy",
+ "RW50cnkSWwoRbWFwX3VpbnQ2NF91aW50NjQYOyADKAsyQC5wcm90b2J1Zl90",
+ "ZXN0X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXMuTWFwVWludDY0VWlu",
+ "dDY0RW50cnkSWwoRbWFwX3NpbnQzMl9zaW50MzIYPCADKAsyQC5wcm90b2J1",
+ "Zl90ZXN0X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXMuTWFwU2ludDMy",
+ "U2ludDMyRW50cnkSWwoRbWFwX3NpbnQ2NF9zaW50NjQYPSADKAsyQC5wcm90",
+ "b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXMuTWFwU2lu",
+ "dDY0U2ludDY0RW50cnkSXwoTbWFwX2ZpeGVkMzJfZml4ZWQzMhg+IAMoCzJC",
+ "LnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zLlRlc3RBbGxUeXBlcy5N",
+ "YXBGaXhlZDMyRml4ZWQzMkVudHJ5El8KE21hcF9maXhlZDY0X2ZpeGVkNjQY",
+ "PyADKAsyQi5wcm90b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxs",
+ "VHlwZXMuTWFwRml4ZWQ2NEZpeGVkNjRFbnRyeRJjChVtYXBfc2ZpeGVkMzJf",
+ "c2ZpeGVkMzIYQCADKAsyRC5wcm90b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3Rv",
+ "My5UZXN0QWxsVHlwZXMuTWFwU2ZpeGVkMzJTZml4ZWQzMkVudHJ5EmMKFW1h",
+ "cF9zZml4ZWQ2NF9zZml4ZWQ2NBhBIAMoCzJELnByb3RvYnVmX3Rlc3RfbWVz",
+ "c2FnZXMucHJvdG8zLlRlc3RBbGxUeXBlcy5NYXBTZml4ZWQ2NFNmaXhlZDY0",
+ "RW50cnkSVwoPbWFwX2ludDMyX2Zsb2F0GEIgAygLMj4ucHJvdG9idWZfdGVz",
+ "dF9tZXNzYWdlcy5wcm90bzMuVGVzdEFsbFR5cGVzLk1hcEludDMyRmxvYXRF",
+ "bnRyeRJZChBtYXBfaW50MzJfZG91YmxlGEMgAygLMj8ucHJvdG9idWZfdGVz",
+ "dF9tZXNzYWdlcy5wcm90bzMuVGVzdEFsbFR5cGVzLk1hcEludDMyRG91Ymxl",
+ "RW50cnkSUwoNbWFwX2Jvb2xfYm9vbBhEIAMoCzI8LnByb3RvYnVmX3Rlc3Rf",
+ "bWVzc2FnZXMucHJvdG8zLlRlc3RBbGxUeXBlcy5NYXBCb29sQm9vbEVudHJ5",
+ "ElsKEW1hcF9zdHJpbmdfc3RyaW5nGEUgAygLMkAucHJvdG9idWZfdGVzdF9t",
+ "ZXNzYWdlcy5wcm90bzMuVGVzdEFsbFR5cGVzLk1hcFN0cmluZ1N0cmluZ0Vu",
+ "dHJ5ElkKEG1hcF9zdHJpbmdfYnl0ZXMYRiADKAsyPy5wcm90b2J1Zl90ZXN0",
+ "X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXMuTWFwU3RyaW5nQnl0ZXNF",
+ "bnRyeRJqChltYXBfc3RyaW5nX25lc3RlZF9tZXNzYWdlGEcgAygLMkcucHJv",
+ "dG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzMuVGVzdEFsbFR5cGVzLk1hcFN0",
+ "cmluZ05lc3RlZE1lc3NhZ2VFbnRyeRJsChptYXBfc3RyaW5nX2ZvcmVpZ25f",
+ "bWVzc2FnZRhIIAMoCzJILnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8z",
+ "LlRlc3RBbGxUeXBlcy5NYXBTdHJpbmdGb3JlaWduTWVzc2FnZUVudHJ5EmQK",
+ "Fm1hcF9zdHJpbmdfbmVzdGVkX2VudW0YSSADKAsyRC5wcm90b2J1Zl90ZXN0",
+ "X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXMuTWFwU3RyaW5nTmVzdGVk",
+ "RW51bUVudHJ5EmYKF21hcF9zdHJpbmdfZm9yZWlnbl9lbnVtGEogAygLMkUu",
+ "cHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzMuVGVzdEFsbFR5cGVzLk1h",
+ "cFN0cmluZ0ZvcmVpZ25FbnVtRW50cnkSFgoMb25lb2ZfdWludDMyGG8gASgN",
+ "SAASWQoUb25lb2ZfbmVzdGVkX21lc3NhZ2UYcCABKAsyOS5wcm90b2J1Zl90",
+ "ZXN0X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXMuTmVzdGVkTWVzc2Fn",
+ "ZUgAEhYKDG9uZW9mX3N0cmluZxhxIAEoCUgAEhUKC29uZW9mX2J5dGVzGHIg",
+ "ASgMSAASFAoKb25lb2ZfYm9vbBhzIAEoCEgAEhYKDG9uZW9mX3VpbnQ2NBh0",
+ "IAEoBEgAEhUKC29uZW9mX2Zsb2F0GHUgASgCSAASFgoMb25lb2ZfZG91Ymxl",
+ "GHYgASgBSAASTAoKb25lb2ZfZW51bRh3IAEoDjI2LnByb3RvYnVmX3Rlc3Rf",
+ "bWVzc2FnZXMucHJvdG8zLlRlc3RBbGxUeXBlcy5OZXN0ZWRFbnVtSAASOgoV",
+ "b3B0aW9uYWxfYm9vbF93cmFwcGVyGMkBIAEoCzIaLmdvb2dsZS5wcm90b2J1",
+ "Zi5Cb29sVmFsdWUSPAoWb3B0aW9uYWxfaW50MzJfd3JhcHBlchjKASABKAsy",
+ "Gy5nb29nbGUucHJvdG9idWYuSW50MzJWYWx1ZRI8ChZvcHRpb25hbF9pbnQ2",
+ "NF93cmFwcGVyGMsBIAEoCzIbLmdvb2dsZS5wcm90b2J1Zi5JbnQ2NFZhbHVl",
+ "Ej4KF29wdGlvbmFsX3VpbnQzMl93cmFwcGVyGMwBIAEoCzIcLmdvb2dsZS5w",
+ "cm90b2J1Zi5VSW50MzJWYWx1ZRI+ChdvcHRpb25hbF91aW50NjRfd3JhcHBl",
+ "chjNASABKAsyHC5nb29nbGUucHJvdG9idWYuVUludDY0VmFsdWUSPAoWb3B0",
+ "aW9uYWxfZmxvYXRfd3JhcHBlchjOASABKAsyGy5nb29nbGUucHJvdG9idWYu",
+ "RmxvYXRWYWx1ZRI+ChdvcHRpb25hbF9kb3VibGVfd3JhcHBlchjPASABKAsy",
+ "HC5nb29nbGUucHJvdG9idWYuRG91YmxlVmFsdWUSPgoXb3B0aW9uYWxfc3Ry",
+ "aW5nX3dyYXBwZXIY0AEgASgLMhwuZ29vZ2xlLnByb3RvYnVmLlN0cmluZ1Zh",
+ "bHVlEjwKFm9wdGlvbmFsX2J5dGVzX3dyYXBwZXIY0QEgASgLMhsuZ29vZ2xl",
+ "LnByb3RvYnVmLkJ5dGVzVmFsdWUSOgoVcmVwZWF0ZWRfYm9vbF93cmFwcGVy",
+ "GNMBIAMoCzIaLmdvb2dsZS5wcm90b2J1Zi5Cb29sVmFsdWUSPAoWcmVwZWF0",
+ "ZWRfaW50MzJfd3JhcHBlchjUASADKAsyGy5nb29nbGUucHJvdG9idWYuSW50",
+ "MzJWYWx1ZRI8ChZyZXBlYXRlZF9pbnQ2NF93cmFwcGVyGNUBIAMoCzIbLmdv",
+ "b2dsZS5wcm90b2J1Zi5JbnQ2NFZhbHVlEj4KF3JlcGVhdGVkX3VpbnQzMl93",
+ "cmFwcGVyGNYBIAMoCzIcLmdvb2dsZS5wcm90b2J1Zi5VSW50MzJWYWx1ZRI+",
+ "ChdyZXBlYXRlZF91aW50NjRfd3JhcHBlchjXASADKAsyHC5nb29nbGUucHJv",
+ "dG9idWYuVUludDY0VmFsdWUSPAoWcmVwZWF0ZWRfZmxvYXRfd3JhcHBlchjY",
+ "ASADKAsyGy5nb29nbGUucHJvdG9idWYuRmxvYXRWYWx1ZRI+ChdyZXBlYXRl",
+ "ZF9kb3VibGVfd3JhcHBlchjZASADKAsyHC5nb29nbGUucHJvdG9idWYuRG91",
+ "YmxlVmFsdWUSPgoXcmVwZWF0ZWRfc3RyaW5nX3dyYXBwZXIY2gEgAygLMhwu",
+ "Z29vZ2xlLnByb3RvYnVmLlN0cmluZ1ZhbHVlEjwKFnJlcGVhdGVkX2J5dGVz",
+ "X3dyYXBwZXIY2wEgAygLMhsuZ29vZ2xlLnByb3RvYnVmLkJ5dGVzVmFsdWUS",
+ "NQoRb3B0aW9uYWxfZHVyYXRpb24YrQIgASgLMhkuZ29vZ2xlLnByb3RvYnVm",
+ "LkR1cmF0aW9uEjcKEm9wdGlvbmFsX3RpbWVzdGFtcBiuAiABKAsyGi5nb29n",
+ "bGUucHJvdG9idWYuVGltZXN0YW1wEjgKE29wdGlvbmFsX2ZpZWxkX21hc2sY",
+ "rwIgASgLMhouZ29vZ2xlLnByb3RvYnVmLkZpZWxkTWFzaxIxCg9vcHRpb25h",
+ "bF9zdHJ1Y3QYsAIgASgLMhcuZ29vZ2xlLnByb3RvYnVmLlN0cnVjdBIrCgxv",
+ "cHRpb25hbF9hbnkYsQIgASgLMhQuZ29vZ2xlLnByb3RvYnVmLkFueRIvCg5v",
+ "cHRpb25hbF92YWx1ZRiyAiABKAsyFi5nb29nbGUucHJvdG9idWYuVmFsdWUS",
+ "NQoRcmVwZWF0ZWRfZHVyYXRpb24YtwIgAygLMhkuZ29vZ2xlLnByb3RvYnVm",
+ "LkR1cmF0aW9uEjcKEnJlcGVhdGVkX3RpbWVzdGFtcBi4AiADKAsyGi5nb29n",
+ "bGUucHJvdG9idWYuVGltZXN0YW1wEjcKEnJlcGVhdGVkX2ZpZWxkbWFzaxi5",
+ "AiADKAsyGi5nb29nbGUucHJvdG9idWYuRmllbGRNYXNrEjEKD3JlcGVhdGVk",
+ "X3N0cnVjdBjEAiADKAsyFy5nb29nbGUucHJvdG9idWYuU3RydWN0EisKDHJl",
+ "cGVhdGVkX2FueRi7AiADKAsyFC5nb29nbGUucHJvdG9idWYuQW55Ei8KDnJl",
+ "cGVhdGVkX3ZhbHVlGLwCIAMoCzIWLmdvb2dsZS5wcm90b2J1Zi5WYWx1ZRIT",
+ "CgpmaWVsZG5hbWUxGJEDIAEoBRIUCgtmaWVsZF9uYW1lMhiSAyABKAUSFQoM",
+ "X2ZpZWxkX25hbWUzGJMDIAEoBRIWCg1maWVsZF9fbmFtZTRfGJQDIAEoBRIU",
+ "CgtmaWVsZDBuYW1lNRiVAyABKAUSFgoNZmllbGRfMF9uYW1lNhiWAyABKAUS",
+ "EwoKZmllbGROYW1lNxiXAyABKAUSEwoKRmllbGROYW1lOBiYAyABKAUSFAoL",
+ "ZmllbGRfTmFtZTkYmQMgASgFEhUKDEZpZWxkX05hbWUxMBiaAyABKAUSFQoM",
+ "RklFTERfTkFNRTExGJsDIAEoBRIVCgxGSUVMRF9uYW1lMTIYnAMgASgFEhcK",
+ "Dl9fZmllbGRfbmFtZTEzGJ0DIAEoBRIXCg5fX0ZpZWxkX25hbWUxNBieAyAB",
+ "KAUSFgoNZmllbGRfX25hbWUxNRifAyABKAUSFgoNZmllbGRfX05hbWUxNhig",
+ "AyABKAUSFwoOZmllbGRfbmFtZTE3X18YoQMgASgFEhcKDkZpZWxkX25hbWUx",
+ "OF9fGKIDIAEoBRpcCg1OZXN0ZWRNZXNzYWdlEgkKAWEYASABKAUSQAoLY29y",
+ "ZWN1cnNpdmUYAiABKAsyKy5wcm90b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3Rv",
+ "My5UZXN0QWxsVHlwZXMaNAoSTWFwSW50MzJJbnQzMkVudHJ5EgsKA2tleRgB",
+ "IAEoBRINCgV2YWx1ZRgCIAEoBToCOAEaNAoSTWFwSW50NjRJbnQ2NEVudHJ5",
+ "EgsKA2tleRgBIAEoAxINCgV2YWx1ZRgCIAEoAzoCOAEaNgoUTWFwVWludDMy",
+ "VWludDMyRW50cnkSCwoDa2V5GAEgASgNEg0KBXZhbHVlGAIgASgNOgI4ARo2",
+ "ChRNYXBVaW50NjRVaW50NjRFbnRyeRILCgNrZXkYASABKAQSDQoFdmFsdWUY",
+ "AiABKAQ6AjgBGjYKFE1hcFNpbnQzMlNpbnQzMkVudHJ5EgsKA2tleRgBIAEo",
+ "ERINCgV2YWx1ZRgCIAEoEToCOAEaNgoUTWFwU2ludDY0U2ludDY0RW50cnkS",
+ "CwoDa2V5GAEgASgSEg0KBXZhbHVlGAIgASgSOgI4ARo4ChZNYXBGaXhlZDMy",
+ "Rml4ZWQzMkVudHJ5EgsKA2tleRgBIAEoBxINCgV2YWx1ZRgCIAEoBzoCOAEa",
+ "OAoWTWFwRml4ZWQ2NEZpeGVkNjRFbnRyeRILCgNrZXkYASABKAYSDQoFdmFs",
+ "dWUYAiABKAY6AjgBGjoKGE1hcFNmaXhlZDMyU2ZpeGVkMzJFbnRyeRILCgNr",
+ "ZXkYASABKA8SDQoFdmFsdWUYAiABKA86AjgBGjoKGE1hcFNmaXhlZDY0U2Zp",
+ "eGVkNjRFbnRyeRILCgNrZXkYASABKBASDQoFdmFsdWUYAiABKBA6AjgBGjQK",
+ "Ek1hcEludDMyRmxvYXRFbnRyeRILCgNrZXkYASABKAUSDQoFdmFsdWUYAiAB",
+ "KAI6AjgBGjUKE01hcEludDMyRG91YmxlRW50cnkSCwoDa2V5GAEgASgFEg0K",
+ "BXZhbHVlGAIgASgBOgI4ARoyChBNYXBCb29sQm9vbEVudHJ5EgsKA2tleRgB",
+ "IAEoCBINCgV2YWx1ZRgCIAEoCDoCOAEaNgoUTWFwU3RyaW5nU3RyaW5nRW50",
+ "cnkSCwoDa2V5GAEgASgJEg0KBXZhbHVlGAIgASgJOgI4ARo1ChNNYXBTdHJp",
+ "bmdCeXRlc0VudHJ5EgsKA2tleRgBIAEoCRINCgV2YWx1ZRgCIAEoDDoCOAEa",
+ "eAobTWFwU3RyaW5nTmVzdGVkTWVzc2FnZUVudHJ5EgsKA2tleRgBIAEoCRJI",
+ "CgV2YWx1ZRgCIAEoCzI5LnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8z",
+ "LlRlc3RBbGxUeXBlcy5OZXN0ZWRNZXNzYWdlOgI4ARptChxNYXBTdHJpbmdG",
+ "b3JlaWduTWVzc2FnZUVudHJ5EgsKA2tleRgBIAEoCRI8CgV2YWx1ZRgCIAEo",
+ "CzItLnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zLkZvcmVpZ25NZXNz",
+ "YWdlOgI4ARpyChhNYXBTdHJpbmdOZXN0ZWRFbnVtRW50cnkSCwoDa2V5GAEg",
+ "ASgJEkUKBXZhbHVlGAIgASgOMjYucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5w",
+ "cm90bzMuVGVzdEFsbFR5cGVzLk5lc3RlZEVudW06AjgBGmcKGU1hcFN0cmlu",
+ "Z0ZvcmVpZ25FbnVtRW50cnkSCwoDa2V5GAEgASgJEjkKBXZhbHVlGAIgASgO",
+ "MioucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzMuRm9yZWlnbkVudW06",
+ "AjgBIjkKCk5lc3RlZEVudW0SBwoDRk9PEAASBwoDQkFSEAESBwoDQkFaEAIS",
+ "EAoDTkVHEP///////////wFCDQoLb25lb2ZfZmllbGQiGwoORm9yZWlnbk1l",
+ "c3NhZ2USCQoBYxgBIAEoBSpACgtGb3JlaWduRW51bRIPCgtGT1JFSUdOX0ZP",
+ "TxAAEg8KC0ZPUkVJR05fQkFSEAESDwoLRk9SRUlHTl9CQVoQAkIvCihjb20u",
+ "Z29vZ2xlLnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zSAH4AQFiBnBy",
+ "b3RvMw=="));
+ descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
+ new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.AnyReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.DurationReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.FieldMaskReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.StructReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.TimestampReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.WrappersReflection.Descriptor, },
+ new pbr::GeneratedClrTypeInfo(new[] {typeof(global::ProtobufTestMessages.Proto3.ForeignEnum), }, new pbr::GeneratedClrTypeInfo[] {
+ new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto3.TestAllTypes), global::ProtobufTestMessages.Proto3.TestAllTypes.Parser, new[]{ "OptionalInt32", "OptionalInt64", "OptionalUint32", "OptionalUint64", "OptionalSint32", "OptionalSint64", "OptionalFixed32", "OptionalFixed64", "OptionalSfixed32", "OptionalSfixed64", "OptionalFloat", "OptionalDouble", "OptionalBool", "OptionalString", "OptionalBytes", "OptionalNestedMessage", "OptionalForeignMessage", "OptionalNestedEnum", "OptionalForeignEnum", "OptionalStringPiece", "OptionalCord", "RecursiveMessage", "RepeatedInt32", "RepeatedInt64", "RepeatedUint32", "RepeatedUint64", "RepeatedSint32", "RepeatedSint64", "RepeatedFixed32", "RepeatedFixed64", "RepeatedSfixed32", "RepeatedSfixed64", "RepeatedFloat", "RepeatedDouble", "RepeatedBool", "RepeatedString", "RepeatedBytes", "RepeatedNestedMessage", "RepeatedForeignMessage", "RepeatedNestedEnum", "RepeatedForeignEnum", "RepeatedStringPiece", "RepeatedCord", "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapStringString", "MapStringBytes", "MapStringNestedMessage", "MapStringForeignMessage", "MapStringNestedEnum", "MapStringForeignEnum", "OneofUint32", "OneofNestedMessage", "OneofString", "OneofBytes", "OneofBool", "OneofUint64", "OneofFloat", "OneofDouble", "OneofEnum", "OptionalBoolWrapper", "OptionalInt32Wrapper", "OptionalInt64Wrapper", "OptionalUint32Wrapper", "OptionalUint64Wrapper", "OptionalFloatWrapper", "OptionalDoubleWrapper", "OptionalStringWrapper", "OptionalBytesWrapper", "RepeatedBoolWrapper", "RepeatedInt32Wrapper", "RepeatedInt64Wrapper", "RepeatedUint32Wrapper", "RepeatedUint64Wrapper", "RepeatedFloatWrapper", "RepeatedDoubleWrapper", "RepeatedStringWrapper", "RepeatedBytesWrapper", "OptionalDuration", "OptionalTimestamp", "OptionalFieldMask", "OptionalStruct", "OptionalAny", "OptionalValue", "RepeatedDuration", "RepeatedTimestamp", "RepeatedFieldmask", "RepeatedStruct", "RepeatedAny", "RepeatedValue", "Fieldname1", "FieldName2", "FieldName3", "FieldName4", "Field0Name5", "Field0Name6", "FieldName7", "FieldName8", "FieldName9", "FieldName10", "FIELDNAME11", "FIELDName12", "FieldName13", "FieldName14", "FieldName15", "FieldName16", "FieldName17", "FieldName18" }, new[]{ "OneofField" }, new[]{ typeof(global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum) }, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage), global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage.Parser, new[]{ "A", "Corecursive" }, null, null, null),
+ null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, }),
+ new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto3.ForeignMessage), global::ProtobufTestMessages.Proto3.ForeignMessage.Parser, new[]{ "C" }, null, null, null)
+ }));
+ }
+ #endregion
+
+ }
+ #region Enums
+ public enum ForeignEnum {
+ [pbr::OriginalName("FOREIGN_FOO")] ForeignFoo = 0,
+ [pbr::OriginalName("FOREIGN_BAR")] ForeignBar = 1,
+ [pbr::OriginalName("FOREIGN_BAZ")] ForeignBaz = 2,
+ }
+
+ #endregion
+
+ #region Messages
+ /// <summary>
+ /// This proto includes every type of field in both singular and repeated
+ /// forms.
+ ///
+ /// Also, crucially, all messages and enums in this file are eventually
+ /// submessages of this message. So for example, a fuzz test of TestAllTypes
+ /// could trigger bugs that occur in any message type in this file. We verify
+ /// this stays true in a unit test.
+ /// </summary>
+ public sealed partial class TestAllTypes : pb::IMessage<TestAllTypes> {
+ private static readonly pb::MessageParser<TestAllTypes> _parser = new pb::MessageParser<TestAllTypes>(() => new TestAllTypes());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<TestAllTypes> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::ProtobufTestMessages.Proto3.TestMessagesProto3Reflection.Descriptor.MessageTypes[0]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public TestAllTypes() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public TestAllTypes(TestAllTypes other) : this() {
+ optionalInt32_ = other.optionalInt32_;
+ optionalInt64_ = other.optionalInt64_;
+ optionalUint32_ = other.optionalUint32_;
+ optionalUint64_ = other.optionalUint64_;
+ optionalSint32_ = other.optionalSint32_;
+ optionalSint64_ = other.optionalSint64_;
+ optionalFixed32_ = other.optionalFixed32_;
+ optionalFixed64_ = other.optionalFixed64_;
+ optionalSfixed32_ = other.optionalSfixed32_;
+ optionalSfixed64_ = other.optionalSfixed64_;
+ optionalFloat_ = other.optionalFloat_;
+ optionalDouble_ = other.optionalDouble_;
+ optionalBool_ = other.optionalBool_;
+ optionalString_ = other.optionalString_;
+ optionalBytes_ = other.optionalBytes_;
+ OptionalNestedMessage = other.optionalNestedMessage_ != null ? other.OptionalNestedMessage.Clone() : null;
+ OptionalForeignMessage = other.optionalForeignMessage_ != null ? other.OptionalForeignMessage.Clone() : null;
+ optionalNestedEnum_ = other.optionalNestedEnum_;
+ optionalForeignEnum_ = other.optionalForeignEnum_;
+ optionalStringPiece_ = other.optionalStringPiece_;
+ optionalCord_ = other.optionalCord_;
+ RecursiveMessage = other.recursiveMessage_ != null ? other.RecursiveMessage.Clone() : null;
+ repeatedInt32_ = other.repeatedInt32_.Clone();
+ repeatedInt64_ = other.repeatedInt64_.Clone();
+ repeatedUint32_ = other.repeatedUint32_.Clone();
+ repeatedUint64_ = other.repeatedUint64_.Clone();
+ repeatedSint32_ = other.repeatedSint32_.Clone();
+ repeatedSint64_ = other.repeatedSint64_.Clone();
+ repeatedFixed32_ = other.repeatedFixed32_.Clone();
+ repeatedFixed64_ = other.repeatedFixed64_.Clone();
+ repeatedSfixed32_ = other.repeatedSfixed32_.Clone();
+ repeatedSfixed64_ = other.repeatedSfixed64_.Clone();
+ repeatedFloat_ = other.repeatedFloat_.Clone();
+ repeatedDouble_ = other.repeatedDouble_.Clone();
+ repeatedBool_ = other.repeatedBool_.Clone();
+ repeatedString_ = other.repeatedString_.Clone();
+ repeatedBytes_ = other.repeatedBytes_.Clone();
+ repeatedNestedMessage_ = other.repeatedNestedMessage_.Clone();
+ repeatedForeignMessage_ = other.repeatedForeignMessage_.Clone();
+ repeatedNestedEnum_ = other.repeatedNestedEnum_.Clone();
+ repeatedForeignEnum_ = other.repeatedForeignEnum_.Clone();
+ repeatedStringPiece_ = other.repeatedStringPiece_.Clone();
+ repeatedCord_ = other.repeatedCord_.Clone();
+ mapInt32Int32_ = other.mapInt32Int32_.Clone();
+ mapInt64Int64_ = other.mapInt64Int64_.Clone();
+ mapUint32Uint32_ = other.mapUint32Uint32_.Clone();
+ mapUint64Uint64_ = other.mapUint64Uint64_.Clone();
+ mapSint32Sint32_ = other.mapSint32Sint32_.Clone();
+ mapSint64Sint64_ = other.mapSint64Sint64_.Clone();
+ mapFixed32Fixed32_ = other.mapFixed32Fixed32_.Clone();
+ mapFixed64Fixed64_ = other.mapFixed64Fixed64_.Clone();
+ mapSfixed32Sfixed32_ = other.mapSfixed32Sfixed32_.Clone();
+ mapSfixed64Sfixed64_ = other.mapSfixed64Sfixed64_.Clone();
+ mapInt32Float_ = other.mapInt32Float_.Clone();
+ mapInt32Double_ = other.mapInt32Double_.Clone();
+ mapBoolBool_ = other.mapBoolBool_.Clone();
+ mapStringString_ = other.mapStringString_.Clone();
+ mapStringBytes_ = other.mapStringBytes_.Clone();
+ mapStringNestedMessage_ = other.mapStringNestedMessage_.Clone();
+ mapStringForeignMessage_ = other.mapStringForeignMessage_.Clone();
+ mapStringNestedEnum_ = other.mapStringNestedEnum_.Clone();
+ mapStringForeignEnum_ = other.mapStringForeignEnum_.Clone();
+ OptionalBoolWrapper = other.OptionalBoolWrapper;
+ OptionalInt32Wrapper = other.OptionalInt32Wrapper;
+ OptionalInt64Wrapper = other.OptionalInt64Wrapper;
+ OptionalUint32Wrapper = other.OptionalUint32Wrapper;
+ OptionalUint64Wrapper = other.OptionalUint64Wrapper;
+ OptionalFloatWrapper = other.OptionalFloatWrapper;
+ OptionalDoubleWrapper = other.OptionalDoubleWrapper;
+ OptionalStringWrapper = other.OptionalStringWrapper;
+ OptionalBytesWrapper = other.OptionalBytesWrapper;
+ repeatedBoolWrapper_ = other.repeatedBoolWrapper_.Clone();
+ repeatedInt32Wrapper_ = other.repeatedInt32Wrapper_.Clone();
+ repeatedInt64Wrapper_ = other.repeatedInt64Wrapper_.Clone();
+ repeatedUint32Wrapper_ = other.repeatedUint32Wrapper_.Clone();
+ repeatedUint64Wrapper_ = other.repeatedUint64Wrapper_.Clone();
+ repeatedFloatWrapper_ = other.repeatedFloatWrapper_.Clone();
+ repeatedDoubleWrapper_ = other.repeatedDoubleWrapper_.Clone();
+ repeatedStringWrapper_ = other.repeatedStringWrapper_.Clone();
+ repeatedBytesWrapper_ = other.repeatedBytesWrapper_.Clone();
+ OptionalDuration = other.optionalDuration_ != null ? other.OptionalDuration.Clone() : null;
+ OptionalTimestamp = other.optionalTimestamp_ != null ? other.OptionalTimestamp.Clone() : null;
+ OptionalFieldMask = other.optionalFieldMask_ != null ? other.OptionalFieldMask.Clone() : null;
+ OptionalStruct = other.optionalStruct_ != null ? other.OptionalStruct.Clone() : null;
+ OptionalAny = other.optionalAny_ != null ? other.OptionalAny.Clone() : null;
+ OptionalValue = other.optionalValue_ != null ? other.OptionalValue.Clone() : null;
+ repeatedDuration_ = other.repeatedDuration_.Clone();
+ repeatedTimestamp_ = other.repeatedTimestamp_.Clone();
+ repeatedFieldmask_ = other.repeatedFieldmask_.Clone();
+ repeatedStruct_ = other.repeatedStruct_.Clone();
+ repeatedAny_ = other.repeatedAny_.Clone();
+ repeatedValue_ = other.repeatedValue_.Clone();
+ fieldname1_ = other.fieldname1_;
+ fieldName2_ = other.fieldName2_;
+ FieldName3_ = other.FieldName3_;
+ fieldName4_ = other.fieldName4_;
+ field0Name5_ = other.field0Name5_;
+ field0Name6_ = other.field0Name6_;
+ fieldName7_ = other.fieldName7_;
+ fieldName8_ = other.fieldName8_;
+ fieldName9_ = other.fieldName9_;
+ fieldName10_ = other.fieldName10_;
+ fIELDNAME11_ = other.fIELDNAME11_;
+ fIELDName12_ = other.fIELDName12_;
+ FieldName13_ = other.FieldName13_;
+ FieldName14_ = other.FieldName14_;
+ fieldName15_ = other.fieldName15_;
+ fieldName16_ = other.fieldName16_;
+ fieldName17_ = other.fieldName17_;
+ fieldName18_ = other.fieldName18_;
+ switch (other.OneofFieldCase) {
+ case OneofFieldOneofCase.OneofUint32:
+ OneofUint32 = other.OneofUint32;
+ break;
+ case OneofFieldOneofCase.OneofNestedMessage:
+ OneofNestedMessage = other.OneofNestedMessage.Clone();
+ break;
+ case OneofFieldOneofCase.OneofString:
+ OneofString = other.OneofString;
+ break;
+ case OneofFieldOneofCase.OneofBytes:
+ OneofBytes = other.OneofBytes;
+ break;
+ case OneofFieldOneofCase.OneofBool:
+ OneofBool = other.OneofBool;
+ break;
+ case OneofFieldOneofCase.OneofUint64:
+ OneofUint64 = other.OneofUint64;
+ break;
+ case OneofFieldOneofCase.OneofFloat:
+ OneofFloat = other.OneofFloat;
+ break;
+ case OneofFieldOneofCase.OneofDouble:
+ OneofDouble = other.OneofDouble;
+ break;
+ case OneofFieldOneofCase.OneofEnum:
+ OneofEnum = other.OneofEnum;
+ break;
+ }
+
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public TestAllTypes Clone() {
+ return new TestAllTypes(this);
+ }
+
+ /// <summary>Field number for the "optional_int32" field.</summary>
+ public const int OptionalInt32FieldNumber = 1;
+ private int optionalInt32_;
+ /// <summary>
+ /// Singular
+ /// </summary>
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int OptionalInt32 {
+ get { return optionalInt32_; }
+ set {
+ optionalInt32_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_int64" field.</summary>
+ public const int OptionalInt64FieldNumber = 2;
+ private long optionalInt64_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public long OptionalInt64 {
+ get { return optionalInt64_; }
+ set {
+ optionalInt64_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_uint32" field.</summary>
+ public const int OptionalUint32FieldNumber = 3;
+ private uint optionalUint32_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public uint OptionalUint32 {
+ get { return optionalUint32_; }
+ set {
+ optionalUint32_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_uint64" field.</summary>
+ public const int OptionalUint64FieldNumber = 4;
+ private ulong optionalUint64_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public ulong OptionalUint64 {
+ get { return optionalUint64_; }
+ set {
+ optionalUint64_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_sint32" field.</summary>
+ public const int OptionalSint32FieldNumber = 5;
+ private int optionalSint32_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int OptionalSint32 {
+ get { return optionalSint32_; }
+ set {
+ optionalSint32_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_sint64" field.</summary>
+ public const int OptionalSint64FieldNumber = 6;
+ private long optionalSint64_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public long OptionalSint64 {
+ get { return optionalSint64_; }
+ set {
+ optionalSint64_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_fixed32" field.</summary>
+ public const int OptionalFixed32FieldNumber = 7;
+ private uint optionalFixed32_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public uint OptionalFixed32 {
+ get { return optionalFixed32_; }
+ set {
+ optionalFixed32_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_fixed64" field.</summary>
+ public const int OptionalFixed64FieldNumber = 8;
+ private ulong optionalFixed64_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public ulong OptionalFixed64 {
+ get { return optionalFixed64_; }
+ set {
+ optionalFixed64_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_sfixed32" field.</summary>
+ public const int OptionalSfixed32FieldNumber = 9;
+ private int optionalSfixed32_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int OptionalSfixed32 {
+ get { return optionalSfixed32_; }
+ set {
+ optionalSfixed32_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_sfixed64" field.</summary>
+ public const int OptionalSfixed64FieldNumber = 10;
+ private long optionalSfixed64_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public long OptionalSfixed64 {
+ get { return optionalSfixed64_; }
+ set {
+ optionalSfixed64_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_float" field.</summary>
+ public const int OptionalFloatFieldNumber = 11;
+ private float optionalFloat_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public float OptionalFloat {
+ get { return optionalFloat_; }
+ set {
+ optionalFloat_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_double" field.</summary>
+ public const int OptionalDoubleFieldNumber = 12;
+ private double optionalDouble_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public double OptionalDouble {
+ get { return optionalDouble_; }
+ set {
+ optionalDouble_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_bool" field.</summary>
+ public const int OptionalBoolFieldNumber = 13;
+ private bool optionalBool_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool OptionalBool {
+ get { return optionalBool_; }
+ set {
+ optionalBool_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_string" field.</summary>
+ public const int OptionalStringFieldNumber = 14;
+ private string optionalString_ = "";
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public string OptionalString {
+ get { return optionalString_; }
+ set {
+ optionalString_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
+ }
+ }
+
+ /// <summary>Field number for the "optional_bytes" field.</summary>
+ public const int OptionalBytesFieldNumber = 15;
+ private pb::ByteString optionalBytes_ = pb::ByteString.Empty;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pb::ByteString OptionalBytes {
+ get { return optionalBytes_; }
+ set {
+ optionalBytes_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
+ }
+ }
+
+ /// <summary>Field number for the "optional_nested_message" field.</summary>
+ public const int OptionalNestedMessageFieldNumber = 18;
+ private global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage optionalNestedMessage_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage OptionalNestedMessage {
+ get { return optionalNestedMessage_; }
+ set {
+ optionalNestedMessage_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_foreign_message" field.</summary>
+ public const int OptionalForeignMessageFieldNumber = 19;
+ private global::ProtobufTestMessages.Proto3.ForeignMessage optionalForeignMessage_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public global::ProtobufTestMessages.Proto3.ForeignMessage OptionalForeignMessage {
+ get { return optionalForeignMessage_; }
+ set {
+ optionalForeignMessage_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_nested_enum" field.</summary>
+ public const int OptionalNestedEnumFieldNumber = 21;
+ private global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum optionalNestedEnum_ = 0;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum OptionalNestedEnum {
+ get { return optionalNestedEnum_; }
+ set {
+ optionalNestedEnum_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_foreign_enum" field.</summary>
+ public const int OptionalForeignEnumFieldNumber = 22;
+ private global::ProtobufTestMessages.Proto3.ForeignEnum optionalForeignEnum_ = 0;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public global::ProtobufTestMessages.Proto3.ForeignEnum OptionalForeignEnum {
+ get { return optionalForeignEnum_; }
+ set {
+ optionalForeignEnum_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_string_piece" field.</summary>
+ public const int OptionalStringPieceFieldNumber = 24;
+ private string optionalStringPiece_ = "";
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public string OptionalStringPiece {
+ get { return optionalStringPiece_; }
+ set {
+ optionalStringPiece_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
+ }
+ }
+
+ /// <summary>Field number for the "optional_cord" field.</summary>
+ public const int OptionalCordFieldNumber = 25;
+ private string optionalCord_ = "";
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public string OptionalCord {
+ get { return optionalCord_; }
+ set {
+ optionalCord_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
+ }
+ }
+
+ /// <summary>Field number for the "recursive_message" field.</summary>
+ public const int RecursiveMessageFieldNumber = 27;
+ private global::ProtobufTestMessages.Proto3.TestAllTypes recursiveMessage_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public global::ProtobufTestMessages.Proto3.TestAllTypes RecursiveMessage {
+ get { return recursiveMessage_; }
+ set {
+ recursiveMessage_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "repeated_int32" field.</summary>
+ public const int RepeatedInt32FieldNumber = 31;
+ private static readonly pb::FieldCodec<int> _repeated_repeatedInt32_codec
+ = pb::FieldCodec.ForInt32(250);
+ private readonly pbc::RepeatedField<int> repeatedInt32_ = new pbc::RepeatedField<int>();
+ /// <summary>
+ /// Repeated
+ /// </summary>
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<int> RepeatedInt32 {
+ get { return repeatedInt32_; }
+ }
+
+ /// <summary>Field number for the "repeated_int64" field.</summary>
+ public const int RepeatedInt64FieldNumber = 32;
+ private static readonly pb::FieldCodec<long> _repeated_repeatedInt64_codec
+ = pb::FieldCodec.ForInt64(258);
+ private readonly pbc::RepeatedField<long> repeatedInt64_ = new pbc::RepeatedField<long>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<long> RepeatedInt64 {
+ get { return repeatedInt64_; }
+ }
+
+ /// <summary>Field number for the "repeated_uint32" field.</summary>
+ public const int RepeatedUint32FieldNumber = 33;
+ private static readonly pb::FieldCodec<uint> _repeated_repeatedUint32_codec
+ = pb::FieldCodec.ForUInt32(266);
+ private readonly pbc::RepeatedField<uint> repeatedUint32_ = new pbc::RepeatedField<uint>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<uint> RepeatedUint32 {
+ get { return repeatedUint32_; }
+ }
+
+ /// <summary>Field number for the "repeated_uint64" field.</summary>
+ public const int RepeatedUint64FieldNumber = 34;
+ private static readonly pb::FieldCodec<ulong> _repeated_repeatedUint64_codec
+ = pb::FieldCodec.ForUInt64(274);
+ private readonly pbc::RepeatedField<ulong> repeatedUint64_ = new pbc::RepeatedField<ulong>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<ulong> RepeatedUint64 {
+ get { return repeatedUint64_; }
+ }
+
+ /// <summary>Field number for the "repeated_sint32" field.</summary>
+ public const int RepeatedSint32FieldNumber = 35;
+ private static readonly pb::FieldCodec<int> _repeated_repeatedSint32_codec
+ = pb::FieldCodec.ForSInt32(282);
+ private readonly pbc::RepeatedField<int> repeatedSint32_ = new pbc::RepeatedField<int>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<int> RepeatedSint32 {
+ get { return repeatedSint32_; }
+ }
+
+ /// <summary>Field number for the "repeated_sint64" field.</summary>
+ public const int RepeatedSint64FieldNumber = 36;
+ private static readonly pb::FieldCodec<long> _repeated_repeatedSint64_codec
+ = pb::FieldCodec.ForSInt64(290);
+ private readonly pbc::RepeatedField<long> repeatedSint64_ = new pbc::RepeatedField<long>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<long> RepeatedSint64 {
+ get { return repeatedSint64_; }
+ }
+
+ /// <summary>Field number for the "repeated_fixed32" field.</summary>
+ public const int RepeatedFixed32FieldNumber = 37;
+ private static readonly pb::FieldCodec<uint> _repeated_repeatedFixed32_codec
+ = pb::FieldCodec.ForFixed32(298);
+ private readonly pbc::RepeatedField<uint> repeatedFixed32_ = new pbc::RepeatedField<uint>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<uint> RepeatedFixed32 {
+ get { return repeatedFixed32_; }
+ }
+
+ /// <summary>Field number for the "repeated_fixed64" field.</summary>
+ public const int RepeatedFixed64FieldNumber = 38;
+ private static readonly pb::FieldCodec<ulong> _repeated_repeatedFixed64_codec
+ = pb::FieldCodec.ForFixed64(306);
+ private readonly pbc::RepeatedField<ulong> repeatedFixed64_ = new pbc::RepeatedField<ulong>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<ulong> RepeatedFixed64 {
+ get { return repeatedFixed64_; }
+ }
+
+ /// <summary>Field number for the "repeated_sfixed32" field.</summary>
+ public const int RepeatedSfixed32FieldNumber = 39;
+ private static readonly pb::FieldCodec<int> _repeated_repeatedSfixed32_codec
+ = pb::FieldCodec.ForSFixed32(314);
+ private readonly pbc::RepeatedField<int> repeatedSfixed32_ = new pbc::RepeatedField<int>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<int> RepeatedSfixed32 {
+ get { return repeatedSfixed32_; }
+ }
+
+ /// <summary>Field number for the "repeated_sfixed64" field.</summary>
+ public const int RepeatedSfixed64FieldNumber = 40;
+ private static readonly pb::FieldCodec<long> _repeated_repeatedSfixed64_codec
+ = pb::FieldCodec.ForSFixed64(322);
+ private readonly pbc::RepeatedField<long> repeatedSfixed64_ = new pbc::RepeatedField<long>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<long> RepeatedSfixed64 {
+ get { return repeatedSfixed64_; }
+ }
+
+ /// <summary>Field number for the "repeated_float" field.</summary>
+ public const int RepeatedFloatFieldNumber = 41;
+ private static readonly pb::FieldCodec<float> _repeated_repeatedFloat_codec
+ = pb::FieldCodec.ForFloat(330);
+ private readonly pbc::RepeatedField<float> repeatedFloat_ = new pbc::RepeatedField<float>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<float> RepeatedFloat {
+ get { return repeatedFloat_; }
+ }
+
+ /// <summary>Field number for the "repeated_double" field.</summary>
+ public const int RepeatedDoubleFieldNumber = 42;
+ private static readonly pb::FieldCodec<double> _repeated_repeatedDouble_codec
+ = pb::FieldCodec.ForDouble(338);
+ private readonly pbc::RepeatedField<double> repeatedDouble_ = new pbc::RepeatedField<double>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<double> RepeatedDouble {
+ get { return repeatedDouble_; }
+ }
+
+ /// <summary>Field number for the "repeated_bool" field.</summary>
+ public const int RepeatedBoolFieldNumber = 43;
+ private static readonly pb::FieldCodec<bool> _repeated_repeatedBool_codec
+ = pb::FieldCodec.ForBool(346);
+ private readonly pbc::RepeatedField<bool> repeatedBool_ = new pbc::RepeatedField<bool>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<bool> RepeatedBool {
+ get { return repeatedBool_; }
+ }
+
+ /// <summary>Field number for the "repeated_string" field.</summary>
+ public const int RepeatedStringFieldNumber = 44;
+ private static readonly pb::FieldCodec<string> _repeated_repeatedString_codec
+ = pb::FieldCodec.ForString(354);
+ private readonly pbc::RepeatedField<string> repeatedString_ = new pbc::RepeatedField<string>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<string> RepeatedString {
+ get { return repeatedString_; }
+ }
+
+ /// <summary>Field number for the "repeated_bytes" field.</summary>
+ public const int RepeatedBytesFieldNumber = 45;
+ private static readonly pb::FieldCodec<pb::ByteString> _repeated_repeatedBytes_codec
+ = pb::FieldCodec.ForBytes(362);
+ private readonly pbc::RepeatedField<pb::ByteString> repeatedBytes_ = new pbc::RepeatedField<pb::ByteString>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<pb::ByteString> RepeatedBytes {
+ get { return repeatedBytes_; }
+ }
+
+ /// <summary>Field number for the "repeated_nested_message" field.</summary>
+ public const int RepeatedNestedMessageFieldNumber = 48;
+ private static readonly pb::FieldCodec<global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage> _repeated_repeatedNestedMessage_codec
+ = pb::FieldCodec.ForMessage(386, global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage.Parser);
+ private readonly pbc::RepeatedField<global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage> repeatedNestedMessage_ = new pbc::RepeatedField<global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage> RepeatedNestedMessage {
+ get { return repeatedNestedMessage_; }
+ }
+
+ /// <summary>Field number for the "repeated_foreign_message" field.</summary>
+ public const int RepeatedForeignMessageFieldNumber = 49;
+ private static readonly pb::FieldCodec<global::ProtobufTestMessages.Proto3.ForeignMessage> _repeated_repeatedForeignMessage_codec
+ = pb::FieldCodec.ForMessage(394, global::ProtobufTestMessages.Proto3.ForeignMessage.Parser);
+ private readonly pbc::RepeatedField<global::ProtobufTestMessages.Proto3.ForeignMessage> repeatedForeignMessage_ = new pbc::RepeatedField<global::ProtobufTestMessages.Proto3.ForeignMessage>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<global::ProtobufTestMessages.Proto3.ForeignMessage> RepeatedForeignMessage {
+ get { return repeatedForeignMessage_; }
+ }
+
+ /// <summary>Field number for the "repeated_nested_enum" field.</summary>
+ public const int RepeatedNestedEnumFieldNumber = 51;
+ private static readonly pb::FieldCodec<global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum> _repeated_repeatedNestedEnum_codec
+ = pb::FieldCodec.ForEnum(410, x => (int) x, x => (global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum) x);
+ private readonly pbc::RepeatedField<global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum> repeatedNestedEnum_ = new pbc::RepeatedField<global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum> RepeatedNestedEnum {
+ get { return repeatedNestedEnum_; }
+ }
+
+ /// <summary>Field number for the "repeated_foreign_enum" field.</summary>
+ public const int RepeatedForeignEnumFieldNumber = 52;
+ private static readonly pb::FieldCodec<global::ProtobufTestMessages.Proto3.ForeignEnum> _repeated_repeatedForeignEnum_codec
+ = pb::FieldCodec.ForEnum(418, x => (int) x, x => (global::ProtobufTestMessages.Proto3.ForeignEnum) x);
+ private readonly pbc::RepeatedField<global::ProtobufTestMessages.Proto3.ForeignEnum> repeatedForeignEnum_ = new pbc::RepeatedField<global::ProtobufTestMessages.Proto3.ForeignEnum>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<global::ProtobufTestMessages.Proto3.ForeignEnum> RepeatedForeignEnum {
+ get { return repeatedForeignEnum_; }
+ }
+
+ /// <summary>Field number for the "repeated_string_piece" field.</summary>
+ public const int RepeatedStringPieceFieldNumber = 54;
+ private static readonly pb::FieldCodec<string> _repeated_repeatedStringPiece_codec
+ = pb::FieldCodec.ForString(434);
+ private readonly pbc::RepeatedField<string> repeatedStringPiece_ = new pbc::RepeatedField<string>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<string> RepeatedStringPiece {
+ get { return repeatedStringPiece_; }
+ }
+
+ /// <summary>Field number for the "repeated_cord" field.</summary>
+ public const int RepeatedCordFieldNumber = 55;
+ private static readonly pb::FieldCodec<string> _repeated_repeatedCord_codec
+ = pb::FieldCodec.ForString(442);
+ private readonly pbc::RepeatedField<string> repeatedCord_ = new pbc::RepeatedField<string>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<string> RepeatedCord {
+ get { return repeatedCord_; }
+ }
+
+ /// <summary>Field number for the "map_int32_int32" field.</summary>
+ public const int MapInt32Int32FieldNumber = 56;
+ private static readonly pbc::MapField<int, int>.Codec _map_mapInt32Int32_codec
+ = new pbc::MapField<int, int>.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForInt32(16), 450);
+ private readonly pbc::MapField<int, int> mapInt32Int32_ = new pbc::MapField<int, int>();
+ /// <summary>
+ /// Map
+ /// </summary>
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::MapField<int, int> MapInt32Int32 {
+ get { return mapInt32Int32_; }
+ }
+
+ /// <summary>Field number for the "map_int64_int64" field.</summary>
+ public const int MapInt64Int64FieldNumber = 57;
+ private static readonly pbc::MapField<long, long>.Codec _map_mapInt64Int64_codec
+ = new pbc::MapField<long, long>.Codec(pb::FieldCodec.ForInt64(8), pb::FieldCodec.ForInt64(16), 458);
+ private readonly pbc::MapField<long, long> mapInt64Int64_ = new pbc::MapField<long, long>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::MapField<long, long> MapInt64Int64 {
+ get { return mapInt64Int64_; }
+ }
+
+ /// <summary>Field number for the "map_uint32_uint32" field.</summary>
+ public const int MapUint32Uint32FieldNumber = 58;
+ private static readonly pbc::MapField<uint, uint>.Codec _map_mapUint32Uint32_codec
+ = new pbc::MapField<uint, uint>.Codec(pb::FieldCodec.ForUInt32(8), pb::FieldCodec.ForUInt32(16), 466);
+ private readonly pbc::MapField<uint, uint> mapUint32Uint32_ = new pbc::MapField<uint, uint>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::MapField<uint, uint> MapUint32Uint32 {
+ get { return mapUint32Uint32_; }
+ }
+
+ /// <summary>Field number for the "map_uint64_uint64" field.</summary>
+ public const int MapUint64Uint64FieldNumber = 59;
+ private static readonly pbc::MapField<ulong, ulong>.Codec _map_mapUint64Uint64_codec
+ = new pbc::MapField<ulong, ulong>.Codec(pb::FieldCodec.ForUInt64(8), pb::FieldCodec.ForUInt64(16), 474);
+ private readonly pbc::MapField<ulong, ulong> mapUint64Uint64_ = new pbc::MapField<ulong, ulong>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::MapField<ulong, ulong> MapUint64Uint64 {
+ get { return mapUint64Uint64_; }
+ }
+
+ /// <summary>Field number for the "map_sint32_sint32" field.</summary>
+ public const int MapSint32Sint32FieldNumber = 60;
+ private static readonly pbc::MapField<int, int>.Codec _map_mapSint32Sint32_codec
+ = new pbc::MapField<int, int>.Codec(pb::FieldCodec.ForSInt32(8), pb::FieldCodec.ForSInt32(16), 482);
+ private readonly pbc::MapField<int, int> mapSint32Sint32_ = new pbc::MapField<int, int>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::MapField<int, int> MapSint32Sint32 {
+ get { return mapSint32Sint32_; }
+ }
+
+ /// <summary>Field number for the "map_sint64_sint64" field.</summary>
+ public const int MapSint64Sint64FieldNumber = 61;
+ private static readonly pbc::MapField<long, long>.Codec _map_mapSint64Sint64_codec
+ = new pbc::MapField<long, long>.Codec(pb::FieldCodec.ForSInt64(8), pb::FieldCodec.ForSInt64(16), 490);
+ private readonly pbc::MapField<long, long> mapSint64Sint64_ = new pbc::MapField<long, long>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::MapField<long, long> MapSint64Sint64 {
+ get { return mapSint64Sint64_; }
+ }
+
+ /// <summary>Field number for the "map_fixed32_fixed32" field.</summary>
+ public const int MapFixed32Fixed32FieldNumber = 62;
+ private static readonly pbc::MapField<uint, uint>.Codec _map_mapFixed32Fixed32_codec
+ = new pbc::MapField<uint, uint>.Codec(pb::FieldCodec.ForFixed32(13), pb::FieldCodec.ForFixed32(21), 498);
+ private readonly pbc::MapField<uint, uint> mapFixed32Fixed32_ = new pbc::MapField<uint, uint>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::MapField<uint, uint> MapFixed32Fixed32 {
+ get { return mapFixed32Fixed32_; }
+ }
+
+ /// <summary>Field number for the "map_fixed64_fixed64" field.</summary>
+ public const int MapFixed64Fixed64FieldNumber = 63;
+ private static readonly pbc::MapField<ulong, ulong>.Codec _map_mapFixed64Fixed64_codec
+ = new pbc::MapField<ulong, ulong>.Codec(pb::FieldCodec.ForFixed64(9), pb::FieldCodec.ForFixed64(17), 506);
+ private readonly pbc::MapField<ulong, ulong> mapFixed64Fixed64_ = new pbc::MapField<ulong, ulong>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::MapField<ulong, ulong> MapFixed64Fixed64 {
+ get { return mapFixed64Fixed64_; }
+ }
+
+ /// <summary>Field number for the "map_sfixed32_sfixed32" field.</summary>
+ public const int MapSfixed32Sfixed32FieldNumber = 64;
+ private static readonly pbc::MapField<int, int>.Codec _map_mapSfixed32Sfixed32_codec
+ = new pbc::MapField<int, int>.Codec(pb::FieldCodec.ForSFixed32(13), pb::FieldCodec.ForSFixed32(21), 514);
+ private readonly pbc::MapField<int, int> mapSfixed32Sfixed32_ = new pbc::MapField<int, int>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::MapField<int, int> MapSfixed32Sfixed32 {
+ get { return mapSfixed32Sfixed32_; }
+ }
+
+ /// <summary>Field number for the "map_sfixed64_sfixed64" field.</summary>
+ public const int MapSfixed64Sfixed64FieldNumber = 65;
+ private static readonly pbc::MapField<long, long>.Codec _map_mapSfixed64Sfixed64_codec
+ = new pbc::MapField<long, long>.Codec(pb::FieldCodec.ForSFixed64(9), pb::FieldCodec.ForSFixed64(17), 522);
+ private readonly pbc::MapField<long, long> mapSfixed64Sfixed64_ = new pbc::MapField<long, long>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::MapField<long, long> MapSfixed64Sfixed64 {
+ get { return mapSfixed64Sfixed64_; }
+ }
+
+ /// <summary>Field number for the "map_int32_float" field.</summary>
+ public const int MapInt32FloatFieldNumber = 66;
+ private static readonly pbc::MapField<int, float>.Codec _map_mapInt32Float_codec
+ = new pbc::MapField<int, float>.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForFloat(21), 530);
+ private readonly pbc::MapField<int, float> mapInt32Float_ = new pbc::MapField<int, float>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::MapField<int, float> MapInt32Float {
+ get { return mapInt32Float_; }
+ }
+
+ /// <summary>Field number for the "map_int32_double" field.</summary>
+ public const int MapInt32DoubleFieldNumber = 67;
+ private static readonly pbc::MapField<int, double>.Codec _map_mapInt32Double_codec
+ = new pbc::MapField<int, double>.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForDouble(17), 538);
+ private readonly pbc::MapField<int, double> mapInt32Double_ = new pbc::MapField<int, double>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::MapField<int, double> MapInt32Double {
+ get { return mapInt32Double_; }
+ }
+
+ /// <summary>Field number for the "map_bool_bool" field.</summary>
+ public const int MapBoolBoolFieldNumber = 68;
+ private static readonly pbc::MapField<bool, bool>.Codec _map_mapBoolBool_codec
+ = new pbc::MapField<bool, bool>.Codec(pb::FieldCodec.ForBool(8), pb::FieldCodec.ForBool(16), 546);
+ private readonly pbc::MapField<bool, bool> mapBoolBool_ = new pbc::MapField<bool, bool>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::MapField<bool, bool> MapBoolBool {
+ get { return mapBoolBool_; }
+ }
+
+ /// <summary>Field number for the "map_string_string" field.</summary>
+ public const int MapStringStringFieldNumber = 69;
+ private static readonly pbc::MapField<string, string>.Codec _map_mapStringString_codec
+ = new pbc::MapField<string, string>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForString(18), 554);
+ private readonly pbc::MapField<string, string> mapStringString_ = new pbc::MapField<string, string>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::MapField<string, string> MapStringString {
+ get { return mapStringString_; }
+ }
+
+ /// <summary>Field number for the "map_string_bytes" field.</summary>
+ public const int MapStringBytesFieldNumber = 70;
+ private static readonly pbc::MapField<string, pb::ByteString>.Codec _map_mapStringBytes_codec
+ = new pbc::MapField<string, pb::ByteString>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForBytes(18), 562);
+ private readonly pbc::MapField<string, pb::ByteString> mapStringBytes_ = new pbc::MapField<string, pb::ByteString>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::MapField<string, pb::ByteString> MapStringBytes {
+ get { return mapStringBytes_; }
+ }
+
+ /// <summary>Field number for the "map_string_nested_message" field.</summary>
+ public const int MapStringNestedMessageFieldNumber = 71;
+ private static readonly pbc::MapField<string, global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage>.Codec _map_mapStringNestedMessage_codec
+ = new pbc::MapField<string, global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForMessage(18, global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage.Parser), 570);
+ private readonly pbc::MapField<string, global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage> mapStringNestedMessage_ = new pbc::MapField<string, global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::MapField<string, global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage> MapStringNestedMessage {
+ get { return mapStringNestedMessage_; }
+ }
+
+ /// <summary>Field number for the "map_string_foreign_message" field.</summary>
+ public const int MapStringForeignMessageFieldNumber = 72;
+ private static readonly pbc::MapField<string, global::ProtobufTestMessages.Proto3.ForeignMessage>.Codec _map_mapStringForeignMessage_codec
+ = new pbc::MapField<string, global::ProtobufTestMessages.Proto3.ForeignMessage>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForMessage(18, global::ProtobufTestMessages.Proto3.ForeignMessage.Parser), 578);
+ private readonly pbc::MapField<string, global::ProtobufTestMessages.Proto3.ForeignMessage> mapStringForeignMessage_ = new pbc::MapField<string, global::ProtobufTestMessages.Proto3.ForeignMessage>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::MapField<string, global::ProtobufTestMessages.Proto3.ForeignMessage> MapStringForeignMessage {
+ get { return mapStringForeignMessage_; }
+ }
+
+ /// <summary>Field number for the "map_string_nested_enum" field.</summary>
+ public const int MapStringNestedEnumFieldNumber = 73;
+ private static readonly pbc::MapField<string, global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum>.Codec _map_mapStringNestedEnum_codec
+ = new pbc::MapField<string, global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForEnum(16, x => (int) x, x => (global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum) x), 586);
+ private readonly pbc::MapField<string, global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum> mapStringNestedEnum_ = new pbc::MapField<string, global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::MapField<string, global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum> MapStringNestedEnum {
+ get { return mapStringNestedEnum_; }
+ }
+
+ /// <summary>Field number for the "map_string_foreign_enum" field.</summary>
+ public const int MapStringForeignEnumFieldNumber = 74;
+ private static readonly pbc::MapField<string, global::ProtobufTestMessages.Proto3.ForeignEnum>.Codec _map_mapStringForeignEnum_codec
+ = new pbc::MapField<string, global::ProtobufTestMessages.Proto3.ForeignEnum>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForEnum(16, x => (int) x, x => (global::ProtobufTestMessages.Proto3.ForeignEnum) x), 594);
+ private readonly pbc::MapField<string, global::ProtobufTestMessages.Proto3.ForeignEnum> mapStringForeignEnum_ = new pbc::MapField<string, global::ProtobufTestMessages.Proto3.ForeignEnum>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::MapField<string, global::ProtobufTestMessages.Proto3.ForeignEnum> MapStringForeignEnum {
+ get { return mapStringForeignEnum_; }
+ }
+
+ /// <summary>Field number for the "oneof_uint32" field.</summary>
+ public const int OneofUint32FieldNumber = 111;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public uint OneofUint32 {
+ get { return oneofFieldCase_ == OneofFieldOneofCase.OneofUint32 ? (uint) oneofField_ : 0; }
+ set {
+ oneofField_ = value;
+ oneofFieldCase_ = OneofFieldOneofCase.OneofUint32;
+ }
+ }
+
+ /// <summary>Field number for the "oneof_nested_message" field.</summary>
+ public const int OneofNestedMessageFieldNumber = 112;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage OneofNestedMessage {
+ get { return oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage ? (global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage) oneofField_ : null; }
+ set {
+ oneofField_ = value;
+ oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.OneofNestedMessage;
+ }
+ }
+
+ /// <summary>Field number for the "oneof_string" field.</summary>
+ public const int OneofStringFieldNumber = 113;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public string OneofString {
+ get { return oneofFieldCase_ == OneofFieldOneofCase.OneofString ? (string) oneofField_ : ""; }
+ set {
+ oneofField_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
+ oneofFieldCase_ = OneofFieldOneofCase.OneofString;
+ }
+ }
+
+ /// <summary>Field number for the "oneof_bytes" field.</summary>
+ public const int OneofBytesFieldNumber = 114;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pb::ByteString OneofBytes {
+ get { return oneofFieldCase_ == OneofFieldOneofCase.OneofBytes ? (pb::ByteString) oneofField_ : pb::ByteString.Empty; }
+ set {
+ oneofField_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
+ oneofFieldCase_ = OneofFieldOneofCase.OneofBytes;
+ }
+ }
+
+ /// <summary>Field number for the "oneof_bool" field.</summary>
+ public const int OneofBoolFieldNumber = 115;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool OneofBool {
+ get { return oneofFieldCase_ == OneofFieldOneofCase.OneofBool ? (bool) oneofField_ : false; }
+ set {
+ oneofField_ = value;
+ oneofFieldCase_ = OneofFieldOneofCase.OneofBool;
+ }
+ }
+
+ /// <summary>Field number for the "oneof_uint64" field.</summary>
+ public const int OneofUint64FieldNumber = 116;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public ulong OneofUint64 {
+ get { return oneofFieldCase_ == OneofFieldOneofCase.OneofUint64 ? (ulong) oneofField_ : 0UL; }
+ set {
+ oneofField_ = value;
+ oneofFieldCase_ = OneofFieldOneofCase.OneofUint64;
+ }
+ }
+
+ /// <summary>Field number for the "oneof_float" field.</summary>
+ public const int OneofFloatFieldNumber = 117;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public float OneofFloat {
+ get { return oneofFieldCase_ == OneofFieldOneofCase.OneofFloat ? (float) oneofField_ : 0F; }
+ set {
+ oneofField_ = value;
+ oneofFieldCase_ = OneofFieldOneofCase.OneofFloat;
+ }
+ }
+
+ /// <summary>Field number for the "oneof_double" field.</summary>
+ public const int OneofDoubleFieldNumber = 118;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public double OneofDouble {
+ get { return oneofFieldCase_ == OneofFieldOneofCase.OneofDouble ? (double) oneofField_ : 0D; }
+ set {
+ oneofField_ = value;
+ oneofFieldCase_ = OneofFieldOneofCase.OneofDouble;
+ }
+ }
+
+ /// <summary>Field number for the "oneof_enum" field.</summary>
+ public const int OneofEnumFieldNumber = 119;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum OneofEnum {
+ get { return oneofFieldCase_ == OneofFieldOneofCase.OneofEnum ? (global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum) oneofField_ : 0; }
+ set {
+ oneofField_ = value;
+ oneofFieldCase_ = OneofFieldOneofCase.OneofEnum;
+ }
+ }
+
+ /// <summary>Field number for the "optional_bool_wrapper" field.</summary>
+ public const int OptionalBoolWrapperFieldNumber = 201;
+ private static readonly pb::FieldCodec<bool?> _single_optionalBoolWrapper_codec = pb::FieldCodec.ForStructWrapper<bool>(1610);
+ private bool? optionalBoolWrapper_;
+ /// <summary>
+ /// Well-known types
+ /// </summary>
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool? OptionalBoolWrapper {
+ get { return optionalBoolWrapper_; }
+ set {
+ optionalBoolWrapper_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_int32_wrapper" field.</summary>
+ public const int OptionalInt32WrapperFieldNumber = 202;
+ private static readonly pb::FieldCodec<int?> _single_optionalInt32Wrapper_codec = pb::FieldCodec.ForStructWrapper<int>(1618);
+ private int? optionalInt32Wrapper_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int? OptionalInt32Wrapper {
+ get { return optionalInt32Wrapper_; }
+ set {
+ optionalInt32Wrapper_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_int64_wrapper" field.</summary>
+ public const int OptionalInt64WrapperFieldNumber = 203;
+ private static readonly pb::FieldCodec<long?> _single_optionalInt64Wrapper_codec = pb::FieldCodec.ForStructWrapper<long>(1626);
+ private long? optionalInt64Wrapper_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public long? OptionalInt64Wrapper {
+ get { return optionalInt64Wrapper_; }
+ set {
+ optionalInt64Wrapper_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_uint32_wrapper" field.</summary>
+ public const int OptionalUint32WrapperFieldNumber = 204;
+ private static readonly pb::FieldCodec<uint?> _single_optionalUint32Wrapper_codec = pb::FieldCodec.ForStructWrapper<uint>(1634);
+ private uint? optionalUint32Wrapper_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public uint? OptionalUint32Wrapper {
+ get { return optionalUint32Wrapper_; }
+ set {
+ optionalUint32Wrapper_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_uint64_wrapper" field.</summary>
+ public const int OptionalUint64WrapperFieldNumber = 205;
+ private static readonly pb::FieldCodec<ulong?> _single_optionalUint64Wrapper_codec = pb::FieldCodec.ForStructWrapper<ulong>(1642);
+ private ulong? optionalUint64Wrapper_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public ulong? OptionalUint64Wrapper {
+ get { return optionalUint64Wrapper_; }
+ set {
+ optionalUint64Wrapper_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_float_wrapper" field.</summary>
+ public const int OptionalFloatWrapperFieldNumber = 206;
+ private static readonly pb::FieldCodec<float?> _single_optionalFloatWrapper_codec = pb::FieldCodec.ForStructWrapper<float>(1650);
+ private float? optionalFloatWrapper_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public float? OptionalFloatWrapper {
+ get { return optionalFloatWrapper_; }
+ set {
+ optionalFloatWrapper_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_double_wrapper" field.</summary>
+ public const int OptionalDoubleWrapperFieldNumber = 207;
+ private static readonly pb::FieldCodec<double?> _single_optionalDoubleWrapper_codec = pb::FieldCodec.ForStructWrapper<double>(1658);
+ private double? optionalDoubleWrapper_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public double? OptionalDoubleWrapper {
+ get { return optionalDoubleWrapper_; }
+ set {
+ optionalDoubleWrapper_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_string_wrapper" field.</summary>
+ public const int OptionalStringWrapperFieldNumber = 208;
+ private static readonly pb::FieldCodec<string> _single_optionalStringWrapper_codec = pb::FieldCodec.ForClassWrapper<string>(1666);
+ private string optionalStringWrapper_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public string OptionalStringWrapper {
+ get { return optionalStringWrapper_; }
+ set {
+ optionalStringWrapper_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_bytes_wrapper" field.</summary>
+ public const int OptionalBytesWrapperFieldNumber = 209;
+ private static readonly pb::FieldCodec<pb::ByteString> _single_optionalBytesWrapper_codec = pb::FieldCodec.ForClassWrapper<pb::ByteString>(1674);
+ private pb::ByteString optionalBytesWrapper_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pb::ByteString OptionalBytesWrapper {
+ get { return optionalBytesWrapper_; }
+ set {
+ optionalBytesWrapper_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "repeated_bool_wrapper" field.</summary>
+ public const int RepeatedBoolWrapperFieldNumber = 211;
+ private static readonly pb::FieldCodec<bool?> _repeated_repeatedBoolWrapper_codec
+ = pb::FieldCodec.ForStructWrapper<bool>(1690);
+ private readonly pbc::RepeatedField<bool?> repeatedBoolWrapper_ = new pbc::RepeatedField<bool?>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<bool?> RepeatedBoolWrapper {
+ get { return repeatedBoolWrapper_; }
+ }
+
+ /// <summary>Field number for the "repeated_int32_wrapper" field.</summary>
+ public const int RepeatedInt32WrapperFieldNumber = 212;
+ private static readonly pb::FieldCodec<int?> _repeated_repeatedInt32Wrapper_codec
+ = pb::FieldCodec.ForStructWrapper<int>(1698);
+ private readonly pbc::RepeatedField<int?> repeatedInt32Wrapper_ = new pbc::RepeatedField<int?>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<int?> RepeatedInt32Wrapper {
+ get { return repeatedInt32Wrapper_; }
+ }
+
+ /// <summary>Field number for the "repeated_int64_wrapper" field.</summary>
+ public const int RepeatedInt64WrapperFieldNumber = 213;
+ private static readonly pb::FieldCodec<long?> _repeated_repeatedInt64Wrapper_codec
+ = pb::FieldCodec.ForStructWrapper<long>(1706);
+ private readonly pbc::RepeatedField<long?> repeatedInt64Wrapper_ = new pbc::RepeatedField<long?>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<long?> RepeatedInt64Wrapper {
+ get { return repeatedInt64Wrapper_; }
+ }
+
+ /// <summary>Field number for the "repeated_uint32_wrapper" field.</summary>
+ public const int RepeatedUint32WrapperFieldNumber = 214;
+ private static readonly pb::FieldCodec<uint?> _repeated_repeatedUint32Wrapper_codec
+ = pb::FieldCodec.ForStructWrapper<uint>(1714);
+ private readonly pbc::RepeatedField<uint?> repeatedUint32Wrapper_ = new pbc::RepeatedField<uint?>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<uint?> RepeatedUint32Wrapper {
+ get { return repeatedUint32Wrapper_; }
+ }
+
+ /// <summary>Field number for the "repeated_uint64_wrapper" field.</summary>
+ public const int RepeatedUint64WrapperFieldNumber = 215;
+ private static readonly pb::FieldCodec<ulong?> _repeated_repeatedUint64Wrapper_codec
+ = pb::FieldCodec.ForStructWrapper<ulong>(1722);
+ private readonly pbc::RepeatedField<ulong?> repeatedUint64Wrapper_ = new pbc::RepeatedField<ulong?>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<ulong?> RepeatedUint64Wrapper {
+ get { return repeatedUint64Wrapper_; }
+ }
+
+ /// <summary>Field number for the "repeated_float_wrapper" field.</summary>
+ public const int RepeatedFloatWrapperFieldNumber = 216;
+ private static readonly pb::FieldCodec<float?> _repeated_repeatedFloatWrapper_codec
+ = pb::FieldCodec.ForStructWrapper<float>(1730);
+ private readonly pbc::RepeatedField<float?> repeatedFloatWrapper_ = new pbc::RepeatedField<float?>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<float?> RepeatedFloatWrapper {
+ get { return repeatedFloatWrapper_; }
+ }
+
+ /// <summary>Field number for the "repeated_double_wrapper" field.</summary>
+ public const int RepeatedDoubleWrapperFieldNumber = 217;
+ private static readonly pb::FieldCodec<double?> _repeated_repeatedDoubleWrapper_codec
+ = pb::FieldCodec.ForStructWrapper<double>(1738);
+ private readonly pbc::RepeatedField<double?> repeatedDoubleWrapper_ = new pbc::RepeatedField<double?>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<double?> RepeatedDoubleWrapper {
+ get { return repeatedDoubleWrapper_; }
+ }
+
+ /// <summary>Field number for the "repeated_string_wrapper" field.</summary>
+ public const int RepeatedStringWrapperFieldNumber = 218;
+ private static readonly pb::FieldCodec<string> _repeated_repeatedStringWrapper_codec
+ = pb::FieldCodec.ForClassWrapper<string>(1746);
+ private readonly pbc::RepeatedField<string> repeatedStringWrapper_ = new pbc::RepeatedField<string>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<string> RepeatedStringWrapper {
+ get { return repeatedStringWrapper_; }
+ }
+
+ /// <summary>Field number for the "repeated_bytes_wrapper" field.</summary>
+ public const int RepeatedBytesWrapperFieldNumber = 219;
+ private static readonly pb::FieldCodec<pb::ByteString> _repeated_repeatedBytesWrapper_codec
+ = pb::FieldCodec.ForClassWrapper<pb::ByteString>(1754);
+ private readonly pbc::RepeatedField<pb::ByteString> repeatedBytesWrapper_ = new pbc::RepeatedField<pb::ByteString>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<pb::ByteString> RepeatedBytesWrapper {
+ get { return repeatedBytesWrapper_; }
+ }
+
+ /// <summary>Field number for the "optional_duration" field.</summary>
+ public const int OptionalDurationFieldNumber = 301;
+ private global::Google.Protobuf.WellKnownTypes.Duration optionalDuration_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public global::Google.Protobuf.WellKnownTypes.Duration OptionalDuration {
+ get { return optionalDuration_; }
+ set {
+ optionalDuration_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_timestamp" field.</summary>
+ public const int OptionalTimestampFieldNumber = 302;
+ private global::Google.Protobuf.WellKnownTypes.Timestamp optionalTimestamp_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public global::Google.Protobuf.WellKnownTypes.Timestamp OptionalTimestamp {
+ get { return optionalTimestamp_; }
+ set {
+ optionalTimestamp_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_field_mask" field.</summary>
+ public const int OptionalFieldMaskFieldNumber = 303;
+ private global::Google.Protobuf.WellKnownTypes.FieldMask optionalFieldMask_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public global::Google.Protobuf.WellKnownTypes.FieldMask OptionalFieldMask {
+ get { return optionalFieldMask_; }
+ set {
+ optionalFieldMask_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_struct" field.</summary>
+ public const int OptionalStructFieldNumber = 304;
+ private global::Google.Protobuf.WellKnownTypes.Struct optionalStruct_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public global::Google.Protobuf.WellKnownTypes.Struct OptionalStruct {
+ get { return optionalStruct_; }
+ set {
+ optionalStruct_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_any" field.</summary>
+ public const int OptionalAnyFieldNumber = 305;
+ private global::Google.Protobuf.WellKnownTypes.Any optionalAny_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public global::Google.Protobuf.WellKnownTypes.Any OptionalAny {
+ get { return optionalAny_; }
+ set {
+ optionalAny_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "optional_value" field.</summary>
+ public const int OptionalValueFieldNumber = 306;
+ private global::Google.Protobuf.WellKnownTypes.Value optionalValue_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public global::Google.Protobuf.WellKnownTypes.Value OptionalValue {
+ get { return optionalValue_; }
+ set {
+ optionalValue_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "repeated_duration" field.</summary>
+ public const int RepeatedDurationFieldNumber = 311;
+ private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Duration> _repeated_repeatedDuration_codec
+ = pb::FieldCodec.ForMessage(2490, global::Google.Protobuf.WellKnownTypes.Duration.Parser);
+ private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Duration> repeatedDuration_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Duration>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Duration> RepeatedDuration {
+ get { return repeatedDuration_; }
+ }
+
+ /// <summary>Field number for the "repeated_timestamp" field.</summary>
+ public const int RepeatedTimestampFieldNumber = 312;
+ private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Timestamp> _repeated_repeatedTimestamp_codec
+ = pb::FieldCodec.ForMessage(2498, global::Google.Protobuf.WellKnownTypes.Timestamp.Parser);
+ private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Timestamp> repeatedTimestamp_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Timestamp>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Timestamp> RepeatedTimestamp {
+ get { return repeatedTimestamp_; }
+ }
+
+ /// <summary>Field number for the "repeated_fieldmask" field.</summary>
+ public const int RepeatedFieldmaskFieldNumber = 313;
+ private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.FieldMask> _repeated_repeatedFieldmask_codec
+ = pb::FieldCodec.ForMessage(2506, global::Google.Protobuf.WellKnownTypes.FieldMask.Parser);
+ private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.FieldMask> repeatedFieldmask_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.FieldMask>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.FieldMask> RepeatedFieldmask {
+ get { return repeatedFieldmask_; }
+ }
+
+ /// <summary>Field number for the "repeated_struct" field.</summary>
+ public const int RepeatedStructFieldNumber = 324;
+ private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Struct> _repeated_repeatedStruct_codec
+ = pb::FieldCodec.ForMessage(2594, global::Google.Protobuf.WellKnownTypes.Struct.Parser);
+ private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Struct> repeatedStruct_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Struct>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Struct> RepeatedStruct {
+ get { return repeatedStruct_; }
+ }
+
+ /// <summary>Field number for the "repeated_any" field.</summary>
+ public const int RepeatedAnyFieldNumber = 315;
+ private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Any> _repeated_repeatedAny_codec
+ = pb::FieldCodec.ForMessage(2522, global::Google.Protobuf.WellKnownTypes.Any.Parser);
+ private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Any> repeatedAny_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Any>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Any> RepeatedAny {
+ get { return repeatedAny_; }
+ }
+
+ /// <summary>Field number for the "repeated_value" field.</summary>
+ public const int RepeatedValueFieldNumber = 316;
+ private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Value> _repeated_repeatedValue_codec
+ = pb::FieldCodec.ForMessage(2530, global::Google.Protobuf.WellKnownTypes.Value.Parser);
+ private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Value> repeatedValue_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Value>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Value> RepeatedValue {
+ get { return repeatedValue_; }
+ }
+
+ /// <summary>Field number for the "fieldname1" field.</summary>
+ public const int Fieldname1FieldNumber = 401;
+ private int fieldname1_;
+ /// <summary>
+ /// Test field-name-to-JSON-name convention.
+ /// (protobuf says names can be any valid C/C++ identifier.)
+ /// </summary>
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int Fieldname1 {
+ get { return fieldname1_; }
+ set {
+ fieldname1_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "field_name2" field.</summary>
+ public const int FieldName2FieldNumber = 402;
+ private int fieldName2_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int FieldName2 {
+ get { return fieldName2_; }
+ set {
+ fieldName2_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "_field_name3" field.</summary>
+ public const int FieldName3FieldNumber = 403;
+ private int FieldName3_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int FieldName3 {
+ get { return FieldName3_; }
+ set {
+ FieldName3_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "field__name4_" field.</summary>
+ public const int FieldName4FieldNumber = 404;
+ private int fieldName4_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int FieldName4 {
+ get { return fieldName4_; }
+ set {
+ fieldName4_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "field0name5" field.</summary>
+ public const int Field0Name5FieldNumber = 405;
+ private int field0Name5_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int Field0Name5 {
+ get { return field0Name5_; }
+ set {
+ field0Name5_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "field_0_name6" field.</summary>
+ public const int Field0Name6FieldNumber = 406;
+ private int field0Name6_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int Field0Name6 {
+ get { return field0Name6_; }
+ set {
+ field0Name6_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "fieldName7" field.</summary>
+ public const int FieldName7FieldNumber = 407;
+ private int fieldName7_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int FieldName7 {
+ get { return fieldName7_; }
+ set {
+ fieldName7_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "FieldName8" field.</summary>
+ public const int FieldName8FieldNumber = 408;
+ private int fieldName8_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int FieldName8 {
+ get { return fieldName8_; }
+ set {
+ fieldName8_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "field_Name9" field.</summary>
+ public const int FieldName9FieldNumber = 409;
+ private int fieldName9_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int FieldName9 {
+ get { return fieldName9_; }
+ set {
+ fieldName9_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "Field_Name10" field.</summary>
+ public const int FieldName10FieldNumber = 410;
+ private int fieldName10_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int FieldName10 {
+ get { return fieldName10_; }
+ set {
+ fieldName10_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "FIELD_NAME11" field.</summary>
+ public const int FIELDNAME11FieldNumber = 411;
+ private int fIELDNAME11_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int FIELDNAME11 {
+ get { return fIELDNAME11_; }
+ set {
+ fIELDNAME11_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "FIELD_name12" field.</summary>
+ public const int FIELDName12FieldNumber = 412;
+ private int fIELDName12_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int FIELDName12 {
+ get { return fIELDName12_; }
+ set {
+ fIELDName12_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "__field_name13" field.</summary>
+ public const int FieldName13FieldNumber = 413;
+ private int FieldName13_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int FieldName13 {
+ get { return FieldName13_; }
+ set {
+ FieldName13_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "__Field_name14" field.</summary>
+ public const int FieldName14FieldNumber = 414;
+ private int FieldName14_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int FieldName14 {
+ get { return FieldName14_; }
+ set {
+ FieldName14_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "field__name15" field.</summary>
+ public const int FieldName15FieldNumber = 415;
+ private int fieldName15_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int FieldName15 {
+ get { return fieldName15_; }
+ set {
+ fieldName15_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "field__Name16" field.</summary>
+ public const int FieldName16FieldNumber = 416;
+ private int fieldName16_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int FieldName16 {
+ get { return fieldName16_; }
+ set {
+ fieldName16_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "field_name17__" field.</summary>
+ public const int FieldName17FieldNumber = 417;
+ private int fieldName17_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int FieldName17 {
+ get { return fieldName17_; }
+ set {
+ fieldName17_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "Field_name18__" field.</summary>
+ public const int FieldName18FieldNumber = 418;
+ private int fieldName18_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int FieldName18 {
+ get { return fieldName18_; }
+ set {
+ fieldName18_ = value;
+ }
+ }
+
+ private object oneofField_;
+ /// <summary>Enum of possible cases for the "oneof_field" oneof.</summary>
+ public enum OneofFieldOneofCase {
+ None = 0,
+ OneofUint32 = 111,
+ OneofNestedMessage = 112,
+ OneofString = 113,
+ OneofBytes = 114,
+ OneofBool = 115,
+ OneofUint64 = 116,
+ OneofFloat = 117,
+ OneofDouble = 118,
+ OneofEnum = 119,
+ }
+ private OneofFieldOneofCase oneofFieldCase_ = OneofFieldOneofCase.None;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public OneofFieldOneofCase OneofFieldCase {
+ get { return oneofFieldCase_; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void ClearOneofField() {
+ oneofFieldCase_ = OneofFieldOneofCase.None;
+ oneofField_ = null;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as TestAllTypes);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(TestAllTypes other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ if (OptionalInt32 != other.OptionalInt32) return false;
+ if (OptionalInt64 != other.OptionalInt64) return false;
+ if (OptionalUint32 != other.OptionalUint32) return false;
+ if (OptionalUint64 != other.OptionalUint64) return false;
+ if (OptionalSint32 != other.OptionalSint32) return false;
+ if (OptionalSint64 != other.OptionalSint64) return false;
+ if (OptionalFixed32 != other.OptionalFixed32) return false;
+ if (OptionalFixed64 != other.OptionalFixed64) return false;
+ if (OptionalSfixed32 != other.OptionalSfixed32) return false;
+ if (OptionalSfixed64 != other.OptionalSfixed64) return false;
+ if (OptionalFloat != other.OptionalFloat) return false;
+ if (OptionalDouble != other.OptionalDouble) return false;
+ if (OptionalBool != other.OptionalBool) return false;
+ if (OptionalString != other.OptionalString) return false;
+ if (OptionalBytes != other.OptionalBytes) return false;
+ if (!object.Equals(OptionalNestedMessage, other.OptionalNestedMessage)) return false;
+ if (!object.Equals(OptionalForeignMessage, other.OptionalForeignMessage)) return false;
+ if (OptionalNestedEnum != other.OptionalNestedEnum) return false;
+ if (OptionalForeignEnum != other.OptionalForeignEnum) return false;
+ if (OptionalStringPiece != other.OptionalStringPiece) return false;
+ if (OptionalCord != other.OptionalCord) return false;
+ if (!object.Equals(RecursiveMessage, other.RecursiveMessage)) return false;
+ if(!repeatedInt32_.Equals(other.repeatedInt32_)) return false;
+ if(!repeatedInt64_.Equals(other.repeatedInt64_)) return false;
+ if(!repeatedUint32_.Equals(other.repeatedUint32_)) return false;
+ if(!repeatedUint64_.Equals(other.repeatedUint64_)) return false;
+ if(!repeatedSint32_.Equals(other.repeatedSint32_)) return false;
+ if(!repeatedSint64_.Equals(other.repeatedSint64_)) return false;
+ if(!repeatedFixed32_.Equals(other.repeatedFixed32_)) return false;
+ if(!repeatedFixed64_.Equals(other.repeatedFixed64_)) return false;
+ if(!repeatedSfixed32_.Equals(other.repeatedSfixed32_)) return false;
+ if(!repeatedSfixed64_.Equals(other.repeatedSfixed64_)) return false;
+ if(!repeatedFloat_.Equals(other.repeatedFloat_)) return false;
+ if(!repeatedDouble_.Equals(other.repeatedDouble_)) return false;
+ if(!repeatedBool_.Equals(other.repeatedBool_)) return false;
+ if(!repeatedString_.Equals(other.repeatedString_)) return false;
+ if(!repeatedBytes_.Equals(other.repeatedBytes_)) return false;
+ if(!repeatedNestedMessage_.Equals(other.repeatedNestedMessage_)) return false;
+ if(!repeatedForeignMessage_.Equals(other.repeatedForeignMessage_)) return false;
+ if(!repeatedNestedEnum_.Equals(other.repeatedNestedEnum_)) return false;
+ if(!repeatedForeignEnum_.Equals(other.repeatedForeignEnum_)) return false;
+ if(!repeatedStringPiece_.Equals(other.repeatedStringPiece_)) return false;
+ if(!repeatedCord_.Equals(other.repeatedCord_)) return false;
+ if (!MapInt32Int32.Equals(other.MapInt32Int32)) return false;
+ if (!MapInt64Int64.Equals(other.MapInt64Int64)) return false;
+ if (!MapUint32Uint32.Equals(other.MapUint32Uint32)) return false;
+ if (!MapUint64Uint64.Equals(other.MapUint64Uint64)) return false;
+ if (!MapSint32Sint32.Equals(other.MapSint32Sint32)) return false;
+ if (!MapSint64Sint64.Equals(other.MapSint64Sint64)) return false;
+ if (!MapFixed32Fixed32.Equals(other.MapFixed32Fixed32)) return false;
+ if (!MapFixed64Fixed64.Equals(other.MapFixed64Fixed64)) return false;
+ if (!MapSfixed32Sfixed32.Equals(other.MapSfixed32Sfixed32)) return false;
+ if (!MapSfixed64Sfixed64.Equals(other.MapSfixed64Sfixed64)) return false;
+ if (!MapInt32Float.Equals(other.MapInt32Float)) return false;
+ if (!MapInt32Double.Equals(other.MapInt32Double)) return false;
+ if (!MapBoolBool.Equals(other.MapBoolBool)) return false;
+ if (!MapStringString.Equals(other.MapStringString)) return false;
+ if (!MapStringBytes.Equals(other.MapStringBytes)) return false;
+ if (!MapStringNestedMessage.Equals(other.MapStringNestedMessage)) return false;
+ if (!MapStringForeignMessage.Equals(other.MapStringForeignMessage)) return false;
+ if (!MapStringNestedEnum.Equals(other.MapStringNestedEnum)) return false;
+ if (!MapStringForeignEnum.Equals(other.MapStringForeignEnum)) return false;
+ if (OneofUint32 != other.OneofUint32) return false;
+ if (!object.Equals(OneofNestedMessage, other.OneofNestedMessage)) return false;
+ if (OneofString != other.OneofString) return false;
+ if (OneofBytes != other.OneofBytes) return false;
+ if (OneofBool != other.OneofBool) return false;
+ if (OneofUint64 != other.OneofUint64) return false;
+ if (OneofFloat != other.OneofFloat) return false;
+ if (OneofDouble != other.OneofDouble) return false;
+ if (OneofEnum != other.OneofEnum) return false;
+ if (OptionalBoolWrapper != other.OptionalBoolWrapper) return false;
+ if (OptionalInt32Wrapper != other.OptionalInt32Wrapper) return false;
+ if (OptionalInt64Wrapper != other.OptionalInt64Wrapper) return false;
+ if (OptionalUint32Wrapper != other.OptionalUint32Wrapper) return false;
+ if (OptionalUint64Wrapper != other.OptionalUint64Wrapper) return false;
+ if (OptionalFloatWrapper != other.OptionalFloatWrapper) return false;
+ if (OptionalDoubleWrapper != other.OptionalDoubleWrapper) return false;
+ if (OptionalStringWrapper != other.OptionalStringWrapper) return false;
+ if (OptionalBytesWrapper != other.OptionalBytesWrapper) return false;
+ if(!repeatedBoolWrapper_.Equals(other.repeatedBoolWrapper_)) return false;
+ if(!repeatedInt32Wrapper_.Equals(other.repeatedInt32Wrapper_)) return false;
+ if(!repeatedInt64Wrapper_.Equals(other.repeatedInt64Wrapper_)) return false;
+ if(!repeatedUint32Wrapper_.Equals(other.repeatedUint32Wrapper_)) return false;
+ if(!repeatedUint64Wrapper_.Equals(other.repeatedUint64Wrapper_)) return false;
+ if(!repeatedFloatWrapper_.Equals(other.repeatedFloatWrapper_)) return false;
+ if(!repeatedDoubleWrapper_.Equals(other.repeatedDoubleWrapper_)) return false;
+ if(!repeatedStringWrapper_.Equals(other.repeatedStringWrapper_)) return false;
+ if(!repeatedBytesWrapper_.Equals(other.repeatedBytesWrapper_)) return false;
+ if (!object.Equals(OptionalDuration, other.OptionalDuration)) return false;
+ if (!object.Equals(OptionalTimestamp, other.OptionalTimestamp)) return false;
+ if (!object.Equals(OptionalFieldMask, other.OptionalFieldMask)) return false;
+ if (!object.Equals(OptionalStruct, other.OptionalStruct)) return false;
+ if (!object.Equals(OptionalAny, other.OptionalAny)) return false;
+ if (!object.Equals(OptionalValue, other.OptionalValue)) return false;
+ if(!repeatedDuration_.Equals(other.repeatedDuration_)) return false;
+ if(!repeatedTimestamp_.Equals(other.repeatedTimestamp_)) return false;
+ if(!repeatedFieldmask_.Equals(other.repeatedFieldmask_)) return false;
+ if(!repeatedStruct_.Equals(other.repeatedStruct_)) return false;
+ if(!repeatedAny_.Equals(other.repeatedAny_)) return false;
+ if(!repeatedValue_.Equals(other.repeatedValue_)) return false;
+ if (Fieldname1 != other.Fieldname1) return false;
+ if (FieldName2 != other.FieldName2) return false;
+ if (FieldName3 != other.FieldName3) return false;
+ if (FieldName4 != other.FieldName4) return false;
+ if (Field0Name5 != other.Field0Name5) return false;
+ if (Field0Name6 != other.Field0Name6) return false;
+ if (FieldName7 != other.FieldName7) return false;
+ if (FieldName8 != other.FieldName8) return false;
+ if (FieldName9 != other.FieldName9) return false;
+ if (FieldName10 != other.FieldName10) return false;
+ if (FIELDNAME11 != other.FIELDNAME11) return false;
+ if (FIELDName12 != other.FIELDName12) return false;
+ if (FieldName13 != other.FieldName13) return false;
+ if (FieldName14 != other.FieldName14) return false;
+ if (FieldName15 != other.FieldName15) return false;
+ if (FieldName16 != other.FieldName16) return false;
+ if (FieldName17 != other.FieldName17) return false;
+ if (FieldName18 != other.FieldName18) return false;
+ if (OneofFieldCase != other.OneofFieldCase) return false;
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ if (OptionalInt32 != 0) hash ^= OptionalInt32.GetHashCode();
+ if (OptionalInt64 != 0L) hash ^= OptionalInt64.GetHashCode();
+ if (OptionalUint32 != 0) hash ^= OptionalUint32.GetHashCode();
+ if (OptionalUint64 != 0UL) hash ^= OptionalUint64.GetHashCode();
+ if (OptionalSint32 != 0) hash ^= OptionalSint32.GetHashCode();
+ if (OptionalSint64 != 0L) hash ^= OptionalSint64.GetHashCode();
+ if (OptionalFixed32 != 0) hash ^= OptionalFixed32.GetHashCode();
+ if (OptionalFixed64 != 0UL) hash ^= OptionalFixed64.GetHashCode();
+ if (OptionalSfixed32 != 0) hash ^= OptionalSfixed32.GetHashCode();
+ if (OptionalSfixed64 != 0L) hash ^= OptionalSfixed64.GetHashCode();
+ if (OptionalFloat != 0F) hash ^= OptionalFloat.GetHashCode();
+ if (OptionalDouble != 0D) hash ^= OptionalDouble.GetHashCode();
+ if (OptionalBool != false) hash ^= OptionalBool.GetHashCode();
+ if (OptionalString.Length != 0) hash ^= OptionalString.GetHashCode();
+ if (OptionalBytes.Length != 0) hash ^= OptionalBytes.GetHashCode();
+ if (optionalNestedMessage_ != null) hash ^= OptionalNestedMessage.GetHashCode();
+ if (optionalForeignMessage_ != null) hash ^= OptionalForeignMessage.GetHashCode();
+ if (OptionalNestedEnum != 0) hash ^= OptionalNestedEnum.GetHashCode();
+ if (OptionalForeignEnum != 0) hash ^= OptionalForeignEnum.GetHashCode();
+ if (OptionalStringPiece.Length != 0) hash ^= OptionalStringPiece.GetHashCode();
+ if (OptionalCord.Length != 0) hash ^= OptionalCord.GetHashCode();
+ if (recursiveMessage_ != null) hash ^= RecursiveMessage.GetHashCode();
+ hash ^= repeatedInt32_.GetHashCode();
+ hash ^= repeatedInt64_.GetHashCode();
+ hash ^= repeatedUint32_.GetHashCode();
+ hash ^= repeatedUint64_.GetHashCode();
+ hash ^= repeatedSint32_.GetHashCode();
+ hash ^= repeatedSint64_.GetHashCode();
+ hash ^= repeatedFixed32_.GetHashCode();
+ hash ^= repeatedFixed64_.GetHashCode();
+ hash ^= repeatedSfixed32_.GetHashCode();
+ hash ^= repeatedSfixed64_.GetHashCode();
+ hash ^= repeatedFloat_.GetHashCode();
+ hash ^= repeatedDouble_.GetHashCode();
+ hash ^= repeatedBool_.GetHashCode();
+ hash ^= repeatedString_.GetHashCode();
+ hash ^= repeatedBytes_.GetHashCode();
+ hash ^= repeatedNestedMessage_.GetHashCode();
+ hash ^= repeatedForeignMessage_.GetHashCode();
+ hash ^= repeatedNestedEnum_.GetHashCode();
+ hash ^= repeatedForeignEnum_.GetHashCode();
+ hash ^= repeatedStringPiece_.GetHashCode();
+ hash ^= repeatedCord_.GetHashCode();
+ hash ^= MapInt32Int32.GetHashCode();
+ hash ^= MapInt64Int64.GetHashCode();
+ hash ^= MapUint32Uint32.GetHashCode();
+ hash ^= MapUint64Uint64.GetHashCode();
+ hash ^= MapSint32Sint32.GetHashCode();
+ hash ^= MapSint64Sint64.GetHashCode();
+ hash ^= MapFixed32Fixed32.GetHashCode();
+ hash ^= MapFixed64Fixed64.GetHashCode();
+ hash ^= MapSfixed32Sfixed32.GetHashCode();
+ hash ^= MapSfixed64Sfixed64.GetHashCode();
+ hash ^= MapInt32Float.GetHashCode();
+ hash ^= MapInt32Double.GetHashCode();
+ hash ^= MapBoolBool.GetHashCode();
+ hash ^= MapStringString.GetHashCode();
+ hash ^= MapStringBytes.GetHashCode();
+ hash ^= MapStringNestedMessage.GetHashCode();
+ hash ^= MapStringForeignMessage.GetHashCode();
+ hash ^= MapStringNestedEnum.GetHashCode();
+ hash ^= MapStringForeignEnum.GetHashCode();
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) hash ^= OneofUint32.GetHashCode();
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) hash ^= OneofNestedMessage.GetHashCode();
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) hash ^= OneofString.GetHashCode();
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) hash ^= OneofBytes.GetHashCode();
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofBool) hash ^= OneofBool.GetHashCode();
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint64) hash ^= OneofUint64.GetHashCode();
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofFloat) hash ^= OneofFloat.GetHashCode();
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofDouble) hash ^= OneofDouble.GetHashCode();
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofEnum) hash ^= OneofEnum.GetHashCode();
+ if (optionalBoolWrapper_ != null) hash ^= OptionalBoolWrapper.GetHashCode();
+ if (optionalInt32Wrapper_ != null) hash ^= OptionalInt32Wrapper.GetHashCode();
+ if (optionalInt64Wrapper_ != null) hash ^= OptionalInt64Wrapper.GetHashCode();
+ if (optionalUint32Wrapper_ != null) hash ^= OptionalUint32Wrapper.GetHashCode();
+ if (optionalUint64Wrapper_ != null) hash ^= OptionalUint64Wrapper.GetHashCode();
+ if (optionalFloatWrapper_ != null) hash ^= OptionalFloatWrapper.GetHashCode();
+ if (optionalDoubleWrapper_ != null) hash ^= OptionalDoubleWrapper.GetHashCode();
+ if (optionalStringWrapper_ != null) hash ^= OptionalStringWrapper.GetHashCode();
+ if (optionalBytesWrapper_ != null) hash ^= OptionalBytesWrapper.GetHashCode();
+ hash ^= repeatedBoolWrapper_.GetHashCode();
+ hash ^= repeatedInt32Wrapper_.GetHashCode();
+ hash ^= repeatedInt64Wrapper_.GetHashCode();
+ hash ^= repeatedUint32Wrapper_.GetHashCode();
+ hash ^= repeatedUint64Wrapper_.GetHashCode();
+ hash ^= repeatedFloatWrapper_.GetHashCode();
+ hash ^= repeatedDoubleWrapper_.GetHashCode();
+ hash ^= repeatedStringWrapper_.GetHashCode();
+ hash ^= repeatedBytesWrapper_.GetHashCode();
+ if (optionalDuration_ != null) hash ^= OptionalDuration.GetHashCode();
+ if (optionalTimestamp_ != null) hash ^= OptionalTimestamp.GetHashCode();
+ if (optionalFieldMask_ != null) hash ^= OptionalFieldMask.GetHashCode();
+ if (optionalStruct_ != null) hash ^= OptionalStruct.GetHashCode();
+ if (optionalAny_ != null) hash ^= OptionalAny.GetHashCode();
+ if (optionalValue_ != null) hash ^= OptionalValue.GetHashCode();
+ hash ^= repeatedDuration_.GetHashCode();
+ hash ^= repeatedTimestamp_.GetHashCode();
+ hash ^= repeatedFieldmask_.GetHashCode();
+ hash ^= repeatedStruct_.GetHashCode();
+ hash ^= repeatedAny_.GetHashCode();
+ hash ^= repeatedValue_.GetHashCode();
+ if (Fieldname1 != 0) hash ^= Fieldname1.GetHashCode();
+ if (FieldName2 != 0) hash ^= FieldName2.GetHashCode();
+ if (FieldName3 != 0) hash ^= FieldName3.GetHashCode();
+ if (FieldName4 != 0) hash ^= FieldName4.GetHashCode();
+ if (Field0Name5 != 0) hash ^= Field0Name5.GetHashCode();
+ if (Field0Name6 != 0) hash ^= Field0Name6.GetHashCode();
+ if (FieldName7 != 0) hash ^= FieldName7.GetHashCode();
+ if (FieldName8 != 0) hash ^= FieldName8.GetHashCode();
+ if (FieldName9 != 0) hash ^= FieldName9.GetHashCode();
+ if (FieldName10 != 0) hash ^= FieldName10.GetHashCode();
+ if (FIELDNAME11 != 0) hash ^= FIELDNAME11.GetHashCode();
+ if (FIELDName12 != 0) hash ^= FIELDName12.GetHashCode();
+ if (FieldName13 != 0) hash ^= FieldName13.GetHashCode();
+ if (FieldName14 != 0) hash ^= FieldName14.GetHashCode();
+ if (FieldName15 != 0) hash ^= FieldName15.GetHashCode();
+ if (FieldName16 != 0) hash ^= FieldName16.GetHashCode();
+ if (FieldName17 != 0) hash ^= FieldName17.GetHashCode();
+ if (FieldName18 != 0) hash ^= FieldName18.GetHashCode();
+ hash ^= (int) oneofFieldCase_;
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (OptionalInt32 != 0) {
+ output.WriteRawTag(8);
+ output.WriteInt32(OptionalInt32);
+ }
+ if (OptionalInt64 != 0L) {
+ output.WriteRawTag(16);
+ output.WriteInt64(OptionalInt64);
+ }
+ if (OptionalUint32 != 0) {
+ output.WriteRawTag(24);
+ output.WriteUInt32(OptionalUint32);
+ }
+ if (OptionalUint64 != 0UL) {
+ output.WriteRawTag(32);
+ output.WriteUInt64(OptionalUint64);
+ }
+ if (OptionalSint32 != 0) {
+ output.WriteRawTag(40);
+ output.WriteSInt32(OptionalSint32);
+ }
+ if (OptionalSint64 != 0L) {
+ output.WriteRawTag(48);
+ output.WriteSInt64(OptionalSint64);
+ }
+ if (OptionalFixed32 != 0) {
+ output.WriteRawTag(61);
+ output.WriteFixed32(OptionalFixed32);
+ }
+ if (OptionalFixed64 != 0UL) {
+ output.WriteRawTag(65);
+ output.WriteFixed64(OptionalFixed64);
+ }
+ if (OptionalSfixed32 != 0) {
+ output.WriteRawTag(77);
+ output.WriteSFixed32(OptionalSfixed32);
+ }
+ if (OptionalSfixed64 != 0L) {
+ output.WriteRawTag(81);
+ output.WriteSFixed64(OptionalSfixed64);
+ }
+ if (OptionalFloat != 0F) {
+ output.WriteRawTag(93);
+ output.WriteFloat(OptionalFloat);
+ }
+ if (OptionalDouble != 0D) {
+ output.WriteRawTag(97);
+ output.WriteDouble(OptionalDouble);
+ }
+ if (OptionalBool != false) {
+ output.WriteRawTag(104);
+ output.WriteBool(OptionalBool);
+ }
+ if (OptionalString.Length != 0) {
+ output.WriteRawTag(114);
+ output.WriteString(OptionalString);
+ }
+ if (OptionalBytes.Length != 0) {
+ output.WriteRawTag(122);
+ output.WriteBytes(OptionalBytes);
+ }
+ if (optionalNestedMessage_ != null) {
+ output.WriteRawTag(146, 1);
+ output.WriteMessage(OptionalNestedMessage);
+ }
+ if (optionalForeignMessage_ != null) {
+ output.WriteRawTag(154, 1);
+ output.WriteMessage(OptionalForeignMessage);
+ }
+ if (OptionalNestedEnum != 0) {
+ output.WriteRawTag(168, 1);
+ output.WriteEnum((int) OptionalNestedEnum);
+ }
+ if (OptionalForeignEnum != 0) {
+ output.WriteRawTag(176, 1);
+ output.WriteEnum((int) OptionalForeignEnum);
+ }
+ if (OptionalStringPiece.Length != 0) {
+ output.WriteRawTag(194, 1);
+ output.WriteString(OptionalStringPiece);
+ }
+ if (OptionalCord.Length != 0) {
+ output.WriteRawTag(202, 1);
+ output.WriteString(OptionalCord);
+ }
+ if (recursiveMessage_ != null) {
+ output.WriteRawTag(218, 1);
+ output.WriteMessage(RecursiveMessage);
+ }
+ repeatedInt32_.WriteTo(output, _repeated_repeatedInt32_codec);
+ repeatedInt64_.WriteTo(output, _repeated_repeatedInt64_codec);
+ repeatedUint32_.WriteTo(output, _repeated_repeatedUint32_codec);
+ repeatedUint64_.WriteTo(output, _repeated_repeatedUint64_codec);
+ repeatedSint32_.WriteTo(output, _repeated_repeatedSint32_codec);
+ repeatedSint64_.WriteTo(output, _repeated_repeatedSint64_codec);
+ repeatedFixed32_.WriteTo(output, _repeated_repeatedFixed32_codec);
+ repeatedFixed64_.WriteTo(output, _repeated_repeatedFixed64_codec);
+ repeatedSfixed32_.WriteTo(output, _repeated_repeatedSfixed32_codec);
+ repeatedSfixed64_.WriteTo(output, _repeated_repeatedSfixed64_codec);
+ repeatedFloat_.WriteTo(output, _repeated_repeatedFloat_codec);
+ repeatedDouble_.WriteTo(output, _repeated_repeatedDouble_codec);
+ repeatedBool_.WriteTo(output, _repeated_repeatedBool_codec);
+ repeatedString_.WriteTo(output, _repeated_repeatedString_codec);
+ repeatedBytes_.WriteTo(output, _repeated_repeatedBytes_codec);
+ repeatedNestedMessage_.WriteTo(output, _repeated_repeatedNestedMessage_codec);
+ repeatedForeignMessage_.WriteTo(output, _repeated_repeatedForeignMessage_codec);
+ repeatedNestedEnum_.WriteTo(output, _repeated_repeatedNestedEnum_codec);
+ repeatedForeignEnum_.WriteTo(output, _repeated_repeatedForeignEnum_codec);
+ repeatedStringPiece_.WriteTo(output, _repeated_repeatedStringPiece_codec);
+ repeatedCord_.WriteTo(output, _repeated_repeatedCord_codec);
+ mapInt32Int32_.WriteTo(output, _map_mapInt32Int32_codec);
+ mapInt64Int64_.WriteTo(output, _map_mapInt64Int64_codec);
+ mapUint32Uint32_.WriteTo(output, _map_mapUint32Uint32_codec);
+ mapUint64Uint64_.WriteTo(output, _map_mapUint64Uint64_codec);
+ mapSint32Sint32_.WriteTo(output, _map_mapSint32Sint32_codec);
+ mapSint64Sint64_.WriteTo(output, _map_mapSint64Sint64_codec);
+ mapFixed32Fixed32_.WriteTo(output, _map_mapFixed32Fixed32_codec);
+ mapFixed64Fixed64_.WriteTo(output, _map_mapFixed64Fixed64_codec);
+ mapSfixed32Sfixed32_.WriteTo(output, _map_mapSfixed32Sfixed32_codec);
+ mapSfixed64Sfixed64_.WriteTo(output, _map_mapSfixed64Sfixed64_codec);
+ mapInt32Float_.WriteTo(output, _map_mapInt32Float_codec);
+ mapInt32Double_.WriteTo(output, _map_mapInt32Double_codec);
+ mapBoolBool_.WriteTo(output, _map_mapBoolBool_codec);
+ mapStringString_.WriteTo(output, _map_mapStringString_codec);
+ mapStringBytes_.WriteTo(output, _map_mapStringBytes_codec);
+ mapStringNestedMessage_.WriteTo(output, _map_mapStringNestedMessage_codec);
+ mapStringForeignMessage_.WriteTo(output, _map_mapStringForeignMessage_codec);
+ mapStringNestedEnum_.WriteTo(output, _map_mapStringNestedEnum_codec);
+ mapStringForeignEnum_.WriteTo(output, _map_mapStringForeignEnum_codec);
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) {
+ output.WriteRawTag(248, 6);
+ output.WriteUInt32(OneofUint32);
+ }
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) {
+ output.WriteRawTag(130, 7);
+ output.WriteMessage(OneofNestedMessage);
+ }
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) {
+ output.WriteRawTag(138, 7);
+ output.WriteString(OneofString);
+ }
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) {
+ output.WriteRawTag(146, 7);
+ output.WriteBytes(OneofBytes);
+ }
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofBool) {
+ output.WriteRawTag(152, 7);
+ output.WriteBool(OneofBool);
+ }
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint64) {
+ output.WriteRawTag(160, 7);
+ output.WriteUInt64(OneofUint64);
+ }
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofFloat) {
+ output.WriteRawTag(173, 7);
+ output.WriteFloat(OneofFloat);
+ }
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofDouble) {
+ output.WriteRawTag(177, 7);
+ output.WriteDouble(OneofDouble);
+ }
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofEnum) {
+ output.WriteRawTag(184, 7);
+ output.WriteEnum((int) OneofEnum);
+ }
+ if (optionalBoolWrapper_ != null) {
+ _single_optionalBoolWrapper_codec.WriteTagAndValue(output, OptionalBoolWrapper);
+ }
+ if (optionalInt32Wrapper_ != null) {
+ _single_optionalInt32Wrapper_codec.WriteTagAndValue(output, OptionalInt32Wrapper);
+ }
+ if (optionalInt64Wrapper_ != null) {
+ _single_optionalInt64Wrapper_codec.WriteTagAndValue(output, OptionalInt64Wrapper);
+ }
+ if (optionalUint32Wrapper_ != null) {
+ _single_optionalUint32Wrapper_codec.WriteTagAndValue(output, OptionalUint32Wrapper);
+ }
+ if (optionalUint64Wrapper_ != null) {
+ _single_optionalUint64Wrapper_codec.WriteTagAndValue(output, OptionalUint64Wrapper);
+ }
+ if (optionalFloatWrapper_ != null) {
+ _single_optionalFloatWrapper_codec.WriteTagAndValue(output, OptionalFloatWrapper);
+ }
+ if (optionalDoubleWrapper_ != null) {
+ _single_optionalDoubleWrapper_codec.WriteTagAndValue(output, OptionalDoubleWrapper);
+ }
+ if (optionalStringWrapper_ != null) {
+ _single_optionalStringWrapper_codec.WriteTagAndValue(output, OptionalStringWrapper);
+ }
+ if (optionalBytesWrapper_ != null) {
+ _single_optionalBytesWrapper_codec.WriteTagAndValue(output, OptionalBytesWrapper);
+ }
+ repeatedBoolWrapper_.WriteTo(output, _repeated_repeatedBoolWrapper_codec);
+ repeatedInt32Wrapper_.WriteTo(output, _repeated_repeatedInt32Wrapper_codec);
+ repeatedInt64Wrapper_.WriteTo(output, _repeated_repeatedInt64Wrapper_codec);
+ repeatedUint32Wrapper_.WriteTo(output, _repeated_repeatedUint32Wrapper_codec);
+ repeatedUint64Wrapper_.WriteTo(output, _repeated_repeatedUint64Wrapper_codec);
+ repeatedFloatWrapper_.WriteTo(output, _repeated_repeatedFloatWrapper_codec);
+ repeatedDoubleWrapper_.WriteTo(output, _repeated_repeatedDoubleWrapper_codec);
+ repeatedStringWrapper_.WriteTo(output, _repeated_repeatedStringWrapper_codec);
+ repeatedBytesWrapper_.WriteTo(output, _repeated_repeatedBytesWrapper_codec);
+ if (optionalDuration_ != null) {
+ output.WriteRawTag(234, 18);
+ output.WriteMessage(OptionalDuration);
+ }
+ if (optionalTimestamp_ != null) {
+ output.WriteRawTag(242, 18);
+ output.WriteMessage(OptionalTimestamp);
+ }
+ if (optionalFieldMask_ != null) {
+ output.WriteRawTag(250, 18);
+ output.WriteMessage(OptionalFieldMask);
+ }
+ if (optionalStruct_ != null) {
+ output.WriteRawTag(130, 19);
+ output.WriteMessage(OptionalStruct);
+ }
+ if (optionalAny_ != null) {
+ output.WriteRawTag(138, 19);
+ output.WriteMessage(OptionalAny);
+ }
+ if (optionalValue_ != null) {
+ output.WriteRawTag(146, 19);
+ output.WriteMessage(OptionalValue);
+ }
+ repeatedDuration_.WriteTo(output, _repeated_repeatedDuration_codec);
+ repeatedTimestamp_.WriteTo(output, _repeated_repeatedTimestamp_codec);
+ repeatedFieldmask_.WriteTo(output, _repeated_repeatedFieldmask_codec);
+ repeatedAny_.WriteTo(output, _repeated_repeatedAny_codec);
+ repeatedValue_.WriteTo(output, _repeated_repeatedValue_codec);
+ repeatedStruct_.WriteTo(output, _repeated_repeatedStruct_codec);
+ if (Fieldname1 != 0) {
+ output.WriteRawTag(136, 25);
+ output.WriteInt32(Fieldname1);
+ }
+ if (FieldName2 != 0) {
+ output.WriteRawTag(144, 25);
+ output.WriteInt32(FieldName2);
+ }
+ if (FieldName3 != 0) {
+ output.WriteRawTag(152, 25);
+ output.WriteInt32(FieldName3);
+ }
+ if (FieldName4 != 0) {
+ output.WriteRawTag(160, 25);
+ output.WriteInt32(FieldName4);
+ }
+ if (Field0Name5 != 0) {
+ output.WriteRawTag(168, 25);
+ output.WriteInt32(Field0Name5);
+ }
+ if (Field0Name6 != 0) {
+ output.WriteRawTag(176, 25);
+ output.WriteInt32(Field0Name6);
+ }
+ if (FieldName7 != 0) {
+ output.WriteRawTag(184, 25);
+ output.WriteInt32(FieldName7);
+ }
+ if (FieldName8 != 0) {
+ output.WriteRawTag(192, 25);
+ output.WriteInt32(FieldName8);
+ }
+ if (FieldName9 != 0) {
+ output.WriteRawTag(200, 25);
+ output.WriteInt32(FieldName9);
+ }
+ if (FieldName10 != 0) {
+ output.WriteRawTag(208, 25);
+ output.WriteInt32(FieldName10);
+ }
+ if (FIELDNAME11 != 0) {
+ output.WriteRawTag(216, 25);
+ output.WriteInt32(FIELDNAME11);
+ }
+ if (FIELDName12 != 0) {
+ output.WriteRawTag(224, 25);
+ output.WriteInt32(FIELDName12);
+ }
+ if (FieldName13 != 0) {
+ output.WriteRawTag(232, 25);
+ output.WriteInt32(FieldName13);
+ }
+ if (FieldName14 != 0) {
+ output.WriteRawTag(240, 25);
+ output.WriteInt32(FieldName14);
+ }
+ if (FieldName15 != 0) {
+ output.WriteRawTag(248, 25);
+ output.WriteInt32(FieldName15);
+ }
+ if (FieldName16 != 0) {
+ output.WriteRawTag(128, 26);
+ output.WriteInt32(FieldName16);
+ }
+ if (FieldName17 != 0) {
+ output.WriteRawTag(136, 26);
+ output.WriteInt32(FieldName17);
+ }
+ if (FieldName18 != 0) {
+ output.WriteRawTag(144, 26);
+ output.WriteInt32(FieldName18);
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ if (OptionalInt32 != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(OptionalInt32);
+ }
+ if (OptionalInt64 != 0L) {
+ size += 1 + pb::CodedOutputStream.ComputeInt64Size(OptionalInt64);
+ }
+ if (OptionalUint32 != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeUInt32Size(OptionalUint32);
+ }
+ if (OptionalUint64 != 0UL) {
+ size += 1 + pb::CodedOutputStream.ComputeUInt64Size(OptionalUint64);
+ }
+ if (OptionalSint32 != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeSInt32Size(OptionalSint32);
+ }
+ if (OptionalSint64 != 0L) {
+ size += 1 + pb::CodedOutputStream.ComputeSInt64Size(OptionalSint64);
+ }
+ if (OptionalFixed32 != 0) {
+ size += 1 + 4;
+ }
+ if (OptionalFixed64 != 0UL) {
+ size += 1 + 8;
+ }
+ if (OptionalSfixed32 != 0) {
+ size += 1 + 4;
+ }
+ if (OptionalSfixed64 != 0L) {
+ size += 1 + 8;
+ }
+ if (OptionalFloat != 0F) {
+ size += 1 + 4;
+ }
+ if (OptionalDouble != 0D) {
+ size += 1 + 8;
+ }
+ if (OptionalBool != false) {
+ size += 1 + 1;
+ }
+ if (OptionalString.Length != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(OptionalString);
+ }
+ if (OptionalBytes.Length != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeBytesSize(OptionalBytes);
+ }
+ if (optionalNestedMessage_ != null) {
+ size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalNestedMessage);
+ }
+ if (optionalForeignMessage_ != null) {
+ size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalForeignMessage);
+ }
+ if (OptionalNestedEnum != 0) {
+ size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) OptionalNestedEnum);
+ }
+ if (OptionalForeignEnum != 0) {
+ size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) OptionalForeignEnum);
+ }
+ if (OptionalStringPiece.Length != 0) {
+ size += 2 + pb::CodedOutputStream.ComputeStringSize(OptionalStringPiece);
+ }
+ if (OptionalCord.Length != 0) {
+ size += 2 + pb::CodedOutputStream.ComputeStringSize(OptionalCord);
+ }
+ if (recursiveMessage_ != null) {
+ size += 2 + pb::CodedOutputStream.ComputeMessageSize(RecursiveMessage);
+ }
+ size += repeatedInt32_.CalculateSize(_repeated_repeatedInt32_codec);
+ size += repeatedInt64_.CalculateSize(_repeated_repeatedInt64_codec);
+ size += repeatedUint32_.CalculateSize(_repeated_repeatedUint32_codec);
+ size += repeatedUint64_.CalculateSize(_repeated_repeatedUint64_codec);
+ size += repeatedSint32_.CalculateSize(_repeated_repeatedSint32_codec);
+ size += repeatedSint64_.CalculateSize(_repeated_repeatedSint64_codec);
+ size += repeatedFixed32_.CalculateSize(_repeated_repeatedFixed32_codec);
+ size += repeatedFixed64_.CalculateSize(_repeated_repeatedFixed64_codec);
+ size += repeatedSfixed32_.CalculateSize(_repeated_repeatedSfixed32_codec);
+ size += repeatedSfixed64_.CalculateSize(_repeated_repeatedSfixed64_codec);
+ size += repeatedFloat_.CalculateSize(_repeated_repeatedFloat_codec);
+ size += repeatedDouble_.CalculateSize(_repeated_repeatedDouble_codec);
+ size += repeatedBool_.CalculateSize(_repeated_repeatedBool_codec);
+ size += repeatedString_.CalculateSize(_repeated_repeatedString_codec);
+ size += repeatedBytes_.CalculateSize(_repeated_repeatedBytes_codec);
+ size += repeatedNestedMessage_.CalculateSize(_repeated_repeatedNestedMessage_codec);
+ size += repeatedForeignMessage_.CalculateSize(_repeated_repeatedForeignMessage_codec);
+ size += repeatedNestedEnum_.CalculateSize(_repeated_repeatedNestedEnum_codec);
+ size += repeatedForeignEnum_.CalculateSize(_repeated_repeatedForeignEnum_codec);
+ size += repeatedStringPiece_.CalculateSize(_repeated_repeatedStringPiece_codec);
+ size += repeatedCord_.CalculateSize(_repeated_repeatedCord_codec);
+ size += mapInt32Int32_.CalculateSize(_map_mapInt32Int32_codec);
+ size += mapInt64Int64_.CalculateSize(_map_mapInt64Int64_codec);
+ size += mapUint32Uint32_.CalculateSize(_map_mapUint32Uint32_codec);
+ size += mapUint64Uint64_.CalculateSize(_map_mapUint64Uint64_codec);
+ size += mapSint32Sint32_.CalculateSize(_map_mapSint32Sint32_codec);
+ size += mapSint64Sint64_.CalculateSize(_map_mapSint64Sint64_codec);
+ size += mapFixed32Fixed32_.CalculateSize(_map_mapFixed32Fixed32_codec);
+ size += mapFixed64Fixed64_.CalculateSize(_map_mapFixed64Fixed64_codec);
+ size += mapSfixed32Sfixed32_.CalculateSize(_map_mapSfixed32Sfixed32_codec);
+ size += mapSfixed64Sfixed64_.CalculateSize(_map_mapSfixed64Sfixed64_codec);
+ size += mapInt32Float_.CalculateSize(_map_mapInt32Float_codec);
+ size += mapInt32Double_.CalculateSize(_map_mapInt32Double_codec);
+ size += mapBoolBool_.CalculateSize(_map_mapBoolBool_codec);
+ size += mapStringString_.CalculateSize(_map_mapStringString_codec);
+ size += mapStringBytes_.CalculateSize(_map_mapStringBytes_codec);
+ size += mapStringNestedMessage_.CalculateSize(_map_mapStringNestedMessage_codec);
+ size += mapStringForeignMessage_.CalculateSize(_map_mapStringForeignMessage_codec);
+ size += mapStringNestedEnum_.CalculateSize(_map_mapStringNestedEnum_codec);
+ size += mapStringForeignEnum_.CalculateSize(_map_mapStringForeignEnum_codec);
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) {
+ size += 2 + pb::CodedOutputStream.ComputeUInt32Size(OneofUint32);
+ }
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) {
+ size += 2 + pb::CodedOutputStream.ComputeMessageSize(OneofNestedMessage);
+ }
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) {
+ size += 2 + pb::CodedOutputStream.ComputeStringSize(OneofString);
+ }
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) {
+ size += 2 + pb::CodedOutputStream.ComputeBytesSize(OneofBytes);
+ }
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofBool) {
+ size += 2 + 1;
+ }
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint64) {
+ size += 2 + pb::CodedOutputStream.ComputeUInt64Size(OneofUint64);
+ }
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofFloat) {
+ size += 2 + 4;
+ }
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofDouble) {
+ size += 2 + 8;
+ }
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofEnum) {
+ size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) OneofEnum);
+ }
+ if (optionalBoolWrapper_ != null) {
+ size += _single_optionalBoolWrapper_codec.CalculateSizeWithTag(OptionalBoolWrapper);
+ }
+ if (optionalInt32Wrapper_ != null) {
+ size += _single_optionalInt32Wrapper_codec.CalculateSizeWithTag(OptionalInt32Wrapper);
+ }
+ if (optionalInt64Wrapper_ != null) {
+ size += _single_optionalInt64Wrapper_codec.CalculateSizeWithTag(OptionalInt64Wrapper);
+ }
+ if (optionalUint32Wrapper_ != null) {
+ size += _single_optionalUint32Wrapper_codec.CalculateSizeWithTag(OptionalUint32Wrapper);
+ }
+ if (optionalUint64Wrapper_ != null) {
+ size += _single_optionalUint64Wrapper_codec.CalculateSizeWithTag(OptionalUint64Wrapper);
+ }
+ if (optionalFloatWrapper_ != null) {
+ size += _single_optionalFloatWrapper_codec.CalculateSizeWithTag(OptionalFloatWrapper);
+ }
+ if (optionalDoubleWrapper_ != null) {
+ size += _single_optionalDoubleWrapper_codec.CalculateSizeWithTag(OptionalDoubleWrapper);
+ }
+ if (optionalStringWrapper_ != null) {
+ size += _single_optionalStringWrapper_codec.CalculateSizeWithTag(OptionalStringWrapper);
+ }
+ if (optionalBytesWrapper_ != null) {
+ size += _single_optionalBytesWrapper_codec.CalculateSizeWithTag(OptionalBytesWrapper);
+ }
+ size += repeatedBoolWrapper_.CalculateSize(_repeated_repeatedBoolWrapper_codec);
+ size += repeatedInt32Wrapper_.CalculateSize(_repeated_repeatedInt32Wrapper_codec);
+ size += repeatedInt64Wrapper_.CalculateSize(_repeated_repeatedInt64Wrapper_codec);
+ size += repeatedUint32Wrapper_.CalculateSize(_repeated_repeatedUint32Wrapper_codec);
+ size += repeatedUint64Wrapper_.CalculateSize(_repeated_repeatedUint64Wrapper_codec);
+ size += repeatedFloatWrapper_.CalculateSize(_repeated_repeatedFloatWrapper_codec);
+ size += repeatedDoubleWrapper_.CalculateSize(_repeated_repeatedDoubleWrapper_codec);
+ size += repeatedStringWrapper_.CalculateSize(_repeated_repeatedStringWrapper_codec);
+ size += repeatedBytesWrapper_.CalculateSize(_repeated_repeatedBytesWrapper_codec);
+ if (optionalDuration_ != null) {
+ size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalDuration);
+ }
+ if (optionalTimestamp_ != null) {
+ size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalTimestamp);
+ }
+ if (optionalFieldMask_ != null) {
+ size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalFieldMask);
+ }
+ if (optionalStruct_ != null) {
+ size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalStruct);
+ }
+ if (optionalAny_ != null) {
+ size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalAny);
+ }
+ if (optionalValue_ != null) {
+ size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalValue);
+ }
+ size += repeatedDuration_.CalculateSize(_repeated_repeatedDuration_codec);
+ size += repeatedTimestamp_.CalculateSize(_repeated_repeatedTimestamp_codec);
+ size += repeatedFieldmask_.CalculateSize(_repeated_repeatedFieldmask_codec);
+ size += repeatedStruct_.CalculateSize(_repeated_repeatedStruct_codec);
+ size += repeatedAny_.CalculateSize(_repeated_repeatedAny_codec);
+ size += repeatedValue_.CalculateSize(_repeated_repeatedValue_codec);
+ if (Fieldname1 != 0) {
+ size += 2 + pb::CodedOutputStream.ComputeInt32Size(Fieldname1);
+ }
+ if (FieldName2 != 0) {
+ size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName2);
+ }
+ if (FieldName3 != 0) {
+ size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName3);
+ }
+ if (FieldName4 != 0) {
+ size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName4);
+ }
+ if (Field0Name5 != 0) {
+ size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field0Name5);
+ }
+ if (Field0Name6 != 0) {
+ size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field0Name6);
+ }
+ if (FieldName7 != 0) {
+ size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName7);
+ }
+ if (FieldName8 != 0) {
+ size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName8);
+ }
+ if (FieldName9 != 0) {
+ size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName9);
+ }
+ if (FieldName10 != 0) {
+ size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName10);
+ }
+ if (FIELDNAME11 != 0) {
+ size += 2 + pb::CodedOutputStream.ComputeInt32Size(FIELDNAME11);
+ }
+ if (FIELDName12 != 0) {
+ size += 2 + pb::CodedOutputStream.ComputeInt32Size(FIELDName12);
+ }
+ if (FieldName13 != 0) {
+ size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName13);
+ }
+ if (FieldName14 != 0) {
+ size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName14);
+ }
+ if (FieldName15 != 0) {
+ size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName15);
+ }
+ if (FieldName16 != 0) {
+ size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName16);
+ }
+ if (FieldName17 != 0) {
+ size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName17);
+ }
+ if (FieldName18 != 0) {
+ size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName18);
+ }
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(TestAllTypes other) {
+ if (other == null) {
+ return;
+ }
+ if (other.OptionalInt32 != 0) {
+ OptionalInt32 = other.OptionalInt32;
+ }
+ if (other.OptionalInt64 != 0L) {
+ OptionalInt64 = other.OptionalInt64;
+ }
+ if (other.OptionalUint32 != 0) {
+ OptionalUint32 = other.OptionalUint32;
+ }
+ if (other.OptionalUint64 != 0UL) {
+ OptionalUint64 = other.OptionalUint64;
+ }
+ if (other.OptionalSint32 != 0) {
+ OptionalSint32 = other.OptionalSint32;
+ }
+ if (other.OptionalSint64 != 0L) {
+ OptionalSint64 = other.OptionalSint64;
+ }
+ if (other.OptionalFixed32 != 0) {
+ OptionalFixed32 = other.OptionalFixed32;
+ }
+ if (other.OptionalFixed64 != 0UL) {
+ OptionalFixed64 = other.OptionalFixed64;
+ }
+ if (other.OptionalSfixed32 != 0) {
+ OptionalSfixed32 = other.OptionalSfixed32;
+ }
+ if (other.OptionalSfixed64 != 0L) {
+ OptionalSfixed64 = other.OptionalSfixed64;
+ }
+ if (other.OptionalFloat != 0F) {
+ OptionalFloat = other.OptionalFloat;
+ }
+ if (other.OptionalDouble != 0D) {
+ OptionalDouble = other.OptionalDouble;
+ }
+ if (other.OptionalBool != false) {
+ OptionalBool = other.OptionalBool;
+ }
+ if (other.OptionalString.Length != 0) {
+ OptionalString = other.OptionalString;
+ }
+ if (other.OptionalBytes.Length != 0) {
+ OptionalBytes = other.OptionalBytes;
+ }
+ if (other.optionalNestedMessage_ != null) {
+ if (optionalNestedMessage_ == null) {
+ optionalNestedMessage_ = new global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage();
+ }
+ OptionalNestedMessage.MergeFrom(other.OptionalNestedMessage);
+ }
+ if (other.optionalForeignMessage_ != null) {
+ if (optionalForeignMessage_ == null) {
+ optionalForeignMessage_ = new global::ProtobufTestMessages.Proto3.ForeignMessage();
+ }
+ OptionalForeignMessage.MergeFrom(other.OptionalForeignMessage);
+ }
+ if (other.OptionalNestedEnum != 0) {
+ OptionalNestedEnum = other.OptionalNestedEnum;
+ }
+ if (other.OptionalForeignEnum != 0) {
+ OptionalForeignEnum = other.OptionalForeignEnum;
+ }
+ if (other.OptionalStringPiece.Length != 0) {
+ OptionalStringPiece = other.OptionalStringPiece;
+ }
+ if (other.OptionalCord.Length != 0) {
+ OptionalCord = other.OptionalCord;
+ }
+ if (other.recursiveMessage_ != null) {
+ if (recursiveMessage_ == null) {
+ recursiveMessage_ = new global::ProtobufTestMessages.Proto3.TestAllTypes();
+ }
+ RecursiveMessage.MergeFrom(other.RecursiveMessage);
+ }
+ repeatedInt32_.Add(other.repeatedInt32_);
+ repeatedInt64_.Add(other.repeatedInt64_);
+ repeatedUint32_.Add(other.repeatedUint32_);
+ repeatedUint64_.Add(other.repeatedUint64_);
+ repeatedSint32_.Add(other.repeatedSint32_);
+ repeatedSint64_.Add(other.repeatedSint64_);
+ repeatedFixed32_.Add(other.repeatedFixed32_);
+ repeatedFixed64_.Add(other.repeatedFixed64_);
+ repeatedSfixed32_.Add(other.repeatedSfixed32_);
+ repeatedSfixed64_.Add(other.repeatedSfixed64_);
+ repeatedFloat_.Add(other.repeatedFloat_);
+ repeatedDouble_.Add(other.repeatedDouble_);
+ repeatedBool_.Add(other.repeatedBool_);
+ repeatedString_.Add(other.repeatedString_);
+ repeatedBytes_.Add(other.repeatedBytes_);
+ repeatedNestedMessage_.Add(other.repeatedNestedMessage_);
+ repeatedForeignMessage_.Add(other.repeatedForeignMessage_);
+ repeatedNestedEnum_.Add(other.repeatedNestedEnum_);
+ repeatedForeignEnum_.Add(other.repeatedForeignEnum_);
+ repeatedStringPiece_.Add(other.repeatedStringPiece_);
+ repeatedCord_.Add(other.repeatedCord_);
+ mapInt32Int32_.Add(other.mapInt32Int32_);
+ mapInt64Int64_.Add(other.mapInt64Int64_);
+ mapUint32Uint32_.Add(other.mapUint32Uint32_);
+ mapUint64Uint64_.Add(other.mapUint64Uint64_);
+ mapSint32Sint32_.Add(other.mapSint32Sint32_);
+ mapSint64Sint64_.Add(other.mapSint64Sint64_);
+ mapFixed32Fixed32_.Add(other.mapFixed32Fixed32_);
+ mapFixed64Fixed64_.Add(other.mapFixed64Fixed64_);
+ mapSfixed32Sfixed32_.Add(other.mapSfixed32Sfixed32_);
+ mapSfixed64Sfixed64_.Add(other.mapSfixed64Sfixed64_);
+ mapInt32Float_.Add(other.mapInt32Float_);
+ mapInt32Double_.Add(other.mapInt32Double_);
+ mapBoolBool_.Add(other.mapBoolBool_);
+ mapStringString_.Add(other.mapStringString_);
+ mapStringBytes_.Add(other.mapStringBytes_);
+ mapStringNestedMessage_.Add(other.mapStringNestedMessage_);
+ mapStringForeignMessage_.Add(other.mapStringForeignMessage_);
+ mapStringNestedEnum_.Add(other.mapStringNestedEnum_);
+ mapStringForeignEnum_.Add(other.mapStringForeignEnum_);
+ if (other.optionalBoolWrapper_ != null) {
+ if (optionalBoolWrapper_ == null || other.OptionalBoolWrapper != false) {
+ OptionalBoolWrapper = other.OptionalBoolWrapper;
+ }
+ }
+ if (other.optionalInt32Wrapper_ != null) {
+ if (optionalInt32Wrapper_ == null || other.OptionalInt32Wrapper != 0) {
+ OptionalInt32Wrapper = other.OptionalInt32Wrapper;
+ }
+ }
+ if (other.optionalInt64Wrapper_ != null) {
+ if (optionalInt64Wrapper_ == null || other.OptionalInt64Wrapper != 0L) {
+ OptionalInt64Wrapper = other.OptionalInt64Wrapper;
+ }
+ }
+ if (other.optionalUint32Wrapper_ != null) {
+ if (optionalUint32Wrapper_ == null || other.OptionalUint32Wrapper != 0) {
+ OptionalUint32Wrapper = other.OptionalUint32Wrapper;
+ }
+ }
+ if (other.optionalUint64Wrapper_ != null) {
+ if (optionalUint64Wrapper_ == null || other.OptionalUint64Wrapper != 0UL) {
+ OptionalUint64Wrapper = other.OptionalUint64Wrapper;
+ }
+ }
+ if (other.optionalFloatWrapper_ != null) {
+ if (optionalFloatWrapper_ == null || other.OptionalFloatWrapper != 0F) {
+ OptionalFloatWrapper = other.OptionalFloatWrapper;
+ }
+ }
+ if (other.optionalDoubleWrapper_ != null) {
+ if (optionalDoubleWrapper_ == null || other.OptionalDoubleWrapper != 0D) {
+ OptionalDoubleWrapper = other.OptionalDoubleWrapper;
+ }
+ }
+ if (other.optionalStringWrapper_ != null) {
+ if (optionalStringWrapper_ == null || other.OptionalStringWrapper != "") {
+ OptionalStringWrapper = other.OptionalStringWrapper;
+ }
+ }
+ if (other.optionalBytesWrapper_ != null) {
+ if (optionalBytesWrapper_ == null || other.OptionalBytesWrapper != pb::ByteString.Empty) {
+ OptionalBytesWrapper = other.OptionalBytesWrapper;
+ }
+ }
+ repeatedBoolWrapper_.Add(other.repeatedBoolWrapper_);
+ repeatedInt32Wrapper_.Add(other.repeatedInt32Wrapper_);
+ repeatedInt64Wrapper_.Add(other.repeatedInt64Wrapper_);
+ repeatedUint32Wrapper_.Add(other.repeatedUint32Wrapper_);
+ repeatedUint64Wrapper_.Add(other.repeatedUint64Wrapper_);
+ repeatedFloatWrapper_.Add(other.repeatedFloatWrapper_);
+ repeatedDoubleWrapper_.Add(other.repeatedDoubleWrapper_);
+ repeatedStringWrapper_.Add(other.repeatedStringWrapper_);
+ repeatedBytesWrapper_.Add(other.repeatedBytesWrapper_);
+ if (other.optionalDuration_ != null) {
+ if (optionalDuration_ == null) {
+ optionalDuration_ = new global::Google.Protobuf.WellKnownTypes.Duration();
+ }
+ OptionalDuration.MergeFrom(other.OptionalDuration);
+ }
+ if (other.optionalTimestamp_ != null) {
+ if (optionalTimestamp_ == null) {
+ optionalTimestamp_ = new global::Google.Protobuf.WellKnownTypes.Timestamp();
+ }
+ OptionalTimestamp.MergeFrom(other.OptionalTimestamp);
+ }
+ if (other.optionalFieldMask_ != null) {
+ if (optionalFieldMask_ == null) {
+ optionalFieldMask_ = new global::Google.Protobuf.WellKnownTypes.FieldMask();
+ }
+ OptionalFieldMask.MergeFrom(other.OptionalFieldMask);
+ }
+ if (other.optionalStruct_ != null) {
+ if (optionalStruct_ == null) {
+ optionalStruct_ = new global::Google.Protobuf.WellKnownTypes.Struct();
+ }
+ OptionalStruct.MergeFrom(other.OptionalStruct);
+ }
+ if (other.optionalAny_ != null) {
+ if (optionalAny_ == null) {
+ optionalAny_ = new global::Google.Protobuf.WellKnownTypes.Any();
+ }
+ OptionalAny.MergeFrom(other.OptionalAny);
+ }
+ if (other.optionalValue_ != null) {
+ if (optionalValue_ == null) {
+ optionalValue_ = new global::Google.Protobuf.WellKnownTypes.Value();
+ }
+ OptionalValue.MergeFrom(other.OptionalValue);
+ }
+ repeatedDuration_.Add(other.repeatedDuration_);
+ repeatedTimestamp_.Add(other.repeatedTimestamp_);
+ repeatedFieldmask_.Add(other.repeatedFieldmask_);
+ repeatedStruct_.Add(other.repeatedStruct_);
+ repeatedAny_.Add(other.repeatedAny_);
+ repeatedValue_.Add(other.repeatedValue_);
+ if (other.Fieldname1 != 0) {
+ Fieldname1 = other.Fieldname1;
+ }
+ if (other.FieldName2 != 0) {
+ FieldName2 = other.FieldName2;
+ }
+ if (other.FieldName3 != 0) {
+ FieldName3 = other.FieldName3;
+ }
+ if (other.FieldName4 != 0) {
+ FieldName4 = other.FieldName4;
+ }
+ if (other.Field0Name5 != 0) {
+ Field0Name5 = other.Field0Name5;
+ }
+ if (other.Field0Name6 != 0) {
+ Field0Name6 = other.Field0Name6;
+ }
+ if (other.FieldName7 != 0) {
+ FieldName7 = other.FieldName7;
+ }
+ if (other.FieldName8 != 0) {
+ FieldName8 = other.FieldName8;
+ }
+ if (other.FieldName9 != 0) {
+ FieldName9 = other.FieldName9;
+ }
+ if (other.FieldName10 != 0) {
+ FieldName10 = other.FieldName10;
+ }
+ if (other.FIELDNAME11 != 0) {
+ FIELDNAME11 = other.FIELDNAME11;
+ }
+ if (other.FIELDName12 != 0) {
+ FIELDName12 = other.FIELDName12;
+ }
+ if (other.FieldName13 != 0) {
+ FieldName13 = other.FieldName13;
+ }
+ if (other.FieldName14 != 0) {
+ FieldName14 = other.FieldName14;
+ }
+ if (other.FieldName15 != 0) {
+ FieldName15 = other.FieldName15;
+ }
+ if (other.FieldName16 != 0) {
+ FieldName16 = other.FieldName16;
+ }
+ if (other.FieldName17 != 0) {
+ FieldName17 = other.FieldName17;
+ }
+ if (other.FieldName18 != 0) {
+ FieldName18 = other.FieldName18;
+ }
+ switch (other.OneofFieldCase) {
+ case OneofFieldOneofCase.OneofUint32:
+ OneofUint32 = other.OneofUint32;
+ break;
+ case OneofFieldOneofCase.OneofNestedMessage:
+ OneofNestedMessage = other.OneofNestedMessage;
+ break;
+ case OneofFieldOneofCase.OneofString:
+ OneofString = other.OneofString;
+ break;
+ case OneofFieldOneofCase.OneofBytes:
+ OneofBytes = other.OneofBytes;
+ break;
+ case OneofFieldOneofCase.OneofBool:
+ OneofBool = other.OneofBool;
+ break;
+ case OneofFieldOneofCase.OneofUint64:
+ OneofUint64 = other.OneofUint64;
+ break;
+ case OneofFieldOneofCase.OneofFloat:
+ OneofFloat = other.OneofFloat;
+ break;
+ case OneofFieldOneofCase.OneofDouble:
+ OneofDouble = other.OneofDouble;
+ break;
+ case OneofFieldOneofCase.OneofEnum:
+ OneofEnum = other.OneofEnum;
+ break;
+ }
+
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 8: {
+ OptionalInt32 = input.ReadInt32();
+ break;
+ }
+ case 16: {
+ OptionalInt64 = input.ReadInt64();
+ break;
+ }
+ case 24: {
+ OptionalUint32 = input.ReadUInt32();
+ break;
+ }
+ case 32: {
+ OptionalUint64 = input.ReadUInt64();
+ break;
+ }
+ case 40: {
+ OptionalSint32 = input.ReadSInt32();
+ break;
+ }
+ case 48: {
+ OptionalSint64 = input.ReadSInt64();
+ break;
+ }
+ case 61: {
+ OptionalFixed32 = input.ReadFixed32();
+ break;
+ }
+ case 65: {
+ OptionalFixed64 = input.ReadFixed64();
+ break;
+ }
+ case 77: {
+ OptionalSfixed32 = input.ReadSFixed32();
+ break;
+ }
+ case 81: {
+ OptionalSfixed64 = input.ReadSFixed64();
+ break;
+ }
+ case 93: {
+ OptionalFloat = input.ReadFloat();
+ break;
+ }
+ case 97: {
+ OptionalDouble = input.ReadDouble();
+ break;
+ }
+ case 104: {
+ OptionalBool = input.ReadBool();
+ break;
+ }
+ case 114: {
+ OptionalString = input.ReadString();
+ break;
+ }
+ case 122: {
+ OptionalBytes = input.ReadBytes();
+ break;
+ }
+ case 146: {
+ if (optionalNestedMessage_ == null) {
+ optionalNestedMessage_ = new global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage();
+ }
+ input.ReadMessage(optionalNestedMessage_);
+ break;
+ }
+ case 154: {
+ if (optionalForeignMessage_ == null) {
+ optionalForeignMessage_ = new global::ProtobufTestMessages.Proto3.ForeignMessage();
+ }
+ input.ReadMessage(optionalForeignMessage_);
+ break;
+ }
+ case 168: {
+ optionalNestedEnum_ = (global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum) input.ReadEnum();
+ break;
+ }
+ case 176: {
+ optionalForeignEnum_ = (global::ProtobufTestMessages.Proto3.ForeignEnum) input.ReadEnum();
+ break;
+ }
+ case 194: {
+ OptionalStringPiece = input.ReadString();
+ break;
+ }
+ case 202: {
+ OptionalCord = input.ReadString();
+ break;
+ }
+ case 218: {
+ if (recursiveMessage_ == null) {
+ recursiveMessage_ = new global::ProtobufTestMessages.Proto3.TestAllTypes();
+ }
+ input.ReadMessage(recursiveMessage_);
+ break;
+ }
+ case 250:
+ case 248: {
+ repeatedInt32_.AddEntriesFrom(input, _repeated_repeatedInt32_codec);
+ break;
+ }
+ case 258:
+ case 256: {
+ repeatedInt64_.AddEntriesFrom(input, _repeated_repeatedInt64_codec);
+ break;
+ }
+ case 266:
+ case 264: {
+ repeatedUint32_.AddEntriesFrom(input, _repeated_repeatedUint32_codec);
+ break;
+ }
+ case 274:
+ case 272: {
+ repeatedUint64_.AddEntriesFrom(input, _repeated_repeatedUint64_codec);
+ break;
+ }
+ case 282:
+ case 280: {
+ repeatedSint32_.AddEntriesFrom(input, _repeated_repeatedSint32_codec);
+ break;
+ }
+ case 290:
+ case 288: {
+ repeatedSint64_.AddEntriesFrom(input, _repeated_repeatedSint64_codec);
+ break;
+ }
+ case 298:
+ case 301: {
+ repeatedFixed32_.AddEntriesFrom(input, _repeated_repeatedFixed32_codec);
+ break;
+ }
+ case 306:
+ case 305: {
+ repeatedFixed64_.AddEntriesFrom(input, _repeated_repeatedFixed64_codec);
+ break;
+ }
+ case 314:
+ case 317: {
+ repeatedSfixed32_.AddEntriesFrom(input, _repeated_repeatedSfixed32_codec);
+ break;
+ }
+ case 322:
+ case 321: {
+ repeatedSfixed64_.AddEntriesFrom(input, _repeated_repeatedSfixed64_codec);
+ break;
+ }
+ case 330:
+ case 333: {
+ repeatedFloat_.AddEntriesFrom(input, _repeated_repeatedFloat_codec);
+ break;
+ }
+ case 338:
+ case 337: {
+ repeatedDouble_.AddEntriesFrom(input, _repeated_repeatedDouble_codec);
+ break;
+ }
+ case 346:
+ case 344: {
+ repeatedBool_.AddEntriesFrom(input, _repeated_repeatedBool_codec);
+ break;
+ }
+ case 354: {
+ repeatedString_.AddEntriesFrom(input, _repeated_repeatedString_codec);
+ break;
+ }
+ case 362: {
+ repeatedBytes_.AddEntriesFrom(input, _repeated_repeatedBytes_codec);
+ break;
+ }
+ case 386: {
+ repeatedNestedMessage_.AddEntriesFrom(input, _repeated_repeatedNestedMessage_codec);
+ break;
+ }
+ case 394: {
+ repeatedForeignMessage_.AddEntriesFrom(input, _repeated_repeatedForeignMessage_codec);
+ break;
+ }
+ case 410:
+ case 408: {
+ repeatedNestedEnum_.AddEntriesFrom(input, _repeated_repeatedNestedEnum_codec);
+ break;
+ }
+ case 418:
+ case 416: {
+ repeatedForeignEnum_.AddEntriesFrom(input, _repeated_repeatedForeignEnum_codec);
+ break;
+ }
+ case 434: {
+ repeatedStringPiece_.AddEntriesFrom(input, _repeated_repeatedStringPiece_codec);
+ break;
+ }
+ case 442: {
+ repeatedCord_.AddEntriesFrom(input, _repeated_repeatedCord_codec);
+ break;
+ }
+ case 450: {
+ mapInt32Int32_.AddEntriesFrom(input, _map_mapInt32Int32_codec);
+ break;
+ }
+ case 458: {
+ mapInt64Int64_.AddEntriesFrom(input, _map_mapInt64Int64_codec);
+ break;
+ }
+ case 466: {
+ mapUint32Uint32_.AddEntriesFrom(input, _map_mapUint32Uint32_codec);
+ break;
+ }
+ case 474: {
+ mapUint64Uint64_.AddEntriesFrom(input, _map_mapUint64Uint64_codec);
+ break;
+ }
+ case 482: {
+ mapSint32Sint32_.AddEntriesFrom(input, _map_mapSint32Sint32_codec);
+ break;
+ }
+ case 490: {
+ mapSint64Sint64_.AddEntriesFrom(input, _map_mapSint64Sint64_codec);
+ break;
+ }
+ case 498: {
+ mapFixed32Fixed32_.AddEntriesFrom(input, _map_mapFixed32Fixed32_codec);
+ break;
+ }
+ case 506: {
+ mapFixed64Fixed64_.AddEntriesFrom(input, _map_mapFixed64Fixed64_codec);
+ break;
+ }
+ case 514: {
+ mapSfixed32Sfixed32_.AddEntriesFrom(input, _map_mapSfixed32Sfixed32_codec);
+ break;
+ }
+ case 522: {
+ mapSfixed64Sfixed64_.AddEntriesFrom(input, _map_mapSfixed64Sfixed64_codec);
+ break;
+ }
+ case 530: {
+ mapInt32Float_.AddEntriesFrom(input, _map_mapInt32Float_codec);
+ break;
+ }
+ case 538: {
+ mapInt32Double_.AddEntriesFrom(input, _map_mapInt32Double_codec);
+ break;
+ }
+ case 546: {
+ mapBoolBool_.AddEntriesFrom(input, _map_mapBoolBool_codec);
+ break;
+ }
+ case 554: {
+ mapStringString_.AddEntriesFrom(input, _map_mapStringString_codec);
+ break;
+ }
+ case 562: {
+ mapStringBytes_.AddEntriesFrom(input, _map_mapStringBytes_codec);
+ break;
+ }
+ case 570: {
+ mapStringNestedMessage_.AddEntriesFrom(input, _map_mapStringNestedMessage_codec);
+ break;
+ }
+ case 578: {
+ mapStringForeignMessage_.AddEntriesFrom(input, _map_mapStringForeignMessage_codec);
+ break;
+ }
+ case 586: {
+ mapStringNestedEnum_.AddEntriesFrom(input, _map_mapStringNestedEnum_codec);
+ break;
+ }
+ case 594: {
+ mapStringForeignEnum_.AddEntriesFrom(input, _map_mapStringForeignEnum_codec);
+ break;
+ }
+ case 888: {
+ OneofUint32 = input.ReadUInt32();
+ break;
+ }
+ case 898: {
+ global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage subBuilder = new global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage();
+ if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) {
+ subBuilder.MergeFrom(OneofNestedMessage);
+ }
+ input.ReadMessage(subBuilder);
+ OneofNestedMessage = subBuilder;
+ break;
+ }
+ case 906: {
+ OneofString = input.ReadString();
+ break;
+ }
+ case 914: {
+ OneofBytes = input.ReadBytes();
+ break;
+ }
+ case 920: {
+ OneofBool = input.ReadBool();
+ break;
+ }
+ case 928: {
+ OneofUint64 = input.ReadUInt64();
+ break;
+ }
+ case 941: {
+ OneofFloat = input.ReadFloat();
+ break;
+ }
+ case 945: {
+ OneofDouble = input.ReadDouble();
+ break;
+ }
+ case 952: {
+ oneofField_ = input.ReadEnum();
+ oneofFieldCase_ = OneofFieldOneofCase.OneofEnum;
+ break;
+ }
+ case 1610: {
+ bool? value = _single_optionalBoolWrapper_codec.Read(input);
+ if (optionalBoolWrapper_ == null || value != false) {
+ OptionalBoolWrapper = value;
+ }
+ break;
+ }
+ case 1618: {
+ int? value = _single_optionalInt32Wrapper_codec.Read(input);
+ if (optionalInt32Wrapper_ == null || value != 0) {
+ OptionalInt32Wrapper = value;
+ }
+ break;
+ }
+ case 1626: {
+ long? value = _single_optionalInt64Wrapper_codec.Read(input);
+ if (optionalInt64Wrapper_ == null || value != 0L) {
+ OptionalInt64Wrapper = value;
+ }
+ break;
+ }
+ case 1634: {
+ uint? value = _single_optionalUint32Wrapper_codec.Read(input);
+ if (optionalUint32Wrapper_ == null || value != 0) {
+ OptionalUint32Wrapper = value;
+ }
+ break;
+ }
+ case 1642: {
+ ulong? value = _single_optionalUint64Wrapper_codec.Read(input);
+ if (optionalUint64Wrapper_ == null || value != 0UL) {
+ OptionalUint64Wrapper = value;
+ }
+ break;
+ }
+ case 1650: {
+ float? value = _single_optionalFloatWrapper_codec.Read(input);
+ if (optionalFloatWrapper_ == null || value != 0F) {
+ OptionalFloatWrapper = value;
+ }
+ break;
+ }
+ case 1658: {
+ double? value = _single_optionalDoubleWrapper_codec.Read(input);
+ if (optionalDoubleWrapper_ == null || value != 0D) {
+ OptionalDoubleWrapper = value;
+ }
+ break;
+ }
+ case 1666: {
+ string value = _single_optionalStringWrapper_codec.Read(input);
+ if (optionalStringWrapper_ == null || value != "") {
+ OptionalStringWrapper = value;
+ }
+ break;
+ }
+ case 1674: {
+ pb::ByteString value = _single_optionalBytesWrapper_codec.Read(input);
+ if (optionalBytesWrapper_ == null || value != pb::ByteString.Empty) {
+ OptionalBytesWrapper = value;
+ }
+ break;
+ }
+ case 1690: {
+ repeatedBoolWrapper_.AddEntriesFrom(input, _repeated_repeatedBoolWrapper_codec);
+ break;
+ }
+ case 1698: {
+ repeatedInt32Wrapper_.AddEntriesFrom(input, _repeated_repeatedInt32Wrapper_codec);
+ break;
+ }
+ case 1706: {
+ repeatedInt64Wrapper_.AddEntriesFrom(input, _repeated_repeatedInt64Wrapper_codec);
+ break;
+ }
+ case 1714: {
+ repeatedUint32Wrapper_.AddEntriesFrom(input, _repeated_repeatedUint32Wrapper_codec);
+ break;
+ }
+ case 1722: {
+ repeatedUint64Wrapper_.AddEntriesFrom(input, _repeated_repeatedUint64Wrapper_codec);
+ break;
+ }
+ case 1730: {
+ repeatedFloatWrapper_.AddEntriesFrom(input, _repeated_repeatedFloatWrapper_codec);
+ break;
+ }
+ case 1738: {
+ repeatedDoubleWrapper_.AddEntriesFrom(input, _repeated_repeatedDoubleWrapper_codec);
+ break;
+ }
+ case 1746: {
+ repeatedStringWrapper_.AddEntriesFrom(input, _repeated_repeatedStringWrapper_codec);
+ break;
+ }
+ case 1754: {
+ repeatedBytesWrapper_.AddEntriesFrom(input, _repeated_repeatedBytesWrapper_codec);
+ break;
+ }
+ case 2410: {
+ if (optionalDuration_ == null) {
+ optionalDuration_ = new global::Google.Protobuf.WellKnownTypes.Duration();
+ }
+ input.ReadMessage(optionalDuration_);
+ break;
+ }
+ case 2418: {
+ if (optionalTimestamp_ == null) {
+ optionalTimestamp_ = new global::Google.Protobuf.WellKnownTypes.Timestamp();
+ }
+ input.ReadMessage(optionalTimestamp_);
+ break;
+ }
+ case 2426: {
+ if (optionalFieldMask_ == null) {
+ optionalFieldMask_ = new global::Google.Protobuf.WellKnownTypes.FieldMask();
+ }
+ input.ReadMessage(optionalFieldMask_);
+ break;
+ }
+ case 2434: {
+ if (optionalStruct_ == null) {
+ optionalStruct_ = new global::Google.Protobuf.WellKnownTypes.Struct();
+ }
+ input.ReadMessage(optionalStruct_);
+ break;
+ }
+ case 2442: {
+ if (optionalAny_ == null) {
+ optionalAny_ = new global::Google.Protobuf.WellKnownTypes.Any();
+ }
+ input.ReadMessage(optionalAny_);
+ break;
+ }
+ case 2450: {
+ if (optionalValue_ == null) {
+ optionalValue_ = new global::Google.Protobuf.WellKnownTypes.Value();
+ }
+ input.ReadMessage(optionalValue_);
+ break;
+ }
+ case 2490: {
+ repeatedDuration_.AddEntriesFrom(input, _repeated_repeatedDuration_codec);
+ break;
+ }
+ case 2498: {
+ repeatedTimestamp_.AddEntriesFrom(input, _repeated_repeatedTimestamp_codec);
+ break;
+ }
+ case 2506: {
+ repeatedFieldmask_.AddEntriesFrom(input, _repeated_repeatedFieldmask_codec);
+ break;
+ }
+ case 2522: {
+ repeatedAny_.AddEntriesFrom(input, _repeated_repeatedAny_codec);
+ break;
+ }
+ case 2530: {
+ repeatedValue_.AddEntriesFrom(input, _repeated_repeatedValue_codec);
+ break;
+ }
+ case 2594: {
+ repeatedStruct_.AddEntriesFrom(input, _repeated_repeatedStruct_codec);
+ break;
+ }
+ case 3208: {
+ Fieldname1 = input.ReadInt32();
+ break;
+ }
+ case 3216: {
+ FieldName2 = input.ReadInt32();
+ break;
+ }
+ case 3224: {
+ FieldName3 = input.ReadInt32();
+ break;
+ }
+ case 3232: {
+ FieldName4 = input.ReadInt32();
+ break;
+ }
+ case 3240: {
+ Field0Name5 = input.ReadInt32();
+ break;
+ }
+ case 3248: {
+ Field0Name6 = input.ReadInt32();
+ break;
+ }
+ case 3256: {
+ FieldName7 = input.ReadInt32();
+ break;
+ }
+ case 3264: {
+ FieldName8 = input.ReadInt32();
+ break;
+ }
+ case 3272: {
+ FieldName9 = input.ReadInt32();
+ break;
+ }
+ case 3280: {
+ FieldName10 = input.ReadInt32();
+ break;
+ }
+ case 3288: {
+ FIELDNAME11 = input.ReadInt32();
+ break;
+ }
+ case 3296: {
+ FIELDName12 = input.ReadInt32();
+ break;
+ }
+ case 3304: {
+ FieldName13 = input.ReadInt32();
+ break;
+ }
+ case 3312: {
+ FieldName14 = input.ReadInt32();
+ break;
+ }
+ case 3320: {
+ FieldName15 = input.ReadInt32();
+ break;
+ }
+ case 3328: {
+ FieldName16 = input.ReadInt32();
+ break;
+ }
+ case 3336: {
+ FieldName17 = input.ReadInt32();
+ break;
+ }
+ case 3344: {
+ FieldName18 = input.ReadInt32();
+ break;
+ }
+ }
+ }
+ }
+
+ #region Nested types
+ /// <summary>Container for nested types declared in the TestAllTypes message type.</summary>
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static partial class Types {
+ public enum NestedEnum {
+ [pbr::OriginalName("FOO")] Foo = 0,
+ [pbr::OriginalName("BAR")] Bar = 1,
+ [pbr::OriginalName("BAZ")] Baz = 2,
+ /// <summary>
+ /// Intentionally negative.
+ /// </summary>
+ [pbr::OriginalName("NEG")] Neg = -1,
+ }
+
+ public sealed partial class NestedMessage : pb::IMessage<NestedMessage> {
+ private static readonly pb::MessageParser<NestedMessage> _parser = new pb::MessageParser<NestedMessage>(() => new NestedMessage());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<NestedMessage> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::ProtobufTestMessages.Proto3.TestAllTypes.Descriptor.NestedTypes[0]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public NestedMessage() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public NestedMessage(NestedMessage other) : this() {
+ a_ = other.a_;
+ Corecursive = other.corecursive_ != null ? other.Corecursive.Clone() : null;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public NestedMessage Clone() {
+ return new NestedMessage(this);
+ }
+
+ /// <summary>Field number for the "a" field.</summary>
+ public const int AFieldNumber = 1;
+ private int a_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int A {
+ get { return a_; }
+ set {
+ a_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "corecursive" field.</summary>
+ public const int CorecursiveFieldNumber = 2;
+ private global::ProtobufTestMessages.Proto3.TestAllTypes corecursive_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public global::ProtobufTestMessages.Proto3.TestAllTypes Corecursive {
+ get { return corecursive_; }
+ set {
+ corecursive_ = value;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as NestedMessage);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(NestedMessage other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ if (A != other.A) return false;
+ if (!object.Equals(Corecursive, other.Corecursive)) return false;
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ if (A != 0) hash ^= A.GetHashCode();
+ if (corecursive_ != null) hash ^= Corecursive.GetHashCode();
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (A != 0) {
+ output.WriteRawTag(8);
+ output.WriteInt32(A);
+ }
+ if (corecursive_ != null) {
+ output.WriteRawTag(18);
+ output.WriteMessage(Corecursive);
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ if (A != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(A);
+ }
+ if (corecursive_ != null) {
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(Corecursive);
+ }
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(NestedMessage other) {
+ if (other == null) {
+ return;
+ }
+ if (other.A != 0) {
+ A = other.A;
+ }
+ if (other.corecursive_ != null) {
+ if (corecursive_ == null) {
+ corecursive_ = new global::ProtobufTestMessages.Proto3.TestAllTypes();
+ }
+ Corecursive.MergeFrom(other.Corecursive);
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 8: {
+ A = input.ReadInt32();
+ break;
+ }
+ case 18: {
+ if (corecursive_ == null) {
+ corecursive_ = new global::ProtobufTestMessages.Proto3.TestAllTypes();
+ }
+ input.ReadMessage(corecursive_);
+ break;
+ }
+ }
+ }
+ }
+
+ }
+
+ }
+ #endregion
+
+ }
+
+ public sealed partial class ForeignMessage : pb::IMessage<ForeignMessage> {
+ private static readonly pb::MessageParser<ForeignMessage> _parser = new pb::MessageParser<ForeignMessage>(() => new ForeignMessage());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<ForeignMessage> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::ProtobufTestMessages.Proto3.TestMessagesProto3Reflection.Descriptor.MessageTypes[1]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public ForeignMessage() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public ForeignMessage(ForeignMessage other) : this() {
+ c_ = other.c_;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public ForeignMessage Clone() {
+ return new ForeignMessage(this);
+ }
+
+ /// <summary>Field number for the "c" field.</summary>
+ public const int CFieldNumber = 1;
+ private int c_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int C {
+ get { return c_; }
+ set {
+ c_ = value;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as ForeignMessage);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(ForeignMessage other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ if (C != other.C) return false;
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ if (C != 0) hash ^= C.GetHashCode();
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (C != 0) {
+ output.WriteRawTag(8);
+ output.WriteInt32(C);
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ if (C != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(C);
+ }
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(ForeignMessage other) {
+ if (other == null) {
+ return;
+ }
+ if (other.C != 0) {
+ C = other.C;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 8: {
+ C = input.ReadInt32();
+ break;
+ }
+ }
+ }
+ }
+
+ }
+
+ #endregion
+
+}
+
+#endregion Designer generated code
diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestCustomOptionsProto3.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestCustomOptionsProto3.cs
new file mode 100644
index 00000000..e21ede9c
--- /dev/null
+++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestCustomOptionsProto3.cs
@@ -0,0 +1,2625 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: unittest_custom_options_proto3.proto
+#pragma warning disable 1591, 0612, 3021
+#region Designer generated code
+
+using pb = global::Google.Protobuf;
+using pbc = global::Google.Protobuf.Collections;
+using pbr = global::Google.Protobuf.Reflection;
+using scg = global::System.Collections.Generic;
+namespace UnitTest.Issues.TestProtos {
+
+ /// <summary>Holder for reflection information generated from unittest_custom_options_proto3.proto</summary>
+ public static partial class UnittestCustomOptionsProto3Reflection {
+
+ #region Descriptor
+ /// <summary>File descriptor for unittest_custom_options_proto3.proto</summary>
+ public static pbr::FileDescriptor Descriptor {
+ get { return descriptor; }
+ }
+ private static pbr::FileDescriptor descriptor;
+
+ static UnittestCustomOptionsProto3Reflection() {
+ byte[] descriptorData = global::System.Convert.FromBase64String(
+ string.Concat(
+ "CiR1bml0dGVzdF9jdXN0b21fb3B0aW9uc19wcm90bzMucHJvdG8SEXByb3Rv",
+ "YnVmX3VuaXR0ZXN0GiBnb29nbGUvcHJvdG9idWYvZGVzY3JpcHRvci5wcm90",
+ "byLXAQocVGVzdE1lc3NhZ2VXaXRoQ3VzdG9tT3B0aW9ucxIeCgZmaWVsZDEY",
+ "ASABKAlCDggBweDDHS3hdQoCAAAAEhUKC29uZW9mX2ZpZWxkGAIgASgFSAAi",
+ "UwoGQW5FbnVtEhYKEkFORU5VTV9VTlNQRUNJRklFRBAAEg8KC0FORU5VTV9W",
+ "QUwxEAESFgoLQU5FTlVNX1ZBTDIQAhoFsIb6BXsaCMX2yR3r/P//OhAIAODp",
+ "wh3I//////////8BQhkKB0FuT25lb2YSDviswx2d//////////8BIhgKFkN1",
+ "c3RvbU9wdGlvbkZvb1JlcXVlc3QiGQoXQ3VzdG9tT3B0aW9uRm9vUmVzcG9u",
+ "c2UiHgocQ3VzdG9tT3B0aW9uRm9vQ2xpZW50TWVzc2FnZSIeChxDdXN0b21P",
+ "cHRpb25Gb29TZXJ2ZXJNZXNzYWdlIo8BChpEdW1teU1lc3NhZ2VDb250YWlu",
+ "aW5nRW51bSJxCgxUZXN0RW51bVR5cGUSIAocVEVTVF9PUFRJT05fRU5VTV9V",
+ "TlNQRUNJRklFRBAAEhoKFlRFU1RfT1BUSU9OX0VOVU1fVFlQRTEQFhIjChZU",
+ "RVNUX09QVElPTl9FTlVNX1RZUEUyEOn//////////wEiIQofRHVtbXlNZXNz",
+ "YWdlSW52YWxpZEFzT3B0aW9uVHlwZSKKAQocQ3VzdG9tT3B0aW9uTWluSW50",
+ "ZWdlclZhbHVlczpq0N6yHQDoxrIdgICAgPj/////AbC8sh2AgICAgICAgIAB",
+ "gJOyHQD49bAdAIDEsB3/////D/iXsB3///////////8BnfWvHQAAAACR7q8d",
+ "AAAAAAAAAACtja8dAAAAgJnWqB0AAAAAAAAAgCKRAQocQ3VzdG9tT3B0aW9u",
+ "TWF4SW50ZWdlclZhbHVlczpx0N6yHQHoxrId/////wewvLId//////////9/",
+ "gJOyHf////8P+PWwHf///////////wGAxLAd/v///w/4l7Ad/v//////////",
+ "AZ31rx3/////ke6vHf//////////rY2vHf///3+Z1qgd/////////38ibgoX",
+ "Q3VzdG9tT3B0aW9uT3RoZXJWYWx1ZXM6U+jGsh2c//////////8B9d+jHeeH",
+ "RUHp3KId+1mMQsrA8z+q3KIdDkhlbGxvLCAiV29ybGQistmiHQtIZWxsbwBX",
+ "b3JsZIjZoh3p//////////8BIjQKHFNldHRpbmdSZWFsc0Zyb21Qb3NpdGl2",
+ "ZUludHM6FPXfox0AAEBB6dyiHQAAAAAAQGNAIjQKHFNldHRpbmdSZWFsc0Zy",
+ "b21OZWdhdGl2ZUludHM6FPXfox0AAEDB6dyiHQAAAAAAQGPAIksKEkNvbXBs",
+ "ZXhPcHRpb25UeXBlMRILCgNmb28YASABKAUSDAoEZm9vMhgCIAEoBRIMCgRm",
+ "b28zGAMgASgFEgwKBGZvbzQYBCADKAUigQMKEkNvbXBsZXhPcHRpb25UeXBl",
+ "MhIyCgNiYXIYASABKAsyJS5wcm90b2J1Zl91bml0dGVzdC5Db21wbGV4T3B0",
+ "aW9uVHlwZTESCwoDYmF6GAIgASgFEkYKBGZyZWQYAyABKAsyOC5wcm90b2J1",
+ "Zl91bml0dGVzdC5Db21wbGV4T3B0aW9uVHlwZTIuQ29tcGxleE9wdGlvblR5",
+ "cGU0EkgKBmJhcm5leRgEIAMoCzI4LnByb3RvYnVmX3VuaXR0ZXN0LkNvbXBs",
+ "ZXhPcHRpb25UeXBlMi5Db21wbGV4T3B0aW9uVHlwZTQalwEKEkNvbXBsZXhP",
+ "cHRpb25UeXBlNBINCgV3YWxkbxgBIAEoBTJyCgxjb21wbGV4X29wdDQSHy5n",
+ "b29nbGUucHJvdG9idWYuTWVzc2FnZU9wdGlvbnMYivXRAyABKAsyOC5wcm90",
+ "b2J1Zl91bml0dGVzdC5Db21wbGV4T3B0aW9uVHlwZTIuQ29tcGxleE9wdGlv",
+ "blR5cGU0IiEKEkNvbXBsZXhPcHRpb25UeXBlMxILCgNxdXgYASABKAUibAoV",
+ "VmFyaW91c0NvbXBsZXhPcHRpb25zOlOi4pUdAggqouKVHQIgY6LilR0CIFiq",
+ "/ZAdAxDbB6r9kB0FCgMI5wXSqI8dAwizD6r9kB0FGgMIwQKq/ZAdBCICCGWq",
+ "/ZAdBSIDCNQB+t6QHQIICSJMCglBZ2dyZWdhdGUSCQoBaRgBIAEoBRIJCgFz",
+ "GAIgASgJEikKA3N1YhgDIAEoCzIcLnByb3RvYnVmX3VuaXR0ZXN0LkFnZ3Jl",
+ "Z2F0ZSJZChBBZ2dyZWdhdGVNZXNzYWdlEikKCWZpZWxkbmFtZRgBIAEoBUIW",
+ "8qGHOxESD0ZpZWxkQW5ub3RhdGlvbjoawtGGOxUIZRIRTWVzc2FnZUFubm90",
+ "YXRpb24ilwEKEE5lc3RlZE9wdGlvblR5cGUaOwoNTmVzdGVkTWVzc2FnZRIi",
+ "CgxuZXN0ZWRfZmllbGQYASABKAVCDMHgwx3qAwAAAAAAADoG4OnCHekHIkYK",
+ "Ck5lc3RlZEVudW0SDwoLVU5TUEVDSUZJRUQQABIdChFORVNURURfRU5VTV9W",
+ "QUxVRRABGgawhvoF7AcaCMX2yR3rAwAAKlIKCk1ldGhvZE9wdDESGgoWTUVU",
+ "SE9ET1BUMV9VTlNQRUNJRklFRBAAEhMKD01FVEhPRE9QVDFfVkFMMRABEhMK",
+ "D01FVEhPRE9QVDFfVkFMMhACKl4KDUFnZ3JlZ2F0ZUVudW0SDwoLVU5TUEVD",
+ "SUZJRUQQABIlCgVWQUxVRRABGhrK/Ik7FRITRW51bVZhbHVlQW5ub3RhdGlv",
+ "bhoVkpWIOxASDkVudW1Bbm5vdGF0aW9uMo4BChxUZXN0U2VydmljZVdpdGhD",
+ "dXN0b21PcHRpb25zEmMKA0ZvbxIpLnByb3RvYnVmX3VuaXR0ZXN0LkN1c3Rv",
+ "bU9wdGlvbkZvb1JlcXVlc3QaKi5wcm90b2J1Zl91bml0dGVzdC5DdXN0b21P",
+ "cHRpb25Gb29SZXNwb25zZSIF4PqMHgIaCZCyix7T24DLSTKZAQoQQWdncmVn",
+ "YXRlU2VydmljZRJrCgZNZXRob2QSIy5wcm90b2J1Zl91bml0dGVzdC5BZ2dy",
+ "ZWdhdGVNZXNzYWdlGiMucHJvdG9idWZfdW5pdHRlc3QuQWdncmVnYXRlTWVz",
+ "c2FnZSIXysiWOxISEE1ldGhvZEFubm90YXRpb24aGMr7jjsTEhFTZXJ2aWNl",
+ "QW5ub3RhdGlvbjoyCglmaWxlX29wdDESHC5nb29nbGUucHJvdG9idWYuRmls",
+ "ZU9wdGlvbnMYjp3YAyABKAQ6OAoMbWVzc2FnZV9vcHQxEh8uZ29vZ2xlLnBy",
+ "b3RvYnVmLk1lc3NhZ2VPcHRpb25zGJyt2AMgASgFOjQKCmZpZWxkX29wdDES",
+ "HS5nb29nbGUucHJvdG9idWYuRmllbGRPcHRpb25zGIi82AMgASgGOjQKCm9u",
+ "ZW9mX29wdDESHS5nb29nbGUucHJvdG9idWYuT25lb2ZPcHRpb25zGM+12AMg",
+ "ASgFOjIKCWVudW1fb3B0MRIcLmdvb2dsZS5wcm90b2J1Zi5FbnVtT3B0aW9u",
+ "cxjontkDIAEoDzo8Cg9lbnVtX3ZhbHVlX29wdDESIS5nb29nbGUucHJvdG9i",
+ "dWYuRW51bVZhbHVlT3B0aW9ucxjmoF8gASgFOjgKDHNlcnZpY2Vfb3B0MRIf",
+ "Lmdvb2dsZS5wcm90b2J1Zi5TZXJ2aWNlT3B0aW9ucxiituEDIAEoEjpVCgtt",
+ "ZXRob2Rfb3B0MRIeLmdvb2dsZS5wcm90b2J1Zi5NZXRob2RPcHRpb25zGKzP",
+ "4QMgASgOMh0ucHJvdG9idWZfdW5pdHRlc3QuTWV0aG9kT3B0MTo0Cghib29s",
+ "X29wdBIfLmdvb2dsZS5wcm90b2J1Zi5NZXNzYWdlT3B0aW9ucxjqq9YDIAEo",
+ "CDo1CglpbnQzMl9vcHQSHy5nb29nbGUucHJvdG9idWYuTWVzc2FnZU9wdGlv",
+ "bnMY7ajWAyABKAU6NQoJaW50NjRfb3B0Eh8uZ29vZ2xlLnByb3RvYnVmLk1l",
+ "c3NhZ2VPcHRpb25zGMan1gMgASgDOjYKCnVpbnQzMl9vcHQSHy5nb29nbGUu",
+ "cHJvdG9idWYuTWVzc2FnZU9wdGlvbnMYsKLWAyABKA06NgoKdWludDY0X29w",
+ "dBIfLmdvb2dsZS5wcm90b2J1Zi5NZXNzYWdlT3B0aW9ucxjfjtYDIAEoBDo2",
+ "CgpzaW50MzJfb3B0Eh8uZ29vZ2xlLnByb3RvYnVmLk1lc3NhZ2VPcHRpb25z",
+ "GMCI1gMgASgROjYKCnNpbnQ2NF9vcHQSHy5nb29nbGUucHJvdG9idWYuTWVz",
+ "c2FnZU9wdGlvbnMY/4LWAyABKBI6NwoLZml4ZWQzMl9vcHQSHy5nb29nbGUu",
+ "cHJvdG9idWYuTWVzc2FnZU9wdGlvbnMY0/7VAyABKAc6NwoLZml4ZWQ2NF9v",
+ "cHQSHy5nb29nbGUucHJvdG9idWYuTWVzc2FnZU9wdGlvbnMY4v3VAyABKAY6",
+ "OAoMc2ZpeGVkMzJfb3B0Eh8uZ29vZ2xlLnByb3RvYnVmLk1lc3NhZ2VPcHRp",
+ "b25zGNXx1QMgASgPOjgKDHNmaXhlZDY0X29wdBIfLmdvb2dsZS5wcm90b2J1",
+ "Zi5NZXNzYWdlT3B0aW9ucxjjitUDIAEoEDo1CglmbG9hdF9vcHQSHy5nb29n",
+ "bGUucHJvdG9idWYuTWVzc2FnZU9wdGlvbnMY/rvUAyABKAI6NgoKZG91Ymxl",
+ "X29wdBIfLmdvb2dsZS5wcm90b2J1Zi5NZXNzYWdlT3B0aW9ucxjNq9QDIAEo",
+ "ATo2CgpzdHJpbmdfb3B0Eh8uZ29vZ2xlLnByb3RvYnVmLk1lc3NhZ2VPcHRp",
+ "b25zGMWr1AMgASgJOjUKCWJ5dGVzX29wdBIfLmdvb2dsZS5wcm90b2J1Zi5N",
+ "ZXNzYWdlT3B0aW9ucxiWq9QDIAEoDDpwCghlbnVtX29wdBIfLmdvb2dsZS5w",
+ "cm90b2J1Zi5NZXNzYWdlT3B0aW9ucxiRq9QDIAEoDjI6LnByb3RvYnVmX3Vu",
+ "aXR0ZXN0LkR1bW15TWVzc2FnZUNvbnRhaW5pbmdFbnVtLlRlc3RFbnVtVHlw",
+ "ZTpwChBtZXNzYWdlX3R5cGVfb3B0Eh8uZ29vZ2xlLnByb3RvYnVmLk1lc3Nh",
+ "Z2VPcHRpb25zGK/y0wMgASgLMjIucHJvdG9idWZfdW5pdHRlc3QuRHVtbXlN",
+ "ZXNzYWdlSW52YWxpZEFzT3B0aW9uVHlwZTpfCgxjb21wbGV4X29wdDESHy5n",
+ "b29nbGUucHJvdG9idWYuTWVzc2FnZU9wdGlvbnMYpNzSAyABKAsyJS5wcm90",
+ "b2J1Zl91bml0dGVzdC5Db21wbGV4T3B0aW9uVHlwZTE6XwoMY29tcGxleF9v",
+ "cHQyEh8uZ29vZ2xlLnByb3RvYnVmLk1lc3NhZ2VPcHRpb25zGNWP0gMgASgL",
+ "MiUucHJvdG9idWZfdW5pdHRlc3QuQ29tcGxleE9wdGlvblR5cGUyOl8KDGNv",
+ "bXBsZXhfb3B0MxIfLmdvb2dsZS5wcm90b2J1Zi5NZXNzYWdlT3B0aW9ucxjv",
+ "i9IDIAEoCzIlLnByb3RvYnVmX3VuaXR0ZXN0LkNvbXBsZXhPcHRpb25UeXBl",
+ "MzpOCgdmaWxlb3B0EhwuZ29vZ2xlLnByb3RvYnVmLkZpbGVPcHRpb25zGM/d",
+ "sAcgASgLMhwucHJvdG9idWZfdW5pdHRlc3QuQWdncmVnYXRlOlAKBm1zZ29w",
+ "dBIfLmdvb2dsZS5wcm90b2J1Zi5NZXNzYWdlT3B0aW9ucxiY6rAHIAEoCzIc",
+ "LnByb3RvYnVmX3VuaXR0ZXN0LkFnZ3JlZ2F0ZTpQCghmaWVsZG9wdBIdLmdv",
+ "b2dsZS5wcm90b2J1Zi5GaWVsZE9wdGlvbnMYnvSwByABKAsyHC5wcm90b2J1",
+ "Zl91bml0dGVzdC5BZ2dyZWdhdGU6TgoHZW51bW9wdBIcLmdvb2dsZS5wcm90",
+ "b2J1Zi5FbnVtT3B0aW9ucxjSgrEHIAEoCzIcLnByb3RvYnVmX3VuaXR0ZXN0",
+ "LkFnZ3JlZ2F0ZTpWCgplbnVtdmFsb3B0EiEuZ29vZ2xlLnByb3RvYnVmLkVu",
+ "dW1WYWx1ZU9wdGlvbnMYyZ+xByABKAsyHC5wcm90b2J1Zl91bml0dGVzdC5B",
+ "Z2dyZWdhdGU6VAoKc2VydmljZW9wdBIfLmdvb2dsZS5wcm90b2J1Zi5TZXJ2",
+ "aWNlT3B0aW9ucxi577EHIAEoCzIcLnByb3RvYnVmX3VuaXR0ZXN0LkFnZ3Jl",
+ "Z2F0ZTpSCgltZXRob2RvcHQSHi5nb29nbGUucHJvdG9idWYuTWV0aG9kT3B0",
+ "aW9ucxiJ6bIHIAEoCzIcLnByb3RvYnVmX3VuaXR0ZXN0LkFnZ3JlZ2F0ZUJV",
+ "qgIaVW5pdFRlc3QuSXNzdWVzLlRlc3RQcm90b3Pw6MEd6q3A5ST67IU7Kghk",
+ "Eg5GaWxlQW5ub3RhdGlvbhoWEhROZXN0ZWRGaWxlQW5ub3RhdGlvbmIGcHJv",
+ "dG8z"));
+ descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
+ new pbr::FileDescriptor[] { pbr::FileDescriptor.DescriptorProtoFileDescriptor, },
+ new pbr::GeneratedClrTypeInfo(new[] {typeof(global::UnitTest.Issues.TestProtos.MethodOpt1), typeof(global::UnitTest.Issues.TestProtos.AggregateEnum), }, new pbr::GeneratedClrTypeInfo[] {
+ new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.TestMessageWithCustomOptions), global::UnitTest.Issues.TestProtos.TestMessageWithCustomOptions.Parser, new[]{ "Field1", "OneofField" }, new[]{ "AnOneof" }, new[]{ typeof(global::UnitTest.Issues.TestProtos.TestMessageWithCustomOptions.Types.AnEnum) }, null),
+ new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.CustomOptionFooRequest), global::UnitTest.Issues.TestProtos.CustomOptionFooRequest.Parser, null, null, null, null),
+ new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.CustomOptionFooResponse), global::UnitTest.Issues.TestProtos.CustomOptionFooResponse.Parser, null, null, null, null),
+ new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.CustomOptionFooClientMessage), global::UnitTest.Issues.TestProtos.CustomOptionFooClientMessage.Parser, null, null, null, null),
+ new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.CustomOptionFooServerMessage), global::UnitTest.Issues.TestProtos.CustomOptionFooServerMessage.Parser, null, null, null, null),
+ new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.DummyMessageContainingEnum), global::UnitTest.Issues.TestProtos.DummyMessageContainingEnum.Parser, null, null, new[]{ typeof(global::UnitTest.Issues.TestProtos.DummyMessageContainingEnum.Types.TestEnumType) }, null),
+ new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.DummyMessageInvalidAsOptionType), global::UnitTest.Issues.TestProtos.DummyMessageInvalidAsOptionType.Parser, null, null, null, null),
+ new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.CustomOptionMinIntegerValues), global::UnitTest.Issues.TestProtos.CustomOptionMinIntegerValues.Parser, null, null, null, null),
+ new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.CustomOptionMaxIntegerValues), global::UnitTest.Issues.TestProtos.CustomOptionMaxIntegerValues.Parser, null, null, null, null),
+ new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.CustomOptionOtherValues), global::UnitTest.Issues.TestProtos.CustomOptionOtherValues.Parser, null, null, null, null),
+ new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.SettingRealsFromPositiveInts), global::UnitTest.Issues.TestProtos.SettingRealsFromPositiveInts.Parser, null, null, null, null),
+ new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.SettingRealsFromNegativeInts), global::UnitTest.Issues.TestProtos.SettingRealsFromNegativeInts.Parser, null, null, null, null),
+ new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.ComplexOptionType1), global::UnitTest.Issues.TestProtos.ComplexOptionType1.Parser, new[]{ "Foo", "Foo2", "Foo3", "Foo4" }, null, null, null),
+ new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.ComplexOptionType2), global::UnitTest.Issues.TestProtos.ComplexOptionType2.Parser, new[]{ "Bar", "Baz", "Fred", "Barney" }, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4), global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4.Parser, new[]{ "Waldo" }, null, null, null)}),
+ new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.ComplexOptionType3), global::UnitTest.Issues.TestProtos.ComplexOptionType3.Parser, new[]{ "Qux" }, null, null, null),
+ new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.VariousComplexOptions), global::UnitTest.Issues.TestProtos.VariousComplexOptions.Parser, null, null, null, null),
+ new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.Aggregate), global::UnitTest.Issues.TestProtos.Aggregate.Parser, new[]{ "I", "S", "Sub" }, null, null, null),
+ new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.AggregateMessage), global::UnitTest.Issues.TestProtos.AggregateMessage.Parser, new[]{ "Fieldname" }, null, null, null),
+ new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.NestedOptionType), global::UnitTest.Issues.TestProtos.NestedOptionType.Parser, null, null, new[]{ typeof(global::UnitTest.Issues.TestProtos.NestedOptionType.Types.NestedEnum) }, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::UnitTest.Issues.TestProtos.NestedOptionType.Types.NestedMessage), global::UnitTest.Issues.TestProtos.NestedOptionType.Types.NestedMessage.Parser, new[]{ "NestedField" }, null, null, null)})
+ }));
+ }
+ #endregion
+
+ }
+ #region Enums
+ public enum MethodOpt1 {
+ [pbr::OriginalName("METHODOPT1_UNSPECIFIED")] Unspecified = 0,
+ [pbr::OriginalName("METHODOPT1_VAL1")] Val1 = 1,
+ [pbr::OriginalName("METHODOPT1_VAL2")] Val2 = 2,
+ }
+
+ public enum AggregateEnum {
+ [pbr::OriginalName("UNSPECIFIED")] Unspecified = 0,
+ [pbr::OriginalName("VALUE")] Value = 1,
+ }
+
+ #endregion
+
+ #region Messages
+ /// <summary>
+ /// A test message with custom options at all possible locations (and also some
+ /// regular options, to make sure they interact nicely).
+ /// </summary>
+ public sealed partial class TestMessageWithCustomOptions : pb::IMessage<TestMessageWithCustomOptions> {
+ private static readonly pb::MessageParser<TestMessageWithCustomOptions> _parser = new pb::MessageParser<TestMessageWithCustomOptions>(() => new TestMessageWithCustomOptions());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<TestMessageWithCustomOptions> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[0]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public TestMessageWithCustomOptions() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public TestMessageWithCustomOptions(TestMessageWithCustomOptions other) : this() {
+ field1_ = other.field1_;
+ switch (other.AnOneofCase) {
+ case AnOneofOneofCase.OneofField:
+ OneofField = other.OneofField;
+ break;
+ }
+
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public TestMessageWithCustomOptions Clone() {
+ return new TestMessageWithCustomOptions(this);
+ }
+
+ /// <summary>Field number for the "field1" field.</summary>
+ public const int Field1FieldNumber = 1;
+ private string field1_ = "";
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public string Field1 {
+ get { return field1_; }
+ set {
+ field1_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
+ }
+ }
+
+ /// <summary>Field number for the "oneof_field" field.</summary>
+ public const int OneofFieldFieldNumber = 2;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int OneofField {
+ get { return anOneofCase_ == AnOneofOneofCase.OneofField ? (int) anOneof_ : 0; }
+ set {
+ anOneof_ = value;
+ anOneofCase_ = AnOneofOneofCase.OneofField;
+ }
+ }
+
+ private object anOneof_;
+ /// <summary>Enum of possible cases for the "AnOneof" oneof.</summary>
+ public enum AnOneofOneofCase {
+ None = 0,
+ OneofField = 2,
+ }
+ private AnOneofOneofCase anOneofCase_ = AnOneofOneofCase.None;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public AnOneofOneofCase AnOneofCase {
+ get { return anOneofCase_; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void ClearAnOneof() {
+ anOneofCase_ = AnOneofOneofCase.None;
+ anOneof_ = null;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as TestMessageWithCustomOptions);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(TestMessageWithCustomOptions other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ if (Field1 != other.Field1) return false;
+ if (OneofField != other.OneofField) return false;
+ if (AnOneofCase != other.AnOneofCase) return false;
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ if (Field1.Length != 0) hash ^= Field1.GetHashCode();
+ if (anOneofCase_ == AnOneofOneofCase.OneofField) hash ^= OneofField.GetHashCode();
+ hash ^= (int) anOneofCase_;
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (Field1.Length != 0) {
+ output.WriteRawTag(10);
+ output.WriteString(Field1);
+ }
+ if (anOneofCase_ == AnOneofOneofCase.OneofField) {
+ output.WriteRawTag(16);
+ output.WriteInt32(OneofField);
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ if (Field1.Length != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(Field1);
+ }
+ if (anOneofCase_ == AnOneofOneofCase.OneofField) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(OneofField);
+ }
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(TestMessageWithCustomOptions other) {
+ if (other == null) {
+ return;
+ }
+ if (other.Field1.Length != 0) {
+ Field1 = other.Field1;
+ }
+ switch (other.AnOneofCase) {
+ case AnOneofOneofCase.OneofField:
+ OneofField = other.OneofField;
+ break;
+ }
+
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 10: {
+ Field1 = input.ReadString();
+ break;
+ }
+ case 16: {
+ OneofField = input.ReadInt32();
+ break;
+ }
+ }
+ }
+ }
+
+ #region Nested types
+ /// <summary>Container for nested types declared in the TestMessageWithCustomOptions message type.</summary>
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static partial class Types {
+ public enum AnEnum {
+ [pbr::OriginalName("ANENUM_UNSPECIFIED")] Unspecified = 0,
+ [pbr::OriginalName("ANENUM_VAL1")] Val1 = 1,
+ [pbr::OriginalName("ANENUM_VAL2")] Val2 = 2,
+ }
+
+ }
+ #endregion
+
+ }
+
+ /// <summary>
+ /// A test RPC service with custom options at all possible locations (and also
+ /// some regular options, to make sure they interact nicely).
+ /// </summary>
+ public sealed partial class CustomOptionFooRequest : pb::IMessage<CustomOptionFooRequest> {
+ private static readonly pb::MessageParser<CustomOptionFooRequest> _parser = new pb::MessageParser<CustomOptionFooRequest>(() => new CustomOptionFooRequest());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<CustomOptionFooRequest> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[1]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public CustomOptionFooRequest() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public CustomOptionFooRequest(CustomOptionFooRequest other) : this() {
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public CustomOptionFooRequest Clone() {
+ return new CustomOptionFooRequest(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as CustomOptionFooRequest);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(CustomOptionFooRequest other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(CustomOptionFooRequest other) {
+ if (other == null) {
+ return;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ }
+ }
+ }
+
+ }
+
+ public sealed partial class CustomOptionFooResponse : pb::IMessage<CustomOptionFooResponse> {
+ private static readonly pb::MessageParser<CustomOptionFooResponse> _parser = new pb::MessageParser<CustomOptionFooResponse>(() => new CustomOptionFooResponse());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<CustomOptionFooResponse> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[2]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public CustomOptionFooResponse() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public CustomOptionFooResponse(CustomOptionFooResponse other) : this() {
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public CustomOptionFooResponse Clone() {
+ return new CustomOptionFooResponse(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as CustomOptionFooResponse);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(CustomOptionFooResponse other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(CustomOptionFooResponse other) {
+ if (other == null) {
+ return;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ }
+ }
+ }
+
+ }
+
+ public sealed partial class CustomOptionFooClientMessage : pb::IMessage<CustomOptionFooClientMessage> {
+ private static readonly pb::MessageParser<CustomOptionFooClientMessage> _parser = new pb::MessageParser<CustomOptionFooClientMessage>(() => new CustomOptionFooClientMessage());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<CustomOptionFooClientMessage> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[3]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public CustomOptionFooClientMessage() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public CustomOptionFooClientMessage(CustomOptionFooClientMessage other) : this() {
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public CustomOptionFooClientMessage Clone() {
+ return new CustomOptionFooClientMessage(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as CustomOptionFooClientMessage);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(CustomOptionFooClientMessage other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(CustomOptionFooClientMessage other) {
+ if (other == null) {
+ return;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ }
+ }
+ }
+
+ }
+
+ public sealed partial class CustomOptionFooServerMessage : pb::IMessage<CustomOptionFooServerMessage> {
+ private static readonly pb::MessageParser<CustomOptionFooServerMessage> _parser = new pb::MessageParser<CustomOptionFooServerMessage>(() => new CustomOptionFooServerMessage());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<CustomOptionFooServerMessage> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[4]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public CustomOptionFooServerMessage() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public CustomOptionFooServerMessage(CustomOptionFooServerMessage other) : this() {
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public CustomOptionFooServerMessage Clone() {
+ return new CustomOptionFooServerMessage(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as CustomOptionFooServerMessage);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(CustomOptionFooServerMessage other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(CustomOptionFooServerMessage other) {
+ if (other == null) {
+ return;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ }
+ }
+ }
+
+ }
+
+ public sealed partial class DummyMessageContainingEnum : pb::IMessage<DummyMessageContainingEnum> {
+ private static readonly pb::MessageParser<DummyMessageContainingEnum> _parser = new pb::MessageParser<DummyMessageContainingEnum>(() => new DummyMessageContainingEnum());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<DummyMessageContainingEnum> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[5]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public DummyMessageContainingEnum() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public DummyMessageContainingEnum(DummyMessageContainingEnum other) : this() {
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public DummyMessageContainingEnum Clone() {
+ return new DummyMessageContainingEnum(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as DummyMessageContainingEnum);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(DummyMessageContainingEnum other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(DummyMessageContainingEnum other) {
+ if (other == null) {
+ return;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ }
+ }
+ }
+
+ #region Nested types
+ /// <summary>Container for nested types declared in the DummyMessageContainingEnum message type.</summary>
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static partial class Types {
+ public enum TestEnumType {
+ [pbr::OriginalName("TEST_OPTION_ENUM_UNSPECIFIED")] TestOptionEnumUnspecified = 0,
+ [pbr::OriginalName("TEST_OPTION_ENUM_TYPE1")] TestOptionEnumType1 = 22,
+ [pbr::OriginalName("TEST_OPTION_ENUM_TYPE2")] TestOptionEnumType2 = -23,
+ }
+
+ }
+ #endregion
+
+ }
+
+ public sealed partial class DummyMessageInvalidAsOptionType : pb::IMessage<DummyMessageInvalidAsOptionType> {
+ private static readonly pb::MessageParser<DummyMessageInvalidAsOptionType> _parser = new pb::MessageParser<DummyMessageInvalidAsOptionType>(() => new DummyMessageInvalidAsOptionType());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<DummyMessageInvalidAsOptionType> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[6]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public DummyMessageInvalidAsOptionType() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public DummyMessageInvalidAsOptionType(DummyMessageInvalidAsOptionType other) : this() {
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public DummyMessageInvalidAsOptionType Clone() {
+ return new DummyMessageInvalidAsOptionType(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as DummyMessageInvalidAsOptionType);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(DummyMessageInvalidAsOptionType other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(DummyMessageInvalidAsOptionType other) {
+ if (other == null) {
+ return;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ }
+ }
+ }
+
+ }
+
+ public sealed partial class CustomOptionMinIntegerValues : pb::IMessage<CustomOptionMinIntegerValues> {
+ private static readonly pb::MessageParser<CustomOptionMinIntegerValues> _parser = new pb::MessageParser<CustomOptionMinIntegerValues>(() => new CustomOptionMinIntegerValues());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<CustomOptionMinIntegerValues> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[7]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public CustomOptionMinIntegerValues() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public CustomOptionMinIntegerValues(CustomOptionMinIntegerValues other) : this() {
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public CustomOptionMinIntegerValues Clone() {
+ return new CustomOptionMinIntegerValues(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as CustomOptionMinIntegerValues);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(CustomOptionMinIntegerValues other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(CustomOptionMinIntegerValues other) {
+ if (other == null) {
+ return;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ }
+ }
+ }
+
+ }
+
+ public sealed partial class CustomOptionMaxIntegerValues : pb::IMessage<CustomOptionMaxIntegerValues> {
+ private static readonly pb::MessageParser<CustomOptionMaxIntegerValues> _parser = new pb::MessageParser<CustomOptionMaxIntegerValues>(() => new CustomOptionMaxIntegerValues());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<CustomOptionMaxIntegerValues> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[8]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public CustomOptionMaxIntegerValues() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public CustomOptionMaxIntegerValues(CustomOptionMaxIntegerValues other) : this() {
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public CustomOptionMaxIntegerValues Clone() {
+ return new CustomOptionMaxIntegerValues(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as CustomOptionMaxIntegerValues);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(CustomOptionMaxIntegerValues other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(CustomOptionMaxIntegerValues other) {
+ if (other == null) {
+ return;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ }
+ }
+ }
+
+ }
+
+ public sealed partial class CustomOptionOtherValues : pb::IMessage<CustomOptionOtherValues> {
+ private static readonly pb::MessageParser<CustomOptionOtherValues> _parser = new pb::MessageParser<CustomOptionOtherValues>(() => new CustomOptionOtherValues());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<CustomOptionOtherValues> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[9]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public CustomOptionOtherValues() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public CustomOptionOtherValues(CustomOptionOtherValues other) : this() {
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public CustomOptionOtherValues Clone() {
+ return new CustomOptionOtherValues(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as CustomOptionOtherValues);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(CustomOptionOtherValues other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(CustomOptionOtherValues other) {
+ if (other == null) {
+ return;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ }
+ }
+ }
+
+ }
+
+ public sealed partial class SettingRealsFromPositiveInts : pb::IMessage<SettingRealsFromPositiveInts> {
+ private static readonly pb::MessageParser<SettingRealsFromPositiveInts> _parser = new pb::MessageParser<SettingRealsFromPositiveInts>(() => new SettingRealsFromPositiveInts());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<SettingRealsFromPositiveInts> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[10]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public SettingRealsFromPositiveInts() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public SettingRealsFromPositiveInts(SettingRealsFromPositiveInts other) : this() {
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public SettingRealsFromPositiveInts Clone() {
+ return new SettingRealsFromPositiveInts(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as SettingRealsFromPositiveInts);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(SettingRealsFromPositiveInts other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(SettingRealsFromPositiveInts other) {
+ if (other == null) {
+ return;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ }
+ }
+ }
+
+ }
+
+ public sealed partial class SettingRealsFromNegativeInts : pb::IMessage<SettingRealsFromNegativeInts> {
+ private static readonly pb::MessageParser<SettingRealsFromNegativeInts> _parser = new pb::MessageParser<SettingRealsFromNegativeInts>(() => new SettingRealsFromNegativeInts());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<SettingRealsFromNegativeInts> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[11]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public SettingRealsFromNegativeInts() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public SettingRealsFromNegativeInts(SettingRealsFromNegativeInts other) : this() {
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public SettingRealsFromNegativeInts Clone() {
+ return new SettingRealsFromNegativeInts(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as SettingRealsFromNegativeInts);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(SettingRealsFromNegativeInts other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(SettingRealsFromNegativeInts other) {
+ if (other == null) {
+ return;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ }
+ }
+ }
+
+ }
+
+ public sealed partial class ComplexOptionType1 : pb::IMessage<ComplexOptionType1> {
+ private static readonly pb::MessageParser<ComplexOptionType1> _parser = new pb::MessageParser<ComplexOptionType1>(() => new ComplexOptionType1());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<ComplexOptionType1> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[12]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public ComplexOptionType1() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public ComplexOptionType1(ComplexOptionType1 other) : this() {
+ foo_ = other.foo_;
+ foo2_ = other.foo2_;
+ foo3_ = other.foo3_;
+ foo4_ = other.foo4_.Clone();
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public ComplexOptionType1 Clone() {
+ return new ComplexOptionType1(this);
+ }
+
+ /// <summary>Field number for the "foo" field.</summary>
+ public const int FooFieldNumber = 1;
+ private int foo_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int Foo {
+ get { return foo_; }
+ set {
+ foo_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "foo2" field.</summary>
+ public const int Foo2FieldNumber = 2;
+ private int foo2_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int Foo2 {
+ get { return foo2_; }
+ set {
+ foo2_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "foo3" field.</summary>
+ public const int Foo3FieldNumber = 3;
+ private int foo3_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int Foo3 {
+ get { return foo3_; }
+ set {
+ foo3_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "foo4" field.</summary>
+ public const int Foo4FieldNumber = 4;
+ private static readonly pb::FieldCodec<int> _repeated_foo4_codec
+ = pb::FieldCodec.ForInt32(34);
+ private readonly pbc::RepeatedField<int> foo4_ = new pbc::RepeatedField<int>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<int> Foo4 {
+ get { return foo4_; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as ComplexOptionType1);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(ComplexOptionType1 other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ if (Foo != other.Foo) return false;
+ if (Foo2 != other.Foo2) return false;
+ if (Foo3 != other.Foo3) return false;
+ if(!foo4_.Equals(other.foo4_)) return false;
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ if (Foo != 0) hash ^= Foo.GetHashCode();
+ if (Foo2 != 0) hash ^= Foo2.GetHashCode();
+ if (Foo3 != 0) hash ^= Foo3.GetHashCode();
+ hash ^= foo4_.GetHashCode();
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (Foo != 0) {
+ output.WriteRawTag(8);
+ output.WriteInt32(Foo);
+ }
+ if (Foo2 != 0) {
+ output.WriteRawTag(16);
+ output.WriteInt32(Foo2);
+ }
+ if (Foo3 != 0) {
+ output.WriteRawTag(24);
+ output.WriteInt32(Foo3);
+ }
+ foo4_.WriteTo(output, _repeated_foo4_codec);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ if (Foo != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(Foo);
+ }
+ if (Foo2 != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(Foo2);
+ }
+ if (Foo3 != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(Foo3);
+ }
+ size += foo4_.CalculateSize(_repeated_foo4_codec);
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(ComplexOptionType1 other) {
+ if (other == null) {
+ return;
+ }
+ if (other.Foo != 0) {
+ Foo = other.Foo;
+ }
+ if (other.Foo2 != 0) {
+ Foo2 = other.Foo2;
+ }
+ if (other.Foo3 != 0) {
+ Foo3 = other.Foo3;
+ }
+ foo4_.Add(other.foo4_);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 8: {
+ Foo = input.ReadInt32();
+ break;
+ }
+ case 16: {
+ Foo2 = input.ReadInt32();
+ break;
+ }
+ case 24: {
+ Foo3 = input.ReadInt32();
+ break;
+ }
+ case 34:
+ case 32: {
+ foo4_.AddEntriesFrom(input, _repeated_foo4_codec);
+ break;
+ }
+ }
+ }
+ }
+
+ }
+
+ public sealed partial class ComplexOptionType2 : pb::IMessage<ComplexOptionType2> {
+ private static readonly pb::MessageParser<ComplexOptionType2> _parser = new pb::MessageParser<ComplexOptionType2>(() => new ComplexOptionType2());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<ComplexOptionType2> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[13]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public ComplexOptionType2() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public ComplexOptionType2(ComplexOptionType2 other) : this() {
+ Bar = other.bar_ != null ? other.Bar.Clone() : null;
+ baz_ = other.baz_;
+ Fred = other.fred_ != null ? other.Fred.Clone() : null;
+ barney_ = other.barney_.Clone();
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public ComplexOptionType2 Clone() {
+ return new ComplexOptionType2(this);
+ }
+
+ /// <summary>Field number for the "bar" field.</summary>
+ public const int BarFieldNumber = 1;
+ private global::UnitTest.Issues.TestProtos.ComplexOptionType1 bar_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public global::UnitTest.Issues.TestProtos.ComplexOptionType1 Bar {
+ get { return bar_; }
+ set {
+ bar_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "baz" field.</summary>
+ public const int BazFieldNumber = 2;
+ private int baz_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int Baz {
+ get { return baz_; }
+ set {
+ baz_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "fred" field.</summary>
+ public const int FredFieldNumber = 3;
+ private global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4 fred_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4 Fred {
+ get { return fred_; }
+ set {
+ fred_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "barney" field.</summary>
+ public const int BarneyFieldNumber = 4;
+ private static readonly pb::FieldCodec<global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4> _repeated_barney_codec
+ = pb::FieldCodec.ForMessage(34, global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4.Parser);
+ private readonly pbc::RepeatedField<global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4> barney_ = new pbc::RepeatedField<global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4>();
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public pbc::RepeatedField<global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4> Barney {
+ get { return barney_; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as ComplexOptionType2);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(ComplexOptionType2 other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ if (!object.Equals(Bar, other.Bar)) return false;
+ if (Baz != other.Baz) return false;
+ if (!object.Equals(Fred, other.Fred)) return false;
+ if(!barney_.Equals(other.barney_)) return false;
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ if (bar_ != null) hash ^= Bar.GetHashCode();
+ if (Baz != 0) hash ^= Baz.GetHashCode();
+ if (fred_ != null) hash ^= Fred.GetHashCode();
+ hash ^= barney_.GetHashCode();
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (bar_ != null) {
+ output.WriteRawTag(10);
+ output.WriteMessage(Bar);
+ }
+ if (Baz != 0) {
+ output.WriteRawTag(16);
+ output.WriteInt32(Baz);
+ }
+ if (fred_ != null) {
+ output.WriteRawTag(26);
+ output.WriteMessage(Fred);
+ }
+ barney_.WriteTo(output, _repeated_barney_codec);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ if (bar_ != null) {
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(Bar);
+ }
+ if (Baz != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(Baz);
+ }
+ if (fred_ != null) {
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(Fred);
+ }
+ size += barney_.CalculateSize(_repeated_barney_codec);
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(ComplexOptionType2 other) {
+ if (other == null) {
+ return;
+ }
+ if (other.bar_ != null) {
+ if (bar_ == null) {
+ bar_ = new global::UnitTest.Issues.TestProtos.ComplexOptionType1();
+ }
+ Bar.MergeFrom(other.Bar);
+ }
+ if (other.Baz != 0) {
+ Baz = other.Baz;
+ }
+ if (other.fred_ != null) {
+ if (fred_ == null) {
+ fred_ = new global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4();
+ }
+ Fred.MergeFrom(other.Fred);
+ }
+ barney_.Add(other.barney_);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 10: {
+ if (bar_ == null) {
+ bar_ = new global::UnitTest.Issues.TestProtos.ComplexOptionType1();
+ }
+ input.ReadMessage(bar_);
+ break;
+ }
+ case 16: {
+ Baz = input.ReadInt32();
+ break;
+ }
+ case 26: {
+ if (fred_ == null) {
+ fred_ = new global::UnitTest.Issues.TestProtos.ComplexOptionType2.Types.ComplexOptionType4();
+ }
+ input.ReadMessage(fred_);
+ break;
+ }
+ case 34: {
+ barney_.AddEntriesFrom(input, _repeated_barney_codec);
+ break;
+ }
+ }
+ }
+ }
+
+ #region Nested types
+ /// <summary>Container for nested types declared in the ComplexOptionType2 message type.</summary>
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static partial class Types {
+ public sealed partial class ComplexOptionType4 : pb::IMessage<ComplexOptionType4> {
+ private static readonly pb::MessageParser<ComplexOptionType4> _parser = new pb::MessageParser<ComplexOptionType4>(() => new ComplexOptionType4());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<ComplexOptionType4> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::UnitTest.Issues.TestProtos.ComplexOptionType2.Descriptor.NestedTypes[0]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public ComplexOptionType4() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public ComplexOptionType4(ComplexOptionType4 other) : this() {
+ waldo_ = other.waldo_;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public ComplexOptionType4 Clone() {
+ return new ComplexOptionType4(this);
+ }
+
+ /// <summary>Field number for the "waldo" field.</summary>
+ public const int WaldoFieldNumber = 1;
+ private int waldo_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int Waldo {
+ get { return waldo_; }
+ set {
+ waldo_ = value;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as ComplexOptionType4);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(ComplexOptionType4 other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ if (Waldo != other.Waldo) return false;
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ if (Waldo != 0) hash ^= Waldo.GetHashCode();
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (Waldo != 0) {
+ output.WriteRawTag(8);
+ output.WriteInt32(Waldo);
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ if (Waldo != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(Waldo);
+ }
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(ComplexOptionType4 other) {
+ if (other == null) {
+ return;
+ }
+ if (other.Waldo != 0) {
+ Waldo = other.Waldo;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 8: {
+ Waldo = input.ReadInt32();
+ break;
+ }
+ }
+ }
+ }
+
+ }
+
+ }
+ #endregion
+
+ }
+
+ public sealed partial class ComplexOptionType3 : pb::IMessage<ComplexOptionType3> {
+ private static readonly pb::MessageParser<ComplexOptionType3> _parser = new pb::MessageParser<ComplexOptionType3>(() => new ComplexOptionType3());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<ComplexOptionType3> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[14]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public ComplexOptionType3() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public ComplexOptionType3(ComplexOptionType3 other) : this() {
+ qux_ = other.qux_;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public ComplexOptionType3 Clone() {
+ return new ComplexOptionType3(this);
+ }
+
+ /// <summary>Field number for the "qux" field.</summary>
+ public const int QuxFieldNumber = 1;
+ private int qux_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int Qux {
+ get { return qux_; }
+ set {
+ qux_ = value;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as ComplexOptionType3);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(ComplexOptionType3 other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ if (Qux != other.Qux) return false;
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ if (Qux != 0) hash ^= Qux.GetHashCode();
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (Qux != 0) {
+ output.WriteRawTag(8);
+ output.WriteInt32(Qux);
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ if (Qux != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(Qux);
+ }
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(ComplexOptionType3 other) {
+ if (other == null) {
+ return;
+ }
+ if (other.Qux != 0) {
+ Qux = other.Qux;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 8: {
+ Qux = input.ReadInt32();
+ break;
+ }
+ }
+ }
+ }
+
+ }
+
+ /// <summary>
+ /// Note that we try various different ways of naming the same extension.
+ /// </summary>
+ public sealed partial class VariousComplexOptions : pb::IMessage<VariousComplexOptions> {
+ private static readonly pb::MessageParser<VariousComplexOptions> _parser = new pb::MessageParser<VariousComplexOptions>(() => new VariousComplexOptions());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<VariousComplexOptions> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[15]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public VariousComplexOptions() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public VariousComplexOptions(VariousComplexOptions other) : this() {
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public VariousComplexOptions Clone() {
+ return new VariousComplexOptions(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as VariousComplexOptions);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(VariousComplexOptions other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(VariousComplexOptions other) {
+ if (other == null) {
+ return;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ }
+ }
+ }
+
+ }
+
+ /// <summary>
+ /// A helper type used to test aggregate option parsing
+ /// </summary>
+ public sealed partial class Aggregate : pb::IMessage<Aggregate> {
+ private static readonly pb::MessageParser<Aggregate> _parser = new pb::MessageParser<Aggregate>(() => new Aggregate());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<Aggregate> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[16]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public Aggregate() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public Aggregate(Aggregate other) : this() {
+ i_ = other.i_;
+ s_ = other.s_;
+ Sub = other.sub_ != null ? other.Sub.Clone() : null;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public Aggregate Clone() {
+ return new Aggregate(this);
+ }
+
+ /// <summary>Field number for the "i" field.</summary>
+ public const int IFieldNumber = 1;
+ private int i_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int I {
+ get { return i_; }
+ set {
+ i_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "s" field.</summary>
+ public const int SFieldNumber = 2;
+ private string s_ = "";
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public string S {
+ get { return s_; }
+ set {
+ s_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
+ }
+ }
+
+ /// <summary>Field number for the "sub" field.</summary>
+ public const int SubFieldNumber = 3;
+ private global::UnitTest.Issues.TestProtos.Aggregate sub_;
+ /// <summary>
+ /// A nested object
+ /// </summary>
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public global::UnitTest.Issues.TestProtos.Aggregate Sub {
+ get { return sub_; }
+ set {
+ sub_ = value;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as Aggregate);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(Aggregate other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ if (I != other.I) return false;
+ if (S != other.S) return false;
+ if (!object.Equals(Sub, other.Sub)) return false;
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ if (I != 0) hash ^= I.GetHashCode();
+ if (S.Length != 0) hash ^= S.GetHashCode();
+ if (sub_ != null) hash ^= Sub.GetHashCode();
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (I != 0) {
+ output.WriteRawTag(8);
+ output.WriteInt32(I);
+ }
+ if (S.Length != 0) {
+ output.WriteRawTag(18);
+ output.WriteString(S);
+ }
+ if (sub_ != null) {
+ output.WriteRawTag(26);
+ output.WriteMessage(Sub);
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ if (I != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(I);
+ }
+ if (S.Length != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(S);
+ }
+ if (sub_ != null) {
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(Sub);
+ }
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(Aggregate other) {
+ if (other == null) {
+ return;
+ }
+ if (other.I != 0) {
+ I = other.I;
+ }
+ if (other.S.Length != 0) {
+ S = other.S;
+ }
+ if (other.sub_ != null) {
+ if (sub_ == null) {
+ sub_ = new global::UnitTest.Issues.TestProtos.Aggregate();
+ }
+ Sub.MergeFrom(other.Sub);
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 8: {
+ I = input.ReadInt32();
+ break;
+ }
+ case 18: {
+ S = input.ReadString();
+ break;
+ }
+ case 26: {
+ if (sub_ == null) {
+ sub_ = new global::UnitTest.Issues.TestProtos.Aggregate();
+ }
+ input.ReadMessage(sub_);
+ break;
+ }
+ }
+ }
+ }
+
+ }
+
+ public sealed partial class AggregateMessage : pb::IMessage<AggregateMessage> {
+ private static readonly pb::MessageParser<AggregateMessage> _parser = new pb::MessageParser<AggregateMessage>(() => new AggregateMessage());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<AggregateMessage> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[17]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public AggregateMessage() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public AggregateMessage(AggregateMessage other) : this() {
+ fieldname_ = other.fieldname_;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public AggregateMessage Clone() {
+ return new AggregateMessage(this);
+ }
+
+ /// <summary>Field number for the "fieldname" field.</summary>
+ public const int FieldnameFieldNumber = 1;
+ private int fieldname_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int Fieldname {
+ get { return fieldname_; }
+ set {
+ fieldname_ = value;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as AggregateMessage);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(AggregateMessage other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ if (Fieldname != other.Fieldname) return false;
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ if (Fieldname != 0) hash ^= Fieldname.GetHashCode();
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (Fieldname != 0) {
+ output.WriteRawTag(8);
+ output.WriteInt32(Fieldname);
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ if (Fieldname != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(Fieldname);
+ }
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(AggregateMessage other) {
+ if (other == null) {
+ return;
+ }
+ if (other.Fieldname != 0) {
+ Fieldname = other.Fieldname;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 8: {
+ Fieldname = input.ReadInt32();
+ break;
+ }
+ }
+ }
+ }
+
+ }
+
+ /// <summary>
+ /// Test custom options for nested type.
+ /// </summary>
+ public sealed partial class NestedOptionType : pb::IMessage<NestedOptionType> {
+ private static readonly pb::MessageParser<NestedOptionType> _parser = new pb::MessageParser<NestedOptionType>(() => new NestedOptionType());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<NestedOptionType> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::UnitTest.Issues.TestProtos.UnittestCustomOptionsProto3Reflection.Descriptor.MessageTypes[18]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public NestedOptionType() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public NestedOptionType(NestedOptionType other) : this() {
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public NestedOptionType Clone() {
+ return new NestedOptionType(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as NestedOptionType);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(NestedOptionType other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(NestedOptionType other) {
+ if (other == null) {
+ return;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ }
+ }
+ }
+
+ #region Nested types
+ /// <summary>Container for nested types declared in the NestedOptionType message type.</summary>
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static partial class Types {
+ public enum NestedEnum {
+ [pbr::OriginalName("UNSPECIFIED")] Unspecified = 0,
+ [pbr::OriginalName("NESTED_ENUM_VALUE")] Value = 1,
+ }
+
+ public sealed partial class NestedMessage : pb::IMessage<NestedMessage> {
+ private static readonly pb::MessageParser<NestedMessage> _parser = new pb::MessageParser<NestedMessage>(() => new NestedMessage());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<NestedMessage> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::UnitTest.Issues.TestProtos.NestedOptionType.Descriptor.NestedTypes[0]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public NestedMessage() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public NestedMessage(NestedMessage other) : this() {
+ nestedField_ = other.nestedField_;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public NestedMessage Clone() {
+ return new NestedMessage(this);
+ }
+
+ /// <summary>Field number for the "nested_field" field.</summary>
+ public const int NestedFieldFieldNumber = 1;
+ private int nestedField_;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int NestedField {
+ get { return nestedField_; }
+ set {
+ nestedField_ = value;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as NestedMessage);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(NestedMessage other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ if (NestedField != other.NestedField) return false;
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ if (NestedField != 0) hash ^= NestedField.GetHashCode();
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (NestedField != 0) {
+ output.WriteRawTag(8);
+ output.WriteInt32(NestedField);
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ if (NestedField != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(NestedField);
+ }
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(NestedMessage other) {
+ if (other == null) {
+ return;
+ }
+ if (other.NestedField != 0) {
+ NestedField = other.NestedField;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 8: {
+ NestedField = input.ReadInt32();
+ break;
+ }
+ }
+ }
+ }
+
+ }
+
+ }
+ #endregion
+
+ }
+
+ #endregion
+
+}
+
+#endregion Designer generated code
diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs
index f2db6b4e..7c0ba8a6 100644
--- a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs
+++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs
@@ -79,8 +79,8 @@ namespace UnitTest.Issues.TestProtos {
#region Messages
/// <summary>
- /// Issue 307: when generating doubly-nested types, any references
- /// should be of the form A.Types.B.Types.C.
+ /// Issue 307: when generating doubly-nested types, any references
+ /// should be of the form A.Types.B.Types.C.
/// </summary>
public sealed partial class Issue307 : pb::IMessage<Issue307> {
private static readonly pb::MessageParser<Issue307> _parser = new pb::MessageParser<Issue307>(() => new Issue307());
@@ -859,7 +859,7 @@ namespace UnitTest.Issues.TestProtos {
}
/// <summary>
- /// Issue 45: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=45
+ /// Issue 45: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=45
/// </summary>
public sealed partial class ItemField : pb::IMessage<ItemField> {
private static readonly pb::MessageParser<ItemField> _parser = new pb::MessageParser<ItemField>(() => new ItemField());
@@ -1126,7 +1126,7 @@ namespace UnitTest.Issues.TestProtos {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static partial class Types {
/// <summary>
- /// Force a nested type called Types
+ /// Force a nested type called Types
/// </summary>
public sealed partial class SomeNestedType : pb::IMessage<SomeNestedType> {
private static readonly pb::MessageParser<SomeNestedType> _parser = new pb::MessageParser<SomeNestedType>(() => new SomeNestedType());
@@ -1223,16 +1223,16 @@ namespace UnitTest.Issues.TestProtos {
}
/// <summary>
- /// These fields are deliberately not declared in numeric
- /// order, and the oneof fields aren't contiguous either.
- /// This allows for reasonably robust tests of JSON output
- /// ordering.
- /// TestFieldOrderings in unittest_proto3.proto is similar,
- /// but doesn't include oneofs.
- /// TODO: Consider adding oneofs to TestFieldOrderings, although
- /// that will require fixing other tests in multiple platforms.
- /// Alternatively, consider just adding this to
- /// unittest_proto3.proto if multiple platforms want it.
+ /// These fields are deliberately not declared in numeric
+ /// order, and the oneof fields aren't contiguous either.
+ /// This allows for reasonably robust tests of JSON output
+ /// ordering.
+ /// TestFieldOrderings in unittest_proto3.proto is similar,
+ /// but doesn't include oneofs.
+ /// TODO: Consider adding oneofs to TestFieldOrderings, although
+ /// that will require fixing other tests in multiple platforms.
+ /// Alternatively, consider just adding this to
+ /// unittest_proto3.proto if multiple platforms want it.
/// </summary>
public sealed partial class TestJsonFieldOrdering : pb::IMessage<TestJsonFieldOrdering> {
private static readonly pb::MessageParser<TestJsonFieldOrdering> _parser = new pb::MessageParser<TestJsonFieldOrdering>(() => new TestJsonFieldOrdering());
@@ -1591,7 +1591,7 @@ namespace UnitTest.Issues.TestProtos {
public const int NameFieldNumber = 1;
private string name_ = "";
/// <summary>
- /// Message for testing the effects for of the json_name option
+ /// Message for testing the effects for of the json_name option
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Name {
diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs
index 7e71f94d..d89bbbb0 100644
--- a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs
+++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs
@@ -199,7 +199,7 @@ namespace Google.Protobuf.TestProtos {
}
/// <summary>
- /// Test an enum that has multiple values with the same number.
+ /// Test an enum that has multiple values with the same number.
/// </summary>
public enum TestEnumWithDupValue {
[pbr::OriginalName("TEST_ENUM_WITH_DUP_VALUE_UNSPECIFIED")] Unspecified = 0,
@@ -211,7 +211,7 @@ namespace Google.Protobuf.TestProtos {
}
/// <summary>
- /// Test an enum with large, unordered values.
+ /// Test an enum with large, unordered values.
/// </summary>
public enum TestSparseEnum {
[pbr::OriginalName("TEST_SPARSE_ENUM_UNSPECIFIED")] Unspecified = 0,
@@ -221,8 +221,8 @@ namespace Google.Protobuf.TestProtos {
[pbr::OriginalName("SPARSE_D")] SparseD = -15,
[pbr::OriginalName("SPARSE_E")] SparseE = -53452,
/// <summary>
- /// In proto3, value 0 must be the first one specified
- /// SPARSE_F = 0;
+ /// In proto3, value 0 must be the first one specified
+ /// SPARSE_F = 0;
/// </summary>
[pbr::OriginalName("SPARSE_G")] SparseG = 2,
}
@@ -231,8 +231,8 @@ namespace Google.Protobuf.TestProtos {
#region Messages
/// <summary>
- /// This proto includes every type of field in both singular and repeated
- /// forms.
+ /// This proto includes every type of field in both singular and repeated
+ /// forms.
/// </summary>
public sealed partial class TestAllTypes : pb::IMessage<TestAllTypes> {
private static readonly pb::MessageParser<TestAllTypes> _parser = new pb::MessageParser<TestAllTypes>(() => new TestAllTypes());
@@ -328,7 +328,7 @@ namespace Google.Protobuf.TestProtos {
public const int SingleInt32FieldNumber = 1;
private int singleInt32_;
/// <summary>
- /// Singular
+ /// Singular
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int SingleInt32 {
@@ -562,7 +562,7 @@ namespace Google.Protobuf.TestProtos {
public const int SinglePublicImportMessageFieldNumber = 26;
private global::Google.Protobuf.TestProtos.PublicImportMessage singlePublicImportMessage_;
/// <summary>
- /// Defined in unittest_import_public.proto
+ /// Defined in unittest_import_public.proto
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Google.Protobuf.TestProtos.PublicImportMessage SinglePublicImportMessage {
@@ -578,7 +578,7 @@ namespace Google.Protobuf.TestProtos {
= pb::FieldCodec.ForInt32(250);
private readonly pbc::RepeatedField<int> repeatedInt32_ = new pbc::RepeatedField<int>();
/// <summary>
- /// Repeated
+ /// Repeated
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<int> RepeatedInt32 {
@@ -791,7 +791,7 @@ namespace Google.Protobuf.TestProtos {
= pb::FieldCodec.ForMessage(434, global::Google.Protobuf.TestProtos.PublicImportMessage.Parser);
private readonly pbc::RepeatedField<global::Google.Protobuf.TestProtos.PublicImportMessage> repeatedPublicImportMessage_ = new pbc::RepeatedField<global::Google.Protobuf.TestProtos.PublicImportMessage>();
/// <summary>
- /// Defined in unittest_import_public.proto
+ /// Defined in unittest_import_public.proto
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Google.Protobuf.TestProtos.PublicImportMessage> RepeatedPublicImportMessage {
@@ -1593,7 +1593,7 @@ namespace Google.Protobuf.TestProtos {
[pbr::OriginalName("BAR")] Bar = 2,
[pbr::OriginalName("BAZ")] Baz = 3,
/// <summary>
- /// Intentionally negative.
+ /// Intentionally negative.
/// </summary>
[pbr::OriginalName("NEG")] Neg = -1,
}
@@ -1634,9 +1634,9 @@ namespace Google.Protobuf.TestProtos {
public const int BbFieldNumber = 1;
private int bb_;
/// <summary>
- /// The field name "b" fails to compile in proto1 because it conflicts with
- /// a local variable named "b" in one of the generated methods. Doh.
- /// This file needs to compile in proto1 to test backwards-compatibility.
+ /// The field name "b" fails to compile in proto1 because it conflicts with
+ /// a local variable named "b" in one of the generated methods. Doh.
+ /// This file needs to compile in proto1 to test backwards-compatibility.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int Bb {
@@ -1726,7 +1726,7 @@ namespace Google.Protobuf.TestProtos {
}
/// <summary>
- /// This proto includes a recusively nested message.
+ /// This proto includes a recusively nested message.
/// </summary>
public sealed partial class NestedTestAllTypes : pb::IMessage<NestedTestAllTypes> {
private static readonly pb::MessageParser<NestedTestAllTypes> _parser = new pb::MessageParser<NestedTestAllTypes>(() => new NestedTestAllTypes());
@@ -2024,8 +2024,8 @@ namespace Google.Protobuf.TestProtos {
}
/// <summary>
- /// Define these after TestAllTypes to make sure the compiler can handle
- /// that.
+ /// Define these after TestAllTypes to make sure the compiler can handle
+ /// that.
/// </summary>
public sealed partial class ForeignMessage : pb::IMessage<ForeignMessage> {
private static readonly pb::MessageParser<ForeignMessage> _parser = new pb::MessageParser<ForeignMessage>(() => new ForeignMessage());
@@ -2234,7 +2234,7 @@ namespace Google.Protobuf.TestProtos {
}
/// <summary>
- /// Test that we can use NestedMessage from outside TestAllTypes.
+ /// Test that we can use NestedMessage from outside TestAllTypes.
/// </summary>
public sealed partial class TestForeignNested : pb::IMessage<TestForeignNested> {
private static readonly pb::MessageParser<TestForeignNested> _parser = new pb::MessageParser<TestForeignNested>(() => new TestForeignNested());
@@ -2360,7 +2360,7 @@ namespace Google.Protobuf.TestProtos {
}
/// <summary>
- /// Test that really large tag numbers don't break anything.
+ /// Test that really large tag numbers don't break anything.
/// </summary>
public sealed partial class TestReallyLargeTagNumber : pb::IMessage<TestReallyLargeTagNumber> {
private static readonly pb::MessageParser<TestReallyLargeTagNumber> _parser = new pb::MessageParser<TestReallyLargeTagNumber>(() => new TestReallyLargeTagNumber());
@@ -2399,8 +2399,8 @@ namespace Google.Protobuf.TestProtos {
public const int AFieldNumber = 1;
private int a_;
/// <summary>
- /// The largest possible tag number is 2^28 - 1, since the wire format uses
- /// three bits to communicate wire type.
+ /// The largest possible tag number is 2^28 - 1, since the wire format uses
+ /// three bits to communicate wire type.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int A {
@@ -2663,7 +2663,7 @@ namespace Google.Protobuf.TestProtos {
}
/// <summary>
- /// Test that mutual recursion works.
+ /// Test that mutual recursion works.
/// </summary>
public sealed partial class TestMutualRecursionA : pb::IMessage<TestMutualRecursionA> {
private static readonly pb::MessageParser<TestMutualRecursionA> _parser = new pb::MessageParser<TestMutualRecursionA>(() => new TestMutualRecursionA());
@@ -2940,8 +2940,8 @@ namespace Google.Protobuf.TestProtos {
}
/// <summary>
- /// Test message with CamelCase field names. This violates Protocol Buffer
- /// standard style.
+ /// Test message with CamelCase field names. This violates Protocol Buffer
+ /// standard style.
/// </summary>
public sealed partial class TestCamelCaseFieldNames : pb::IMessage<TestCamelCaseFieldNames> {
private static readonly pb::MessageParser<TestCamelCaseFieldNames> _parser = new pb::MessageParser<TestCamelCaseFieldNames>(() => new TestCamelCaseFieldNames());
@@ -3233,8 +3233,8 @@ namespace Google.Protobuf.TestProtos {
}
/// <summary>
- /// We list fields out of order, to ensure that we're using field number and not
- /// field index to determine serialization order.
+ /// We list fields out of order, to ensure that we're using field number and not
+ /// field index to determine serialization order.
/// </summary>
public sealed partial class TestFieldOrderings : pb::IMessage<TestFieldOrderings> {
private static readonly pb::MessageParser<TestFieldOrderings> _parser = new pb::MessageParser<TestFieldOrderings>(() => new TestFieldOrderings());
@@ -3493,9 +3493,9 @@ namespace Google.Protobuf.TestProtos {
public const int BbFieldNumber = 1;
private int bb_;
/// <summary>
- /// The field name "b" fails to compile in proto1 because it conflicts with
- /// a local variable named "b" in one of the generated methods. Doh.
- /// This file needs to compile in proto1 to test backwards-compatibility.
+ /// The field name "b" fails to compile in proto1 because it conflicts with
+ /// a local variable named "b" in one of the generated methods. Doh.
+ /// This file needs to compile in proto1 to test backwards-compatibility.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int Bb {
@@ -3718,7 +3718,7 @@ namespace Google.Protobuf.TestProtos {
}
/// <summary>
- /// Test String and Bytes: string is for valid UTF-8 strings
+ /// Test String and Bytes: string is for valid UTF-8 strings
/// </summary>
public sealed partial class OneString : pb::IMessage<OneString> {
private static readonly pb::MessageParser<OneString> _parser = new pb::MessageParser<OneString>(() => new OneString());
@@ -4181,7 +4181,7 @@ namespace Google.Protobuf.TestProtos {
}
/// <summary>
- /// Test int32, uint32, int64, uint64, and bool are all compatible
+ /// Test int32, uint32, int64, uint64, and bool are all compatible
/// </summary>
public sealed partial class Int32Message : pb::IMessage<Int32Message> {
private static readonly pb::MessageParser<Int32Message> _parser = new pb::MessageParser<Int32Message>(() => new Int32Message());
@@ -4769,7 +4769,7 @@ namespace Google.Protobuf.TestProtos {
}
/// <summary>
- /// Test oneofs.
+ /// Test oneofs.
/// </summary>
public sealed partial class TestOneof : pb::IMessage<TestOneof> {
private static readonly pb::MessageParser<TestOneof> _parser = new pb::MessageParser<TestOneof>(() => new TestOneof());
@@ -5367,8 +5367,8 @@ namespace Google.Protobuf.TestProtos {
}
/// <summary>
- /// A message with the same fields as TestPackedTypes, but without packing. Used
- /// to test packed &lt;-> unpacked wire compatibility.
+ /// A message with the same fields as TestPackedTypes, but without packing. Used
+ /// to test packed &lt;-> unpacked wire compatibility.
/// </summary>
public sealed partial class TestUnpackedTypes : pb::IMessage<TestUnpackedTypes> {
private static readonly pb::MessageParser<TestUnpackedTypes> _parser = new pb::MessageParser<TestUnpackedTypes>(() => new TestUnpackedTypes());
@@ -5796,9 +5796,9 @@ namespace Google.Protobuf.TestProtos {
= pb::FieldCodec.ForFixed32(98);
private readonly pbc::RepeatedField<uint> repeatedFixed32_ = new pbc::RepeatedField<uint>();
/// <summary>
- /// Parsing repeated fixed size values used to fail. This message needs to be
- /// used in order to get a tag of the right size; all of the repeated fields
- /// in TestAllTypes didn't trigger the check.
+ /// Parsing repeated fixed size values used to fail. This message needs to be
+ /// used in order to get a tag of the right size; all of the repeated fields
+ /// in TestAllTypes didn't trigger the check.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<uint> RepeatedFixed32 {
@@ -5811,7 +5811,7 @@ namespace Google.Protobuf.TestProtos {
= pb::FieldCodec.ForInt32(106);
private readonly pbc::RepeatedField<int> repeatedInt32_ = new pbc::RepeatedField<int>();
/// <summary>
- /// Check for a varint type, just for good measure.
+ /// Check for a varint type, just for good measure.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<int> RepeatedInt32 {
@@ -5824,7 +5824,7 @@ namespace Google.Protobuf.TestProtos {
= pb::FieldCodec.ForFixed64(16370);
private readonly pbc::RepeatedField<ulong> repeatedFixed64_ = new pbc::RepeatedField<ulong>();
/// <summary>
- /// These have two-byte tags.
+ /// These have two-byte tags.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<ulong> RepeatedFixed64 {
@@ -5847,7 +5847,7 @@ namespace Google.Protobuf.TestProtos {
= pb::FieldCodec.ForFloat(2097138);
private readonly pbc::RepeatedField<float> repeatedFloat_ = new pbc::RepeatedField<float>();
/// <summary>
- /// Three byte tags.
+ /// Three byte tags.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<float> RepeatedFloat {
@@ -6018,7 +6018,7 @@ namespace Google.Protobuf.TestProtos {
public const int AFieldNumber = 1;
private string a_ = "";
/// <summary>
- /// */ &lt;- This should not close the generated doc comment
+ /// */ &lt;- This should not close the generated doc comment
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string A {
@@ -6103,7 +6103,7 @@ namespace Google.Protobuf.TestProtos {
}
/// <summary>
- /// Test that RPC services work.
+ /// Test that RPC services work.
/// </summary>
public sealed partial class FooRequest : pb::IMessage<FooRequest> {
private static readonly pb::MessageParser<FooRequest> _parser = new pb::MessageParser<FooRequest>(() => new FooRequest());
diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs
index 6e87fb5d..2c7f0e0e 100644
--- a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs
+++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs
@@ -173,9 +173,9 @@ namespace Google.Protobuf.TestProtos {
}
#region Messages
/// <summary>
- /// Test that we can include all well-known types.
- /// Each wrapper type is included separately, as languages
- /// map handle different wrappers in different ways.
+ /// Test that we can include all well-known types.
+ /// Each wrapper type is included separately, as languages
+ /// map handle different wrappers in different ways.
/// </summary>
public sealed partial class TestWellKnownTypes : pb::IMessage<TestWellKnownTypes> {
private static readonly pb::MessageParser<TestWellKnownTypes> _parser = new pb::MessageParser<TestWellKnownTypes>(() => new TestWellKnownTypes());
@@ -438,7 +438,7 @@ namespace Google.Protobuf.TestProtos {
public const int ValueFieldFieldNumber = 19;
private global::Google.Protobuf.WellKnownTypes.Value valueField_;
/// <summary>
- /// Part of struct, but useful to be able to test separately
+ /// Part of struct, but useful to be able to test separately
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Google.Protobuf.WellKnownTypes.Value ValueField {
@@ -907,7 +907,7 @@ namespace Google.Protobuf.TestProtos {
}
/// <summary>
- /// A repeated field for each well-known type.
+ /// A repeated field for each well-known type.
/// </summary>
public sealed partial class RepeatedWellKnownTypes : pb::IMessage<RepeatedWellKnownTypes> {
private static readonly pb::MessageParser<RepeatedWellKnownTypes> _parser = new pb::MessageParser<RepeatedWellKnownTypes>(() => new RepeatedWellKnownTypes());
@@ -1054,7 +1054,7 @@ namespace Google.Protobuf.TestProtos {
= pb::FieldCodec.ForStructWrapper<double>(82);
private readonly pbc::RepeatedField<double?> doubleField_ = new pbc::RepeatedField<double?>();
/// <summary>
- /// These don't actually make a lot of sense, but they're not prohibited...
+ /// These don't actually make a lot of sense, but they're not prohibited...
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<double?> DoubleField {
@@ -2079,9 +2079,9 @@ namespace Google.Protobuf.TestProtos {
}
/// <summary>
- /// A map field for each well-known type. We only
- /// need to worry about the value part of the map being the
- /// well-known types, as messages can't be map keys.
+ /// A map field for each well-known type. We only
+ /// need to worry about the value part of the map being the
+ /// well-known types, as messages can't be map keys.
/// </summary>
public sealed partial class MapWellKnownTypes : pb::IMessage<MapWellKnownTypes> {
private static readonly pb::MessageParser<MapWellKnownTypes> _parser = new pb::MessageParser<MapWellKnownTypes>(() => new MapWellKnownTypes());
diff --git a/csharp/src/Google.Protobuf.Test/project.json b/csharp/src/Google.Protobuf.Test/project.json
index 87b732c9..eaa7f79d 100644
--- a/csharp/src/Google.Protobuf.Test/project.json
+++ b/csharp/src/Google.Protobuf.Test/project.json
@@ -20,13 +20,14 @@
"dependencies": {
"Google.Protobuf": { "target": "project" },
- "NUnit": "3.4.0",
- "dotnet-test-nunit": "3.4.0-alpha-2",
+ "dotnet-test-nunit": "3.4.0-beta-3",
+ "NUnit": "3.6.0"
},
"testRunner": "nunit",
"frameworks": {
+ "net451": {},
"netcoreapp1.0": {
"imports" : [ "dnxcore50", "netcoreapp1.0", "portable-net45+win8" ],
"buildOptions": {
diff --git a/csharp/src/Google.Protobuf/ByteString.cs b/csharp/src/Google.Protobuf/ByteString.cs
index dd7f22d6..4abdb718 100644..100755
--- a/csharp/src/Google.Protobuf/ByteString.cs
+++ b/csharp/src/Google.Protobuf/ByteString.cs
@@ -35,6 +35,13 @@ using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
+#if !NET35
+using System.Threading;
+using System.Threading.Tasks;
+#endif
+#if NET35
+using Google.Protobuf.Compatibility;
+#endif
namespace Google.Protobuf
{
@@ -142,6 +149,55 @@ namespace Google.Protobuf
}
/// <summary>
+ /// Constructs a <see cref="ByteString"/> from data in the given stream, synchronously.
+ /// </summary>
+ /// <remarks>If successful, <paramref name="stream"/> will be read completely, from the position
+ /// at the start of the call.</remarks>
+ /// <param name="stream">The stream to copy into a ByteString.</param>
+ /// <returns>A ByteString with content read from the given stream.</returns>
+ public static ByteString FromStream(Stream stream)
+ {
+ ProtoPreconditions.CheckNotNull(stream, nameof(stream));
+ int capacity = stream.CanSeek ? checked((int) (stream.Length - stream.Position)) : 0;
+ var memoryStream = new MemoryStream(capacity);
+ stream.CopyTo(memoryStream);
+#if NETSTANDARD1_0
+ byte[] bytes = memoryStream.ToArray();
+#else
+ // Avoid an extra copy if we can.
+ byte[] bytes = memoryStream.Length == memoryStream.Capacity ? memoryStream.GetBuffer() : memoryStream.ToArray();
+#endif
+ return AttachBytes(bytes);
+ }
+
+#if !NET35
+ /// <summary>
+ /// Constructs a <see cref="ByteString"/> from data in the given stream, asynchronously.
+ /// </summary>
+ /// <remarks>If successful, <paramref name="stream"/> will be read completely, from the position
+ /// at the start of the call.</remarks>
+ /// <param name="stream">The stream to copy into a ByteString.</param>
+ /// <param name="cancellationToken">The cancellation token to use when reading from the stream, if any.</param>
+ /// <returns>A ByteString with content read from the given stream.</returns>
+ public async static Task<ByteString> FromStreamAsync(Stream stream, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ ProtoPreconditions.CheckNotNull(stream, nameof(stream));
+ int capacity = stream.CanSeek ? checked((int) (stream.Length - stream.Position)) : 0;
+ var memoryStream = new MemoryStream(capacity);
+ // We have to specify the buffer size here, as there's no overload accepting the cancellation token
+ // alone. But it's documented to use 81920 by default if not specified.
+ await stream.CopyToAsync(memoryStream, 81920, cancellationToken);
+#if NETSTANDARD1_0
+ byte[] bytes = memoryStream.ToArray();
+#else
+ // Avoid an extra copy if we can.
+ byte[] bytes = memoryStream.Length == memoryStream.Capacity ? memoryStream.GetBuffer() : memoryStream.ToArray();
+#endif
+ return AttachBytes(bytes);
+ }
+#endif
+
+ /// <summary>
/// Constructs a <see cref="ByteString" /> from the given array. The contents
/// are copied, so further modifications to the array will not
/// be reflected in the returned ByteString.
@@ -303,7 +359,7 @@ namespace Google.Protobuf
int ret = 23;
foreach (byte b in bytes)
{
- ret = (ret << 8) | b;
+ ret = (ret * 31) + b;
}
return ret;
}
diff --git a/csharp/src/Google.Protobuf/Collections/MapField.cs b/csharp/src/Google.Protobuf/Collections/MapField.cs
index 537ce261..ef5651c9 100644
--- a/csharp/src/Google.Protobuf/Collections/MapField.cs
+++ b/csharp/src/Google.Protobuf/Collections/MapField.cs
@@ -715,7 +715,7 @@ namespace Google.Protobuf.Collections
{
throw new ArgumentOutOfRangeException(nameof(arrayIndex));
}
- if (arrayIndex + Count >= array.Length)
+ if (arrayIndex + Count > array.Length)
{
throw new ArgumentException("Not enough space in the array", nameof(array));
}
@@ -746,7 +746,7 @@ namespace Google.Protobuf.Collections
{
throw new ArgumentOutOfRangeException(nameof(index));
}
- if (index + Count >= array.Length)
+ if (index + Count > array.Length)
{
throw new ArgumentException("Not enough space in the array", nameof(array));
}
diff --git a/csharp/src/Google.Protobuf/Collections/RepeatedField.cs b/csharp/src/Google.Protobuf/Collections/RepeatedField.cs
index 7bb56448..6063ff61 100644..100755
--- a/csharp/src/Google.Protobuf/Collections/RepeatedField.cs
+++ b/csharp/src/Google.Protobuf/Collections/RepeatedField.cs
@@ -47,6 +47,9 @@ namespace Google.Protobuf.Collections
/// </remarks>
/// <typeparam name="T">The element type of the repeated field.</typeparam>
public sealed class RepeatedField<T> : IList<T>, IList, IDeepCloneable<RepeatedField<T>>, IEquatable<RepeatedField<T>>
+#if !NET35
+ , IReadOnlyList<T>
+#endif
{
private static readonly T[] EmptyArray = new T[0];
private const int MinArraySize = 8;
diff --git a/csharp/src/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs b/csharp/src/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs
index e3914dd3..95a02c72 100644..100755
--- a/csharp/src/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs
+++ b/csharp/src/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs
@@ -47,7 +47,7 @@ namespace Google.Protobuf.Compatibility
/// </summary>
internal static MethodInfo GetGetMethod(this PropertyInfo target)
{
-#if DOTNET35
+#if NET35
var method = target.GetGetMethod();
#else
var method = target.GetMethod;
@@ -61,7 +61,7 @@ namespace Google.Protobuf.Compatibility
/// </summary>
internal static MethodInfo GetSetMethod(this PropertyInfo target)
{
-#if DOTNET35
+#if NET35
var method = target.GetSetMethod();
#else
var method = target.SetMethod;
diff --git a/csharp/src/Google.Protobuf/Compatibility/StreamExtensions.cs b/csharp/src/Google.Protobuf/Compatibility/StreamExtensions.cs
new file mode 100755
index 00000000..bf4bf220
--- /dev/null
+++ b/csharp/src/Google.Protobuf/Compatibility/StreamExtensions.cs
@@ -0,0 +1,66 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2015 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+#if NET35
+using System;
+using System.IO;
+
+namespace Google.Protobuf.Compatibility
+{
+ /// <summary>
+ /// Extension methods for <see cref="Stream"/> in order to provide
+ /// backwards compatibility with .NET 3.5
+ /// </summary>
+ public static class StreamExtensions
+ {
+ // 81920 seems to be the default buffer size used in .NET 4.5.1
+ private const int BUFFER_SIZE = 81920;
+
+ /// <summary>
+ /// Write the contents of the current stream to the destination stream
+ /// </summary>
+ public static void CopyTo(this Stream source, Stream destination)
+ {
+ if (destination == null)
+ {
+ throw new ArgumentNullException(nameof(destination));
+ }
+
+ byte[] buffer = new byte[BUFFER_SIZE];
+ int numBytesRead;
+ while ((numBytesRead = source.Read(buffer, 0, buffer.Length)) > 0) {
+ destination.Write(buffer, 0, numBytesRead);
+ }
+ }
+ }
+}
+#endif
diff --git a/csharp/src/Google.Protobuf/Compatibility/TypeExtensions.cs b/csharp/src/Google.Protobuf/Compatibility/TypeExtensions.cs
index 2d93183b..2f237138 100644..100755
--- a/csharp/src/Google.Protobuf/Compatibility/TypeExtensions.cs
+++ b/csharp/src/Google.Protobuf/Compatibility/TypeExtensions.cs
@@ -33,7 +33,7 @@
using System;
using System.Reflection;
-#if !DOTNET35
+#if !NET35
namespace Google.Protobuf.Compatibility
{
/// <summary>
diff --git a/csharp/src/Google.Protobuf/JsonFormatter.cs b/csharp/src/Google.Protobuf/JsonFormatter.cs
index bb1a361e..05282775 100644..100755
--- a/csharp/src/Google.Protobuf/JsonFormatter.cs
+++ b/csharp/src/Google.Protobuf/JsonFormatter.cs
@@ -831,7 +831,7 @@ namespace Google.Protobuf
return originalName;
}
-#if DOTNET35
+#if NET35
// TODO: Consider adding functionality to TypeExtensions to avoid this difference.
private static Dictionary<object, string> GetNameMapping(System.Type enumType) =>
enumType.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static)
diff --git a/csharp/src/Google.Protobuf/Reflection/CustomOptions.cs b/csharp/src/Google.Protobuf/Reflection/CustomOptions.cs
new file mode 100644
index 00000000..88b3ec00
--- /dev/null
+++ b/csharp/src/Google.Protobuf/Reflection/CustomOptions.cs
@@ -0,0 +1,390 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2017 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using System;
+using System.Collections.Generic;
+
+namespace Google.Protobuf.Reflection
+{
+ /// <summary>
+ /// Container for a set of custom options specified within a message, field etc.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This type is publicly immutable, but internally mutable. It is only populated
+ /// by the descriptor parsing code - by the time any user code is able to see an instance,
+ /// it will be fully initialized.
+ /// </para>
+ /// <para>
+ /// If an option is requested using the incorrect method, an answer may still be returned: all
+ /// of the numeric types are represented internally using 64-bit integers, for example. It is up to
+ /// the caller to ensure that they make the appropriate method call for the option they're interested in.
+ /// Note that enum options are simply stored as integers, so the value should be fetched using
+ /// <see cref="TryGetInt32(int, out int)"/> and then cast appropriately.
+ /// </para>
+ /// <para>
+ /// Repeated options are currently not supported. Asking for a single value of an option
+ /// which was actually repeated will return the last value, except for message types where
+ /// all the set values are merged together.
+ /// </para>
+ /// </remarks>
+ public sealed class CustomOptions
+ {
+ /// <summary>
+ /// Singleton for all descriptors with an empty set of options.
+ /// </summary>
+ internal static readonly CustomOptions Empty = new CustomOptions();
+
+ /// <summary>
+ /// A sequence of values per field. This needs to be per field rather than per tag to allow correct deserialization
+ /// of repeated fields which could be "int, ByteString, int" - unlikely as that is. The fact that values are boxed
+ /// is unfortunate; we might be able to use a struct instead, and we could combine uint and ulong values.
+ /// </summary>
+ private readonly Dictionary<int, List<FieldValue>> valuesByField = new Dictionary<int, List<FieldValue>>();
+
+ private CustomOptions() { }
+
+ /// <summary>
+ /// Retrieves a Boolean value for the specified option field.
+ /// </summary>
+ /// <param name="field">The field to fetch the value for.</param>
+ /// <param name="value">The output variable to populate.</param>
+ /// <returns><c>true</c> if a suitable value for the field was found; <c>false</c> otherwise.</returns>
+ public bool TryGetBool(int field, out bool value)
+ {
+ ulong? tmp = GetLastNumericValue(field);
+ value = tmp == 1UL;
+ return tmp != null;
+ }
+
+ /// <summary>
+ /// Retrieves a signed 32-bit integer value for the specified option field.
+ /// </summary>
+ /// <param name="field">The field to fetch the value for.</param>
+ /// <param name="value">The output variable to populate.</param>
+ /// <returns><c>true</c> if a suitable value for the field was found; <c>false</c> otherwise.</returns>
+ public bool TryGetInt32(int field, out int value)
+ {
+ ulong? tmp = GetLastNumericValue(field);
+ value = (int) tmp.GetValueOrDefault();
+ return tmp != null;
+ }
+
+ /// <summary>
+ /// Retrieves a signed 64-bit integer value for the specified option field.
+ /// </summary>
+ /// <param name="field">The field to fetch the value for.</param>
+ /// <param name="value">The output variable to populate.</param>
+ /// <returns><c>true</c> if a suitable value for the field was found; <c>false</c> otherwise.</returns>
+ public bool TryGetInt64(int field, out long value)
+ {
+ ulong? tmp = GetLastNumericValue(field);
+ value = (long) tmp.GetValueOrDefault();
+ return tmp != null;
+ }
+
+ /// <summary>
+ /// Retrieves an unsigned 32-bit integer value for the specified option field,
+ /// assuming a fixed-length representation.
+ /// </summary>
+ /// <param name="field">The field to fetch the value for.</param>
+ /// <param name="value">The output variable to populate.</param>
+ /// <returns><c>true</c> if a suitable value for the field was found; <c>false</c> otherwise.</returns>
+ public bool TryGetFixed32(int field, out uint value) => TryGetUInt32(field, out value);
+
+ /// <summary>
+ /// Retrieves an unsigned 64-bit integer value for the specified option field,
+ /// assuming a fixed-length representation.
+ /// </summary>
+ /// <param name="field">The field to fetch the value for.</param>
+ /// <param name="value">The output variable to populate.</param>
+ /// <returns><c>true</c> if a suitable value for the field was found; <c>false</c> otherwise.</returns>
+ public bool TryGetFixed64(int field, out ulong value) => TryGetUInt64(field, out value);
+
+ /// <summary>
+ /// Retrieves a signed 32-bit integer value for the specified option field,
+ /// assuming a fixed-length representation.
+ /// </summary>
+ /// <param name="field">The field to fetch the value for.</param>
+ /// <param name="value">The output variable to populate.</param>
+ /// <returns><c>true</c> if a suitable value for the field was found; <c>false</c> otherwise.</returns>
+ public bool TryGetSFixed32(int field, out int value) => TryGetInt32(field, out value);
+
+ /// <summary>
+ /// Retrieves a signed 64-bit integer value for the specified option field,
+ /// assuming a fixed-length representation.
+ /// </summary>
+ /// <param name="field">The field to fetch the value for.</param>
+ /// <param name="value">The output variable to populate.</param>
+ /// <returns><c>true</c> if a suitable value for the field was found; <c>false</c> otherwise.</returns>
+ public bool TryGetSFixed64(int field, out long value) => TryGetInt64(field, out value);
+
+ /// <summary>
+ /// Retrieves a signed 32-bit integer value for the specified option field,
+ /// assuming a zigzag encoding.
+ /// </summary>
+ /// <param name="field">The field to fetch the value for.</param>
+ /// <param name="value">The output variable to populate.</param>
+ /// <returns><c>true</c> if a suitable value for the field was found; <c>false</c> otherwise.</returns>
+ public bool TryGetSInt32(int field, out int value)
+ {
+ ulong? tmp = GetLastNumericValue(field);
+ value = CodedInputStream.DecodeZigZag32((uint) tmp.GetValueOrDefault());
+ return tmp != null;
+ }
+
+ /// <summary>
+ /// Retrieves a signed 64-bit integer value for the specified option field,
+ /// assuming a zigzag encoding.
+ /// </summary>
+ /// <param name="field">The field to fetch the value for.</param>
+ /// <param name="value">The output variable to populate.</param>
+ /// <returns><c>true</c> if a suitable value for the field was found; <c>false</c> otherwise.</returns>
+ public bool TryGetSInt64(int field, out long value)
+ {
+ ulong? tmp = GetLastNumericValue(field);
+ value = CodedInputStream.DecodeZigZag64(tmp.GetValueOrDefault());
+ return tmp != null;
+ }
+
+ /// <summary>
+ /// Retrieves an unsigned 32-bit integer value for the specified option field.
+ /// </summary>
+ /// <param name="field">The field to fetch the value for.</param>
+ /// <param name="value">The output variable to populate.</param>
+ /// <returns><c>true</c> if a suitable value for the field was found; <c>false</c> otherwise.</returns>
+ public bool TryGetUInt32(int field, out uint value)
+ {
+ ulong? tmp = GetLastNumericValue(field);
+ value = (uint) tmp.GetValueOrDefault();
+ return tmp != null;
+ }
+
+ /// <summary>
+ /// Retrieves an unsigned 64-bit integer value for the specified option field.
+ /// </summary>
+ /// <param name="field">The field to fetch the value for.</param>
+ /// <param name="value">The output variable to populate.</param>
+ /// <returns><c>true</c> if a suitable value for the field was found; <c>false</c> otherwise.</returns>
+ public bool TryGetUInt64(int field, out ulong value)
+ {
+ ulong? tmp = GetLastNumericValue(field);
+ value = tmp.GetValueOrDefault();
+ return tmp != null;
+ }
+
+ /// <summary>
+ /// Retrieves a 32-bit floating point value for the specified option field.
+ /// </summary>
+ /// <param name="field">The field to fetch the value for.</param>
+ /// <param name="value">The output variable to populate.</param>
+ /// <returns><c>true</c> if a suitable value for the field was found; <c>false</c> otherwise.</returns>
+ public bool TryGetFloat(int field, out float value)
+ {
+ ulong? tmp = GetLastNumericValue(field);
+ int int32 = (int) tmp.GetValueOrDefault();
+ byte[] bytes = BitConverter.GetBytes(int32);
+ value = BitConverter.ToSingle(bytes, 0);
+ return tmp != null;
+ }
+
+ /// <summary>
+ /// Retrieves a 64-bit floating point value for the specified option field.
+ /// </summary>
+ /// <param name="field">The field to fetch the value for.</param>
+ /// <param name="value">The output variable to populate.</param>
+ /// <returns><c>true</c> if a suitable value for the field was found; <c>false</c> otherwise.</returns>
+ public bool TryGetDouble(int field, out double value)
+ {
+ ulong? tmp = GetLastNumericValue(field);
+ value = BitConverter.Int64BitsToDouble((long) tmp.GetValueOrDefault());
+ return tmp != null;
+ }
+
+ /// <summary>
+ /// Retrieves a string value for the specified option field.
+ /// </summary>
+ /// <param name="field">The field to fetch the value for.</param>
+ /// <param name="value">The output variable to populate.</param>
+ /// <returns><c>true</c> if a suitable value for the field was found; <c>false</c> otherwise.</returns>
+ public bool TryGetString(int field, out string value)
+ {
+ ByteString bytes = GetLastByteStringValue(field);
+ value = bytes?.ToStringUtf8();
+ return bytes != null;
+ }
+
+ /// <summary>
+ /// Retrieves a bytes value for the specified option field.
+ /// </summary>
+ /// <param name="field">The field to fetch the value for.</param>
+ /// <param name="value">The output variable to populate.</param>
+ /// <returns><c>true</c> if a suitable value for the field was found; <c>false</c> otherwise.</returns>
+ public bool TryGetBytes(int field, out ByteString value)
+ {
+ ByteString bytes = GetLastByteStringValue(field);
+ value = bytes;
+ return bytes != null;
+ }
+
+ /// <summary>
+ /// Retrieves a message value for the specified option field.
+ /// </summary>
+ /// <param name="field">The field to fetch the value for.</param>
+ /// <param name="value">The output variable to populate.</param>
+ /// <returns><c>true</c> if a suitable value for the field was found; <c>false</c> otherwise.</returns>
+ public bool TryGetMessage<T>(int field, out T value) where T : class, IMessage, new()
+ {
+ value = null;
+ List<FieldValue> values;
+ if (!valuesByField.TryGetValue(field, out values))
+ {
+ return false;
+ }
+ foreach (FieldValue fieldValue in values)
+ {
+ if (fieldValue.ByteString != null)
+ {
+ if (value == null)
+ {
+ value = new T();
+ }
+ value.MergeFrom(fieldValue.ByteString);
+ }
+ }
+ return value != null;
+ }
+
+ private ulong? GetLastNumericValue(int field)
+ {
+ List<FieldValue> values;
+ if (!valuesByField.TryGetValue(field, out values))
+ {
+ return null;
+ }
+ for (int i = values.Count - 1; i >= 0; i--)
+ {
+ // A non-bytestring value is a numeric value
+ if (values[i].ByteString == null)
+ {
+ return values[i].Number;
+ }
+ }
+ return null;
+ }
+
+ private ByteString GetLastByteStringValue(int field)
+ {
+ List<FieldValue> values;
+ if (!valuesByField.TryGetValue(field, out values))
+ {
+ return null;
+ }
+ for (int i = values.Count - 1; i >= 0; i--)
+ {
+ if (values[i].ByteString != null)
+ {
+ return values[i].ByteString;
+ }
+ }
+ return null;
+ }
+
+ /// <summary>
+ /// Reads an unknown field, either parsing it and storing it or skipping it.
+ /// </summary>
+ /// <remarks>
+ /// If the current set of options is empty and we manage to read a field, a new set of options
+ /// will be created and returned. Otherwise, the return value is <c>this</c>. This allows
+ /// us to start with a singleton empty set of options and just create new ones where necessary.
+ /// </remarks>
+ /// <param name="input">Input stream to read from. </param>
+ /// <returns>The resulting set of custom options, either <c>this</c> or a new set.</returns>
+ internal CustomOptions ReadOrSkipUnknownField(CodedInputStream input)
+ {
+ var tag = input.LastTag;
+ var field = WireFormat.GetTagFieldNumber(tag);
+ switch (WireFormat.GetTagWireType(tag))
+ {
+ case WireFormat.WireType.LengthDelimited:
+ return AddValue(field, new FieldValue(input.ReadBytes()));
+ case WireFormat.WireType.Fixed32:
+ return AddValue(field, new FieldValue(input.ReadFixed32()));
+ case WireFormat.WireType.Fixed64:
+ return AddValue(field, new FieldValue(input.ReadFixed64()));
+ case WireFormat.WireType.Varint:
+ return AddValue(field, new FieldValue(input.ReadRawVarint64()));
+ // For StartGroup, EndGroup or any wire format we don't understand,
+ // just use the normal behavior (call SkipLastField).
+ default:
+ input.SkipLastField();
+ return this;
+ }
+ }
+
+ private CustomOptions AddValue(int field, FieldValue value)
+ {
+ var ret = valuesByField.Count == 0 ? new CustomOptions() : this;
+ List<FieldValue> valuesForField;
+ if (!ret.valuesByField.TryGetValue(field, out valuesForField))
+ {
+ // Expect almost all
+ valuesForField = new List<FieldValue>(1);
+ ret.valuesByField[field] = valuesForField;
+ }
+ valuesForField.Add(value);
+ return ret;
+ }
+
+ /// <summary>
+ /// All field values can be stored as a byte string or a 64-bit integer.
+ /// This struct avoids unnecessary boxing.
+ /// </summary>
+ private struct FieldValue
+ {
+ internal ulong Number { get; }
+ internal ByteString ByteString { get; }
+
+ internal FieldValue(ulong number)
+ {
+ Number = number;
+ ByteString = null;
+ }
+
+ internal FieldValue(ByteString byteString)
+ {
+ Number = 0;
+ ByteString = byteString;
+ }
+ }
+ }
+}
diff --git a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs
index 19155469..c6819899 100644
--- a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs
@@ -80,7 +80,7 @@ namespace Google.Protobuf.Reflection {
"ASgJEhMKC291dHB1dF90eXBlGAMgASgJEi8KB29wdGlvbnMYBCABKAsyHi5n",
"b29nbGUucHJvdG9idWYuTWV0aG9kT3B0aW9ucxIfChBjbGllbnRfc3RyZWFt",
"aW5nGAUgASgIOgVmYWxzZRIfChBzZXJ2ZXJfc3RyZWFtaW5nGAYgASgIOgVm",
- "YWxzZSKEBQoLRmlsZU9wdGlvbnMSFAoMamF2YV9wYWNrYWdlGAEgASgJEhwK",
+ "YWxzZSKaBQoLRmlsZU9wdGlvbnMSFAoMamF2YV9wYWNrYWdlGAEgASgJEhwK",
"FGphdmFfb3V0ZXJfY2xhc3NuYW1lGAggASgJEiIKE2phdmFfbXVsdGlwbGVf",
"ZmlsZXMYCiABKAg6BWZhbHNlEikKHWphdmFfZ2VuZXJhdGVfZXF1YWxzX2Fu",
"ZF9oYXNoGBQgASgIQgIYARIlChZqYXZhX3N0cmluZ19jaGVja191dGY4GBsg",
@@ -91,55 +91,61 @@ namespace Google.Protobuf.Reflection {
"cHlfZ2VuZXJpY19zZXJ2aWNlcxgSIAEoCDoFZmFsc2USGQoKZGVwcmVjYXRl",
"ZBgXIAEoCDoFZmFsc2USHwoQY2NfZW5hYmxlX2FyZW5hcxgfIAEoCDoFZmFs",
"c2USGQoRb2JqY19jbGFzc19wcmVmaXgYJCABKAkSGAoQY3NoYXJwX25hbWVz",
- "cGFjZRglIAEoCRJDChR1bmludGVycHJldGVkX29wdGlvbhjnByADKAsyJC5n",
- "b29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9wdGlvbiI6CgxPcHRpbWl6",
- "ZU1vZGUSCQoFU1BFRUQQARINCglDT0RFX1NJWkUQAhIQCgxMSVRFX1JVTlRJ",
- "TUUQAyoJCOgHEICAgIACSgQIJhAnIuwBCg5NZXNzYWdlT3B0aW9ucxImChdt",
- "ZXNzYWdlX3NldF93aXJlX2Zvcm1hdBgBIAEoCDoFZmFsc2USLgofbm9fc3Rh",
- "bmRhcmRfZGVzY3JpcHRvcl9hY2Nlc3NvchgCIAEoCDoFZmFsc2USGQoKZGVw",
- "cmVjYXRlZBgDIAEoCDoFZmFsc2USEQoJbWFwX2VudHJ5GAcgASgIEkMKFHVu",
- "aW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5V",
- "bmludGVycHJldGVkT3B0aW9uKgkI6AcQgICAgAJKBAgIEAkingMKDEZpZWxk",
- "T3B0aW9ucxI6CgVjdHlwZRgBIAEoDjIjLmdvb2dsZS5wcm90b2J1Zi5GaWVs",
- "ZE9wdGlvbnMuQ1R5cGU6BlNUUklORxIOCgZwYWNrZWQYAiABKAgSPwoGanN0",
- "eXBlGAYgASgOMiQuZ29vZ2xlLnByb3RvYnVmLkZpZWxkT3B0aW9ucy5KU1R5",
- "cGU6CUpTX05PUk1BTBITCgRsYXp5GAUgASgIOgVmYWxzZRIZCgpkZXByZWNh",
- "dGVkGAMgASgIOgVmYWxzZRITCgR3ZWFrGAogASgIOgVmYWxzZRJDChR1bmlu",
- "dGVycHJldGVkX29wdGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9idWYuVW5p",
- "bnRlcnByZXRlZE9wdGlvbiIvCgVDVHlwZRIKCgZTVFJJTkcQABIICgRDT1JE",
- "EAESEAoMU1RSSU5HX1BJRUNFEAIiNQoGSlNUeXBlEg0KCUpTX05PUk1BTBAA",
- "Eg0KCUpTX1NUUklORxABEg0KCUpTX05VTUJFUhACKgkI6AcQgICAgAJKBAgE",
- "EAUiXgoMT25lb2ZPcHRpb25zEkMKFHVuaW50ZXJwcmV0ZWRfb3B0aW9uGOcH",
- "IAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0aW9uKgkI",
- "6AcQgICAgAIijQEKC0VudW1PcHRpb25zEhMKC2FsbG93X2FsaWFzGAIgASgI",
- "EhkKCmRlcHJlY2F0ZWQYAyABKAg6BWZhbHNlEkMKFHVuaW50ZXJwcmV0ZWRf",
- "b3B0aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVk",
- "T3B0aW9uKgkI6AcQgICAgAIifQoQRW51bVZhbHVlT3B0aW9ucxIZCgpkZXBy",
- "ZWNhdGVkGAEgASgIOgVmYWxzZRJDChR1bmludGVycHJldGVkX29wdGlvbhjn",
- "ByADKAsyJC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9wdGlvbioJ",
- "COgHEICAgIACInsKDlNlcnZpY2VPcHRpb25zEhkKCmRlcHJlY2F0ZWQYISAB",
- "KAg6BWZhbHNlEkMKFHVuaW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdv",
- "b2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0aW9uKgkI6AcQgICAgAIi",
- "egoNTWV0aG9kT3B0aW9ucxIZCgpkZXByZWNhdGVkGCEgASgIOgVmYWxzZRJD",
- "ChR1bmludGVycHJldGVkX29wdGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9i",
- "dWYuVW5pbnRlcnByZXRlZE9wdGlvbioJCOgHEICAgIACIp4CChNVbmludGVy",
- "cHJldGVkT3B0aW9uEjsKBG5hbWUYAiADKAsyLS5nb29nbGUucHJvdG9idWYu",
- "VW5pbnRlcnByZXRlZE9wdGlvbi5OYW1lUGFydBIYChBpZGVudGlmaWVyX3Zh",
- "bHVlGAMgASgJEhoKEnBvc2l0aXZlX2ludF92YWx1ZRgEIAEoBBIaChJuZWdh",
- "dGl2ZV9pbnRfdmFsdWUYBSABKAMSFAoMZG91YmxlX3ZhbHVlGAYgASgBEhQK",
- "DHN0cmluZ192YWx1ZRgHIAEoDBIXCg9hZ2dyZWdhdGVfdmFsdWUYCCABKAka",
- "MwoITmFtZVBhcnQSEQoJbmFtZV9wYXJ0GAEgAigJEhQKDGlzX2V4dGVuc2lv",
- "bhgCIAIoCCLVAQoOU291cmNlQ29kZUluZm8SOgoIbG9jYXRpb24YASADKAsy",
- "KC5nb29nbGUucHJvdG9idWYuU291cmNlQ29kZUluZm8uTG9jYXRpb24ahgEK",
- "CExvY2F0aW9uEhAKBHBhdGgYASADKAVCAhABEhAKBHNwYW4YAiADKAVCAhAB",
- "EhgKEGxlYWRpbmdfY29tbWVudHMYAyABKAkSGQoRdHJhaWxpbmdfY29tbWVu",
- "dHMYBCABKAkSIQoZbGVhZGluZ19kZXRhY2hlZF9jb21tZW50cxgGIAMoCSKn",
- "AQoRR2VuZXJhdGVkQ29kZUluZm8SQQoKYW5ub3RhdGlvbhgBIAMoCzItLmdv",
- "b2dsZS5wcm90b2J1Zi5HZW5lcmF0ZWRDb2RlSW5mby5Bbm5vdGF0aW9uGk8K",
- "CkFubm90YXRpb24SEAoEcGF0aBgBIAMoBUICEAESEwoLc291cmNlX2ZpbGUY",
- "AiABKAkSDQoFYmVnaW4YAyABKAUSCwoDZW5kGAQgASgFQlgKE2NvbS5nb29n",
- "bGUucHJvdG9idWZCEERlc2NyaXB0b3JQcm90b3NIAVoKZGVzY3JpcHRvcqIC",
- "A0dQQqoCGkdvb2dsZS5Qcm90b2J1Zi5SZWZsZWN0aW9u"));
+ "cGFjZRglIAEoCRIUCgxzd2lmdF9wcmVmaXgYJyABKAkSQwoUdW5pbnRlcnBy",
+ "ZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xlLnByb3RvYnVmLlVuaW50ZXJw",
+ "cmV0ZWRPcHRpb24iOgoMT3B0aW1pemVNb2RlEgkKBVNQRUVEEAESDQoJQ09E",
+ "RV9TSVpFEAISEAoMTElURV9SVU5USU1FEAMqCQjoBxCAgICAAkoECCYQJyLs",
+ "AQoOTWVzc2FnZU9wdGlvbnMSJgoXbWVzc2FnZV9zZXRfd2lyZV9mb3JtYXQY",
+ "ASABKAg6BWZhbHNlEi4KH25vX3N0YW5kYXJkX2Rlc2NyaXB0b3JfYWNjZXNz",
+ "b3IYAiABKAg6BWZhbHNlEhkKCmRlcHJlY2F0ZWQYAyABKAg6BWZhbHNlEhEK",
+ "CW1hcF9lbnRyeRgHIAEoCBJDChR1bmludGVycHJldGVkX29wdGlvbhjnByAD",
+ "KAsyJC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9wdGlvbioJCOgH",
+ "EICAgIACSgQICBAJIp4DCgxGaWVsZE9wdGlvbnMSOgoFY3R5cGUYASABKA4y",
+ "Iy5nb29nbGUucHJvdG9idWYuRmllbGRPcHRpb25zLkNUeXBlOgZTVFJJTkcS",
+ "DgoGcGFja2VkGAIgASgIEj8KBmpzdHlwZRgGIAEoDjIkLmdvb2dsZS5wcm90",
+ "b2J1Zi5GaWVsZE9wdGlvbnMuSlNUeXBlOglKU19OT1JNQUwSEwoEbGF6eRgF",
+ "IAEoCDoFZmFsc2USGQoKZGVwcmVjYXRlZBgDIAEoCDoFZmFsc2USEwoEd2Vh",
+ "axgKIAEoCDoFZmFsc2USQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygL",
+ "MiQuZ29vZ2xlLnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24iLwoFQ1R5",
+ "cGUSCgoGU1RSSU5HEAASCAoEQ09SRBABEhAKDFNUUklOR19QSUVDRRACIjUK",
+ "BkpTVHlwZRINCglKU19OT1JNQUwQABINCglKU19TVFJJTkcQARINCglKU19O",
+ "VU1CRVIQAioJCOgHEICAgIACSgQIBBAFIl4KDE9uZW9mT3B0aW9ucxJDChR1",
+ "bmludGVycHJldGVkX29wdGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9idWYu",
+ "VW5pbnRlcnByZXRlZE9wdGlvbioJCOgHEICAgIACIo0BCgtFbnVtT3B0aW9u",
+ "cxITCgthbGxvd19hbGlhcxgCIAEoCBIZCgpkZXByZWNhdGVkGAMgASgIOgVm",
+ "YWxzZRJDChR1bmludGVycHJldGVkX29wdGlvbhjnByADKAsyJC5nb29nbGUu",
+ "cHJvdG9idWYuVW5pbnRlcnByZXRlZE9wdGlvbioJCOgHEICAgIACIn0KEEVu",
+ "dW1WYWx1ZU9wdGlvbnMSGQoKZGVwcmVjYXRlZBgBIAEoCDoFZmFsc2USQwoU",
+ "dW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xlLnByb3RvYnVm",
+ "LlVuaW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCAgICAAiJ7Cg5TZXJ2aWNlT3B0",
+ "aW9ucxIZCgpkZXByZWNhdGVkGCEgASgIOgVmYWxzZRJDChR1bmludGVycHJl",
+ "dGVkX29wdGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnBy",
+ "ZXRlZE9wdGlvbioJCOgHEICAgIACIq0CCg1NZXRob2RPcHRpb25zEhkKCmRl",
+ "cHJlY2F0ZWQYISABKAg6BWZhbHNlEl8KEWlkZW1wb3RlbmN5X2xldmVsGCIg",
+ "ASgOMi8uZ29vZ2xlLnByb3RvYnVmLk1ldGhvZE9wdGlvbnMuSWRlbXBvdGVu",
+ "Y3lMZXZlbDoTSURFTVBPVEVOQ1lfVU5LTk9XThJDChR1bmludGVycHJldGVk",
+ "X29wdGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRl",
+ "ZE9wdGlvbiJQChBJZGVtcG90ZW5jeUxldmVsEhcKE0lERU1QT1RFTkNZX1VO",
+ "S05PV04QABITCg9OT19TSURFX0VGRkVDVFMQARIOCgpJREVNUE9URU5UEAIq",
+ "CQjoBxCAgICAAiKeAgoTVW5pbnRlcnByZXRlZE9wdGlvbhI7CgRuYW1lGAIg",
+ "AygLMi0uZ29vZ2xlLnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24uTmFt",
+ "ZVBhcnQSGAoQaWRlbnRpZmllcl92YWx1ZRgDIAEoCRIaChJwb3NpdGl2ZV9p",
+ "bnRfdmFsdWUYBCABKAQSGgoSbmVnYXRpdmVfaW50X3ZhbHVlGAUgASgDEhQK",
+ "DGRvdWJsZV92YWx1ZRgGIAEoARIUCgxzdHJpbmdfdmFsdWUYByABKAwSFwoP",
+ "YWdncmVnYXRlX3ZhbHVlGAggASgJGjMKCE5hbWVQYXJ0EhEKCW5hbWVfcGFy",
+ "dBgBIAIoCRIUCgxpc19leHRlbnNpb24YAiACKAgi1QEKDlNvdXJjZUNvZGVJ",
+ "bmZvEjoKCGxvY2F0aW9uGAEgAygLMiguZ29vZ2xlLnByb3RvYnVmLlNvdXJj",
+ "ZUNvZGVJbmZvLkxvY2F0aW9uGoYBCghMb2NhdGlvbhIQCgRwYXRoGAEgAygF",
+ "QgIQARIQCgRzcGFuGAIgAygFQgIQARIYChBsZWFkaW5nX2NvbW1lbnRzGAMg",
+ "ASgJEhkKEXRyYWlsaW5nX2NvbW1lbnRzGAQgASgJEiEKGWxlYWRpbmdfZGV0",
+ "YWNoZWRfY29tbWVudHMYBiADKAkipwEKEUdlbmVyYXRlZENvZGVJbmZvEkEK",
+ "CmFubm90YXRpb24YASADKAsyLS5nb29nbGUucHJvdG9idWYuR2VuZXJhdGVk",
+ "Q29kZUluZm8uQW5ub3RhdGlvbhpPCgpBbm5vdGF0aW9uEhAKBHBhdGgYASAD",
+ "KAVCAhABEhMKC3NvdXJjZV9maWxlGAIgASgJEg0KBWJlZ2luGAMgASgFEgsK",
+ "A2VuZBgEIAEoBUKMAQoTY29tLmdvb2dsZS5wcm90b2J1ZkIQRGVzY3JpcHRv",
+ "clByb3Rvc0gBWj5naXRodWIuY29tL2dvbGFuZy9wcm90b2J1Zi9wcm90b2Mt",
+ "Z2VuLWdvL2Rlc2NyaXB0b3I7ZGVzY3JpcHRvcqICA0dQQqoCGkdvb2dsZS5Q",
+ "cm90b2J1Zi5SZWZsZWN0aW9u"));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
@@ -153,14 +159,14 @@ namespace Google.Protobuf.Reflection {
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumValueDescriptorProto), global::Google.Protobuf.Reflection.EnumValueDescriptorProto.Parser, new[]{ "Name", "Number", "Options" }, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.ServiceDescriptorProto), global::Google.Protobuf.Reflection.ServiceDescriptorProto.Parser, new[]{ "Name", "Method", "Options" }, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MethodDescriptorProto), global::Google.Protobuf.Reflection.MethodDescriptorProto.Parser, new[]{ "Name", "InputType", "OutputType", "Options", "ClientStreaming", "ServerStreaming" }, null, null, null),
- new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FileOptions), global::Google.Protobuf.Reflection.FileOptions.Parser, new[]{ "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode) }, null),
+ new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FileOptions), global::Google.Protobuf.Reflection.FileOptions.Parser, new[]{ "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "SwiftPrefix", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode) }, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MessageOptions), global::Google.Protobuf.Reflection.MessageOptions.Parser, new[]{ "MessageSetWireFormat", "NoStandardDescriptorAccessor", "Deprecated", "MapEntry", "UninterpretedOption" }, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FieldOptions), global::Google.Protobuf.Reflection.FieldOptions.Parser, new[]{ "Ctype", "Packed", "Jstype", "Lazy", "Deprecated", "Weak", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.CType), typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.JSType) }, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.OneofOptions), global::Google.Protobuf.Reflection.OneofOptions.Parser, new[]{ "UninterpretedOption" }, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumOptions), global::Google.Protobuf.Reflection.EnumOptions.Parser, new[]{ "AllowAlias", "Deprecated", "UninterpretedOption" }, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumValueOptions), global::Google.Protobuf.Reflection.EnumValueOptions.Parser, new[]{ "Deprecated", "UninterpretedOption" }, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.ServiceOptions), global::Google.Protobuf.Reflection.ServiceOptions.Parser, new[]{ "Deprecated", "UninterpretedOption" }, null, null, null),
- new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MethodOptions), global::Google.Protobuf.Reflection.MethodOptions.Parser, new[]{ "Deprecated", "UninterpretedOption" }, null, null, null),
+ new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MethodOptions), global::Google.Protobuf.Reflection.MethodOptions.Parser, new[]{ "Deprecated", "IdempotencyLevel", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.MethodOptions.Types.IdempotencyLevel) }, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.UninterpretedOption), global::Google.Protobuf.Reflection.UninterpretedOption.Parser, new[]{ "Name", "IdentifierValue", "PositiveIntValue", "NegativeIntValue", "DoubleValue", "StringValue", "AggregateValue" }, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.UninterpretedOption.Types.NamePart), global::Google.Protobuf.Reflection.UninterpretedOption.Types.NamePart.Parser, new[]{ "NamePart_", "IsExtension" }, null, null, null)}),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.SourceCodeInfo), global::Google.Protobuf.Reflection.SourceCodeInfo.Parser, new[]{ "Location" }, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.SourceCodeInfo.Types.Location), global::Google.Protobuf.Reflection.SourceCodeInfo.Types.Location.Parser, new[]{ "Path", "Span", "LeadingComments", "TrailingComments", "LeadingDetachedComments" }, null, null, null)}),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.GeneratedCodeInfo), global::Google.Protobuf.Reflection.GeneratedCodeInfo.Parser, new[]{ "Annotation" }, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.GeneratedCodeInfo.Types.Annotation), global::Google.Protobuf.Reflection.GeneratedCodeInfo.Types.Annotation.Parser, new[]{ "Path", "SourceFile", "Begin", "End" }, null, null, null)})
@@ -171,8 +177,8 @@ namespace Google.Protobuf.Reflection {
}
#region Messages
/// <summary>
- /// The protocol compiler can output a FileDescriptorSet containing the .proto
- /// files it parses.
+ /// The protocol compiler can output a FileDescriptorSet containing the .proto
+ /// files it parses.
/// </summary>
internal sealed partial class FileDescriptorSet : pb::IMessage<FileDescriptorSet> {
private static readonly pb::MessageParser<FileDescriptorSet> _parser = new pb::MessageParser<FileDescriptorSet>(() => new FileDescriptorSet());
@@ -284,7 +290,7 @@ namespace Google.Protobuf.Reflection {
}
/// <summary>
- /// Describes a complete .proto file.
+ /// Describes a complete .proto file.
/// </summary>
internal sealed partial class FileDescriptorProto : pb::IMessage<FileDescriptorProto> {
private static readonly pb::MessageParser<FileDescriptorProto> _parser = new pb::MessageParser<FileDescriptorProto>(() => new FileDescriptorProto());
@@ -333,7 +339,7 @@ namespace Google.Protobuf.Reflection {
public const int NameFieldNumber = 1;
private string name_ = "";
/// <summary>
- /// file name, relative to root of source tree
+ /// file name, relative to root of source tree
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Name {
@@ -347,7 +353,7 @@ namespace Google.Protobuf.Reflection {
public const int PackageFieldNumber = 2;
private string package_ = "";
/// <summary>
- /// e.g. "foo", "foo.bar", etc.
+ /// e.g. "foo", "foo.bar", etc.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Package {
@@ -363,7 +369,7 @@ namespace Google.Protobuf.Reflection {
= pb::FieldCodec.ForString(26);
private readonly pbc::RepeatedField<string> dependency_ = new pbc::RepeatedField<string>();
/// <summary>
- /// Names of files imported by this file.
+ /// Names of files imported by this file.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<string> Dependency {
@@ -376,7 +382,7 @@ namespace Google.Protobuf.Reflection {
= pb::FieldCodec.ForInt32(80);
private readonly pbc::RepeatedField<int> publicDependency_ = new pbc::RepeatedField<int>();
/// <summary>
- /// Indexes of the public imported files in the dependency list above.
+ /// Indexes of the public imported files in the dependency list above.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<int> PublicDependency {
@@ -389,8 +395,8 @@ namespace Google.Protobuf.Reflection {
= pb::FieldCodec.ForInt32(88);
private readonly pbc::RepeatedField<int> weakDependency_ = new pbc::RepeatedField<int>();
/// <summary>
- /// Indexes of the weak imported files in the dependency list.
- /// For Google-internal migration only. Do not use.
+ /// Indexes of the weak imported files in the dependency list.
+ /// For Google-internal migration only. Do not use.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<int> WeakDependency {
@@ -403,7 +409,7 @@ namespace Google.Protobuf.Reflection {
= pb::FieldCodec.ForMessage(34, global::Google.Protobuf.Reflection.DescriptorProto.Parser);
private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.DescriptorProto> messageType_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.DescriptorProto>();
/// <summary>
- /// All top-level definitions in this file.
+ /// All top-level definitions in this file.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Google.Protobuf.Reflection.DescriptorProto> MessageType {
@@ -455,10 +461,10 @@ namespace Google.Protobuf.Reflection {
public const int SourceCodeInfoFieldNumber = 9;
private global::Google.Protobuf.Reflection.SourceCodeInfo sourceCodeInfo_;
/// <summary>
- /// This field contains optional information about the original source code.
- /// You may safely remove this entire field without harming runtime
- /// functionality of the descriptors -- the information is needed only by
- /// development tools.
+ /// This field contains optional information about the original source code.
+ /// You may safely remove this entire field without harming runtime
+ /// functionality of the descriptors -- the information is needed only by
+ /// development tools.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Google.Protobuf.Reflection.SourceCodeInfo SourceCodeInfo {
@@ -472,8 +478,8 @@ namespace Google.Protobuf.Reflection {
public const int SyntaxFieldNumber = 12;
private string syntax_ = "";
/// <summary>
- /// The syntax of the proto file.
- /// The supported values are "proto2" and "proto3".
+ /// The syntax of the proto file.
+ /// The supported values are "proto2" and "proto3".
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Syntax {
@@ -699,7 +705,7 @@ namespace Google.Protobuf.Reflection {
}
/// <summary>
- /// Describes a message type.
+ /// Describes a message type.
/// </summary>
internal sealed partial class DescriptorProto : pb::IMessage<DescriptorProto> {
private static readonly pb::MessageParser<DescriptorProto> _parser = new pb::MessageParser<DescriptorProto>(() => new DescriptorProto());
@@ -840,8 +846,8 @@ namespace Google.Protobuf.Reflection {
= pb::FieldCodec.ForString(82);
private readonly pbc::RepeatedField<string> reservedName_ = new pbc::RepeatedField<string>();
/// <summary>
- /// Reserved field names, which may not be used by fields in the same message.
- /// A given name may only be reserved once.
+ /// Reserved field names, which may not be used by fields in the same message.
+ /// A given name may only be reserved once.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<string> ReservedName {
@@ -1164,9 +1170,9 @@ namespace Google.Protobuf.Reflection {
}
/// <summary>
- /// Range of reserved tag numbers. Reserved tag numbers may not be used by
- /// fields or extension ranges in the same message. Reserved ranges may
- /// not overlap.
+ /// Range of reserved tag numbers. Reserved tag numbers may not be used by
+ /// fields or extension ranges in the same message. Reserved ranges may
+ /// not overlap.
/// </summary>
internal sealed partial class ReservedRange : pb::IMessage<ReservedRange> {
private static readonly pb::MessageParser<ReservedRange> _parser = new pb::MessageParser<ReservedRange>(() => new ReservedRange());
@@ -1205,7 +1211,7 @@ namespace Google.Protobuf.Reflection {
public const int StartFieldNumber = 1;
private int start_;
/// <summary>
- /// Inclusive.
+ /// Inclusive.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int Start {
@@ -1219,7 +1225,7 @@ namespace Google.Protobuf.Reflection {
public const int EndFieldNumber = 2;
private int end_;
/// <summary>
- /// Exclusive.
+ /// Exclusive.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int End {
@@ -1325,7 +1331,7 @@ namespace Google.Protobuf.Reflection {
}
/// <summary>
- /// Describes a field within a message.
+ /// Describes a field within a message.
/// </summary>
internal sealed partial class FieldDescriptorProto : pb::IMessage<FieldDescriptorProto> {
private static readonly pb::MessageParser<FieldDescriptorProto> _parser = new pb::MessageParser<FieldDescriptorProto>(() => new FieldDescriptorProto());
@@ -1405,8 +1411,8 @@ namespace Google.Protobuf.Reflection {
public const int TypeFieldNumber = 5;
private global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type type_ = 0;
/// <summary>
- /// If type_name is set, this need not be set. If both this and type_name
- /// are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
+ /// If type_name is set, this need not be set. If both this and type_name
+ /// are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type Type {
@@ -1420,11 +1426,11 @@ namespace Google.Protobuf.Reflection {
public const int TypeNameFieldNumber = 6;
private string typeName_ = "";
/// <summary>
- /// For message and enum types, this is the name of the type. If the name
- /// starts with a '.', it is fully-qualified. Otherwise, C++-like scoping
- /// rules are used to find the type (i.e. first the nested types within this
- /// message are searched, then within the parent, on up to the root
- /// namespace).
+ /// For message and enum types, this is the name of the type. If the name
+ /// starts with a '.', it is fully-qualified. Otherwise, C++-like scoping
+ /// rules are used to find the type (i.e. first the nested types within this
+ /// message are searched, then within the parent, on up to the root
+ /// namespace).
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string TypeName {
@@ -1438,8 +1444,8 @@ namespace Google.Protobuf.Reflection {
public const int ExtendeeFieldNumber = 2;
private string extendee_ = "";
/// <summary>
- /// For extensions, this is the name of the type being extended. It is
- /// resolved in the same manner as type_name.
+ /// For extensions, this is the name of the type being extended. It is
+ /// resolved in the same manner as type_name.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Extendee {
@@ -1453,11 +1459,11 @@ namespace Google.Protobuf.Reflection {
public const int DefaultValueFieldNumber = 7;
private string defaultValue_ = "";
/// <summary>
- /// For numeric types, contains the original text representation of the value.
- /// For booleans, "true" or "false".
- /// For strings, contains the default text contents (not escaped in any way).
- /// For bytes, contains the C escaped value. All bytes >= 128 are escaped.
- /// TODO(kenton): Base-64 encode?
+ /// For numeric types, contains the original text representation of the value.
+ /// For booleans, "true" or "false".
+ /// For strings, contains the default text contents (not escaped in any way).
+ /// For bytes, contains the C escaped value. All bytes >= 128 are escaped.
+ /// TODO(kenton): Base-64 encode?
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string DefaultValue {
@@ -1471,8 +1477,8 @@ namespace Google.Protobuf.Reflection {
public const int OneofIndexFieldNumber = 9;
private int oneofIndex_;
/// <summary>
- /// If set, gives the index of a oneof in the containing type's oneof_decl
- /// list. This field is a member of that oneof.
+ /// If set, gives the index of a oneof in the containing type's oneof_decl
+ /// list. This field is a member of that oneof.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int OneofIndex {
@@ -1486,10 +1492,10 @@ namespace Google.Protobuf.Reflection {
public const int JsonNameFieldNumber = 10;
private string jsonName_ = "";
/// <summary>
- /// JSON name of this field. The value is set by protocol compiler. If the
- /// user has set a "json_name" option on this field, that option's value
- /// will be used. Otherwise, it's deduced from the field's name by converting
- /// it to camelCase.
+ /// JSON name of this field. The value is set by protocol compiler. If the
+ /// user has set a "json_name" option on this field, that option's value
+ /// will be used. Otherwise, it's deduced from the field's name by converting
+ /// it to camelCase.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string JsonName {
@@ -1738,20 +1744,20 @@ namespace Google.Protobuf.Reflection {
public static partial class Types {
internal enum Type {
/// <summary>
- /// 0 is reserved for errors.
- /// Order is weird for historical reasons.
+ /// 0 is reserved for errors.
+ /// Order is weird for historical reasons.
/// </summary>
[pbr::OriginalName("TYPE_DOUBLE")] Double = 1,
[pbr::OriginalName("TYPE_FLOAT")] Float = 2,
/// <summary>
- /// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if
- /// negative values are likely.
+ /// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if
+ /// negative values are likely.
/// </summary>
[pbr::OriginalName("TYPE_INT64")] Int64 = 3,
[pbr::OriginalName("TYPE_UINT64")] Uint64 = 4,
/// <summary>
- /// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if
- /// negative values are likely.
+ /// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if
+ /// negative values are likely.
/// </summary>
[pbr::OriginalName("TYPE_INT32")] Int32 = 5,
[pbr::OriginalName("TYPE_FIXED64")] Fixed64 = 6,
@@ -1759,15 +1765,18 @@ namespace Google.Protobuf.Reflection {
[pbr::OriginalName("TYPE_BOOL")] Bool = 8,
[pbr::OriginalName("TYPE_STRING")] String = 9,
/// <summary>
- /// Tag-delimited aggregate.
+ /// Tag-delimited aggregate.
+ /// Group type is deprecated and not supported in proto3. However, Proto3
+ /// implementations should still be able to parse the group wire format and
+ /// treat group fields as unknown fields.
/// </summary>
[pbr::OriginalName("TYPE_GROUP")] Group = 10,
/// <summary>
- /// Length-delimited aggregate.
+ /// Length-delimited aggregate.
/// </summary>
[pbr::OriginalName("TYPE_MESSAGE")] Message = 11,
/// <summary>
- /// New in version 2.
+ /// New in version 2.
/// </summary>
[pbr::OriginalName("TYPE_BYTES")] Bytes = 12,
[pbr::OriginalName("TYPE_UINT32")] Uint32 = 13,
@@ -1775,24 +1784,21 @@ namespace Google.Protobuf.Reflection {
[pbr::OriginalName("TYPE_SFIXED32")] Sfixed32 = 15,
[pbr::OriginalName("TYPE_SFIXED64")] Sfixed64 = 16,
/// <summary>
- /// Uses ZigZag encoding.
+ /// Uses ZigZag encoding.
/// </summary>
[pbr::OriginalName("TYPE_SINT32")] Sint32 = 17,
/// <summary>
- /// Uses ZigZag encoding.
+ /// Uses ZigZag encoding.
/// </summary>
[pbr::OriginalName("TYPE_SINT64")] Sint64 = 18,
}
internal enum Label {
/// <summary>
- /// 0 is reserved for errors
+ /// 0 is reserved for errors
/// </summary>
[pbr::OriginalName("LABEL_OPTIONAL")] Optional = 1,
[pbr::OriginalName("LABEL_REQUIRED")] Required = 2,
- /// <summary>
- /// TODO(sanjay): Should we add LABEL_MAP?
- /// </summary>
[pbr::OriginalName("LABEL_REPEATED")] Repeated = 3,
}
@@ -1802,7 +1808,7 @@ namespace Google.Protobuf.Reflection {
}
/// <summary>
- /// Describes a oneof.
+ /// Describes a oneof.
/// </summary>
internal sealed partial class OneofDescriptorProto : pb::IMessage<OneofDescriptorProto> {
private static readonly pb::MessageParser<OneofDescriptorProto> _parser = new pb::MessageParser<OneofDescriptorProto>(() => new OneofDescriptorProto());
@@ -1956,7 +1962,7 @@ namespace Google.Protobuf.Reflection {
}
/// <summary>
- /// Describes an enum type.
+ /// Describes an enum type.
/// </summary>
internal sealed partial class EnumDescriptorProto : pb::IMessage<EnumDescriptorProto> {
private static readonly pb::MessageParser<EnumDescriptorProto> _parser = new pb::MessageParser<EnumDescriptorProto>(() => new EnumDescriptorProto());
@@ -2130,7 +2136,7 @@ namespace Google.Protobuf.Reflection {
}
/// <summary>
- /// Describes a value within an enum.
+ /// Describes a value within an enum.
/// </summary>
internal sealed partial class EnumValueDescriptorProto : pb::IMessage<EnumValueDescriptorProto> {
private static readonly pb::MessageParser<EnumValueDescriptorProto> _parser = new pb::MessageParser<EnumValueDescriptorProto>(() => new EnumValueDescriptorProto());
@@ -2312,7 +2318,7 @@ namespace Google.Protobuf.Reflection {
}
/// <summary>
- /// Describes a service.
+ /// Describes a service.
/// </summary>
internal sealed partial class ServiceDescriptorProto : pb::IMessage<ServiceDescriptorProto> {
private static readonly pb::MessageParser<ServiceDescriptorProto> _parser = new pb::MessageParser<ServiceDescriptorProto>(() => new ServiceDescriptorProto());
@@ -2486,7 +2492,7 @@ namespace Google.Protobuf.Reflection {
}
/// <summary>
- /// Describes a method of a service.
+ /// Describes a method of a service.
/// </summary>
internal sealed partial class MethodDescriptorProto : pb::IMessage<MethodDescriptorProto> {
private static readonly pb::MessageParser<MethodDescriptorProto> _parser = new pb::MessageParser<MethodDescriptorProto>(() => new MethodDescriptorProto());
@@ -2540,8 +2546,8 @@ namespace Google.Protobuf.Reflection {
public const int InputTypeFieldNumber = 2;
private string inputType_ = "";
/// <summary>
- /// Input and output type names. These are resolved in the same way as
- /// FieldDescriptorProto.type_name, but must refer to a message type.
+ /// Input and output type names. These are resolved in the same way as
+ /// FieldDescriptorProto.type_name, but must refer to a message type.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string InputType {
@@ -2577,7 +2583,7 @@ namespace Google.Protobuf.Reflection {
public const int ClientStreamingFieldNumber = 5;
private bool clientStreaming_;
/// <summary>
- /// Identifies if client streams multiple client messages
+ /// Identifies if client streams multiple client messages
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool ClientStreaming {
@@ -2591,7 +2597,7 @@ namespace Google.Protobuf.Reflection {
public const int ServerStreamingFieldNumber = 6;
private bool serverStreaming_;
/// <summary>
- /// Identifies if server streams multiple server messages
+ /// Identifies if server streams multiple server messages
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool ServerStreaming {
@@ -2776,6 +2782,8 @@ namespace Google.Protobuf.Reflection {
get { return Descriptor; }
}
+ internal CustomOptions CustomOptions{ get; private set; } = CustomOptions.Empty;
+
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public FileOptions() {
OnConstruction();
@@ -2799,6 +2807,7 @@ namespace Google.Protobuf.Reflection {
ccEnableArenas_ = other.ccEnableArenas_;
objcClassPrefix_ = other.objcClassPrefix_;
csharpNamespace_ = other.csharpNamespace_;
+ swiftPrefix_ = other.swiftPrefix_;
uninterpretedOption_ = other.uninterpretedOption_.Clone();
}
@@ -2811,10 +2820,10 @@ namespace Google.Protobuf.Reflection {
public const int JavaPackageFieldNumber = 1;
private string javaPackage_ = "";
/// <summary>
- /// Sets the Java package where classes generated from this .proto will be
- /// placed. By default, the proto package is used, but this is often
- /// inappropriate because proto packages do not normally start with backwards
- /// domain names.
+ /// Sets the Java package where classes generated from this .proto will be
+ /// placed. By default, the proto package is used, but this is often
+ /// inappropriate because proto packages do not normally start with backwards
+ /// domain names.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string JavaPackage {
@@ -2828,11 +2837,11 @@ namespace Google.Protobuf.Reflection {
public const int JavaOuterClassnameFieldNumber = 8;
private string javaOuterClassname_ = "";
/// <summary>
- /// If set, all the classes from the .proto file are wrapped in a single
- /// outer class with the given name. This applies to both Proto1
- /// (equivalent to the old "--one_java_file" option) and Proto2 (where
- /// a .proto always translates to a single class, but you may want to
- /// explicitly choose the class name).
+ /// If set, all the classes from the .proto file are wrapped in a single
+ /// outer class with the given name. This applies to both Proto1
+ /// (equivalent to the old "--one_java_file" option) and Proto2 (where
+ /// a .proto always translates to a single class, but you may want to
+ /// explicitly choose the class name).
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string JavaOuterClassname {
@@ -2846,12 +2855,12 @@ namespace Google.Protobuf.Reflection {
public const int JavaMultipleFilesFieldNumber = 10;
private bool javaMultipleFiles_;
/// <summary>
- /// If set true, then the Java code generator will generate a separate .java
- /// file for each top-level message, enum, and service defined in the .proto
- /// file. Thus, these types will *not* be nested inside the outer class
- /// named by java_outer_classname. However, the outer class will still be
- /// generated to contain the file's getDescriptor() method as well as any
- /// top-level extensions defined in the file.
+ /// If set true, then the Java code generator will generate a separate .java
+ /// file for each top-level message, enum, and service defined in the .proto
+ /// file. Thus, these types will *not* be nested inside the outer class
+ /// named by java_outer_classname. However, the outer class will still be
+ /// generated to contain the file's getDescriptor() method as well as any
+ /// top-level extensions defined in the file.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool JavaMultipleFiles {
@@ -2865,7 +2874,7 @@ namespace Google.Protobuf.Reflection {
public const int JavaGenerateEqualsAndHashFieldNumber = 20;
private bool javaGenerateEqualsAndHash_;
/// <summary>
- /// This option does nothing.
+ /// This option does nothing.
/// </summary>
[global::System.ObsoleteAttribute]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -2880,12 +2889,12 @@ namespace Google.Protobuf.Reflection {
public const int JavaStringCheckUtf8FieldNumber = 27;
private bool javaStringCheckUtf8_;
/// <summary>
- /// If set true, then the Java2 code generator will generate code that
- /// throws an exception whenever an attempt is made to assign a non-UTF-8
- /// byte sequence to a string field.
- /// Message reflection will do the same.
- /// However, an extension field still accepts non-UTF-8 byte sequences.
- /// This option has no effect on when used with the lite runtime.
+ /// If set true, then the Java2 code generator will generate code that
+ /// throws an exception whenever an attempt is made to assign a non-UTF-8
+ /// byte sequence to a string field.
+ /// Message reflection will do the same.
+ /// However, an extension field still accepts non-UTF-8 byte sequences.
+ /// This option has no effect on when used with the lite runtime.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool JavaStringCheckUtf8 {
@@ -2910,11 +2919,11 @@ namespace Google.Protobuf.Reflection {
public const int GoPackageFieldNumber = 11;
private string goPackage_ = "";
/// <summary>
- /// Sets the Go package where structs generated from this .proto will be
- /// placed. If omitted, the Go package will be derived from the following:
- /// - The basename of the package import path, if provided.
- /// - Otherwise, the package statement in the .proto file, if present.
- /// - Otherwise, the basename of the .proto file, without extension.
+ /// Sets the Go package where structs generated from this .proto will be
+ /// placed. If omitted, the Go package will be derived from the following:
+ /// - The basename of the package import path, if provided.
+ /// - Otherwise, the package statement in the .proto file, if present.
+ /// - Otherwise, the basename of the .proto file, without extension.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string GoPackage {
@@ -2928,16 +2937,16 @@ namespace Google.Protobuf.Reflection {
public const int CcGenericServicesFieldNumber = 16;
private bool ccGenericServices_;
/// <summary>
- /// Should generic services be generated in each language? "Generic" services
- /// are not specific to any particular RPC system. They are generated by the
- /// main code generators in each language (without additional plugins).
- /// Generic services were the only kind of service generation supported by
- /// early versions of google.protobuf.
+ /// Should generic services be generated in each language? "Generic" services
+ /// are not specific to any particular RPC system. They are generated by the
+ /// main code generators in each language (without additional plugins).
+ /// Generic services were the only kind of service generation supported by
+ /// early versions of google.protobuf.
///
- /// Generic services are now considered deprecated in favor of using plugins
- /// that generate code specific to your particular RPC system. Therefore,
- /// these default to false. Old code which depends on generic services should
- /// explicitly set them to true.
+ /// Generic services are now considered deprecated in favor of using plugins
+ /// that generate code specific to your particular RPC system. Therefore,
+ /// these default to false. Old code which depends on generic services should
+ /// explicitly set them to true.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool CcGenericServices {
@@ -2973,10 +2982,10 @@ namespace Google.Protobuf.Reflection {
public const int DeprecatedFieldNumber = 23;
private bool deprecated_;
/// <summary>
- /// Is this file deprecated?
- /// Depending on the target platform, this can emit Deprecated annotations
- /// for everything in the file, or it will be completely ignored; in the very
- /// least, this is a formalization for deprecating files.
+ /// Is this file deprecated?
+ /// Depending on the target platform, this can emit Deprecated annotations
+ /// for everything in the file, or it will be completely ignored; in the very
+ /// least, this is a formalization for deprecating files.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Deprecated {
@@ -2990,8 +2999,8 @@ namespace Google.Protobuf.Reflection {
public const int CcEnableArenasFieldNumber = 31;
private bool ccEnableArenas_;
/// <summary>
- /// Enables the use of arenas for the proto messages in this file. This applies
- /// only to generated classes for C++.
+ /// Enables the use of arenas for the proto messages in this file. This applies
+ /// only to generated classes for C++.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool CcEnableArenas {
@@ -3005,8 +3014,8 @@ namespace Google.Protobuf.Reflection {
public const int ObjcClassPrefixFieldNumber = 36;
private string objcClassPrefix_ = "";
/// <summary>
- /// Sets the objective c class prefix which is prepended to all objective c
- /// generated classes from this .proto. There is no default.
+ /// Sets the objective c class prefix which is prepended to all objective c
+ /// generated classes from this .proto. There is no default.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string ObjcClassPrefix {
@@ -3020,7 +3029,7 @@ namespace Google.Protobuf.Reflection {
public const int CsharpNamespaceFieldNumber = 37;
private string csharpNamespace_ = "";
/// <summary>
- /// Namespace for generated classes; defaults to the package.
+ /// Namespace for generated classes; defaults to the package.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string CsharpNamespace {
@@ -3030,13 +3039,30 @@ namespace Google.Protobuf.Reflection {
}
}
+ /// <summary>Field number for the "swift_prefix" field.</summary>
+ public const int SwiftPrefixFieldNumber = 39;
+ private string swiftPrefix_ = "";
+ /// <summary>
+ /// By default Swift generators will take the proto package and CamelCase it
+ /// replacing '.' with underscore and use that to prefix the types/symbols
+ /// defined. When this options is provided, they will use this value instead
+ /// to prefix the types/symbols defined.
+ /// </summary>
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public string SwiftPrefix {
+ get { return swiftPrefix_; }
+ set {
+ swiftPrefix_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
+ }
+ }
+
/// <summary>Field number for the "uninterpreted_option" field.</summary>
public const int UninterpretedOptionFieldNumber = 999;
private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.UninterpretedOption> _repeated_uninterpretedOption_codec
= pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser);
private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption>();
/// <summary>
- /// The parser stores options it doesn't recognize here. See above.
+ /// The parser stores options it doesn't recognize here. See above.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> UninterpretedOption {
@@ -3070,6 +3096,7 @@ namespace Google.Protobuf.Reflection {
if (CcEnableArenas != other.CcEnableArenas) return false;
if (ObjcClassPrefix != other.ObjcClassPrefix) return false;
if (CsharpNamespace != other.CsharpNamespace) return false;
+ if (SwiftPrefix != other.SwiftPrefix) return false;
if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false;
return true;
}
@@ -3091,6 +3118,7 @@ namespace Google.Protobuf.Reflection {
if (CcEnableArenas != false) hash ^= CcEnableArenas.GetHashCode();
if (ObjcClassPrefix.Length != 0) hash ^= ObjcClassPrefix.GetHashCode();
if (CsharpNamespace.Length != 0) hash ^= CsharpNamespace.GetHashCode();
+ if (SwiftPrefix.Length != 0) hash ^= SwiftPrefix.GetHashCode();
hash ^= uninterpretedOption_.GetHashCode();
return hash;
}
@@ -3158,6 +3186,10 @@ namespace Google.Protobuf.Reflection {
output.WriteRawTag(170, 2);
output.WriteString(CsharpNamespace);
}
+ if (SwiftPrefix.Length != 0) {
+ output.WriteRawTag(186, 2);
+ output.WriteString(SwiftPrefix);
+ }
uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec);
}
@@ -3206,6 +3238,9 @@ namespace Google.Protobuf.Reflection {
if (CsharpNamespace.Length != 0) {
size += 2 + pb::CodedOutputStream.ComputeStringSize(CsharpNamespace);
}
+ if (SwiftPrefix.Length != 0) {
+ size += 2 + pb::CodedOutputStream.ComputeStringSize(SwiftPrefix);
+ }
size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec);
return size;
}
@@ -3257,6 +3292,9 @@ namespace Google.Protobuf.Reflection {
if (other.CsharpNamespace.Length != 0) {
CsharpNamespace = other.CsharpNamespace;
}
+ if (other.SwiftPrefix.Length != 0) {
+ SwiftPrefix = other.SwiftPrefix;
+ }
uninterpretedOption_.Add(other.uninterpretedOption_);
}
@@ -3266,7 +3304,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- input.SkipLastField();
+ CustomOptions = CustomOptions.ReadOrSkipUnknownField(input);
break;
case 10: {
JavaPackage = input.ReadString();
@@ -3324,6 +3362,10 @@ namespace Google.Protobuf.Reflection {
CsharpNamespace = input.ReadString();
break;
}
+ case 314: {
+ SwiftPrefix = input.ReadString();
+ break;
+ }
case 7994: {
uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec);
break;
@@ -3337,19 +3379,19 @@ namespace Google.Protobuf.Reflection {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static partial class Types {
/// <summary>
- /// Generated classes can be optimized for speed or code size.
+ /// Generated classes can be optimized for speed or code size.
/// </summary>
internal enum OptimizeMode {
/// <summary>
- /// Generate complete code for parsing, serialization,
+ /// Generate complete code for parsing, serialization,
/// </summary>
[pbr::OriginalName("SPEED")] Speed = 1,
/// <summary>
- /// etc.
+ /// etc.
/// </summary>
[pbr::OriginalName("CODE_SIZE")] CodeSize = 2,
/// <summary>
- /// Generate code using MessageLite and the lite runtime.
+ /// Generate code using MessageLite and the lite runtime.
/// </summary>
[pbr::OriginalName("LITE_RUNTIME")] LiteRuntime = 3,
}
@@ -3374,6 +3416,8 @@ namespace Google.Protobuf.Reflection {
get { return Descriptor; }
}
+ internal CustomOptions CustomOptions{ get; private set; } = CustomOptions.Empty;
+
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public MessageOptions() {
OnConstruction();
@@ -3399,24 +3443,24 @@ namespace Google.Protobuf.Reflection {
public const int MessageSetWireFormatFieldNumber = 1;
private bool messageSetWireFormat_;
/// <summary>
- /// Set true to use the old proto1 MessageSet wire format for extensions.
- /// This is provided for backwards-compatibility with the MessageSet wire
- /// format. You should not use this for any other reason: It's less
- /// efficient, has fewer features, and is more complicated.
+ /// Set true to use the old proto1 MessageSet wire format for extensions.
+ /// This is provided for backwards-compatibility with the MessageSet wire
+ /// format. You should not use this for any other reason: It's less
+ /// efficient, has fewer features, and is more complicated.
///
- /// The message must be defined exactly as follows:
- /// message Foo {
- /// option message_set_wire_format = true;
- /// extensions 4 to max;
- /// }
- /// Note that the message cannot have any defined fields; MessageSets only
- /// have extensions.
+ /// The message must be defined exactly as follows:
+ /// message Foo {
+ /// option message_set_wire_format = true;
+ /// extensions 4 to max;
+ /// }
+ /// Note that the message cannot have any defined fields; MessageSets only
+ /// have extensions.
///
- /// All extensions of your type must be singular messages; e.g. they cannot
- /// be int32s, enums, or repeated messages.
+ /// All extensions of your type must be singular messages; e.g. they cannot
+ /// be int32s, enums, or repeated messages.
///
- /// Because this is an option, the above two restrictions are not enforced by
- /// the protocol compiler.
+ /// Because this is an option, the above two restrictions are not enforced by
+ /// the protocol compiler.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool MessageSetWireFormat {
@@ -3430,9 +3474,9 @@ namespace Google.Protobuf.Reflection {
public const int NoStandardDescriptorAccessorFieldNumber = 2;
private bool noStandardDescriptorAccessor_;
/// <summary>
- /// Disables the generation of the standard "descriptor()" accessor, which can
- /// conflict with a field of the same name. This is meant to make migration
- /// from proto1 easier; new code should avoid fields named "descriptor".
+ /// Disables the generation of the standard "descriptor()" accessor, which can
+ /// conflict with a field of the same name. This is meant to make migration
+ /// from proto1 easier; new code should avoid fields named "descriptor".
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool NoStandardDescriptorAccessor {
@@ -3446,10 +3490,10 @@ namespace Google.Protobuf.Reflection {
public const int DeprecatedFieldNumber = 3;
private bool deprecated_;
/// <summary>
- /// Is this message deprecated?
- /// Depending on the target platform, this can emit Deprecated annotations
- /// for the message, or it will be completely ignored; in the very least,
- /// this is a formalization for deprecating messages.
+ /// Is this message deprecated?
+ /// Depending on the target platform, this can emit Deprecated annotations
+ /// for the message, or it will be completely ignored; in the very least,
+ /// this is a formalization for deprecating messages.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Deprecated {
@@ -3463,27 +3507,27 @@ namespace Google.Protobuf.Reflection {
public const int MapEntryFieldNumber = 7;
private bool mapEntry_;
/// <summary>
- /// Whether the message is an automatically generated map entry type for the
- /// maps field.
+ /// Whether the message is an automatically generated map entry type for the
+ /// maps field.
///
- /// For maps fields:
- /// map&lt;KeyType, ValueType> map_field = 1;
- /// The parsed descriptor looks like:
- /// message MapFieldEntry {
- /// option map_entry = true;
- /// optional KeyType key = 1;
- /// optional ValueType value = 2;
- /// }
- /// repeated MapFieldEntry map_field = 1;
+ /// For maps fields:
+ /// map&lt;KeyType, ValueType> map_field = 1;
+ /// The parsed descriptor looks like:
+ /// message MapFieldEntry {
+ /// option map_entry = true;
+ /// optional KeyType key = 1;
+ /// optional ValueType value = 2;
+ /// }
+ /// repeated MapFieldEntry map_field = 1;
///
- /// Implementations may choose not to generate the map_entry=true message, but
- /// use a native map in the target language to hold the keys and values.
- /// The reflection APIs in such implementions still need to work as
- /// if the field is a repeated message field.
+ /// Implementations may choose not to generate the map_entry=true message, but
+ /// use a native map in the target language to hold the keys and values.
+ /// The reflection APIs in such implementions still need to work as
+ /// if the field is a repeated message field.
///
- /// NOTE: Do not set the option in .proto files. Always use the maps syntax
- /// instead. The option should only be implicitly set by the proto compiler
- /// parser.
+ /// NOTE: Do not set the option in .proto files. Always use the maps syntax
+ /// instead. The option should only be implicitly set by the proto compiler
+ /// parser.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool MapEntry {
@@ -3499,7 +3543,7 @@ namespace Google.Protobuf.Reflection {
= pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser);
private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption>();
/// <summary>
- /// The parser stores options it doesn't recognize here. See above.
+ /// The parser stores options it doesn't recognize here. See above.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> UninterpretedOption {
@@ -3609,7 +3653,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- input.SkipLastField();
+ CustomOptions = CustomOptions.ReadOrSkipUnknownField(input);
break;
case 8: {
MessageSetWireFormat = input.ReadBool();
@@ -3652,6 +3696,8 @@ namespace Google.Protobuf.Reflection {
get { return Descriptor; }
}
+ internal CustomOptions CustomOptions{ get; private set; } = CustomOptions.Empty;
+
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public FieldOptions() {
OnConstruction();
@@ -3679,10 +3725,10 @@ namespace Google.Protobuf.Reflection {
public const int CtypeFieldNumber = 1;
private global::Google.Protobuf.Reflection.FieldOptions.Types.CType ctype_ = 0;
/// <summary>
- /// The ctype option instructs the C++ code generator to use a different
- /// representation of the field than it normally would. See the specific
- /// options below. This option is not yet implemented in the open source
- /// release -- sorry, we'll try to include it in a future version!
+ /// The ctype option instructs the C++ code generator to use a different
+ /// representation of the field than it normally would. See the specific
+ /// options below. This option is not yet implemented in the open source
+ /// release -- sorry, we'll try to include it in a future version!
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Google.Protobuf.Reflection.FieldOptions.Types.CType Ctype {
@@ -3696,11 +3742,11 @@ namespace Google.Protobuf.Reflection {
public const int PackedFieldNumber = 2;
private bool packed_;
/// <summary>
- /// The packed option can be enabled for repeated primitive fields to enable
- /// a more efficient representation on the wire. Rather than repeatedly
- /// writing the tag and type for each element, the entire array is encoded as
- /// a single length-delimited blob. In proto3, only explicit setting it to
- /// false will avoid using packed encoding.
+ /// The packed option can be enabled for repeated primitive fields to enable
+ /// a more efficient representation on the wire. Rather than repeatedly
+ /// writing the tag and type for each element, the entire array is encoded as
+ /// a single length-delimited blob. In proto3, only explicit setting it to
+ /// false will avoid using packed encoding.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Packed {
@@ -3714,15 +3760,15 @@ namespace Google.Protobuf.Reflection {
public const int JstypeFieldNumber = 6;
private global::Google.Protobuf.Reflection.FieldOptions.Types.JSType jstype_ = 0;
/// <summary>
- /// The jstype option determines the JavaScript type used for values of the
- /// field. The option is permitted only for 64 bit integral and fixed types
- /// (int64, uint64, sint64, fixed64, sfixed64). By default these types are
- /// represented as JavaScript strings. This avoids loss of precision that can
- /// happen when a large value is converted to a floating point JavaScript
- /// numbers. Specifying JS_NUMBER for the jstype causes the generated
- /// JavaScript code to use the JavaScript "number" type instead of strings.
- /// This option is an enum to permit additional types to be added,
- /// e.g. goog.math.Integer.
+ /// The jstype option determines the JavaScript type used for values of the
+ /// field. The option is permitted only for 64 bit integral and fixed types
+ /// (int64, uint64, sint64, fixed64, sfixed64). By default these types are
+ /// represented as JavaScript strings. This avoids loss of precision that can
+ /// happen when a large value is converted to a floating point JavaScript
+ /// numbers. Specifying JS_NUMBER for the jstype causes the generated
+ /// JavaScript code to use the JavaScript "number" type instead of strings.
+ /// This option is an enum to permit additional types to be added,
+ /// e.g. goog.math.Integer.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Google.Protobuf.Reflection.FieldOptions.Types.JSType Jstype {
@@ -3736,33 +3782,33 @@ namespace Google.Protobuf.Reflection {
public const int LazyFieldNumber = 5;
private bool lazy_;
/// <summary>
- /// Should this field be parsed lazily? Lazy applies only to message-type
- /// fields. It means that when the outer message is initially parsed, the
- /// inner message's contents will not be parsed but instead stored in encoded
- /// form. The inner message will actually be parsed when it is first accessed.
+ /// Should this field be parsed lazily? Lazy applies only to message-type
+ /// fields. It means that when the outer message is initially parsed, the
+ /// inner message's contents will not be parsed but instead stored in encoded
+ /// form. The inner message will actually be parsed when it is first accessed.
///
- /// This is only a hint. Implementations are free to choose whether to use
- /// eager or lazy parsing regardless of the value of this option. However,
- /// setting this option true suggests that the protocol author believes that
- /// using lazy parsing on this field is worth the additional bookkeeping
- /// overhead typically needed to implement it.
+ /// This is only a hint. Implementations are free to choose whether to use
+ /// eager or lazy parsing regardless of the value of this option. However,
+ /// setting this option true suggests that the protocol author believes that
+ /// using lazy parsing on this field is worth the additional bookkeeping
+ /// overhead typically needed to implement it.
///
- /// This option does not affect the public interface of any generated code;
- /// all method signatures remain the same. Furthermore, thread-safety of the
- /// interface is not affected by this option; const methods remain safe to
- /// call from multiple threads concurrently, while non-const methods continue
- /// to require exclusive access.
+ /// This option does not affect the public interface of any generated code;
+ /// all method signatures remain the same. Furthermore, thread-safety of the
+ /// interface is not affected by this option; const methods remain safe to
+ /// call from multiple threads concurrently, while non-const methods continue
+ /// to require exclusive access.
///
- /// Note that implementations may choose not to check required fields within
- /// a lazy sub-message. That is, calling IsInitialized() on the outer message
- /// may return true even if the inner message has missing required fields.
- /// This is necessary because otherwise the inner message would have to be
- /// parsed in order to perform the check, defeating the purpose of lazy
- /// parsing. An implementation which chooses not to check required fields
- /// must be consistent about it. That is, for any particular sub-message, the
- /// implementation must either *always* check its required fields, or *never*
- /// check its required fields, regardless of whether or not the message has
- /// been parsed.
+ /// Note that implementations may choose not to check required fields within
+ /// a lazy sub-message. That is, calling IsInitialized() on the outer message
+ /// may return true even if the inner message has missing required fields.
+ /// This is necessary because otherwise the inner message would have to be
+ /// parsed in order to perform the check, defeating the purpose of lazy
+ /// parsing. An implementation which chooses not to check required fields
+ /// must be consistent about it. That is, for any particular sub-message, the
+ /// implementation must either *always* check its required fields, or *never*
+ /// check its required fields, regardless of whether or not the message has
+ /// been parsed.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Lazy {
@@ -3776,10 +3822,10 @@ namespace Google.Protobuf.Reflection {
public const int DeprecatedFieldNumber = 3;
private bool deprecated_;
/// <summary>
- /// Is this field deprecated?
- /// Depending on the target platform, this can emit Deprecated annotations
- /// for accessors, or it will be completely ignored; in the very least, this
- /// is a formalization for deprecating fields.
+ /// Is this field deprecated?
+ /// Depending on the target platform, this can emit Deprecated annotations
+ /// for accessors, or it will be completely ignored; in the very least, this
+ /// is a formalization for deprecating fields.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Deprecated {
@@ -3793,7 +3839,7 @@ namespace Google.Protobuf.Reflection {
public const int WeakFieldNumber = 10;
private bool weak_;
/// <summary>
- /// For Google-internal migration only. Do not use.
+ /// For Google-internal migration only. Do not use.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Weak {
@@ -3809,7 +3855,7 @@ namespace Google.Protobuf.Reflection {
= pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser);
private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption>();
/// <summary>
- /// The parser stores options it doesn't recognize here. See above.
+ /// The parser stores options it doesn't recognize here. See above.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> UninterpretedOption {
@@ -3943,7 +3989,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- input.SkipLastField();
+ CustomOptions = CustomOptions.ReadOrSkipUnknownField(input);
break;
case 8: {
ctype_ = (global::Google.Protobuf.Reflection.FieldOptions.Types.CType) input.ReadEnum();
@@ -3983,7 +4029,7 @@ namespace Google.Protobuf.Reflection {
public static partial class Types {
internal enum CType {
/// <summary>
- /// Default mode.
+ /// Default mode.
/// </summary>
[pbr::OriginalName("STRING")] String = 0,
[pbr::OriginalName("CORD")] Cord = 1,
@@ -3992,15 +4038,15 @@ namespace Google.Protobuf.Reflection {
internal enum JSType {
/// <summary>
- /// Use the default type.
+ /// Use the default type.
/// </summary>
[pbr::OriginalName("JS_NORMAL")] JsNormal = 0,
/// <summary>
- /// Use JavaScript strings.
+ /// Use JavaScript strings.
/// </summary>
[pbr::OriginalName("JS_STRING")] JsString = 1,
/// <summary>
- /// Use JavaScript numbers.
+ /// Use JavaScript numbers.
/// </summary>
[pbr::OriginalName("JS_NUMBER")] JsNumber = 2,
}
@@ -4025,6 +4071,8 @@ namespace Google.Protobuf.Reflection {
get { return Descriptor; }
}
+ internal CustomOptions CustomOptions{ get; private set; } = CustomOptions.Empty;
+
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public OneofOptions() {
OnConstruction();
@@ -4048,7 +4096,7 @@ namespace Google.Protobuf.Reflection {
= pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser);
private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption>();
/// <summary>
- /// The parser stores options it doesn't recognize here. See above.
+ /// The parser stores options it doesn't recognize here. See above.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> UninterpretedOption {
@@ -4110,7 +4158,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- input.SkipLastField();
+ CustomOptions = CustomOptions.ReadOrSkipUnknownField(input);
break;
case 7994: {
uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec);
@@ -4137,6 +4185,8 @@ namespace Google.Protobuf.Reflection {
get { return Descriptor; }
}
+ internal CustomOptions CustomOptions{ get; private set; } = CustomOptions.Empty;
+
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public EnumOptions() {
OnConstruction();
@@ -4160,8 +4210,8 @@ namespace Google.Protobuf.Reflection {
public const int AllowAliasFieldNumber = 2;
private bool allowAlias_;
/// <summary>
- /// Set this option to true to allow mapping different tag names to the same
- /// value.
+ /// Set this option to true to allow mapping different tag names to the same
+ /// value.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool AllowAlias {
@@ -4175,10 +4225,10 @@ namespace Google.Protobuf.Reflection {
public const int DeprecatedFieldNumber = 3;
private bool deprecated_;
/// <summary>
- /// Is this enum deprecated?
- /// Depending on the target platform, this can emit Deprecated annotations
- /// for the enum, or it will be completely ignored; in the very least, this
- /// is a formalization for deprecating enums.
+ /// Is this enum deprecated?
+ /// Depending on the target platform, this can emit Deprecated annotations
+ /// for the enum, or it will be completely ignored; in the very least, this
+ /// is a formalization for deprecating enums.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Deprecated {
@@ -4194,7 +4244,7 @@ namespace Google.Protobuf.Reflection {
= pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser);
private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption>();
/// <summary>
- /// The parser stores options it doesn't recognize here. See above.
+ /// The parser stores options it doesn't recognize here. See above.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> UninterpretedOption {
@@ -4280,7 +4330,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- input.SkipLastField();
+ CustomOptions = CustomOptions.ReadOrSkipUnknownField(input);
break;
case 16: {
AllowAlias = input.ReadBool();
@@ -4315,6 +4365,8 @@ namespace Google.Protobuf.Reflection {
get { return Descriptor; }
}
+ internal CustomOptions CustomOptions{ get; private set; } = CustomOptions.Empty;
+
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public EnumValueOptions() {
OnConstruction();
@@ -4337,10 +4389,10 @@ namespace Google.Protobuf.Reflection {
public const int DeprecatedFieldNumber = 1;
private bool deprecated_;
/// <summary>
- /// Is this enum value deprecated?
- /// Depending on the target platform, this can emit Deprecated annotations
- /// for the enum value, or it will be completely ignored; in the very least,
- /// this is a formalization for deprecating enum values.
+ /// Is this enum value deprecated?
+ /// Depending on the target platform, this can emit Deprecated annotations
+ /// for the enum value, or it will be completely ignored; in the very least,
+ /// this is a formalization for deprecating enum values.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Deprecated {
@@ -4356,7 +4408,7 @@ namespace Google.Protobuf.Reflection {
= pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser);
private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption>();
/// <summary>
- /// The parser stores options it doesn't recognize here. See above.
+ /// The parser stores options it doesn't recognize here. See above.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> UninterpretedOption {
@@ -4430,7 +4482,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- input.SkipLastField();
+ CustomOptions = CustomOptions.ReadOrSkipUnknownField(input);
break;
case 8: {
Deprecated = input.ReadBool();
@@ -4461,6 +4513,8 @@ namespace Google.Protobuf.Reflection {
get { return Descriptor; }
}
+ internal CustomOptions CustomOptions{ get; private set; } = CustomOptions.Empty;
+
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public ServiceOptions() {
OnConstruction();
@@ -4483,10 +4537,10 @@ namespace Google.Protobuf.Reflection {
public const int DeprecatedFieldNumber = 33;
private bool deprecated_;
/// <summary>
- /// Is this service deprecated?
- /// Depending on the target platform, this can emit Deprecated annotations
- /// for the service, or it will be completely ignored; in the very least,
- /// this is a formalization for deprecating services.
+ /// Is this service deprecated?
+ /// Depending on the target platform, this can emit Deprecated annotations
+ /// for the service, or it will be completely ignored; in the very least,
+ /// this is a formalization for deprecating services.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Deprecated {
@@ -4502,7 +4556,7 @@ namespace Google.Protobuf.Reflection {
= pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser);
private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption>();
/// <summary>
- /// The parser stores options it doesn't recognize here. See above.
+ /// The parser stores options it doesn't recognize here. See above.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> UninterpretedOption {
@@ -4576,7 +4630,7 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- input.SkipLastField();
+ CustomOptions = CustomOptions.ReadOrSkipUnknownField(input);
break;
case 264: {
Deprecated = input.ReadBool();
@@ -4607,6 +4661,8 @@ namespace Google.Protobuf.Reflection {
get { return Descriptor; }
}
+ internal CustomOptions CustomOptions{ get; private set; } = CustomOptions.Empty;
+
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public MethodOptions() {
OnConstruction();
@@ -4617,6 +4673,7 @@ namespace Google.Protobuf.Reflection {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public MethodOptions(MethodOptions other) : this() {
deprecated_ = other.deprecated_;
+ idempotencyLevel_ = other.idempotencyLevel_;
uninterpretedOption_ = other.uninterpretedOption_.Clone();
}
@@ -4629,10 +4686,10 @@ namespace Google.Protobuf.Reflection {
public const int DeprecatedFieldNumber = 33;
private bool deprecated_;
/// <summary>
- /// Is this method deprecated?
- /// Depending on the target platform, this can emit Deprecated annotations
- /// for the method, or it will be completely ignored; in the very least,
- /// this is a formalization for deprecating methods.
+ /// Is this method deprecated?
+ /// Depending on the target platform, this can emit Deprecated annotations
+ /// for the method, or it will be completely ignored; in the very least,
+ /// this is a formalization for deprecating methods.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Deprecated {
@@ -4642,13 +4699,24 @@ namespace Google.Protobuf.Reflection {
}
}
+ /// <summary>Field number for the "idempotency_level" field.</summary>
+ public const int IdempotencyLevelFieldNumber = 34;
+ private global::Google.Protobuf.Reflection.MethodOptions.Types.IdempotencyLevel idempotencyLevel_ = 0;
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public global::Google.Protobuf.Reflection.MethodOptions.Types.IdempotencyLevel IdempotencyLevel {
+ get { return idempotencyLevel_; }
+ set {
+ idempotencyLevel_ = value;
+ }
+ }
+
/// <summary>Field number for the "uninterpreted_option" field.</summary>
public const int UninterpretedOptionFieldNumber = 999;
private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.UninterpretedOption> _repeated_uninterpretedOption_codec
= pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser);
private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> uninterpretedOption_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption>();
/// <summary>
- /// The parser stores options it doesn't recognize here. See above.
+ /// The parser stores options it doesn't recognize here. See above.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Google.Protobuf.Reflection.UninterpretedOption> UninterpretedOption {
@@ -4669,6 +4737,7 @@ namespace Google.Protobuf.Reflection {
return true;
}
if (Deprecated != other.Deprecated) return false;
+ if (IdempotencyLevel != other.IdempotencyLevel) return false;
if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false;
return true;
}
@@ -4677,6 +4746,7 @@ namespace Google.Protobuf.Reflection {
public override int GetHashCode() {
int hash = 1;
if (Deprecated != false) hash ^= Deprecated.GetHashCode();
+ if (IdempotencyLevel != 0) hash ^= IdempotencyLevel.GetHashCode();
hash ^= uninterpretedOption_.GetHashCode();
return hash;
}
@@ -4692,6 +4762,10 @@ namespace Google.Protobuf.Reflection {
output.WriteRawTag(136, 2);
output.WriteBool(Deprecated);
}
+ if (IdempotencyLevel != 0) {
+ output.WriteRawTag(144, 2);
+ output.WriteEnum((int) IdempotencyLevel);
+ }
uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec);
}
@@ -4701,6 +4775,9 @@ namespace Google.Protobuf.Reflection {
if (Deprecated != false) {
size += 2 + 1;
}
+ if (IdempotencyLevel != 0) {
+ size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) IdempotencyLevel);
+ }
size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec);
return size;
}
@@ -4713,6 +4790,9 @@ namespace Google.Protobuf.Reflection {
if (other.Deprecated != false) {
Deprecated = other.Deprecated;
}
+ if (other.IdempotencyLevel != 0) {
+ IdempotencyLevel = other.IdempotencyLevel;
+ }
uninterpretedOption_.Add(other.uninterpretedOption_);
}
@@ -4722,12 +4802,16 @@ namespace Google.Protobuf.Reflection {
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
- input.SkipLastField();
+ CustomOptions = CustomOptions.ReadOrSkipUnknownField(input);
break;
case 264: {
Deprecated = input.ReadBool();
break;
}
+ case 272: {
+ idempotencyLevel_ = (global::Google.Protobuf.Reflection.MethodOptions.Types.IdempotencyLevel) input.ReadEnum();
+ break;
+ }
case 7994: {
uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec);
break;
@@ -4736,15 +4820,39 @@ namespace Google.Protobuf.Reflection {
}
}
+ #region Nested types
+ /// <summary>Container for nested types declared in the MethodOptions message type.</summary>
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static partial class Types {
+ /// <summary>
+ /// Is this method side-effect-free (or safe in HTTP parlance), or idempotent,
+ /// or neither? HTTP based RPC implementation may choose GET verb for safe
+ /// methods, and PUT verb for idempotent methods instead of the default POST.
+ /// </summary>
+ internal enum IdempotencyLevel {
+ [pbr::OriginalName("IDEMPOTENCY_UNKNOWN")] IdempotencyUnknown = 0,
+ /// <summary>
+ /// implies idempotent
+ /// </summary>
+ [pbr::OriginalName("NO_SIDE_EFFECTS")] NoSideEffects = 1,
+ /// <summary>
+ /// idempotent, but may have side effects
+ /// </summary>
+ [pbr::OriginalName("IDEMPOTENT")] Idempotent = 2,
+ }
+
+ }
+ #endregion
+
}
/// <summary>
- /// A message representing a option the parser does not recognize. This only
- /// appears in options protos created by the compiler::Parser class.
- /// DescriptorPool resolves these when building Descriptor objects. Therefore,
- /// options protos in descriptor objects (e.g. returned by Descriptor::options(),
- /// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions
- /// in them.
+ /// A message representing a option the parser does not recognize. This only
+ /// appears in options protos created by the compiler::Parser class.
+ /// DescriptorPool resolves these when building Descriptor objects. Therefore,
+ /// options protos in descriptor objects (e.g. returned by Descriptor::options(),
+ /// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions
+ /// in them.
/// </summary>
internal sealed partial class UninterpretedOption : pb::IMessage<UninterpretedOption> {
private static readonly pb::MessageParser<UninterpretedOption> _parser = new pb::MessageParser<UninterpretedOption>(() => new UninterpretedOption());
@@ -4798,8 +4906,8 @@ namespace Google.Protobuf.Reflection {
public const int IdentifierValueFieldNumber = 3;
private string identifierValue_ = "";
/// <summary>
- /// The value of the uninterpreted option, in whatever type the tokenizer
- /// identified it as during parsing. Exactly one of these should be set.
+ /// The value of the uninterpreted option, in whatever type the tokenizer
+ /// identified it as during parsing. Exactly one of these should be set.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string IdentifierValue {
@@ -5030,11 +5138,11 @@ namespace Google.Protobuf.Reflection {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static partial class Types {
/// <summary>
- /// The name of the uninterpreted option. Each string represents a segment in
- /// a dot-separated name. is_extension is true iff a segment represents an
- /// extension (denoted with parentheses in options specs in .proto files).
- /// E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents
- /// "foo.(bar.baz).qux".
+ /// The name of the uninterpreted option. Each string represents a segment in
+ /// a dot-separated name. is_extension is true iff a segment represents an
+ /// extension (denoted with parentheses in options specs in .proto files).
+ /// E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents
+ /// "foo.(bar.baz).qux".
/// </summary>
internal sealed partial class NamePart : pb::IMessage<NamePart> {
private static readonly pb::MessageParser<NamePart> _parser = new pb::MessageParser<NamePart>(() => new NamePart());
@@ -5187,8 +5295,8 @@ namespace Google.Protobuf.Reflection {
}
/// <summary>
- /// Encapsulates information about the original source file from which a
- /// FileDescriptorProto was generated.
+ /// Encapsulates information about the original source file from which a
+ /// FileDescriptorProto was generated.
/// </summary>
internal sealed partial class SourceCodeInfo : pb::IMessage<SourceCodeInfo> {
private static readonly pb::MessageParser<SourceCodeInfo> _parser = new pb::MessageParser<SourceCodeInfo>(() => new SourceCodeInfo());
@@ -5228,49 +5336,49 @@ namespace Google.Protobuf.Reflection {
= pb::FieldCodec.ForMessage(10, global::Google.Protobuf.Reflection.SourceCodeInfo.Types.Location.Parser);
private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.SourceCodeInfo.Types.Location> location_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.SourceCodeInfo.Types.Location>();
/// <summary>
- /// A Location identifies a piece of source code in a .proto file which
- /// corresponds to a particular definition. This information is intended
- /// to be useful to IDEs, code indexers, documentation generators, and similar
- /// tools.
+ /// A Location identifies a piece of source code in a .proto file which
+ /// corresponds to a particular definition. This information is intended
+ /// to be useful to IDEs, code indexers, documentation generators, and similar
+ /// tools.
///
- /// For example, say we have a file like:
- /// message Foo {
- /// optional string foo = 1;
- /// }
- /// Let's look at just the field definition:
- /// optional string foo = 1;
- /// ^ ^^ ^^ ^ ^^^
- /// a bc de f ghi
- /// We have the following locations:
- /// span path represents
- /// [a,i) [ 4, 0, 2, 0 ] The whole field definition.
- /// [a,b) [ 4, 0, 2, 0, 4 ] The label (optional).
- /// [c,d) [ 4, 0, 2, 0, 5 ] The type (string).
- /// [e,f) [ 4, 0, 2, 0, 1 ] The name (foo).
- /// [g,h) [ 4, 0, 2, 0, 3 ] The number (1).
+ /// For example, say we have a file like:
+ /// message Foo {
+ /// optional string foo = 1;
+ /// }
+ /// Let's look at just the field definition:
+ /// optional string foo = 1;
+ /// ^ ^^ ^^ ^ ^^^
+ /// a bc de f ghi
+ /// We have the following locations:
+ /// span path represents
+ /// [a,i) [ 4, 0, 2, 0 ] The whole field definition.
+ /// [a,b) [ 4, 0, 2, 0, 4 ] The label (optional).
+ /// [c,d) [ 4, 0, 2, 0, 5 ] The type (string).
+ /// [e,f) [ 4, 0, 2, 0, 1 ] The name (foo).
+ /// [g,h) [ 4, 0, 2, 0, 3 ] The number (1).
///
- /// Notes:
- /// - A location may refer to a repeated field itself (i.e. not to any
- /// particular index within it). This is used whenever a set of elements are
- /// logically enclosed in a single code segment. For example, an entire
- /// extend block (possibly containing multiple extension definitions) will
- /// have an outer location whose path refers to the "extensions" repeated
- /// field without an index.
- /// - Multiple locations may have the same path. This happens when a single
- /// logical declaration is spread out across multiple places. The most
- /// obvious example is the "extend" block again -- there may be multiple
- /// extend blocks in the same scope, each of which will have the same path.
- /// - A location's span is not always a subset of its parent's span. For
- /// example, the "extendee" of an extension declaration appears at the
- /// beginning of the "extend" block and is shared by all extensions within
- /// the block.
- /// - Just because a location's span is a subset of some other location's span
- /// does not mean that it is a descendent. For example, a "group" defines
- /// both a type and a field in a single declaration. Thus, the locations
- /// corresponding to the type and field and their components will overlap.
- /// - Code which tries to interpret locations should probably be designed to
- /// ignore those that it doesn't understand, as more types of locations could
- /// be recorded in the future.
+ /// Notes:
+ /// - A location may refer to a repeated field itself (i.e. not to any
+ /// particular index within it). This is used whenever a set of elements are
+ /// logically enclosed in a single code segment. For example, an entire
+ /// extend block (possibly containing multiple extension definitions) will
+ /// have an outer location whose path refers to the "extensions" repeated
+ /// field without an index.
+ /// - Multiple locations may have the same path. This happens when a single
+ /// logical declaration is spread out across multiple places. The most
+ /// obvious example is the "extend" block again -- there may be multiple
+ /// extend blocks in the same scope, each of which will have the same path.
+ /// - A location's span is not always a subset of its parent's span. For
+ /// example, the "extendee" of an extension declaration appears at the
+ /// beginning of the "extend" block and is shared by all extensions within
+ /// the block.
+ /// - Just because a location's span is a subset of some other location's span
+ /// does not mean that it is a descendent. For example, a "group" defines
+ /// both a type and a field in a single declaration. Thus, the locations
+ /// corresponding to the type and field and their components will overlap.
+ /// - Code which tries to interpret locations should probably be designed to
+ /// ignore those that it doesn't understand, as more types of locations could
+ /// be recorded in the future.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Google.Protobuf.Reflection.SourceCodeInfo.Types.Location> Location {
@@ -5388,29 +5496,29 @@ namespace Google.Protobuf.Reflection {
= pb::FieldCodec.ForInt32(10);
private readonly pbc::RepeatedField<int> path_ = new pbc::RepeatedField<int>();
/// <summary>
- /// Identifies which part of the FileDescriptorProto was defined at this
- /// location.
+ /// Identifies which part of the FileDescriptorProto was defined at this
+ /// location.
///
- /// Each element is a field number or an index. They form a path from
- /// the root FileDescriptorProto to the place where the definition. For
- /// example, this path:
- /// [ 4, 3, 2, 7, 1 ]
- /// refers to:
- /// file.message_type(3) // 4, 3
- /// .field(7) // 2, 7
- /// .name() // 1
- /// This is because FileDescriptorProto.message_type has field number 4:
- /// repeated DescriptorProto message_type = 4;
- /// and DescriptorProto.field has field number 2:
- /// repeated FieldDescriptorProto field = 2;
- /// and FieldDescriptorProto.name has field number 1:
- /// optional string name = 1;
+ /// Each element is a field number or an index. They form a path from
+ /// the root FileDescriptorProto to the place where the definition. For
+ /// example, this path:
+ /// [ 4, 3, 2, 7, 1 ]
+ /// refers to:
+ /// file.message_type(3) // 4, 3
+ /// .field(7) // 2, 7
+ /// .name() // 1
+ /// This is because FileDescriptorProto.message_type has field number 4:
+ /// repeated DescriptorProto message_type = 4;
+ /// and DescriptorProto.field has field number 2:
+ /// repeated FieldDescriptorProto field = 2;
+ /// and FieldDescriptorProto.name has field number 1:
+ /// optional string name = 1;
///
- /// Thus, the above path gives the location of a field name. If we removed
- /// the last element:
- /// [ 4, 3, 2, 7 ]
- /// this path refers to the whole field declaration (from the beginning
- /// of the label to the terminating semicolon).
+ /// Thus, the above path gives the location of a field name. If we removed
+ /// the last element:
+ /// [ 4, 3, 2, 7 ]
+ /// this path refers to the whole field declaration (from the beginning
+ /// of the label to the terminating semicolon).
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<int> Path {
@@ -5423,11 +5531,11 @@ namespace Google.Protobuf.Reflection {
= pb::FieldCodec.ForInt32(18);
private readonly pbc::RepeatedField<int> span_ = new pbc::RepeatedField<int>();
/// <summary>
- /// Always has exactly three or four elements: start line, start column,
- /// end line (optional, otherwise assumed same as start line), end column.
- /// These are packed into a single field for efficiency. Note that line
- /// and column numbers are zero-based -- typically you will want to add
- /// 1 to each before displaying to a user.
+ /// Always has exactly three or four elements: start line, start column,
+ /// end line (optional, otherwise assumed same as start line), end column.
+ /// These are packed into a single field for efficiency. Note that line
+ /// and column numbers are zero-based -- typically you will want to add
+ /// 1 to each before displaying to a user.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<int> Span {
@@ -5438,53 +5546,53 @@ namespace Google.Protobuf.Reflection {
public const int LeadingCommentsFieldNumber = 3;
private string leadingComments_ = "";
/// <summary>
- /// If this SourceCodeInfo represents a complete declaration, these are any
- /// comments appearing before and after the declaration which appear to be
- /// attached to the declaration.
+ /// If this SourceCodeInfo represents a complete declaration, these are any
+ /// comments appearing before and after the declaration which appear to be
+ /// attached to the declaration.
///
- /// A series of line comments appearing on consecutive lines, with no other
- /// tokens appearing on those lines, will be treated as a single comment.
+ /// A series of line comments appearing on consecutive lines, with no other
+ /// tokens appearing on those lines, will be treated as a single comment.
///
- /// leading_detached_comments will keep paragraphs of comments that appear
- /// before (but not connected to) the current element. Each paragraph,
- /// separated by empty lines, will be one comment element in the repeated
- /// field.
+ /// leading_detached_comments will keep paragraphs of comments that appear
+ /// before (but not connected to) the current element. Each paragraph,
+ /// separated by empty lines, will be one comment element in the repeated
+ /// field.
///
- /// Only the comment content is provided; comment markers (e.g. //) are
- /// stripped out. For block comments, leading whitespace and an asterisk
- /// will be stripped from the beginning of each line other than the first.
- /// Newlines are included in the output.
+ /// Only the comment content is provided; comment markers (e.g. //) are
+ /// stripped out. For block comments, leading whitespace and an asterisk
+ /// will be stripped from the beginning of each line other than the first.
+ /// Newlines are included in the output.
///
- /// Examples:
+ /// Examples:
///
- /// optional int32 foo = 1; // Comment attached to foo.
- /// // Comment attached to bar.
- /// optional int32 bar = 2;
+ /// optional int32 foo = 1; // Comment attached to foo.
+ /// // Comment attached to bar.
+ /// optional int32 bar = 2;
///
- /// optional string baz = 3;
- /// // Comment attached to baz.
- /// // Another line attached to baz.
+ /// optional string baz = 3;
+ /// // Comment attached to baz.
+ /// // Another line attached to baz.
///
- /// // Comment attached to qux.
- /// //
- /// // Another line attached to qux.
- /// optional double qux = 4;
+ /// // Comment attached to qux.
+ /// //
+ /// // Another line attached to qux.
+ /// optional double qux = 4;
///
- /// // Detached comment for corge. This is not leading or trailing comments
- /// // to qux or corge because there are blank lines separating it from
- /// // both.
+ /// // Detached comment for corge. This is not leading or trailing comments
+ /// // to qux or corge because there are blank lines separating it from
+ /// // both.
///
- /// // Detached comment for corge paragraph 2.
+ /// // Detached comment for corge paragraph 2.
///
- /// optional string corge = 5;
- /// /* Block comment attached
- /// * to corge. Leading asterisks
- /// * will be removed. */
- /// /* Block comment attached to
- /// * grault. */
- /// optional int32 grault = 6;
+ /// optional string corge = 5;
+ /// /* Block comment attached
+ /// * to corge. Leading asterisks
+ /// * will be removed. */
+ /// /* Block comment attached to
+ /// * grault. */
+ /// optional int32 grault = 6;
///
- /// // ignored detached comments.
+ /// // ignored detached comments.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string LeadingComments {
@@ -5640,9 +5748,9 @@ namespace Google.Protobuf.Reflection {
}
/// <summary>
- /// Describes the relationship between generated code and its original source
- /// file. A GeneratedCodeInfo message is associated with only one generated
- /// source file, but may contain references to different source .proto files.
+ /// Describes the relationship between generated code and its original source
+ /// file. A GeneratedCodeInfo message is associated with only one generated
+ /// source file, but may contain references to different source .proto files.
/// </summary>
internal sealed partial class GeneratedCodeInfo : pb::IMessage<GeneratedCodeInfo> {
private static readonly pb::MessageParser<GeneratedCodeInfo> _parser = new pb::MessageParser<GeneratedCodeInfo>(() => new GeneratedCodeInfo());
@@ -5682,8 +5790,8 @@ namespace Google.Protobuf.Reflection {
= pb::FieldCodec.ForMessage(10, global::Google.Protobuf.Reflection.GeneratedCodeInfo.Types.Annotation.Parser);
private readonly pbc::RepeatedField<global::Google.Protobuf.Reflection.GeneratedCodeInfo.Types.Annotation> annotation_ = new pbc::RepeatedField<global::Google.Protobuf.Reflection.GeneratedCodeInfo.Types.Annotation>();
/// <summary>
- /// An Annotation connects some span of text in generated code to an element
- /// of its generating .proto file.
+ /// An Annotation connects some span of text in generated code to an element
+ /// of its generating .proto file.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Google.Protobuf.Reflection.GeneratedCodeInfo.Types.Annotation> Annotation {
@@ -5800,8 +5908,8 @@ namespace Google.Protobuf.Reflection {
= pb::FieldCodec.ForInt32(10);
private readonly pbc::RepeatedField<int> path_ = new pbc::RepeatedField<int>();
/// <summary>
- /// Identifies the element in the original source .proto file. This field
- /// is formatted the same as SourceCodeInfo.Location.path.
+ /// Identifies the element in the original source .proto file. This field
+ /// is formatted the same as SourceCodeInfo.Location.path.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<int> Path {
@@ -5812,7 +5920,7 @@ namespace Google.Protobuf.Reflection {
public const int SourceFileFieldNumber = 2;
private string sourceFile_ = "";
/// <summary>
- /// Identifies the filesystem path to the original source .proto.
+ /// Identifies the filesystem path to the original source .proto.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string SourceFile {
@@ -5826,8 +5934,8 @@ namespace Google.Protobuf.Reflection {
public const int BeginFieldNumber = 3;
private int begin_;
/// <summary>
- /// Identifies the starting offset in bytes in the generated code
- /// that relates to the identified object.
+ /// Identifies the starting offset in bytes in the generated code
+ /// that relates to the identified object.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int Begin {
@@ -5841,9 +5949,9 @@ namespace Google.Protobuf.Reflection {
public const int EndFieldNumber = 4;
private int end_;
/// <summary>
- /// Identifies the ending offset in bytes in the generated code that
- /// relates to the identified offset. The end offset should be one past
- /// the last relevant byte (so the length of the text = end - begin).
+ /// Identifies the ending offset in bytes in the generated code that
+ /// relates to the identified offset. The end offset should be one past
+ /// the last relevant byte (so the length of the text = end - begin).
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int End {
diff --git a/csharp/src/Google.Protobuf/Reflection/EnumDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/EnumDescriptor.cs
index c732c93a..89c73a61 100644
--- a/csharp/src/Google.Protobuf/Reflection/EnumDescriptor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/EnumDescriptor.cs
@@ -112,5 +112,10 @@ namespace Google.Protobuf.Reflection
{
return File.DescriptorPool.FindSymbol<EnumValueDescriptor>(FullName + "." + name);
}
+
+ /// <summary>
+ /// The (possibly empty) set of custom options for this enum.
+ /// </summary>
+ public CustomOptions CustomOptions => Proto.Options?.CustomOptions ?? CustomOptions.Empty;
}
} \ No newline at end of file
diff --git a/csharp/src/Google.Protobuf/Reflection/EnumValueDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/EnumValueDescriptor.cs
index b212ce96..8b838c68 100644
--- a/csharp/src/Google.Protobuf/Reflection/EnumValueDescriptor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/EnumValueDescriptor.cs
@@ -66,5 +66,10 @@ namespace Google.Protobuf.Reflection
/// Returns the enum descriptor that this value is part of.
/// </summary>
public EnumDescriptor EnumDescriptor { get { return enumDescriptor; } }
+
+ /// <summary>
+ /// The (possibly empty) set of custom options for this enum value.
+ /// </summary>
+ public CustomOptions CustomOptions => Proto.Options?.CustomOptions ?? CustomOptions.Empty;
}
} \ No newline at end of file
diff --git a/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs
index ed15d0e1..2a3d5c7a 100644
--- a/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs
@@ -251,6 +251,11 @@ namespace Google.Protobuf.Reflection
}
/// <summary>
+ /// The (possibly empty) set of custom options for this field.
+ /// </summary>
+ public CustomOptions CustomOptions => Proto.Options?.CustomOptions ?? CustomOptions.Empty;
+
+ /// <summary>
/// Look up and cross-link all field types etc.
/// </summary>
internal void CrossLink()
diff --git a/csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs
index 94efea9e..9124beee 100644
--- a/csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs
@@ -329,5 +329,10 @@ namespace Google.Protobuf.Reflection
/// The file descriptor for <c>descriptor.proto</c>.
/// </value>
public static FileDescriptor DescriptorProtoFileDescriptor { get { return DescriptorReflection.Descriptor; } }
+
+ /// <summary>
+ /// The (possibly empty) set of custom options for this file.
+ /// </summary>
+ public CustomOptions CustomOptions => Proto.Options?.CustomOptions ?? CustomOptions.Empty;
}
}
diff --git a/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs
index 7a1cb9d5..86942acc 100644..100755
--- a/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs
@@ -34,7 +34,7 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
-#if DOTNET35
+#if NET35
// Needed for ReadOnlyDictionary, which does not exist in .NET 3.5
using Google.Protobuf.Collections;
#endif
@@ -221,6 +221,11 @@ namespace Google.Protobuf.Reflection
File.DescriptorPool.FindSymbol<T>(FullName + "." + name);
/// <summary>
+ /// The (possibly empty) set of custom options for this message.
+ /// </summary>
+ public CustomOptions CustomOptions => Proto.Options?.CustomOptions ?? CustomOptions.Empty;
+
+ /// <summary>
/// Looks up and cross-links all fields and nested types.
/// </summary>
internal void CrossLink()
diff --git a/csharp/src/Google.Protobuf/Reflection/MethodDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/MethodDescriptor.cs
index f9539f6c..19d7f8a0 100644
--- a/csharp/src/Google.Protobuf/Reflection/MethodDescriptor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/MethodDescriptor.cs
@@ -67,6 +67,11 @@ namespace Google.Protobuf.Reflection
/// </value>
public bool IsServerStreaming { get { return proto.ServerStreaming; } }
+ /// <summary>
+ /// The (possibly empty) set of custom options for this method.
+ /// </summary>
+ public CustomOptions CustomOptions => Proto.Options?.CustomOptions ?? CustomOptions.Empty;
+
internal MethodDescriptor(MethodDescriptorProto proto, FileDescriptor file,
ServiceDescriptor parent, int index)
: base(file, parent.FullName + "." + proto.Name, index)
diff --git a/csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs
index 22020acf..5906c2e3 100644
--- a/csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs
@@ -90,6 +90,11 @@ namespace Google.Protobuf.Reflection
/// </value>
public OneofAccessor Accessor { get { return accessor; } }
+ /// <summary>
+ /// The (possibly empty) set of custom options for this oneof.
+ /// </summary>
+ public CustomOptions CustomOptions => proto.Options?.CustomOptions ?? CustomOptions.Empty;
+
internal void CrossLink()
{
List<FieldDescriptor> fieldCollection = new List<FieldDescriptor>();
diff --git a/csharp/src/Google.Protobuf/Reflection/ServiceDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/ServiceDescriptor.cs
index cc0a5010..fe5c072c 100644
--- a/csharp/src/Google.Protobuf/Reflection/ServiceDescriptor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/ServiceDescriptor.cs
@@ -78,6 +78,11 @@ namespace Google.Protobuf.Reflection
return File.DescriptorPool.FindSymbol<MethodDescriptor>(FullName + "." + name);
}
+ /// <summary>
+ /// The (possibly empty) set of custom options for this service.
+ /// </summary>
+ public CustomOptions CustomOptions => Proto.Options?.CustomOptions ?? CustomOptions.Empty;
+
internal void CrossLink()
{
foreach (MethodDescriptor method in methods)
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs
index e36fd5eb..b90c9a2a 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs
@@ -38,74 +38,74 @@ namespace Google.Protobuf.WellKnownTypes {
}
#region Messages
/// <summary>
- /// `Any` contains an arbitrary serialized protocol buffer message along with a
- /// URL that describes the type of the serialized message.
+ /// `Any` contains an arbitrary serialized protocol buffer message along with a
+ /// URL that describes the type of the serialized message.
///
- /// Protobuf library provides support to pack/unpack Any values in the form
- /// of utility functions or additional generated methods of the Any type.
+ /// Protobuf library provides support to pack/unpack Any values in the form
+ /// of utility functions or additional generated methods of the Any type.
///
- /// Example 1: Pack and unpack a message in C++.
+ /// Example 1: Pack and unpack a message in C++.
///
- /// Foo foo = ...;
- /// Any any;
- /// any.PackFrom(foo);
- /// ...
- /// if (any.UnpackTo(&amp;foo)) {
- /// ...
- /// }
+ /// Foo foo = ...;
+ /// Any any;
+ /// any.PackFrom(foo);
+ /// ...
+ /// if (any.UnpackTo(&amp;foo)) {
+ /// ...
+ /// }
///
- /// Example 2: Pack and unpack a message in Java.
+ /// Example 2: Pack and unpack a message in Java.
///
- /// Foo foo = ...;
- /// Any any = Any.pack(foo);
- /// ...
- /// if (any.is(Foo.class)) {
- /// foo = any.unpack(Foo.class);
- /// }
+ /// Foo foo = ...;
+ /// Any any = Any.pack(foo);
+ /// ...
+ /// if (any.is(Foo.class)) {
+ /// foo = any.unpack(Foo.class);
+ /// }
///
- /// Example 3: Pack and unpack a message in Python.
+ /// Example 3: Pack and unpack a message in Python.
///
- /// foo = Foo(...)
- /// any = Any()
- /// any.Pack(foo)
- /// ...
- /// if any.Is(Foo.DESCRIPTOR):
- /// any.Unpack(foo)
- /// ...
+ /// foo = Foo(...)
+ /// any = Any()
+ /// any.Pack(foo)
+ /// ...
+ /// if any.Is(Foo.DESCRIPTOR):
+ /// any.Unpack(foo)
+ /// ...
///
- /// The pack methods provided by protobuf library will by default use
- /// 'type.googleapis.com/full.type.name' as the type URL and the unpack
- /// methods only use the fully qualified type name after the last '/'
- /// in the type URL, for example "foo.bar.com/x/y.z" will yield type
- /// name "y.z".
+ /// The pack methods provided by protobuf library will by default use
+ /// 'type.googleapis.com/full.type.name' as the type URL and the unpack
+ /// methods only use the fully qualified type name after the last '/'
+ /// in the type URL, for example "foo.bar.com/x/y.z" will yield type
+ /// name "y.z".
///
- /// JSON
- /// ====
- /// The JSON representation of an `Any` value uses the regular
- /// representation of the deserialized, embedded message, with an
- /// additional field `@type` which contains the type URL. Example:
+ /// JSON
+ /// ====
+ /// The JSON representation of an `Any` value uses the regular
+ /// representation of the deserialized, embedded message, with an
+ /// additional field `@type` which contains the type URL. Example:
///
- /// package google.profile;
- /// message Person {
- /// string first_name = 1;
- /// string last_name = 2;
- /// }
+ /// package google.profile;
+ /// message Person {
+ /// string first_name = 1;
+ /// string last_name = 2;
+ /// }
///
- /// {
- /// "@type": "type.googleapis.com/google.profile.Person",
- /// "firstName": &lt;string>,
- /// "lastName": &lt;string>
- /// }
+ /// {
+ /// "@type": "type.googleapis.com/google.profile.Person",
+ /// "firstName": &lt;string>,
+ /// "lastName": &lt;string>
+ /// }
///
- /// If the embedded message type is well-known and has a custom JSON
- /// representation, that representation will be embedded adding a field
- /// `value` which holds the custom JSON in addition to the `@type`
- /// field. Example (for message [google.protobuf.Duration][]):
+ /// If the embedded message type is well-known and has a custom JSON
+ /// representation, that representation will be embedded adding a field
+ /// `value` which holds the custom JSON in addition to the `@type`
+ /// field. Example (for message [google.protobuf.Duration][]):
///
- /// {
- /// "@type": "type.googleapis.com/google.protobuf.Duration",
- /// "value": "1.212s"
- /// }
+ /// {
+ /// "@type": "type.googleapis.com/google.protobuf.Duration",
+ /// "value": "1.212s"
+ /// }
/// </summary>
public sealed partial class Any : pb::IMessage<Any> {
private static readonly pb::MessageParser<Any> _parser = new pb::MessageParser<Any>(() => new Any());
@@ -144,27 +144,27 @@ namespace Google.Protobuf.WellKnownTypes {
public const int TypeUrlFieldNumber = 1;
private string typeUrl_ = "";
/// <summary>
- /// A URL/resource name whose content describes the type of the
- /// serialized protocol buffer message.
+ /// A URL/resource name whose content describes the type of the
+ /// serialized protocol buffer message.
///
- /// For URLs which use the scheme `http`, `https`, or no scheme, the
- /// following restrictions and interpretations apply:
+ /// For URLs which use the scheme `http`, `https`, or no scheme, the
+ /// following restrictions and interpretations apply:
///
- /// * If no scheme is provided, `https` is assumed.
- /// * The last segment of the URL's path must represent the fully
- /// qualified name of the type (as in `path/google.protobuf.Duration`).
- /// The name should be in a canonical form (e.g., leading "." is
- /// not accepted).
- /// * An HTTP GET on the URL must yield a [google.protobuf.Type][]
- /// value in binary format, or produce an error.
- /// * Applications are allowed to cache lookup results based on the
- /// URL, or have them precompiled into a binary to avoid any
- /// lookup. Therefore, binary compatibility needs to be preserved
- /// on changes to types. (Use versioned type names to manage
- /// breaking changes.)
+ /// * If no scheme is provided, `https` is assumed.
+ /// * The last segment of the URL's path must represent the fully
+ /// qualified name of the type (as in `path/google.protobuf.Duration`).
+ /// The name should be in a canonical form (e.g., leading "." is
+ /// not accepted).
+ /// * An HTTP GET on the URL must yield a [google.protobuf.Type][]
+ /// value in binary format, or produce an error.
+ /// * Applications are allowed to cache lookup results based on the
+ /// URL, or have them precompiled into a binary to avoid any
+ /// lookup. Therefore, binary compatibility needs to be preserved
+ /// on changes to types. (Use versioned type names to manage
+ /// breaking changes.)
///
- /// Schemes other than `http`, `https` (or the empty scheme) might be
- /// used with implementation specific semantics.
+ /// Schemes other than `http`, `https` (or the empty scheme) might be
+ /// used with implementation specific semantics.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string TypeUrl {
@@ -178,7 +178,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int ValueFieldNumber = 2;
private pb::ByteString value_ = pb::ByteString.Empty;
/// <summary>
- /// Must be a valid serialized protocol buffer of the above specified type.
+ /// Must be a valid serialized protocol buffer of the above specified type.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pb::ByteString Value {
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs
index 234095e9..aeeb8e73 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs
@@ -35,8 +35,9 @@ namespace Google.Protobuf.WellKnownTypes {
"ChFyZXNwb25zZV90eXBlX3VybBgEIAEoCRIaChJyZXNwb25zZV9zdHJlYW1p",
"bmcYBSABKAgSKAoHb3B0aW9ucxgGIAMoCzIXLmdvb2dsZS5wcm90b2J1Zi5P",
"cHRpb24SJwoGc3ludGF4GAcgASgOMhcuZ29vZ2xlLnByb3RvYnVmLlN5bnRh",
- "eCIjCgVNaXhpbhIMCgRuYW1lGAEgASgJEgwKBHJvb3QYAiABKAlCSAoTY29t",
- "Lmdvb2dsZS5wcm90b2J1ZkIIQXBpUHJvdG9QAaICA0dQQqoCHkdvb2dsZS5Q",
+ "eCIjCgVNaXhpbhIMCgRuYW1lGAEgASgJEgwKBHJvb3QYAiABKAlCdQoTY29t",
+ "Lmdvb2dsZS5wcm90b2J1ZkIIQXBpUHJvdG9QAVorZ29vZ2xlLmdvbGFuZy5v",
+ "cmcvZ2VucHJvdG8vcHJvdG9idWYvYXBpO2FwaaICA0dQQqoCHkdvb2dsZS5Q",
"cm90b2J1Zi5XZWxsS25vd25UeXBlc2IGcHJvdG8z"));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.SourceContextReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.TypeReflection.Descriptor, },
@@ -51,7 +52,7 @@ namespace Google.Protobuf.WellKnownTypes {
}
#region Messages
/// <summary>
- /// Api is a light-weight descriptor for a protocol buffer service.
+ /// Api is a light-weight descriptor for a protocol buffer service.
/// </summary>
public sealed partial class Api : pb::IMessage<Api> {
private static readonly pb::MessageParser<Api> _parser = new pb::MessageParser<Api>(() => new Api());
@@ -95,8 +96,8 @@ namespace Google.Protobuf.WellKnownTypes {
public const int NameFieldNumber = 1;
private string name_ = "";
/// <summary>
- /// The fully qualified name of this api, including package name
- /// followed by the api's simple name.
+ /// The fully qualified name of this api, including package name
+ /// followed by the api's simple name.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Name {
@@ -112,7 +113,7 @@ namespace Google.Protobuf.WellKnownTypes {
= pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Method.Parser);
private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Method> methods_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Method>();
/// <summary>
- /// The methods of this api, in unspecified order.
+ /// The methods of this api, in unspecified order.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Method> Methods {
@@ -125,7 +126,7 @@ namespace Google.Protobuf.WellKnownTypes {
= pb::FieldCodec.ForMessage(26, global::Google.Protobuf.WellKnownTypes.Option.Parser);
private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option> options_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option>();
/// <summary>
- /// Any metadata attached to the API.
+ /// Any metadata attached to the API.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option> Options {
@@ -136,26 +137,26 @@ namespace Google.Protobuf.WellKnownTypes {
public const int VersionFieldNumber = 4;
private string version_ = "";
/// <summary>
- /// A version string for this api. If specified, must have the form
- /// `major-version.minor-version`, as in `1.10`. If the minor version
- /// is omitted, it defaults to zero. If the entire version field is
- /// empty, the major version is derived from the package name, as
- /// outlined below. If the field is not empty, the version in the
- /// package name will be verified to be consistent with what is
- /// provided here.
+ /// A version string for this api. If specified, must have the form
+ /// `major-version.minor-version`, as in `1.10`. If the minor version
+ /// is omitted, it defaults to zero. If the entire version field is
+ /// empty, the major version is derived from the package name, as
+ /// outlined below. If the field is not empty, the version in the
+ /// package name will be verified to be consistent with what is
+ /// provided here.
///
- /// The versioning schema uses [semantic
- /// versioning](http://semver.org) where the major version number
- /// indicates a breaking change and the minor version an additive,
- /// non-breaking change. Both version numbers are signals to users
- /// what to expect from different versions, and should be carefully
- /// chosen based on the product plan.
+ /// The versioning schema uses [semantic
+ /// versioning](http://semver.org) where the major version number
+ /// indicates a breaking change and the minor version an additive,
+ /// non-breaking change. Both version numbers are signals to users
+ /// what to expect from different versions, and should be carefully
+ /// chosen based on the product plan.
///
- /// The major version is also reflected in the package name of the
- /// API, which must end in `v&lt;major-version>`, as in
- /// `google.feature.v1`. For major versions 0 and 1, the suffix can
- /// be omitted. Zero major versions must only be used for
- /// experimental, none-GA apis.
+ /// The major version is also reflected in the package name of the
+ /// API, which must end in `v&lt;major-version>`, as in
+ /// `google.feature.v1`. For major versions 0 and 1, the suffix can
+ /// be omitted. Zero major versions must only be used for
+ /// experimental, none-GA apis.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Version {
@@ -169,8 +170,8 @@ namespace Google.Protobuf.WellKnownTypes {
public const int SourceContextFieldNumber = 5;
private global::Google.Protobuf.WellKnownTypes.SourceContext sourceContext_;
/// <summary>
- /// Source context for the protocol buffer service represented by this
- /// message.
+ /// Source context for the protocol buffer service represented by this
+ /// message.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Google.Protobuf.WellKnownTypes.SourceContext SourceContext {
@@ -186,7 +187,7 @@ namespace Google.Protobuf.WellKnownTypes {
= pb::FieldCodec.ForMessage(50, global::Google.Protobuf.WellKnownTypes.Mixin.Parser);
private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Mixin> mixins_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Mixin>();
/// <summary>
- /// Included APIs. See [Mixin][].
+ /// Included APIs. See [Mixin][].
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Mixin> Mixins {
@@ -197,7 +198,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int SyntaxFieldNumber = 7;
private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = 0;
/// <summary>
- /// The source syntax of the service.
+ /// The source syntax of the service.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Google.Protobuf.WellKnownTypes.Syntax Syntax {
@@ -363,7 +364,7 @@ namespace Google.Protobuf.WellKnownTypes {
}
/// <summary>
- /// Method represents a method of an api.
+ /// Method represents a method of an api.
/// </summary>
public sealed partial class Method : pb::IMessage<Method> {
private static readonly pb::MessageParser<Method> _parser = new pb::MessageParser<Method>(() => new Method());
@@ -407,7 +408,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int NameFieldNumber = 1;
private string name_ = "";
/// <summary>
- /// The simple name of this method.
+ /// The simple name of this method.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Name {
@@ -421,7 +422,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int RequestTypeUrlFieldNumber = 2;
private string requestTypeUrl_ = "";
/// <summary>
- /// A URL of the input message type.
+ /// A URL of the input message type.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string RequestTypeUrl {
@@ -435,7 +436,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int RequestStreamingFieldNumber = 3;
private bool requestStreaming_;
/// <summary>
- /// If true, the request is streamed.
+ /// If true, the request is streamed.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool RequestStreaming {
@@ -449,7 +450,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int ResponseTypeUrlFieldNumber = 4;
private string responseTypeUrl_ = "";
/// <summary>
- /// The URL of the output message type.
+ /// The URL of the output message type.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string ResponseTypeUrl {
@@ -463,7 +464,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int ResponseStreamingFieldNumber = 5;
private bool responseStreaming_;
/// <summary>
- /// If true, the response is streamed.
+ /// If true, the response is streamed.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool ResponseStreaming {
@@ -479,7 +480,7 @@ namespace Google.Protobuf.WellKnownTypes {
= pb::FieldCodec.ForMessage(50, global::Google.Protobuf.WellKnownTypes.Option.Parser);
private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option> options_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option>();
/// <summary>
- /// Any metadata attached to the method.
+ /// Any metadata attached to the method.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option> Options {
@@ -490,7 +491,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int SyntaxFieldNumber = 7;
private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = 0;
/// <summary>
- /// The source syntax of this method.
+ /// The source syntax of this method.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Google.Protobuf.WellKnownTypes.Syntax Syntax {
@@ -664,83 +665,83 @@ namespace Google.Protobuf.WellKnownTypes {
}
/// <summary>
- /// Declares an API to be included in this API. The including API must
- /// redeclare all the methods from the included API, but documentation
- /// and options are inherited as follows:
+ /// Declares an API to be included in this API. The including API must
+ /// redeclare all the methods from the included API, but documentation
+ /// and options are inherited as follows:
///
- /// - If after comment and whitespace stripping, the documentation
- /// string of the redeclared method is empty, it will be inherited
- /// from the original method.
+ /// - If after comment and whitespace stripping, the documentation
+ /// string of the redeclared method is empty, it will be inherited
+ /// from the original method.
///
- /// - Each annotation belonging to the service config (http,
- /// visibility) which is not set in the redeclared method will be
- /// inherited.
+ /// - Each annotation belonging to the service config (http,
+ /// visibility) which is not set in the redeclared method will be
+ /// inherited.
///
- /// - If an http annotation is inherited, the path pattern will be
- /// modified as follows. Any version prefix will be replaced by the
- /// version of the including API plus the [root][] path if specified.
+ /// - If an http annotation is inherited, the path pattern will be
+ /// modified as follows. Any version prefix will be replaced by the
+ /// version of the including API plus the [root][] path if specified.
///
- /// Example of a simple mixin:
+ /// Example of a simple mixin:
///
- /// package google.acl.v1;
- /// service AccessControl {
- /// // Get the underlying ACL object.
- /// rpc GetAcl(GetAclRequest) returns (Acl) {
- /// option (google.api.http).get = "/v1/{resource=**}:getAcl";
- /// }
- /// }
+ /// package google.acl.v1;
+ /// service AccessControl {
+ /// // Get the underlying ACL object.
+ /// rpc GetAcl(GetAclRequest) returns (Acl) {
+ /// option (google.api.http).get = "/v1/{resource=**}:getAcl";
+ /// }
+ /// }
///
- /// package google.storage.v2;
- /// service Storage {
- /// rpc GetAcl(GetAclRequest) returns (Acl);
+ /// package google.storage.v2;
+ /// service Storage {
+ /// rpc GetAcl(GetAclRequest) returns (Acl);
///
- /// // Get a data record.
- /// rpc GetData(GetDataRequest) returns (Data) {
- /// option (google.api.http).get = "/v2/{resource=**}";
- /// }
- /// }
+ /// // Get a data record.
+ /// rpc GetData(GetDataRequest) returns (Data) {
+ /// option (google.api.http).get = "/v2/{resource=**}";
+ /// }
+ /// }
///
- /// Example of a mixin configuration:
+ /// Example of a mixin configuration:
///
- /// apis:
- /// - name: google.storage.v2.Storage
- /// mixins:
- /// - name: google.acl.v1.AccessControl
+ /// apis:
+ /// - name: google.storage.v2.Storage
+ /// mixins:
+ /// - name: google.acl.v1.AccessControl
///
- /// The mixin construct implies that all methods in `AccessControl` are
- /// also declared with same name and request/response types in
- /// `Storage`. A documentation generator or annotation processor will
- /// see the effective `Storage.GetAcl` method after inherting
- /// documentation and annotations as follows:
+ /// The mixin construct implies that all methods in `AccessControl` are
+ /// also declared with same name and request/response types in
+ /// `Storage`. A documentation generator or annotation processor will
+ /// see the effective `Storage.GetAcl` method after inherting
+ /// documentation and annotations as follows:
///
- /// service Storage {
- /// // Get the underlying ACL object.
- /// rpc GetAcl(GetAclRequest) returns (Acl) {
- /// option (google.api.http).get = "/v2/{resource=**}:getAcl";
- /// }
- /// ...
- /// }
+ /// service Storage {
+ /// // Get the underlying ACL object.
+ /// rpc GetAcl(GetAclRequest) returns (Acl) {
+ /// option (google.api.http).get = "/v2/{resource=**}:getAcl";
+ /// }
+ /// ...
+ /// }
///
- /// Note how the version in the path pattern changed from `v1` to `v2`.
+ /// Note how the version in the path pattern changed from `v1` to `v2`.
///
- /// If the `root` field in the mixin is specified, it should be a
- /// relative path under which inherited HTTP paths are placed. Example:
+ /// If the `root` field in the mixin is specified, it should be a
+ /// relative path under which inherited HTTP paths are placed. Example:
///
- /// apis:
- /// - name: google.storage.v2.Storage
- /// mixins:
- /// - name: google.acl.v1.AccessControl
- /// root: acls
+ /// apis:
+ /// - name: google.storage.v2.Storage
+ /// mixins:
+ /// - name: google.acl.v1.AccessControl
+ /// root: acls
///
- /// This implies the following inherited HTTP annotation:
+ /// This implies the following inherited HTTP annotation:
///
- /// service Storage {
- /// // Get the underlying ACL object.
- /// rpc GetAcl(GetAclRequest) returns (Acl) {
- /// option (google.api.http).get = "/v2/acls/{resource=**}:getAcl";
- /// }
- /// ...
- /// }
+ /// service Storage {
+ /// // Get the underlying ACL object.
+ /// rpc GetAcl(GetAclRequest) returns (Acl) {
+ /// option (google.api.http).get = "/v2/acls/{resource=**}:getAcl";
+ /// }
+ /// ...
+ /// }
/// </summary>
public sealed partial class Mixin : pb::IMessage<Mixin> {
private static readonly pb::MessageParser<Mixin> _parser = new pb::MessageParser<Mixin>(() => new Mixin());
@@ -779,7 +780,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int NameFieldNumber = 1;
private string name_ = "";
/// <summary>
- /// The fully qualified name of the API which is included.
+ /// The fully qualified name of the API which is included.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Name {
@@ -793,8 +794,8 @@ namespace Google.Protobuf.WellKnownTypes {
public const int RootFieldNumber = 2;
private string root_ = "";
/// <summary>
- /// If non-empty specifies a path under which inherited HTTP paths
- /// are rooted.
+ /// If non-empty specifies a path under which inherited HTTP paths
+ /// are rooted.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Root {
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs
index 66ac7152..03b19c77 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs
@@ -39,52 +39,52 @@ namespace Google.Protobuf.WellKnownTypes {
}
#region Messages
/// <summary>
- /// A Duration represents a signed, fixed-length span of time represented
- /// as a count of seconds and fractions of seconds at nanosecond
- /// resolution. It is independent of any calendar and concepts like "day"
- /// or "month". It is related to Timestamp in that the difference between
- /// two Timestamp values is a Duration and it can be added or subtracted
- /// from a Timestamp. Range is approximately +-10,000 years.
+ /// A Duration represents a signed, fixed-length span of time represented
+ /// as a count of seconds and fractions of seconds at nanosecond
+ /// resolution. It is independent of any calendar and concepts like "day"
+ /// or "month". It is related to Timestamp in that the difference between
+ /// two Timestamp values is a Duration and it can be added or subtracted
+ /// from a Timestamp. Range is approximately +-10,000 years.
///
- /// Example 1: Compute Duration from two Timestamps in pseudo code.
+ /// Example 1: Compute Duration from two Timestamps in pseudo code.
///
- /// Timestamp start = ...;
- /// Timestamp end = ...;
- /// Duration duration = ...;
+ /// Timestamp start = ...;
+ /// Timestamp end = ...;
+ /// Duration duration = ...;
///
- /// duration.seconds = end.seconds - start.seconds;
- /// duration.nanos = end.nanos - start.nanos;
+ /// duration.seconds = end.seconds - start.seconds;
+ /// duration.nanos = end.nanos - start.nanos;
///
- /// if (duration.seconds &lt; 0 &amp;&amp; duration.nanos > 0) {
- /// duration.seconds += 1;
- /// duration.nanos -= 1000000000;
- /// } else if (durations.seconds > 0 &amp;&amp; duration.nanos &lt; 0) {
- /// duration.seconds -= 1;
- /// duration.nanos += 1000000000;
- /// }
+ /// if (duration.seconds &lt; 0 &amp;&amp; duration.nanos > 0) {
+ /// duration.seconds += 1;
+ /// duration.nanos -= 1000000000;
+ /// } else if (durations.seconds > 0 &amp;&amp; duration.nanos &lt; 0) {
+ /// duration.seconds -= 1;
+ /// duration.nanos += 1000000000;
+ /// }
///
- /// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
+ /// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
///
- /// Timestamp start = ...;
- /// Duration duration = ...;
- /// Timestamp end = ...;
+ /// Timestamp start = ...;
+ /// Duration duration = ...;
+ /// Timestamp end = ...;
///
- /// end.seconds = start.seconds + duration.seconds;
- /// end.nanos = start.nanos + duration.nanos;
+ /// end.seconds = start.seconds + duration.seconds;
+ /// end.nanos = start.nanos + duration.nanos;
///
- /// if (end.nanos &lt; 0) {
- /// end.seconds -= 1;
- /// end.nanos += 1000000000;
- /// } else if (end.nanos >= 1000000000) {
- /// end.seconds += 1;
- /// end.nanos -= 1000000000;
- /// }
+ /// if (end.nanos &lt; 0) {
+ /// end.seconds -= 1;
+ /// end.nanos += 1000000000;
+ /// } else if (end.nanos >= 1000000000) {
+ /// end.seconds += 1;
+ /// end.nanos -= 1000000000;
+ /// }
///
- /// Example 3: Compute Duration from datetime.timedelta in Python.
+ /// Example 3: Compute Duration from datetime.timedelta in Python.
///
- /// td = datetime.timedelta(days=3, minutes=10)
- /// duration = Duration()
- /// duration.FromTimedelta(td)
+ /// td = datetime.timedelta(days=3, minutes=10)
+ /// duration = Duration()
+ /// duration.FromTimedelta(td)
/// </summary>
public sealed partial class Duration : pb::IMessage<Duration> {
private static readonly pb::MessageParser<Duration> _parser = new pb::MessageParser<Duration>(() => new Duration());
@@ -123,8 +123,8 @@ namespace Google.Protobuf.WellKnownTypes {
public const int SecondsFieldNumber = 1;
private long seconds_;
/// <summary>
- /// Signed seconds of the span of time. Must be from -315,576,000,000
- /// to +315,576,000,000 inclusive.
+ /// Signed seconds of the span of time. Must be from -315,576,000,000
+ /// to +315,576,000,000 inclusive.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public long Seconds {
@@ -138,12 +138,12 @@ namespace Google.Protobuf.WellKnownTypes {
public const int NanosFieldNumber = 2;
private int nanos_;
/// <summary>
- /// Signed fractions of a second at nanosecond resolution of the span
- /// of time. Durations less than one second are represented with a 0
- /// `seconds` field and a positive or negative `nanos` field. For durations
- /// of one second or more, a non-zero value for the `nanos` field must be
- /// of the same sign as the `seconds` field. Must be from -999,999,999
- /// to +999,999,999 inclusive.
+ /// Signed fractions of a second at nanosecond resolution of the span
+ /// of time. Durations less than one second are represented with a 0
+ /// `seconds` field and a positive or negative `nanos` field. For durations
+ /// of one second or more, a non-zero value for the `nanos` field must be
+ /// of the same sign as the `seconds` field. Must be from -999,999,999
+ /// to +999,999,999 inclusive.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int Nanos {
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs
index 0e64133e..aa89e08f 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs
@@ -38,15 +38,15 @@ namespace Google.Protobuf.WellKnownTypes {
}
#region Messages
/// <summary>
- /// A generic empty message that you can re-use to avoid defining duplicated
- /// empty messages in your APIs. A typical example is to use it as the request
- /// or the response type of an API method. For instance:
+ /// A generic empty message that you can re-use to avoid defining duplicated
+ /// empty messages in your APIs. A typical example is to use it as the request
+ /// or the response type of an API method. For instance:
///
- /// service Foo {
- /// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
- /// }
+ /// service Foo {
+ /// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
+ /// }
///
- /// The JSON representation for `Empty` is empty JSON object `{}`.
+ /// The JSON representation for `Empty` is empty JSON object `{}`.
/// </summary>
public sealed partial class Empty : pb::IMessage<Empty> {
private static readonly pb::MessageParser<Empty> _parser = new pb::MessageParser<Empty>(() => new Empty());
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs b/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs
index c73d6bd8..ef3bc10a 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs
@@ -23,9 +23,11 @@ namespace Google.Protobuf.WellKnownTypes {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
"CiBnb29nbGUvcHJvdG9idWYvZmllbGRfbWFzay5wcm90bxIPZ29vZ2xlLnBy",
- "b3RvYnVmIhoKCUZpZWxkTWFzaxINCgVwYXRocxgBIAMoCUJOChNjb20uZ29v",
- "Z2xlLnByb3RvYnVmQg5GaWVsZE1hc2tQcm90b1ABogIDR1BCqgIeR29vZ2xl",
- "LlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZwcm90bzM="));
+ "b3RvYnVmIhoKCUZpZWxkTWFzaxINCgVwYXRocxgBIAMoCUKJAQoTY29tLmdv",
+ "b2dsZS5wcm90b2J1ZkIORmllbGRNYXNrUHJvdG9QAVo5Z29vZ2xlLmdvbGFu",
+ "Zy5vcmcvZ2VucHJvdG8vcHJvdG9idWYvZmllbGRfbWFzaztmaWVsZF9tYXNr",
+ "ogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZwcm90",
+ "bzM="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
@@ -37,206 +39,206 @@ namespace Google.Protobuf.WellKnownTypes {
}
#region Messages
/// <summary>
- /// `FieldMask` represents a set of symbolic field paths, for example:
- ///
- /// paths: "f.a"
- /// paths: "f.b.d"
- ///
- /// Here `f` represents a field in some root message, `a` and `b`
- /// fields in the message found in `f`, and `d` a field found in the
- /// message in `f.b`.
- ///
- /// Field masks are used to specify a subset of fields that should be
- /// returned by a get operation or modified by an update operation.
- /// Field masks also have a custom JSON encoding (see below).
- ///
- /// # Field Masks in Projections
- ///
- /// When used in the context of a projection, a response message or
- /// sub-message is filtered by the API to only contain those fields as
- /// specified in the mask. For example, if the mask in the previous
- /// example is applied to a response message as follows:
- ///
- /// f {
- /// a : 22
- /// b {
- /// d : 1
- /// x : 2
- /// }
- /// y : 13
- /// }
- /// z: 8
- ///
- /// The result will not contain specific values for fields x,y and z
- /// (their value will be set to the default, and omitted in proto text
- /// output):
- ///
- /// f {
- /// a : 22
- /// b {
- /// d : 1
- /// }
- /// }
- ///
- /// A repeated field is not allowed except at the last position of a
- /// paths string.
- ///
- /// If a FieldMask object is not present in a get operation, the
- /// operation applies to all fields (as if a FieldMask of all fields
- /// had been specified).
- ///
- /// Note that a field mask does not necessarily apply to the
- /// top-level response message. In case of a REST get operation, the
- /// field mask applies directly to the response, but in case of a REST
- /// list operation, the mask instead applies to each individual message
- /// in the returned resource list. In case of a REST custom method,
- /// other definitions may be used. Where the mask applies will be
- /// clearly documented together with its declaration in the API. In
- /// any case, the effect on the returned resource/resources is required
- /// behavior for APIs.
- ///
- /// # Field Masks in Update Operations
- ///
- /// A field mask in update operations specifies which fields of the
- /// targeted resource are going to be updated. The API is required
- /// to only change the values of the fields as specified in the mask
- /// and leave the others untouched. If a resource is passed in to
- /// describe the updated values, the API ignores the values of all
- /// fields not covered by the mask.
- ///
- /// If a repeated field is specified for an update operation, the existing
- /// repeated values in the target resource will be overwritten by the new values.
- /// Note that a repeated field is only allowed in the last position of a `paths`
- /// string.
- ///
- /// If a sub-message is specified in the last position of the field mask for an
- /// update operation, then the existing sub-message in the target resource is
- /// overwritten. Given the target message:
- ///
- /// f {
- /// b {
- /// d : 1
- /// x : 2
- /// }
- /// c : 1
- /// }
- ///
- /// And an update message:
- ///
- /// f {
- /// b {
- /// d : 10
- /// }
- /// }
- ///
- /// then if the field mask is:
- ///
- /// paths: "f.b"
- ///
- /// then the result will be:
- ///
- /// f {
- /// b {
- /// d : 10
- /// }
- /// c : 1
- /// }
- ///
- /// However, if the update mask was:
- ///
- /// paths: "f.b.d"
- ///
- /// then the result would be:
- ///
- /// f {
- /// b {
- /// d : 10
- /// x : 2
- /// }
- /// c : 1
- /// }
- ///
- /// In order to reset a field's value to the default, the field must
- /// be in the mask and set to the default value in the provided resource.
- /// Hence, in order to reset all fields of a resource, provide a default
- /// instance of the resource and set all fields in the mask, or do
- /// not provide a mask as described below.
- ///
- /// If a field mask is not present on update, the operation applies to
- /// all fields (as if a field mask of all fields has been specified).
- /// Note that in the presence of schema evolution, this may mean that
- /// fields the client does not know and has therefore not filled into
- /// the request will be reset to their default. If this is unwanted
- /// behavior, a specific service may require a client to always specify
- /// a field mask, producing an error if not.
- ///
- /// As with get operations, the location of the resource which
- /// describes the updated values in the request message depends on the
- /// operation kind. In any case, the effect of the field mask is
- /// required to be honored by the API.
- ///
- /// ## Considerations for HTTP REST
- ///
- /// The HTTP kind of an update operation which uses a field mask must
- /// be set to PATCH instead of PUT in order to satisfy HTTP semantics
- /// (PUT must only be used for full updates).
- ///
- /// # JSON Encoding of Field Masks
- ///
- /// In JSON, a field mask is encoded as a single string where paths are
- /// separated by a comma. Fields name in each path are converted
- /// to/from lower-camel naming conventions.
- ///
- /// As an example, consider the following message declarations:
- ///
- /// message Profile {
- /// User user = 1;
- /// Photo photo = 2;
- /// }
- /// message User {
- /// string display_name = 1;
- /// string address = 2;
- /// }
- ///
- /// In proto a field mask for `Profile` may look as such:
+ /// `FieldMask` represents a set of symbolic field paths, for example:
+ ///
+ /// paths: "f.a"
+ /// paths: "f.b.d"
+ ///
+ /// Here `f` represents a field in some root message, `a` and `b`
+ /// fields in the message found in `f`, and `d` a field found in the
+ /// message in `f.b`.
+ ///
+ /// Field masks are used to specify a subset of fields that should be
+ /// returned by a get operation or modified by an update operation.
+ /// Field masks also have a custom JSON encoding (see below).
+ ///
+ /// # Field Masks in Projections
+ ///
+ /// When used in the context of a projection, a response message or
+ /// sub-message is filtered by the API to only contain those fields as
+ /// specified in the mask. For example, if the mask in the previous
+ /// example is applied to a response message as follows:
+ ///
+ /// f {
+ /// a : 22
+ /// b {
+ /// d : 1
+ /// x : 2
+ /// }
+ /// y : 13
+ /// }
+ /// z: 8
+ ///
+ /// The result will not contain specific values for fields x,y and z
+ /// (their value will be set to the default, and omitted in proto text
+ /// output):
+ ///
+ /// f {
+ /// a : 22
+ /// b {
+ /// d : 1
+ /// }
+ /// }
+ ///
+ /// A repeated field is not allowed except at the last position of a
+ /// paths string.
+ ///
+ /// If a FieldMask object is not present in a get operation, the
+ /// operation applies to all fields (as if a FieldMask of all fields
+ /// had been specified).
+ ///
+ /// Note that a field mask does not necessarily apply to the
+ /// top-level response message. In case of a REST get operation, the
+ /// field mask applies directly to the response, but in case of a REST
+ /// list operation, the mask instead applies to each individual message
+ /// in the returned resource list. In case of a REST custom method,
+ /// other definitions may be used. Where the mask applies will be
+ /// clearly documented together with its declaration in the API. In
+ /// any case, the effect on the returned resource/resources is required
+ /// behavior for APIs.
+ ///
+ /// # Field Masks in Update Operations
+ ///
+ /// A field mask in update operations specifies which fields of the
+ /// targeted resource are going to be updated. The API is required
+ /// to only change the values of the fields as specified in the mask
+ /// and leave the others untouched. If a resource is passed in to
+ /// describe the updated values, the API ignores the values of all
+ /// fields not covered by the mask.
+ ///
+ /// If a repeated field is specified for an update operation, the existing
+ /// repeated values in the target resource will be overwritten by the new values.
+ /// Note that a repeated field is only allowed in the last position of a `paths`
+ /// string.
+ ///
+ /// If a sub-message is specified in the last position of the field mask for an
+ /// update operation, then the existing sub-message in the target resource is
+ /// overwritten. Given the target message:
+ ///
+ /// f {
+ /// b {
+ /// d : 1
+ /// x : 2
+ /// }
+ /// c : 1
+ /// }
+ ///
+ /// And an update message:
+ ///
+ /// f {
+ /// b {
+ /// d : 10
+ /// }
+ /// }
+ ///
+ /// then if the field mask is:
+ ///
+ /// paths: "f.b"
+ ///
+ /// then the result will be:
+ ///
+ /// f {
+ /// b {
+ /// d : 10
+ /// }
+ /// c : 1
+ /// }
+ ///
+ /// However, if the update mask was:
+ ///
+ /// paths: "f.b.d"
+ ///
+ /// then the result would be:
+ ///
+ /// f {
+ /// b {
+ /// d : 10
+ /// x : 2
+ /// }
+ /// c : 1
+ /// }
+ ///
+ /// In order to reset a field's value to the default, the field must
+ /// be in the mask and set to the default value in the provided resource.
+ /// Hence, in order to reset all fields of a resource, provide a default
+ /// instance of the resource and set all fields in the mask, or do
+ /// not provide a mask as described below.
+ ///
+ /// If a field mask is not present on update, the operation applies to
+ /// all fields (as if a field mask of all fields has been specified).
+ /// Note that in the presence of schema evolution, this may mean that
+ /// fields the client does not know and has therefore not filled into
+ /// the request will be reset to their default. If this is unwanted
+ /// behavior, a specific service may require a client to always specify
+ /// a field mask, producing an error if not.
+ ///
+ /// As with get operations, the location of the resource which
+ /// describes the updated values in the request message depends on the
+ /// operation kind. In any case, the effect of the field mask is
+ /// required to be honored by the API.
+ ///
+ /// ## Considerations for HTTP REST
+ ///
+ /// The HTTP kind of an update operation which uses a field mask must
+ /// be set to PATCH instead of PUT in order to satisfy HTTP semantics
+ /// (PUT must only be used for full updates).
+ ///
+ /// # JSON Encoding of Field Masks
+ ///
+ /// In JSON, a field mask is encoded as a single string where paths are
+ /// separated by a comma. Fields name in each path are converted
+ /// to/from lower-camel naming conventions.
+ ///
+ /// As an example, consider the following message declarations:
+ ///
+ /// message Profile {
+ /// User user = 1;
+ /// Photo photo = 2;
+ /// }
+ /// message User {
+ /// string display_name = 1;
+ /// string address = 2;
+ /// }
+ ///
+ /// In proto a field mask for `Profile` may look as such:
///
- /// mask {
- /// paths: "user.display_name"
- /// paths: "photo"
- /// }
+ /// mask {
+ /// paths: "user.display_name"
+ /// paths: "photo"
+ /// }
///
- /// In JSON, the same mask is represented as below:
+ /// In JSON, the same mask is represented as below:
///
- /// {
- /// mask: "user.displayName,photo"
- /// }
+ /// {
+ /// mask: "user.displayName,photo"
+ /// }
///
- /// # Field Masks and Oneof Fields
+ /// # Field Masks and Oneof Fields
///
- /// Field masks treat fields in oneofs just as regular fields. Consider the
- /// following message:
+ /// Field masks treat fields in oneofs just as regular fields. Consider the
+ /// following message:
///
- /// message SampleMessage {
- /// oneof test_oneof {
- /// string name = 4;
- /// SubMessage sub_message = 9;
- /// }
- /// }
+ /// message SampleMessage {
+ /// oneof test_oneof {
+ /// string name = 4;
+ /// SubMessage sub_message = 9;
+ /// }
+ /// }
///
- /// The field mask can be:
+ /// The field mask can be:
///
- /// mask {
- /// paths: "name"
- /// }
+ /// mask {
+ /// paths: "name"
+ /// }
///
- /// Or:
+ /// Or:
///
- /// mask {
- /// paths: "sub_message"
- /// }
+ /// mask {
+ /// paths: "sub_message"
+ /// }
///
- /// Note that oneof type names ("test_oneof" in this case) cannot be used in
- /// paths.
+ /// Note that oneof type names ("test_oneof" in this case) cannot be used in
+ /// paths.
/// </summary>
public sealed partial class FieldMask : pb::IMessage<FieldMask> {
private static readonly pb::MessageParser<FieldMask> _parser = new pb::MessageParser<FieldMask>(() => new FieldMask());
@@ -276,7 +278,7 @@ namespace Google.Protobuf.WellKnownTypes {
= pb::FieldCodec.ForString(10);
private readonly pbc::RepeatedField<string> paths_ = new pbc::RepeatedField<string>();
/// <summary>
- /// The set of field mask paths.
+ /// The set of field mask paths.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<string> Paths {
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/FieldMaskPartial.cs b/csharp/src/Google.Protobuf/WellKnownTypes/FieldMaskPartial.cs
index 0685c21a..4b0670f6 100644..100755
--- a/csharp/src/Google.Protobuf/WellKnownTypes/FieldMaskPartial.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/FieldMaskPartial.cs
@@ -59,7 +59,7 @@ namespace Google.Protobuf.WellKnownTypes
if (firstInvalid == null)
{
var writer = new StringWriter();
-#if DOTNET35
+#if NET35
var query = paths.Select(JsonFormatter.ToJsonName);
JsonFormatter.WriteString(writer, string.Join(",", query.ToArray()));
#else
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs b/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs
index c3400327..6ddadf19 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs
@@ -24,9 +24,10 @@ namespace Google.Protobuf.WellKnownTypes {
string.Concat(
"CiRnb29nbGUvcHJvdG9idWYvc291cmNlX2NvbnRleHQucHJvdG8SD2dvb2ds",
"ZS5wcm90b2J1ZiIiCg1Tb3VyY2VDb250ZXh0EhEKCWZpbGVfbmFtZRgBIAEo",
- "CUJSChNjb20uZ29vZ2xlLnByb3RvYnVmQhJTb3VyY2VDb250ZXh0UHJvdG9Q",
- "AaICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBlc2IGcHJv",
- "dG8z"));
+ "CUKVAQoTY29tLmdvb2dsZS5wcm90b2J1ZkISU291cmNlQ29udGV4dFByb3Rv",
+ "UAFaQWdvb2dsZS5nb2xhbmcub3JnL2dlbnByb3RvL3Byb3RvYnVmL3NvdXJj",
+ "ZV9jb250ZXh0O3NvdXJjZV9jb250ZXh0ogIDR1BCqgIeR29vZ2xlLlByb3Rv",
+ "YnVmLldlbGxLbm93blR5cGVzYgZwcm90bzM="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
@@ -38,8 +39,8 @@ namespace Google.Protobuf.WellKnownTypes {
}
#region Messages
/// <summary>
- /// `SourceContext` represents information about the source of a
- /// protobuf element, like the file in which it is defined.
+ /// `SourceContext` represents information about the source of a
+ /// protobuf element, like the file in which it is defined.
/// </summary>
public sealed partial class SourceContext : pb::IMessage<SourceContext> {
private static readonly pb::MessageParser<SourceContext> _parser = new pb::MessageParser<SourceContext>(() => new SourceContext());
@@ -77,8 +78,8 @@ namespace Google.Protobuf.WellKnownTypes {
public const int FileNameFieldNumber = 1;
private string fileName_ = "";
/// <summary>
- /// The path-qualified name of the .proto file that contained the associated
- /// protobuf element. For example: `"google/protobuf/source_context.proto"`.
+ /// The path-qualified name of the .proto file that contained the associated
+ /// protobuf element. For example: `"google/protobuf/source_context.proto"`.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string FileName {
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs
index d4556051..1fa35521 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs
@@ -50,14 +50,14 @@ namespace Google.Protobuf.WellKnownTypes {
}
#region Enums
/// <summary>
- /// `NullValue` is a singleton enumeration to represent the null value for the
- /// `Value` type union.
+ /// `NullValue` is a singleton enumeration to represent the null value for the
+ /// `Value` type union.
///
- /// The JSON representation for `NullValue` is JSON `null`.
+ /// The JSON representation for `NullValue` is JSON `null`.
/// </summary>
public enum NullValue {
/// <summary>
- /// Null value.
+ /// Null value.
/// </summary>
[pbr::OriginalName("NULL_VALUE")] NullValue = 0,
}
@@ -66,14 +66,14 @@ namespace Google.Protobuf.WellKnownTypes {
#region Messages
/// <summary>
- /// `Struct` represents a structured data value, consisting of fields
- /// which map to dynamically typed values. In some languages, `Struct`
- /// might be supported by a native representation. For example, in
- /// scripting languages like JS a struct is represented as an
- /// object. The details of that representation are described together
- /// with the proto support for the language.
+ /// `Struct` represents a structured data value, consisting of fields
+ /// which map to dynamically typed values. In some languages, `Struct`
+ /// might be supported by a native representation. For example, in
+ /// scripting languages like JS a struct is represented as an
+ /// object. The details of that representation are described together
+ /// with the proto support for the language.
///
- /// The JSON representation for `Struct` is JSON object.
+ /// The JSON representation for `Struct` is JSON object.
/// </summary>
public sealed partial class Struct : pb::IMessage<Struct> {
private static readonly pb::MessageParser<Struct> _parser = new pb::MessageParser<Struct>(() => new Struct());
@@ -113,7 +113,7 @@ namespace Google.Protobuf.WellKnownTypes {
= new pbc::MapField<string, global::Google.Protobuf.WellKnownTypes.Value>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Value.Parser), 10);
private readonly pbc::MapField<string, global::Google.Protobuf.WellKnownTypes.Value> fields_ = new pbc::MapField<string, global::Google.Protobuf.WellKnownTypes.Value>();
/// <summary>
- /// Unordered map of dynamically typed values.
+ /// Unordered map of dynamically typed values.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::MapField<string, global::Google.Protobuf.WellKnownTypes.Value> Fields {
@@ -188,12 +188,12 @@ namespace Google.Protobuf.WellKnownTypes {
}
/// <summary>
- /// `Value` represents a dynamically typed value which can be either
- /// null, a number, a string, a boolean, a recursive struct value, or a
- /// list of values. A producer of value is expected to set one of that
- /// variants, absence of any variant indicates an error.
+ /// `Value` represents a dynamically typed value which can be either
+ /// null, a number, a string, a boolean, a recursive struct value, or a
+ /// list of values. A producer of value is expected to set one of that
+ /// variants, absence of any variant indicates an error.
///
- /// The JSON representation for `Value` is JSON value.
+ /// The JSON representation for `Value` is JSON value.
/// </summary>
public sealed partial class Value : pb::IMessage<Value> {
private static readonly pb::MessageParser<Value> _parser = new pb::MessageParser<Value>(() => new Value());
@@ -250,7 +250,7 @@ namespace Google.Protobuf.WellKnownTypes {
/// <summary>Field number for the "null_value" field.</summary>
public const int NullValueFieldNumber = 1;
/// <summary>
- /// Represents a null value.
+ /// Represents a null value.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Google.Protobuf.WellKnownTypes.NullValue NullValue {
@@ -264,7 +264,7 @@ namespace Google.Protobuf.WellKnownTypes {
/// <summary>Field number for the "number_value" field.</summary>
public const int NumberValueFieldNumber = 2;
/// <summary>
- /// Represents a double value.
+ /// Represents a double value.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public double NumberValue {
@@ -278,7 +278,7 @@ namespace Google.Protobuf.WellKnownTypes {
/// <summary>Field number for the "string_value" field.</summary>
public const int StringValueFieldNumber = 3;
/// <summary>
- /// Represents a string value.
+ /// Represents a string value.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string StringValue {
@@ -292,7 +292,7 @@ namespace Google.Protobuf.WellKnownTypes {
/// <summary>Field number for the "bool_value" field.</summary>
public const int BoolValueFieldNumber = 4;
/// <summary>
- /// Represents a boolean value.
+ /// Represents a boolean value.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool BoolValue {
@@ -306,7 +306,7 @@ namespace Google.Protobuf.WellKnownTypes {
/// <summary>Field number for the "struct_value" field.</summary>
public const int StructValueFieldNumber = 5;
/// <summary>
- /// Represents a structured value.
+ /// Represents a structured value.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Google.Protobuf.WellKnownTypes.Struct StructValue {
@@ -320,7 +320,7 @@ namespace Google.Protobuf.WellKnownTypes {
/// <summary>Field number for the "list_value" field.</summary>
public const int ListValueFieldNumber = 6;
/// <summary>
- /// Represents a repeated `Value`.
+ /// Represents a repeated `Value`.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Google.Protobuf.WellKnownTypes.ListValue ListValue {
@@ -525,9 +525,9 @@ namespace Google.Protobuf.WellKnownTypes {
}
/// <summary>
- /// `ListValue` is a wrapper around a repeated field of values.
+ /// `ListValue` is a wrapper around a repeated field of values.
///
- /// The JSON representation for `ListValue` is JSON array.
+ /// The JSON representation for `ListValue` is JSON array.
/// </summary>
public sealed partial class ListValue : pb::IMessage<ListValue> {
private static readonly pb::MessageParser<ListValue> _parser = new pb::MessageParser<ListValue>(() => new ListValue());
@@ -567,7 +567,7 @@ namespace Google.Protobuf.WellKnownTypes {
= pb::FieldCodec.ForMessage(10, global::Google.Protobuf.WellKnownTypes.Value.Parser);
private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Value> values_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Value>();
/// <summary>
- /// Repeated field of dynamically typed values.
+ /// Repeated field of dynamically typed values.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Value> Values {
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs
index 6c9a517f..b789f6da 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs
@@ -39,56 +39,56 @@ namespace Google.Protobuf.WellKnownTypes {
}
#region Messages
/// <summary>
- /// A Timestamp represents a point in time independent of any time zone
- /// or calendar, represented as seconds and fractions of seconds at
- /// nanosecond resolution in UTC Epoch time. It is encoded using the
- /// Proleptic Gregorian Calendar which extends the Gregorian calendar
- /// backwards to year one. It is encoded assuming all minutes are 60
- /// seconds long, i.e. leap seconds are "smeared" so that no leap second
- /// table is needed for interpretation. Range is from
- /// 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.
- /// By restricting to that range, we ensure that we can convert to
- /// and from RFC 3339 date strings.
- /// See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt).
+ /// A Timestamp represents a point in time independent of any time zone
+ /// or calendar, represented as seconds and fractions of seconds at
+ /// nanosecond resolution in UTC Epoch time. It is encoded using the
+ /// Proleptic Gregorian Calendar which extends the Gregorian calendar
+ /// backwards to year one. It is encoded assuming all minutes are 60
+ /// seconds long, i.e. leap seconds are "smeared" so that no leap second
+ /// table is needed for interpretation. Range is from
+ /// 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.
+ /// By restricting to that range, we ensure that we can convert to
+ /// and from RFC 3339 date strings.
+ /// See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt).
///
- /// Example 1: Compute Timestamp from POSIX `time()`.
+ /// Example 1: Compute Timestamp from POSIX `time()`.
///
- /// Timestamp timestamp;
- /// timestamp.set_seconds(time(NULL));
- /// timestamp.set_nanos(0);
+ /// Timestamp timestamp;
+ /// timestamp.set_seconds(time(NULL));
+ /// timestamp.set_nanos(0);
///
- /// Example 2: Compute Timestamp from POSIX `gettimeofday()`.
+ /// Example 2: Compute Timestamp from POSIX `gettimeofday()`.
///
- /// struct timeval tv;
- /// gettimeofday(&amp;tv, NULL);
+ /// struct timeval tv;
+ /// gettimeofday(&amp;tv, NULL);
///
- /// Timestamp timestamp;
- /// timestamp.set_seconds(tv.tv_sec);
- /// timestamp.set_nanos(tv.tv_usec * 1000);
+ /// Timestamp timestamp;
+ /// timestamp.set_seconds(tv.tv_sec);
+ /// timestamp.set_nanos(tv.tv_usec * 1000);
///
- /// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
+ /// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
///
- /// FILETIME ft;
- /// GetSystemTimeAsFileTime(&amp;ft);
- /// UINT64 ticks = (((UINT64)ft.dwHighDateTime) &lt;&lt; 32) | ft.dwLowDateTime;
+ /// FILETIME ft;
+ /// GetSystemTimeAsFileTime(&amp;ft);
+ /// UINT64 ticks = (((UINT64)ft.dwHighDateTime) &lt;&lt; 32) | ft.dwLowDateTime;
///
- /// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
- /// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
- /// Timestamp timestamp;
- /// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
- /// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
+ /// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
+ /// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
+ /// Timestamp timestamp;
+ /// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
+ /// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
///
- /// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
+ /// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
///
- /// long millis = System.currentTimeMillis();
+ /// long millis = System.currentTimeMillis();
///
- /// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
- /// .setNanos((int) ((millis % 1000) * 1000000)).build();
+ /// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
+ /// .setNanos((int) ((millis % 1000) * 1000000)).build();
///
- /// Example 5: Compute Timestamp from current time in Python.
+ /// Example 5: Compute Timestamp from current time in Python.
///
- /// timestamp = Timestamp()
- /// timestamp.GetCurrentTime()
+ /// timestamp = Timestamp()
+ /// timestamp.GetCurrentTime()
/// </summary>
public sealed partial class Timestamp : pb::IMessage<Timestamp> {
private static readonly pb::MessageParser<Timestamp> _parser = new pb::MessageParser<Timestamp>(() => new Timestamp());
@@ -127,9 +127,9 @@ namespace Google.Protobuf.WellKnownTypes {
public const int SecondsFieldNumber = 1;
private long seconds_;
/// <summary>
- /// Represents seconds of UTC time since Unix epoch
- /// 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
- /// 9999-12-31T23:59:59Z inclusive.
+ /// Represents seconds of UTC time since Unix epoch
+ /// 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
+ /// 9999-12-31T23:59:59Z inclusive.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public long Seconds {
@@ -143,10 +143,10 @@ namespace Google.Protobuf.WellKnownTypes {
public const int NanosFieldNumber = 2;
private int nanos_;
/// <summary>
- /// Non-negative fractions of a second at nanosecond resolution. Negative
- /// second values with fractions must still have non-negative nanos values
- /// that count forward in time. Must be from 0 to 999,999,999
- /// inclusive.
+ /// Non-negative fractions of a second at nanosecond resolution. Negative
+ /// second values with fractions must still have non-negative nanos values
+ /// that count forward in time. Must be from 0 to 999,999,999
+ /// inclusive.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int Nanos {
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs
index e6363480..7375b6cb 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs
@@ -54,9 +54,10 @@ namespace Google.Protobuf.WellKnownTypes {
"ASgFEigKB29wdGlvbnMYAyADKAsyFy5nb29nbGUucHJvdG9idWYuT3B0aW9u",
"IjsKBk9wdGlvbhIMCgRuYW1lGAEgASgJEiMKBXZhbHVlGAIgASgLMhQuZ29v",
"Z2xlLnByb3RvYnVmLkFueSouCgZTeW50YXgSEQoNU1lOVEFYX1BST1RPMhAA",
- "EhEKDVNZTlRBWF9QUk9UTzMQAUJMChNjb20uZ29vZ2xlLnByb3RvYnVmQglU",
- "eXBlUHJvdG9QAfgBAaICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25v",
- "d25UeXBlc2IGcHJvdG8z"));
+ "EhEKDVNZTlRBWF9QUk9UTzMQAUJ9ChNjb20uZ29vZ2xlLnByb3RvYnVmQglU",
+ "eXBlUHJvdG9QAVovZ29vZ2xlLmdvbGFuZy5vcmcvZ2VucHJvdG8vcHJvdG9i",
+ "dWYvcHR5cGU7cHR5cGX4AQGiAgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2Vs",
+ "bEtub3duVHlwZXNiBnByb3RvMw=="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.AnyReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.SourceContextReflection.Descriptor, },
new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Google.Protobuf.WellKnownTypes.Syntax), }, new pbr::GeneratedClrTypeInfo[] {
@@ -72,15 +73,15 @@ namespace Google.Protobuf.WellKnownTypes {
}
#region Enums
/// <summary>
- /// The syntax in which a protocol buffer element is defined.
+ /// The syntax in which a protocol buffer element is defined.
/// </summary>
public enum Syntax {
/// <summary>
- /// Syntax `proto2`.
+ /// Syntax `proto2`.
/// </summary>
[pbr::OriginalName("SYNTAX_PROTO2")] Proto2 = 0,
/// <summary>
- /// Syntax `proto3`.
+ /// Syntax `proto3`.
/// </summary>
[pbr::OriginalName("SYNTAX_PROTO3")] Proto3 = 1,
}
@@ -89,7 +90,7 @@ namespace Google.Protobuf.WellKnownTypes {
#region Messages
/// <summary>
- /// A protocol buffer message type.
+ /// A protocol buffer message type.
/// </summary>
public sealed partial class Type : pb::IMessage<Type> {
private static readonly pb::MessageParser<Type> _parser = new pb::MessageParser<Type>(() => new Type());
@@ -132,7 +133,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int NameFieldNumber = 1;
private string name_ = "";
/// <summary>
- /// The fully qualified message name.
+ /// The fully qualified message name.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Name {
@@ -148,7 +149,7 @@ namespace Google.Protobuf.WellKnownTypes {
= pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Field.Parser);
private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Field> fields_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Field>();
/// <summary>
- /// The list of fields.
+ /// The list of fields.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Field> Fields {
@@ -161,7 +162,7 @@ namespace Google.Protobuf.WellKnownTypes {
= pb::FieldCodec.ForString(26);
private readonly pbc::RepeatedField<string> oneofs_ = new pbc::RepeatedField<string>();
/// <summary>
- /// The list of types appearing in `oneof` definitions in this type.
+ /// The list of types appearing in `oneof` definitions in this type.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<string> Oneofs {
@@ -174,7 +175,7 @@ namespace Google.Protobuf.WellKnownTypes {
= pb::FieldCodec.ForMessage(34, global::Google.Protobuf.WellKnownTypes.Option.Parser);
private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option> options_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option>();
/// <summary>
- /// The protocol buffer options.
+ /// The protocol buffer options.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option> Options {
@@ -185,7 +186,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int SourceContextFieldNumber = 5;
private global::Google.Protobuf.WellKnownTypes.SourceContext sourceContext_;
/// <summary>
- /// The source context.
+ /// The source context.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Google.Protobuf.WellKnownTypes.SourceContext SourceContext {
@@ -199,7 +200,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int SyntaxFieldNumber = 6;
private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = 0;
/// <summary>
- /// The source syntax.
+ /// The source syntax.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Google.Protobuf.WellKnownTypes.Syntax Syntax {
@@ -349,7 +350,7 @@ namespace Google.Protobuf.WellKnownTypes {
}
/// <summary>
- /// A single field of a message type.
+ /// A single field of a message type.
/// </summary>
public sealed partial class Field : pb::IMessage<Field> {
private static readonly pb::MessageParser<Field> _parser = new pb::MessageParser<Field>(() => new Field());
@@ -396,7 +397,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int KindFieldNumber = 1;
private global::Google.Protobuf.WellKnownTypes.Field.Types.Kind kind_ = 0;
/// <summary>
- /// The field type.
+ /// The field type.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Google.Protobuf.WellKnownTypes.Field.Types.Kind Kind {
@@ -410,7 +411,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int CardinalityFieldNumber = 2;
private global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality cardinality_ = 0;
/// <summary>
- /// The field cardinality.
+ /// The field cardinality.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality Cardinality {
@@ -424,7 +425,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int NumberFieldNumber = 3;
private int number_;
/// <summary>
- /// The field number.
+ /// The field number.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int Number {
@@ -438,7 +439,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int NameFieldNumber = 4;
private string name_ = "";
/// <summary>
- /// The field name.
+ /// The field name.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Name {
@@ -452,8 +453,8 @@ namespace Google.Protobuf.WellKnownTypes {
public const int TypeUrlFieldNumber = 6;
private string typeUrl_ = "";
/// <summary>
- /// The field type URL, without the scheme, for message or enumeration
- /// types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`.
+ /// The field type URL, without the scheme, for message or enumeration
+ /// types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string TypeUrl {
@@ -467,8 +468,8 @@ namespace Google.Protobuf.WellKnownTypes {
public const int OneofIndexFieldNumber = 7;
private int oneofIndex_;
/// <summary>
- /// The index of the field type in `Type.oneofs`, for message or enumeration
- /// types. The first type has index 1; zero means the type is not in the list.
+ /// The index of the field type in `Type.oneofs`, for message or enumeration
+ /// types. The first type has index 1; zero means the type is not in the list.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int OneofIndex {
@@ -482,7 +483,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int PackedFieldNumber = 8;
private bool packed_;
/// <summary>
- /// Whether to use alternative packed wire representation.
+ /// Whether to use alternative packed wire representation.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Packed {
@@ -498,7 +499,7 @@ namespace Google.Protobuf.WellKnownTypes {
= pb::FieldCodec.ForMessage(74, global::Google.Protobuf.WellKnownTypes.Option.Parser);
private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option> options_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option>();
/// <summary>
- /// The protocol buffer options.
+ /// The protocol buffer options.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option> Options {
@@ -509,7 +510,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int JsonNameFieldNumber = 10;
private string jsonName_ = "";
/// <summary>
- /// The field JSON name.
+ /// The field JSON name.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string JsonName {
@@ -523,7 +524,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int DefaultValueFieldNumber = 11;
private string defaultValue_ = "";
/// <summary>
- /// The string value of the default value of this field. Proto2 syntax only.
+ /// The string value of the default value of this field. Proto2 syntax only.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string DefaultValue {
@@ -747,105 +748,105 @@ namespace Google.Protobuf.WellKnownTypes {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static partial class Types {
/// <summary>
- /// Basic field types.
+ /// Basic field types.
/// </summary>
public enum Kind {
/// <summary>
- /// Field type unknown.
+ /// Field type unknown.
/// </summary>
[pbr::OriginalName("TYPE_UNKNOWN")] TypeUnknown = 0,
/// <summary>
- /// Field type double.
+ /// Field type double.
/// </summary>
[pbr::OriginalName("TYPE_DOUBLE")] TypeDouble = 1,
/// <summary>
- /// Field type float.
+ /// Field type float.
/// </summary>
[pbr::OriginalName("TYPE_FLOAT")] TypeFloat = 2,
/// <summary>
- /// Field type int64.
+ /// Field type int64.
/// </summary>
[pbr::OriginalName("TYPE_INT64")] TypeInt64 = 3,
/// <summary>
- /// Field type uint64.
+ /// Field type uint64.
/// </summary>
[pbr::OriginalName("TYPE_UINT64")] TypeUint64 = 4,
/// <summary>
- /// Field type int32.
+ /// Field type int32.
/// </summary>
[pbr::OriginalName("TYPE_INT32")] TypeInt32 = 5,
/// <summary>
- /// Field type fixed64.
+ /// Field type fixed64.
/// </summary>
[pbr::OriginalName("TYPE_FIXED64")] TypeFixed64 = 6,
/// <summary>
- /// Field type fixed32.
+ /// Field type fixed32.
/// </summary>
[pbr::OriginalName("TYPE_FIXED32")] TypeFixed32 = 7,
/// <summary>
- /// Field type bool.
+ /// Field type bool.
/// </summary>
[pbr::OriginalName("TYPE_BOOL")] TypeBool = 8,
/// <summary>
- /// Field type string.
+ /// Field type string.
/// </summary>
[pbr::OriginalName("TYPE_STRING")] TypeString = 9,
/// <summary>
- /// Field type group. Proto2 syntax only, and deprecated.
+ /// Field type group. Proto2 syntax only, and deprecated.
/// </summary>
[pbr::OriginalName("TYPE_GROUP")] TypeGroup = 10,
/// <summary>
- /// Field type message.
+ /// Field type message.
/// </summary>
[pbr::OriginalName("TYPE_MESSAGE")] TypeMessage = 11,
/// <summary>
- /// Field type bytes.
+ /// Field type bytes.
/// </summary>
[pbr::OriginalName("TYPE_BYTES")] TypeBytes = 12,
/// <summary>
- /// Field type uint32.
+ /// Field type uint32.
/// </summary>
[pbr::OriginalName("TYPE_UINT32")] TypeUint32 = 13,
/// <summary>
- /// Field type enum.
+ /// Field type enum.
/// </summary>
[pbr::OriginalName("TYPE_ENUM")] TypeEnum = 14,
/// <summary>
- /// Field type sfixed32.
+ /// Field type sfixed32.
/// </summary>
[pbr::OriginalName("TYPE_SFIXED32")] TypeSfixed32 = 15,
/// <summary>
- /// Field type sfixed64.
+ /// Field type sfixed64.
/// </summary>
[pbr::OriginalName("TYPE_SFIXED64")] TypeSfixed64 = 16,
/// <summary>
- /// Field type sint32.
+ /// Field type sint32.
/// </summary>
[pbr::OriginalName("TYPE_SINT32")] TypeSint32 = 17,
/// <summary>
- /// Field type sint64.
+ /// Field type sint64.
/// </summary>
[pbr::OriginalName("TYPE_SINT64")] TypeSint64 = 18,
}
/// <summary>
- /// Whether a field is optional, required, or repeated.
+ /// Whether a field is optional, required, or repeated.
/// </summary>
public enum Cardinality {
/// <summary>
- /// For fields with unknown cardinality.
+ /// For fields with unknown cardinality.
/// </summary>
[pbr::OriginalName("CARDINALITY_UNKNOWN")] Unknown = 0,
/// <summary>
- /// For optional fields.
+ /// For optional fields.
/// </summary>
[pbr::OriginalName("CARDINALITY_OPTIONAL")] Optional = 1,
/// <summary>
- /// For required fields. Proto2 syntax only.
+ /// For required fields. Proto2 syntax only.
/// </summary>
[pbr::OriginalName("CARDINALITY_REQUIRED")] Required = 2,
/// <summary>
- /// For repeated fields.
+ /// For repeated fields.
/// </summary>
[pbr::OriginalName("CARDINALITY_REPEATED")] Repeated = 3,
}
@@ -856,7 +857,7 @@ namespace Google.Protobuf.WellKnownTypes {
}
/// <summary>
- /// Enum type definition.
+ /// Enum type definition.
/// </summary>
public sealed partial class Enum : pb::IMessage<Enum> {
private static readonly pb::MessageParser<Enum> _parser = new pb::MessageParser<Enum>(() => new Enum());
@@ -898,7 +899,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int NameFieldNumber = 1;
private string name_ = "";
/// <summary>
- /// Enum type name.
+ /// Enum type name.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Name {
@@ -914,7 +915,7 @@ namespace Google.Protobuf.WellKnownTypes {
= pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.EnumValue.Parser);
private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.EnumValue> enumvalue_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.EnumValue>();
/// <summary>
- /// Enum value definitions.
+ /// Enum value definitions.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.EnumValue> Enumvalue {
@@ -927,7 +928,7 @@ namespace Google.Protobuf.WellKnownTypes {
= pb::FieldCodec.ForMessage(26, global::Google.Protobuf.WellKnownTypes.Option.Parser);
private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option> options_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option>();
/// <summary>
- /// Protocol buffer options.
+ /// Protocol buffer options.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option> Options {
@@ -938,7 +939,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int SourceContextFieldNumber = 4;
private global::Google.Protobuf.WellKnownTypes.SourceContext sourceContext_;
/// <summary>
- /// The source context.
+ /// The source context.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Google.Protobuf.WellKnownTypes.SourceContext SourceContext {
@@ -952,7 +953,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int SyntaxFieldNumber = 5;
private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = 0;
/// <summary>
- /// The source syntax.
+ /// The source syntax.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Google.Protobuf.WellKnownTypes.Syntax Syntax {
@@ -1093,7 +1094,7 @@ namespace Google.Protobuf.WellKnownTypes {
}
/// <summary>
- /// Enum value definition.
+ /// Enum value definition.
/// </summary>
public sealed partial class EnumValue : pb::IMessage<EnumValue> {
private static readonly pb::MessageParser<EnumValue> _parser = new pb::MessageParser<EnumValue>(() => new EnumValue());
@@ -1133,7 +1134,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int NameFieldNumber = 1;
private string name_ = "";
/// <summary>
- /// Enum value name.
+ /// Enum value name.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Name {
@@ -1147,7 +1148,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int NumberFieldNumber = 2;
private int number_;
/// <summary>
- /// Enum value number.
+ /// Enum value number.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int Number {
@@ -1163,7 +1164,7 @@ namespace Google.Protobuf.WellKnownTypes {
= pb::FieldCodec.ForMessage(26, global::Google.Protobuf.WellKnownTypes.Option.Parser);
private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option> options_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option>();
/// <summary>
- /// Protocol buffer options.
+ /// Protocol buffer options.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Option> Options {
@@ -1270,8 +1271,8 @@ namespace Google.Protobuf.WellKnownTypes {
}
/// <summary>
- /// A protocol buffer option, which can be attached to a message, field,
- /// enumeration, etc.
+ /// A protocol buffer option, which can be attached to a message, field,
+ /// enumeration, etc.
/// </summary>
public sealed partial class Option : pb::IMessage<Option> {
private static readonly pb::MessageParser<Option> _parser = new pb::MessageParser<Option>(() => new Option());
@@ -1310,7 +1311,10 @@ namespace Google.Protobuf.WellKnownTypes {
public const int NameFieldNumber = 1;
private string name_ = "";
/// <summary>
- /// The option's name. For example, `"java_package"`.
+ /// The option's name. For protobuf built-in options (options defined in
+ /// descriptor.proto), this is the short name. For example, `"map_entry"`.
+ /// For custom options, it should be the fully-qualified name. For example,
+ /// `"google.api.http"`.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Name {
@@ -1324,7 +1328,10 @@ namespace Google.Protobuf.WellKnownTypes {
public const int ValueFieldNumber = 2;
private global::Google.Protobuf.WellKnownTypes.Any value_;
/// <summary>
- /// The option's value. For example, `"com.google.protobuf"`.
+ /// The option's value packed in an Any message. If the value is a primitive,
+ /// the corresponding wrapper type defined in google/protobuf/wrappers.proto
+ /// should be used. If the value is an enum, it should be stored as an int32
+ /// value using the google.protobuf.Int32Value type.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Google.Protobuf.WellKnownTypes.Any Value {
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs
index e97c3d14..9a5fb81e 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs
@@ -51,9 +51,9 @@ namespace Google.Protobuf.WellKnownTypes {
}
#region Messages
/// <summary>
- /// Wrapper message for `double`.
+ /// Wrapper message for `double`.
///
- /// The JSON representation for `DoubleValue` is JSON number.
+ /// The JSON representation for `DoubleValue` is JSON number.
/// </summary>
public sealed partial class DoubleValue : pb::IMessage<DoubleValue> {
private static readonly pb::MessageParser<DoubleValue> _parser = new pb::MessageParser<DoubleValue>(() => new DoubleValue());
@@ -91,7 +91,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int ValueFieldNumber = 1;
private double value_;
/// <summary>
- /// The double value.
+ /// The double value.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public double Value {
@@ -176,9 +176,9 @@ namespace Google.Protobuf.WellKnownTypes {
}
/// <summary>
- /// Wrapper message for `float`.
+ /// Wrapper message for `float`.
///
- /// The JSON representation for `FloatValue` is JSON number.
+ /// The JSON representation for `FloatValue` is JSON number.
/// </summary>
public sealed partial class FloatValue : pb::IMessage<FloatValue> {
private static readonly pb::MessageParser<FloatValue> _parser = new pb::MessageParser<FloatValue>(() => new FloatValue());
@@ -216,7 +216,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int ValueFieldNumber = 1;
private float value_;
/// <summary>
- /// The float value.
+ /// The float value.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public float Value {
@@ -301,9 +301,9 @@ namespace Google.Protobuf.WellKnownTypes {
}
/// <summary>
- /// Wrapper message for `int64`.
+ /// Wrapper message for `int64`.
///
- /// The JSON representation for `Int64Value` is JSON string.
+ /// The JSON representation for `Int64Value` is JSON string.
/// </summary>
public sealed partial class Int64Value : pb::IMessage<Int64Value> {
private static readonly pb::MessageParser<Int64Value> _parser = new pb::MessageParser<Int64Value>(() => new Int64Value());
@@ -341,7 +341,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int ValueFieldNumber = 1;
private long value_;
/// <summary>
- /// The int64 value.
+ /// The int64 value.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public long Value {
@@ -426,9 +426,9 @@ namespace Google.Protobuf.WellKnownTypes {
}
/// <summary>
- /// Wrapper message for `uint64`.
+ /// Wrapper message for `uint64`.
///
- /// The JSON representation for `UInt64Value` is JSON string.
+ /// The JSON representation for `UInt64Value` is JSON string.
/// </summary>
public sealed partial class UInt64Value : pb::IMessage<UInt64Value> {
private static readonly pb::MessageParser<UInt64Value> _parser = new pb::MessageParser<UInt64Value>(() => new UInt64Value());
@@ -466,7 +466,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int ValueFieldNumber = 1;
private ulong value_;
/// <summary>
- /// The uint64 value.
+ /// The uint64 value.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public ulong Value {
@@ -551,9 +551,9 @@ namespace Google.Protobuf.WellKnownTypes {
}
/// <summary>
- /// Wrapper message for `int32`.
+ /// Wrapper message for `int32`.
///
- /// The JSON representation for `Int32Value` is JSON number.
+ /// The JSON representation for `Int32Value` is JSON number.
/// </summary>
public sealed partial class Int32Value : pb::IMessage<Int32Value> {
private static readonly pb::MessageParser<Int32Value> _parser = new pb::MessageParser<Int32Value>(() => new Int32Value());
@@ -591,7 +591,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int ValueFieldNumber = 1;
private int value_;
/// <summary>
- /// The int32 value.
+ /// The int32 value.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int Value {
@@ -676,9 +676,9 @@ namespace Google.Protobuf.WellKnownTypes {
}
/// <summary>
- /// Wrapper message for `uint32`.
+ /// Wrapper message for `uint32`.
///
- /// The JSON representation for `UInt32Value` is JSON number.
+ /// The JSON representation for `UInt32Value` is JSON number.
/// </summary>
public sealed partial class UInt32Value : pb::IMessage<UInt32Value> {
private static readonly pb::MessageParser<UInt32Value> _parser = new pb::MessageParser<UInt32Value>(() => new UInt32Value());
@@ -716,7 +716,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int ValueFieldNumber = 1;
private uint value_;
/// <summary>
- /// The uint32 value.
+ /// The uint32 value.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public uint Value {
@@ -801,9 +801,9 @@ namespace Google.Protobuf.WellKnownTypes {
}
/// <summary>
- /// Wrapper message for `bool`.
+ /// Wrapper message for `bool`.
///
- /// The JSON representation for `BoolValue` is JSON `true` and `false`.
+ /// The JSON representation for `BoolValue` is JSON `true` and `false`.
/// </summary>
public sealed partial class BoolValue : pb::IMessage<BoolValue> {
private static readonly pb::MessageParser<BoolValue> _parser = new pb::MessageParser<BoolValue>(() => new BoolValue());
@@ -841,7 +841,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int ValueFieldNumber = 1;
private bool value_;
/// <summary>
- /// The bool value.
+ /// The bool value.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Value {
@@ -926,9 +926,9 @@ namespace Google.Protobuf.WellKnownTypes {
}
/// <summary>
- /// Wrapper message for `string`.
+ /// Wrapper message for `string`.
///
- /// The JSON representation for `StringValue` is JSON string.
+ /// The JSON representation for `StringValue` is JSON string.
/// </summary>
public sealed partial class StringValue : pb::IMessage<StringValue> {
private static readonly pb::MessageParser<StringValue> _parser = new pb::MessageParser<StringValue>(() => new StringValue());
@@ -966,7 +966,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int ValueFieldNumber = 1;
private string value_ = "";
/// <summary>
- /// The string value.
+ /// The string value.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Value {
@@ -1051,9 +1051,9 @@ namespace Google.Protobuf.WellKnownTypes {
}
/// <summary>
- /// Wrapper message for `bytes`.
+ /// Wrapper message for `bytes`.
///
- /// The JSON representation for `BytesValue` is JSON string.
+ /// The JSON representation for `BytesValue` is JSON string.
/// </summary>
public sealed partial class BytesValue : pb::IMessage<BytesValue> {
private static readonly pb::MessageParser<BytesValue> _parser = new pb::MessageParser<BytesValue>(() => new BytesValue());
@@ -1091,7 +1091,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int ValueFieldNumber = 1;
private pb::ByteString value_ = pb::ByteString.Empty;
/// <summary>
- /// The bytes value.
+ /// The bytes value.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pb::ByteString Value {
diff --git a/csharp/src/Google.Protobuf/project.json b/csharp/src/Google.Protobuf/project.json
index 12e86248..961e037e 100644
--- a/csharp/src/Google.Protobuf/project.json
+++ b/csharp/src/Google.Protobuf/project.json
@@ -1,5 +1,5 @@
{
- "version": "3.1.0",
+ "version": "3.2.0",
"title": "Google Protocol Buffers",
"description": "See project site for more info.",
"authors": [ "Google Inc." ],
diff --git a/csharp/src/global.json b/csharp/src/global.json
new file mode 100644
index 00000000..9d5558b1
--- /dev/null
+++ b/csharp/src/global.json
@@ -0,0 +1,5 @@
+{
+ "sdk": {
+ "version": "1.0.0-preview2-003131"
+ }
+}
diff --git a/docs/third_party.md b/docs/third_party.md
index 161bc3ca..98ac66fc 100644
--- a/docs/third_party.md
+++ b/docs/third_party.md
@@ -32,6 +32,7 @@ These are projects we know about implementing Protocol Buffers for other program
* Delphi: http://sourceforge.net/projects/protobuf-delphi/
* Delphi: http://fundementals.sourceforge.net/dl.html
* Elixir: https://github.com/jeremyong/exprotoc
+* Elm: https://github.com/tiziano88/elm-protobuf
* Erlang: http://github.com/ngerakines/erlang_protobuffs/tree/master
* Erlang: http://piqi.org/
* Erlang: https://code.google.com/p/protoc-gen-erl/
@@ -120,6 +121,10 @@ GRPC (http://www.grpc.io/) is Google's RPC implementation for Protocol Buffers.
There are miscellaneous other things you may find useful as a Protocol Buffers developer.
+* [Bazel Build](https://bazel.build)
+ * [rules_closure](https://github.com/bazelbuild/rules_closure) `js-closure`
+ * [rules_go](https://github.com/bazelbuild/rules_go) `go`
+ * [rules_protobuf](https://github.com/pubref/rules_protobuf) `java` `c++` `c#` `go` `js-closure` `js-node` `python` `ruby`
* [NetBeans IDE plugin](http://code.google.com/p/protobuf-netbeans-plugin/)
* [Wireshark/Ethereal packet sniffer plugin](http://code.google.com/p/protobuf-wireshark/)
* [Alternate encodings (JSON, XML, HTML) for Java protobufs](http://code.google.com/p/protobuf-java-format/)
@@ -130,8 +135,8 @@ There are miscellaneous other things you may find useful as a Protocol Buffers d
* [Oracle PL SQL plugin](http://code.google.com/p/protocol-buffer-plsql/)
* [Eclipse editor for protobuf (from Google)](http://code.google.com/p/protobuf-dt/)
* [C++ Builder compatible protobuf](https://github.com/saadware/protobuf-cppbuilder)
-* Maven Protocol Compiler Plugin
- * https://github.com/sergei-ivanov/maven-protoc-plugin/
+* Maven Protobuf Compiler Plugin
+ * By xolstice.org ([Documentation](https://www.xolstice.org/protobuf-maven-plugin/)) ([Source](https://github.com/xolstice/protobuf-maven-plugin/)) [![Maven Central](https://img.shields.io/maven-central/v/org.xolstice.maven.plugins/protobuf-maven-plugin.svg)](https://repo1.maven.org/maven2/org/xolstice/maven/plugins/protobuf-maven-plugin/)
* http://igor-petruk.github.com/protobuf-maven-plugin/
* http://code.google.com/p/maven-protoc-plugin/
* https://github.com/os72/protoc-jar-maven-plugin
diff --git a/generate_changelog.py b/generate_changelog.py
index d7575d46..d90a9b70 100755
--- a/generate_changelog.py
+++ b/generate_changelog.py
@@ -57,6 +57,7 @@ previous = sys.argv[1]
for language in languages:
print(language.name)
+ sys.stdout.flush()
os.system(("git log --pretty=oneline --abbrev-commit %s...HEAD %s | " +
"sed -e 's/^/ - /'") % (previous, " ".join(language.pathspec)))
print("")
diff --git a/java/core/pom.xml b/java/core/pom.xml
index cced344e..14a4bf6c 100644
--- a/java/core/pom.xml
+++ b/java/core/pom.xml
@@ -6,7 +6,7 @@
<parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
- <version>3.1.0</version>
+ <version>3.2.0</version>
</parent>
<artifactId>protobuf-java</artifactId>
diff --git a/java/core/src/main/java/com/google/protobuf/AbstractMessageLite.java b/java/core/src/main/java/com/google/protobuf/AbstractMessageLite.java
index 046030f3..4f691dfd 100644
--- a/java/core/src/main/java/com/google/protobuf/AbstractMessageLite.java
+++ b/java/core/src/main/java/com/google/protobuf/AbstractMessageLite.java
@@ -48,7 +48,6 @@ public abstract class AbstractMessageLite<
BuilderType extends AbstractMessageLite.Builder<MessageType, BuilderType>>
implements MessageLite {
protected int memoizedHashCode = 0;
-
@Override
public ByteString toByteString() {
try {
diff --git a/java/core/src/main/java/com/google/protobuf/AbstractParser.java b/java/core/src/main/java/com/google/protobuf/AbstractParser.java
index 66b0ee3b..7ff73ba4 100644
--- a/java/core/src/main/java/com/google/protobuf/AbstractParser.java
+++ b/java/core/src/main/java/com/google/protobuf/AbstractParser.java
@@ -232,7 +232,7 @@ public abstract class AbstractParser<MessageType extends MessageLite>
}
size = CodedInputStream.readRawVarint32(firstByte, input);
} catch (IOException e) {
- throw new InvalidProtocolBufferException(e.getMessage());
+ throw new InvalidProtocolBufferException(e);
}
InputStream limitedInput = new LimitedInputStream(input, size);
return parsePartialFrom(limitedInput, extensionRegistry);
diff --git a/java/core/src/main/java/com/google/protobuf/ByteString.java b/java/core/src/main/java/com/google/protobuf/ByteString.java
index 5b24976d..99a31209 100644
--- a/java/core/src/main/java/com/google/protobuf/ByteString.java
+++ b/java/core/src/main/java/com/google/protobuf/ByteString.java
@@ -51,14 +51,12 @@ import java.util.List;
import java.util.NoSuchElementException;
/**
- * Immutable sequence of bytes. Substring is supported by sharing the reference
- * to the immutable underlying bytes. Concatenation is likewise supported
- * without copying (long strings) by building a tree of pieces in
- * {@link RopeByteString}.
- * <p>
- * Like {@link String}, the contents of a {@link ByteString} can never be
- * observed to change, not even in the presence of a data race or incorrect
- * API usage in the client code.
+ * Immutable sequence of bytes. Substring is supported by sharing the reference to the immutable
+ * underlying bytes. Concatenation is likewise supported without copying (long strings) by building
+ * a tree of pieces in {@link RopeByteString}.
+ *
+ * <p>Like {@link String}, the contents of a {@link ByteString} can never be observed to change, not
+ * even in the presence of a data race or incorrect API usage in the client code.
*
* @author crazybob@google.com Bob Lee
* @author kenton@google.com Kenton Varda
@@ -565,7 +563,9 @@ public abstract class ByteString implements Iterable<Byte>, Serializable {
// Create a balanced concatenation of the next "length" elements from the
// iterable.
private static ByteString balancedConcat(Iterator<ByteString> iterator, int length) {
- assert length >= 1;
+ if (length < 1) {
+ throw new IllegalArgumentException(String.format("length (%s) must be >= 1", length));
+ }
ByteString result;
if (length == 1) {
result = iterator.next();
diff --git a/java/core/src/main/java/com/google/protobuf/CodedInputStream.java b/java/core/src/main/java/com/google/protobuf/CodedInputStream.java
index e461fa28..14169dc4 100644
--- a/java/core/src/main/java/com/google/protobuf/CodedInputStream.java
+++ b/java/core/src/main/java/com/google/protobuf/CodedInputStream.java
@@ -60,7 +60,8 @@ import java.util.List;
public abstract class CodedInputStream {
private static final int DEFAULT_BUFFER_SIZE = 4096;
private static final int DEFAULT_RECURSION_LIMIT = 100;
- private static final int DEFAULT_SIZE_LIMIT = 64 << 20; // 64MB
+ // Integer.MAX_VALUE == 0x7FFFFFF == INT_MAX from limits.h
+ private static final int DEFAULT_SIZE_LIMIT = Integer.MAX_VALUE;
/** Visible for subclasses. See setRecursionLimit() */
int recursionDepth;
@@ -2762,9 +2763,9 @@ public abstract class CodedInputStream {
throw InvalidProtocolBufferException.negativeSize();
}
- // Verify that the message size so far has not exceeded sizeLimit.
+ // Integer-overflow-conscious check that the message size so far has not exceeded sizeLimit.
int currentMessageSize = totalBytesRetired + pos + size;
- if (currentMessageSize > sizeLimit) {
+ if (currentMessageSize - sizeLimit > 0) {
throw InvalidProtocolBufferException.sizeLimitExceeded();
}
diff --git a/java/core/src/main/java/com/google/protobuf/Descriptors.java b/java/core/src/main/java/com/google/protobuf/Descriptors.java
index cab7118a..38346f15 100644
--- a/java/core/src/main/java/com/google/protobuf/Descriptors.java
+++ b/java/core/src/main/java/com/google/protobuf/Descriptors.java
@@ -2123,7 +2123,7 @@ public final class Descriptors {
// Can't happen, because addPackage() only fails when the name
// conflicts with a non-package, but we have not yet added any
// non-packages at this point.
- assert false;
+ throw new AssertionError(e);
}
}
}
diff --git a/java/core/src/main/java/com/google/protobuf/DynamicMessage.java b/java/core/src/main/java/com/google/protobuf/DynamicMessage.java
index c54da67f..e6358c3b 100644
--- a/java/core/src/main/java/com/google/protobuf/DynamicMessage.java
+++ b/java/core/src/main/java/com/google/protobuf/DynamicMessage.java
@@ -297,7 +297,7 @@ public final class DynamicMessage extends AbstractMessage {
} catch (InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(builder.buildPartial());
} catch (IOException e) {
- throw new InvalidProtocolBufferException(e.getMessage())
+ throw new InvalidProtocolBufferException(e)
.setUnfinishedMessage(builder.buildPartial());
}
return builder.buildPartial();
diff --git a/java/core/src/main/java/com/google/protobuf/ExtensionRegistry.java b/java/core/src/main/java/com/google/protobuf/ExtensionRegistry.java
index 1c2e7e6f..a22a74a0 100644
--- a/java/core/src/main/java/com/google/protobuf/ExtensionRegistry.java
+++ b/java/core/src/main/java/com/google/protobuf/ExtensionRegistry.java
@@ -32,7 +32,6 @@ package com.google.protobuf;
import com.google.protobuf.Descriptors.Descriptor;
import com.google.protobuf.Descriptors.FieldDescriptor;
-
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
diff --git a/java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java b/java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java
index 5e4d7739..f3d48d3a 100644
--- a/java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java
+++ b/java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java
@@ -105,9 +105,9 @@ public class ExtensionRegistryLite {
/**
* Construct a new, empty instance.
- *
- * <p>
- * This may be an {@code ExtensionRegistry} if the full (non-Lite) proto libraries are available.
+ *
+ * <p>This may be an {@code ExtensionRegistry} if the full (non-Lite) proto libraries are
+ * available.
*/
public static ExtensionRegistryLite newInstance() {
return ExtensionRegistryFactory.create();
@@ -121,6 +121,7 @@ public class ExtensionRegistryLite {
return ExtensionRegistryFactory.createEmpty();
}
+
/** Returns an unmodifiable view of the registry. */
public ExtensionRegistryLite getUnmodifiable() {
return new ExtensionRegistryLite(this);
diff --git a/java/core/src/main/java/com/google/protobuf/FieldSet.java b/java/core/src/main/java/com/google/protobuf/FieldSet.java
index 5b251743..a828f30e 100644
--- a/java/core/src/main/java/com/google/protobuf/FieldSet.java
+++ b/java/core/src/main/java/com/google/protobuf/FieldSet.java
@@ -220,6 +220,7 @@ final class FieldSet<FieldDescriptorType extends
return fields.entrySet().iterator();
}
+
/**
* Useful for implementing
* {@link Message#hasField(Descriptors.FieldDescriptor)}.
diff --git a/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java b/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java
index 214971b1..f885b01e 100644
--- a/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java
+++ b/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java
@@ -39,7 +39,6 @@ import com.google.protobuf.Internal.IntList;
import com.google.protobuf.Internal.LongList;
import com.google.protobuf.Internal.ProtobufList;
import com.google.protobuf.WireFormat.FieldType;
-
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectStreamException;
@@ -479,7 +478,6 @@ public abstract class GeneratedMessageLite<
CodedInputStream input,
ExtensionRegistryLite extensionRegistry,
int tag) throws IOException {
- int wireType = WireFormat.getTagWireType(tag);
int fieldNumber = WireFormat.getTagFieldNumber(tag);
// TODO(dweis): How much bytecode would be saved by not requiring the generated code to
@@ -487,6 +485,17 @@ public abstract class GeneratedMessageLite<
GeneratedExtension<MessageType, ?> extension = extensionRegistry.findLiteExtensionByNumber(
defaultInstance, fieldNumber);
+ return parseExtension(input, extensionRegistry, extension, tag, fieldNumber);
+ }
+
+ private boolean parseExtension(
+ CodedInputStream input,
+ ExtensionRegistryLite extensionRegistry,
+ GeneratedExtension<?, ?> extension,
+ int tag,
+ int fieldNumber)
+ throws IOException {
+ int wireType = WireFormat.getTagWireType(tag);
boolean unknown = false;
boolean packed = false;
if (extension == null) {
@@ -508,7 +517,7 @@ public abstract class GeneratedMessageLite<
if (unknown) { // Unknown field or wrong wire type. Skip.
return parseUnknownField(tag, input);
}
-
+
if (packed) {
int length = input.readRawVarint32();
int limit = input.pushLimit(length);
@@ -587,9 +596,147 @@ public abstract class GeneratedMessageLite<
extension.singularToFieldSetType(value));
}
}
-
return true;
}
+
+ /**
+ * Parse an unknown field or an extension. For use by generated code only.
+ *
+ * <p>For use by generated code only.
+ *
+ * @return {@code true} unless the tag is an end-group tag.
+ */
+ protected <MessageType extends MessageLite> boolean parseUnknownFieldAsMessageSet(
+ MessageType defaultInstance,
+ CodedInputStream input,
+ ExtensionRegistryLite extensionRegistry,
+ int tag)
+ throws IOException {
+
+ if (tag == WireFormat.MESSAGE_SET_ITEM_TAG) {
+ mergeMessageSetExtensionFromCodedStream(defaultInstance, input, extensionRegistry);
+ return true;
+ }
+
+ // TODO(dweis): Do we really want to support non message set wire format in message sets?
+ // Full runtime does... So we do for now.
+ int wireType = WireFormat.getTagWireType(tag);
+ if (wireType == WireFormat.WIRETYPE_LENGTH_DELIMITED) {
+ return parseUnknownField(defaultInstance, input, extensionRegistry, tag);
+ } else {
+ // TODO(dweis): Should we throw on invalid input? Full runtime does not...
+ return input.skipField(tag);
+ }
+ }
+
+ /**
+ * Merges the message set from the input stream; requires message set wire format.
+ *
+ * @param defaultInstance the default instance of the containing message we are parsing in
+ * @param input the stream to parse from
+ * @param extensionRegistry the registry to use when parsing
+ */
+ private <MessageType extends MessageLite> void mergeMessageSetExtensionFromCodedStream(
+ MessageType defaultInstance,
+ CodedInputStream input,
+ ExtensionRegistryLite extensionRegistry)
+ throws IOException {
+ // The wire format for MessageSet is:
+ // message MessageSet {
+ // repeated group Item = 1 {
+ // required int32 typeId = 2;
+ // required bytes message = 3;
+ // }
+ // }
+ // "typeId" is the extension's field number. The extension can only be
+ // a message type, where "message" contains the encoded bytes of that
+ // message.
+ //
+ // In practice, we will probably never see a MessageSet item in which
+ // the message appears before the type ID, or where either field does not
+ // appear exactly once. However, in theory such cases are valid, so we
+ // should be prepared to accept them.
+
+ int typeId = 0;
+ ByteString rawBytes = null; // If we encounter "message" before "typeId"
+ GeneratedExtension<?, ?> extension = null;
+
+ // Read bytes from input, if we get it's type first then parse it eagerly,
+ // otherwise we store the raw bytes in a local variable.
+ while (true) {
+ final int tag = input.readTag();
+ if (tag == 0) {
+ break;
+ }
+
+ if (tag == WireFormat.MESSAGE_SET_TYPE_ID_TAG) {
+ typeId = input.readUInt32();
+ if (typeId != 0) {
+ extension = extensionRegistry.findLiteExtensionByNumber(defaultInstance, typeId);
+ }
+
+ } else if (tag == WireFormat.MESSAGE_SET_MESSAGE_TAG) {
+ if (typeId != 0) {
+ if (extension != null) {
+ // We already know the type, so we can parse directly from the
+ // input with no copying. Hooray!
+ eagerlyMergeMessageSetExtension(input, extension, extensionRegistry, typeId);
+ rawBytes = null;
+ continue;
+ }
+ }
+ // We haven't seen a type ID yet or we want parse message lazily.
+ rawBytes = input.readBytes();
+
+ } else { // Unknown tag. Skip it.
+ if (!input.skipField(tag)) {
+ break; // End of group
+ }
+ }
+ }
+ input.checkLastTagWas(WireFormat.MESSAGE_SET_ITEM_END_TAG);
+
+ // Process the raw bytes.
+ if (rawBytes != null && typeId != 0) { // Zero is not a valid type ID.
+ if (extension != null) { // We known the type
+ mergeMessageSetExtensionFromBytes(rawBytes, extensionRegistry, extension);
+ } else { // We don't know how to parse this. Ignore it.
+ if (rawBytes != null) {
+ mergeLengthDelimitedField(typeId, rawBytes);
+ }
+ }
+ }
+ }
+
+ private void eagerlyMergeMessageSetExtension(
+ CodedInputStream input,
+ GeneratedExtension<?, ?> extension,
+ ExtensionRegistryLite extensionRegistry,
+ int typeId)
+ throws IOException {
+ int fieldNumber = typeId;
+ int tag = WireFormat.makeTag(typeId, WireFormat.WIRETYPE_LENGTH_DELIMITED);
+ parseExtension(input, extensionRegistry, extension, tag, fieldNumber);
+ }
+
+ private void mergeMessageSetExtensionFromBytes(
+ ByteString rawBytes,
+ ExtensionRegistryLite extensionRegistry,
+ GeneratedExtension<?, ?> extension)
+ throws IOException {
+ MessageLite.Builder subBuilder = null;
+ MessageLite existingValue = (MessageLite) extensions.getField(extension.descriptor);
+ if (existingValue != null) {
+ subBuilder = existingValue.toBuilder();
+ }
+ if (subBuilder == null) {
+ subBuilder = extension.getMessageDefaultInstance().newBuilderForType();
+ }
+ rawBytes.newCodedInput().readMessage(subBuilder, extensionRegistry);
+ MessageLite value = subBuilder.build();
+
+ extensions.setField(extension.descriptor, extension.singularToFieldSetType(value));
+ }
private void verifyExtensionContainingType(
final GeneratedExtension<MessageType, ?> extension) {
@@ -807,14 +954,6 @@ public abstract class GeneratedMessageLite<
return instance.getExtension(extension, index);
}
- // This is implemented here only to work around an apparent bug in the
- // Java compiler and/or build system. See bug #1898463. The mere presence
- // of this dummy clone() implementation makes it go away.
- @Override
- public BuilderType clone() {
- return super.clone();
- }
-
/** Set the value of an extension. */
public final <Type> BuilderType setExtension(
final ExtensionLite<MessageType, Type> extension,
diff --git a/java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java b/java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java
index 4cbbd296..2a5d8b50 100644
--- a/java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java
+++ b/java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java
@@ -36,6 +36,16 @@ import com.google.protobuf.Descriptors.EnumValueDescriptor;
import com.google.protobuf.Descriptors.FieldDescriptor;
import com.google.protobuf.Descriptors.FileDescriptor;
import com.google.protobuf.Descriptors.OneofDescriptor;
+// In opensource protobuf, we have versioned this GeneratedMessageV3 class to GeneratedMessageV3V3 and
+// in the future may have GeneratedMessageV3V4 etc. This allows us to change some aspects of this
+// class without breaking binary compatibility with old generated code that still subclasses
+// the old GeneratedMessageV3 class. To allow these different GeneratedMessageV3V? classes to
+// interoperate (e.g., a GeneratedMessageV3V3 object has a message extension field whose class
+// type is GeneratedMessageV3V4), these classes still share a common parent class AbstarctMessage
+// and are using the same GeneratedMessage.GeneratedExtension class for extension definitions.
+// Since this class becomes GeneratedMessageV3V? in opensource, we have to add an import here
+// to be able to use GeneratedMessage.GeneratedExtension. The GeneratedExtension definition in
+// this file is also excluded from opensource to avoid conflict.
import com.google.protobuf.GeneratedMessage.GeneratedExtension;
import java.io.IOException;
@@ -1207,14 +1217,6 @@ public abstract class GeneratedMessageV3 extends AbstractMessage
return super.clear();
}
- // This is implemented here only to work around an apparent bug in the
- // Java compiler and/or build system. See bug #1898463. The mere presence
- // of this clone() implementation makes it go away.
- @Override
- public BuilderType clone() {
- return super.clone();
- }
-
private void ensureExtensionsIsMutable() {
if (extensions.isImmutable()) {
extensions = extensions.clone();
@@ -1610,6 +1612,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage
FieldDescriptor getDescriptor();
}
+
// =================================================================
/** Calls Class.getMethod and throws a RuntimeException if it fails. */
@@ -1705,11 +1708,6 @@ public abstract class GeneratedMessageV3 extends AbstractMessage
initialized = false;
}
- private boolean isMapFieldEnabled(FieldDescriptor field) {
- boolean result = true;
- return result;
- }
-
/**
* Ensures the field accessors are initialized. This method is thread-safe.
*
@@ -1733,7 +1731,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage
}
if (field.isRepeated()) {
if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
- if (field.isMapField() && isMapFieldEnabled(field)) {
+ if (field.isMapField()) {
fields[i] = new MapFieldAccessor(
field, camelCaseNames[i], messageClass, builderClass);
} else {
diff --git a/java/core/src/main/java/com/google/protobuf/LazyFieldLite.java b/java/core/src/main/java/com/google/protobuf/LazyFieldLite.java
index 2febaace..4b0ba0fd 100644
--- a/java/core/src/main/java/com/google/protobuf/LazyFieldLite.java
+++ b/java/core/src/main/java/com/google/protobuf/LazyFieldLite.java
@@ -284,29 +284,8 @@ public class LazyFieldLite {
return;
}
- // At this point we have two fully parsed messages. We can't merge directly from one to the
- // other because only generated builder code contains methods to mergeFrom another parsed
- // message. We have to serialize one instance and then merge the bytes into the other. This may
- // drop extensions from one of the messages if one of the values had an extension set on it
- // directly.
- //
- // To mitigate this we prefer serializing a message that has an extension registry, and
- // therefore a chance that all extensions set on it are in that registry.
- //
- // NOTE: The check for other.extensionRegistry not being null must come first because at this
- // point in time if other.extensionRegistry is not null then this.extensionRegistry will not be
- // null either.
- if (other.extensionRegistry != null) {
- setValue(mergeValueAndBytes(this.value, other.toByteString(), other.extensionRegistry));
- return;
- } else if (this.extensionRegistry != null) {
- setValue(mergeValueAndBytes(other.value, this.toByteString(), this.extensionRegistry));
- return;
- } else {
- // All extensions from the other message will be dropped because we have no registry.
- setValue(mergeValueAndBytes(this.value, other.toByteString(), EMPTY_REGISTRY));
- return;
- }
+ // At this point we have two fully parsed messages.
+ setValue(this.value.toBuilder().mergeFrom(other.value).build());
}
/**
diff --git a/java/core/src/main/java/com/google/protobuf/MapEntry.java b/java/core/src/main/java/com/google/protobuf/MapEntry.java
index 4f0351f4..179c3348 100644
--- a/java/core/src/main/java/com/google/protobuf/MapEntry.java
+++ b/java/core/src/main/java/com/google/protobuf/MapEntry.java
@@ -109,7 +109,7 @@ public final class MapEntry<K, V> extends AbstractMessage {
} catch (InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(this);
} catch (IOException e) {
- throw new InvalidProtocolBufferException(e.getMessage()).setUnfinishedMessage(this);
+ throw new InvalidProtocolBufferException(e).setUnfinishedMessage(this);
}
}
diff --git a/java/core/src/main/java/com/google/protobuf/MapFieldLite.java b/java/core/src/main/java/com/google/protobuf/MapFieldLite.java
index 3c0ad89a..42640279 100644
--- a/java/core/src/main/java/com/google/protobuf/MapFieldLite.java
+++ b/java/core/src/main/java/com/google/protobuf/MapFieldLite.java
@@ -58,7 +58,7 @@ public final class MapFieldLite<K, V> extends LinkedHashMap<K, V> {
}
@SuppressWarnings({"rawtypes", "unchecked"})
- private static final MapFieldLite EMPTY_MAP_FIELD = new MapFieldLite(Collections.emptyMap());
+ private static final MapFieldLite EMPTY_MAP_FIELD = new MapFieldLite();
static {
EMPTY_MAP_FIELD.makeImmutable();
}
@@ -83,7 +83,7 @@ public final class MapFieldLite<K, V> extends LinkedHashMap<K, V> {
@Override public void clear() {
ensureMutable();
- clear();
+ super.clear();
}
@Override public V put(K key, V value) {
diff --git a/java/core/src/main/java/com/google/protobuf/MessageLiteToString.java b/java/core/src/main/java/com/google/protobuf/MessageLiteToString.java
index 43847651..23373ef4 100644
--- a/java/core/src/main/java/com/google/protobuf/MessageLiteToString.java
+++ b/java/core/src/main/java/com/google/protobuf/MessageLiteToString.java
@@ -95,7 +95,7 @@ final class MessageLiteToString {
// Try to reflectively get the value and toString() the field as if it were repeated. This
// only works if the method names have not be proguarded out or renamed.
Method listMethod = nameToNoArgMethod.get("get" + suffix);
- if (listMethod != null) {
+ if (listMethod != null && listMethod.getReturnType().equals(List.class)) {
printField(
buffer,
indent,
@@ -115,7 +115,7 @@ final class MessageLiteToString {
// Heuristic to skip bytes based accessors for string fields.
continue;
}
-
+
String camelCase = suffix.substring(0, 1).toLowerCase() + suffix.substring(1);
// Try to reflectively get the value and toString() the field as if it were optional. This
diff --git a/java/core/src/main/java/com/google/protobuf/SmallSortedMap.java b/java/core/src/main/java/com/google/protobuf/SmallSortedMap.java
index 409fec10..66033f58 100644
--- a/java/core/src/main/java/com/google/protobuf/SmallSortedMap.java
+++ b/java/core/src/main/java/com/google/protobuf/SmallSortedMap.java
@@ -197,6 +197,7 @@ class SmallSortedMap<K extends Comparable<K>, V> extends AbstractMap<K, V> {
overflowEntries.entrySet();
}
+
@Override
public int size() {
return entryList.size() + overflowEntries.size();
@@ -356,6 +357,7 @@ class SmallSortedMap<K extends Comparable<K>, V> extends AbstractMap<K, V> {
return lazyEntrySet;
}
+
/**
* @throws UnsupportedOperationException if {@link #makeImmutable()} has
* has been called.
@@ -525,6 +527,7 @@ class SmallSortedMap<K extends Comparable<K>, V> extends AbstractMap<K, V> {
}
}
+
/**
* Iterator implementation that switches from the entry array to the overflow
* entries appropriately.
@@ -617,43 +620,43 @@ class SmallSortedMap<K extends Comparable<K>, V> extends AbstractMap<K, V> {
return (Iterable<T>) ITERABLE;
}
}
-
+
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
-
+
if (!(o instanceof SmallSortedMap)) {
return super.equals(o);
}
-
+
SmallSortedMap<?, ?> other = (SmallSortedMap<?, ?>) o;
final int size = size();
if (size != other.size()) {
return false;
}
-
+
// Best effort try to avoid allocating an entry set.
final int numArrayEntries = getNumArrayEntries();
if (numArrayEntries != other.getNumArrayEntries()) {
return entrySet().equals(other.entrySet());
}
-
+
for (int i = 0; i < numArrayEntries; i++) {
if (!getArrayEntryAt(i).equals(other.getArrayEntryAt(i))) {
return false;
}
}
-
+
if (numArrayEntries != size) {
return overflowEntries.equals(other.overflowEntries);
}
-
-
+
+
return true;
}
-
+
@Override
public int hashCode() {
int h = 0;
diff --git a/java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java b/java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java
index 6d33d3a8..2bef27e9 100644
--- a/java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java
+++ b/java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java
@@ -31,7 +31,6 @@
package com.google.protobuf;
import com.google.protobuf.AbstractMessageLite.Builder.LimitedInputStream;
-
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -39,6 +38,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import java.util.ListIterator;
import java.util.Map;
import java.util.TreeMap;
@@ -58,7 +58,9 @@ import java.util.TreeMap;
*/
public final class UnknownFieldSet implements MessageLite {
- private UnknownFieldSet() {}
+ private UnknownFieldSet() {
+ fields = null;
+ }
/** Create a new {@link Builder}. */
public static Builder newBuilder() {
@@ -82,16 +84,18 @@ public final class UnknownFieldSet implements MessageLite {
return defaultInstance;
}
private static final UnknownFieldSet defaultInstance =
- new UnknownFieldSet(Collections.<Integer, Field>emptyMap());
+ new UnknownFieldSet(Collections.<Integer, Field>emptyMap(),
+ Collections.<Integer, Field>emptyMap());
/**
* Construct an {@code UnknownFieldSet} around the given map. The map is
* expected to be immutable.
*/
- private UnknownFieldSet(final Map<Integer, Field> fields) {
+ private UnknownFieldSet(final Map<Integer, Field> fields,
+ final Map<Integer, Field> fieldsDescending) {
this.fields = fields;
}
- private Map<Integer, Field> fields;
+ private final Map<Integer, Field> fields;
@Override
@@ -224,10 +228,8 @@ public final class UnknownFieldSet implements MessageLite {
}
}
- /**
- * Get the number of bytes required to encode this set using
- * {@code MessageSet} wire format.
- */
+
+ /** Get the number of bytes required to encode this set using {@code MessageSet} wire format. */
public int getSerializedSizeAsMessageSet() {
int result = 0;
for (final Map.Entry<Integer, Field> entry : fields.entrySet()) {
@@ -343,12 +345,13 @@ public final class UnknownFieldSet implements MessageLite {
*/
@Override
public UnknownFieldSet build() {
- getFieldBuilder(0); // Force lastField to be built.
+ getFieldBuilder(0); // Force lastField to be built.
final UnknownFieldSet result;
if (fields.isEmpty()) {
result = getDefaultInstance();
} else {
- result = new UnknownFieldSet(Collections.unmodifiableMap(fields));
+ Map<Integer, Field> descendingFields = null;
+ result = new UnknownFieldSet(Collections.unmodifiableMap(fields), descendingFields);
}
fields = null;
return result;
@@ -363,8 +366,9 @@ public final class UnknownFieldSet implements MessageLite {
@Override
public Builder clone() {
getFieldBuilder(0); // Force lastField to be built.
+ Map<Integer, Field> descendingFields = null;
return UnknownFieldSet.newBuilder().mergeFrom(
- new UnknownFieldSet(fields));
+ new UnknownFieldSet(fields, descendingFields));
}
@Override
@@ -841,9 +845,10 @@ public final class UnknownFieldSet implements MessageLite {
}
}
+
/**
- * Get the number of bytes required to encode this field, including field
- * number, using {@code MessageSet} wire format.
+ * Get the number of bytes required to encode this field, including field number, using {@code
+ * MessageSet} wire format.
*/
public int getSerializedSizeAsMessageSetExtension(final int fieldNumber) {
int result = 0;
@@ -1022,7 +1027,7 @@ public final class UnknownFieldSet implements MessageLite {
} catch (InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(builder.buildPartial());
} catch (IOException e) {
- throw new InvalidProtocolBufferException(e.getMessage())
+ throw new InvalidProtocolBufferException(e)
.setUnfinishedMessage(builder.buildPartial());
}
return builder.buildPartial();
diff --git a/java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java b/java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java
index 9500f905..d6226fc7 100644
--- a/java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java
+++ b/java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java
@@ -176,6 +176,42 @@ public final class UnknownFieldSetLite {
}
/**
+ * Serializes the set and writes it to {@code output} using {@code MessageSet} wire format.
+ *
+ * <p>For use by generated code only.
+ */
+ public void writeAsMessageSetTo(CodedOutputStream output) throws IOException {
+ for (int i = 0; i < count; i++) {
+ int fieldNumber = WireFormat.getTagFieldNumber(tags[i]);
+ output.writeRawMessageSetExtension(fieldNumber, (ByteString) objects[i]);
+ }
+ }
+
+
+ /**
+ * Get the number of bytes required to encode this field, including field number, using {@code
+ * MessageSet} wire format.
+ */
+ public int getSerializedSizeAsMessageSet() {
+ int size = memoizedSerializedSize;
+ if (size != -1) {
+ return size;
+ }
+
+ size = 0;
+ for (int i = 0; i < count; i++) {
+ int tag = tags[i];
+ int fieldNumber = WireFormat.getTagFieldNumber(tag);
+ size += CodedOutputStream.computeRawMessageSetExtensionSize(
+ fieldNumber, (ByteString) objects[i]);
+ }
+
+ memoizedSerializedSize = size;
+
+ return size;
+ }
+
+ /**
* Get the number of bytes required to encode this set.
*
* <p>For use by generated code only.
@@ -216,6 +252,24 @@ public final class UnknownFieldSetLite {
return size;
}
+
+ private static boolean equals(int[] tags1, int[] tags2, int count) {
+ for (int i = 0; i < count; ++i) {
+ if (tags1[i] != tags2[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private static boolean equals(Object[] objects1, Object[] objects2, int count) {
+ for (int i = 0; i < count; ++i) {
+ if (!objects1[i].equals(objects2[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
@Override
public boolean equals(Object obj) {
@@ -233,9 +287,8 @@ public final class UnknownFieldSetLite {
UnknownFieldSetLite other = (UnknownFieldSetLite) obj;
if (count != other.count
- // TODO(dweis): Only have to compare up to count but at worst 2x worse than we need to do.
- || !Arrays.equals(tags, other.tags)
- || !Arrays.deepEquals(objects, other.objects)) {
+ || !equals(tags, other.tags, count)
+ || !equals(objects, other.objects, count)) {
return false;
}
@@ -268,7 +321,8 @@ public final class UnknownFieldSetLite {
}
}
- private void storeField(int tag, Object value) {
+ // Package private for unsafe experimental runtime.
+ void storeField(int tag, Object value) {
ensureCapacity();
tags[count] = tag;
diff --git a/java/core/src/test/java/com/google/protobuf/CodedInputStreamTest.java b/java/core/src/test/java/com/google/protobuf/CodedInputStreamTest.java
index e2ab0df9..e440c7db 100644
--- a/java/core/src/test/java/com/google/protobuf/CodedInputStreamTest.java
+++ b/java/core/src/test/java/com/google/protobuf/CodedInputStreamTest.java
@@ -30,8 +30,6 @@
package com.google.protobuf;
-import static org.junit.Assert.assertArrayEquals;
-
import protobuf_unittest.UnittestProto.BoolMessage;
import protobuf_unittest.UnittestProto.Int32Message;
import protobuf_unittest.UnittestProto.Int64Message;
@@ -445,6 +443,82 @@ public class CodedInputStreamTest extends TestCase {
}
}
+ /**
+ * Test we can do messages that are up to CodedInputStream#DEFAULT_SIZE_LIMIT
+ * in size (2G or Integer#MAX_SIZE).
+ * @throws IOException
+ */
+ public void testParseMessagesCloseTo2G() throws IOException {
+ byte[] serializedMessage = getBigSerializedMessage();
+ // How many of these big messages do we need to take us near our 2G limit?
+ int count = Integer.MAX_VALUE / serializedMessage.length;
+ // Now make an inputstream that will fake a near 2G message of messages
+ // returning our big serialized message 'count' times.
+ InputStream is = new RepeatingInputStream(serializedMessage, count);
+ // Parse should succeed!
+ TestAllTypes.parseFrom(is);
+ }
+
+ /**
+ * Test there is an exception if a message exceeds
+ * CodedInputStream#DEFAULT_SIZE_LIMIT in size (2G or Integer#MAX_SIZE).
+ * @throws IOException
+ */
+ public void testParseMessagesOver2G() throws IOException {
+ byte[] serializedMessage = getBigSerializedMessage();
+ // How many of these big messages do we need to take us near our 2G limit?
+ int count = Integer.MAX_VALUE / serializedMessage.length;
+ // Now add one to take us over the limit
+ count++;
+ // Now make an inputstream that will fake a near 2G message of messages
+ // returning our big serialized message 'count' times.
+ InputStream is = new RepeatingInputStream(serializedMessage, count);
+ try {
+ TestAllTypes.parseFrom(is);
+ fail("Should have thrown an exception!");
+ } catch (InvalidProtocolBufferException e) {
+ assertTrue(e.getMessage().contains("too large"));
+ }
+ }
+
+ /*
+ * @return A serialized big message.
+ */
+ private static byte[] getBigSerializedMessage() {
+ byte[] value = new byte[16 * 1024 * 1024];
+ ByteString bsValue = ByteString.wrap(value);
+ return TestAllTypes.newBuilder().setOptionalBytes(bsValue).build().toByteArray();
+ }
+
+ /*
+ * An input stream that repeats a byte arrays' content a number of times.
+ * Simulates really large input without consuming loads of memory. Used above
+ * to test the parsing behavior when the input size exceeds 2G or close to it.
+ */
+ private static class RepeatingInputStream extends InputStream {
+ private final byte[] serializedMessage;
+ private final int count;
+ private int index = 0;
+ private int offset = 0;
+
+ RepeatingInputStream(byte[] serializedMessage, int count) {
+ this.serializedMessage = serializedMessage;
+ this.count = count;
+ }
+
+ @Override
+ public int read() throws IOException {
+ if (this.offset == this.serializedMessage.length) {
+ this.index++;
+ this.offset = 0;
+ }
+ if (this.index == this.count) {
+ return -1;
+ }
+ return this.serializedMessage[offset++];
+ }
+ }
+
private TestRecursiveMessage makeRecursiveMessage(int depth) {
if (depth == 0) {
return TestRecursiveMessage.newBuilder().setI(5).build();
diff --git a/java/core/src/test/java/com/google/protobuf/LazyFieldLiteTest.java b/java/core/src/test/java/com/google/protobuf/LazyFieldLiteTest.java
index efdfdfbe..813fe6bc 100644
--- a/java/core/src/test/java/com/google/protobuf/LazyFieldLiteTest.java
+++ b/java/core/src/test/java/com/google/protobuf/LazyFieldLiteTest.java
@@ -31,7 +31,6 @@
package com.google.protobuf;
import static protobuf_unittest.UnittestProto.optionalInt32Extension;
-import static protobuf_unittest.UnittestProto.optionalInt64Extension;
import protobuf_unittest.UnittestProto.TestAllExtensions;
import protobuf_unittest.UnittestProto.TestAllTypes;
@@ -219,29 +218,6 @@ public class LazyFieldLiteTest extends TestCase {
assertEquals(messageWithExtensions, field.getValue(TestAllExtensions.getDefaultInstance()));
}
- public void testMergeMightLoseExtensions() throws Exception {
- // Test that we don't know about the extensions when parsing.
- TestAllExtensions message1 =
- TestAllExtensions.newBuilder().setExtension(optionalInt32Extension, 1).build();
- TestAllExtensions message2 =
- TestAllExtensions.newBuilder().setExtension(optionalInt64Extension, 2L).build();
-
- LazyFieldLite field = LazyFieldLite.fromValue(message1);
- field.merge(LazyFieldLite.fromValue(message2));
-
- // We lose the extensions from message 2 because we have to serialize it and then parse it
- // again, using the empty registry this time.
- TestAllExtensions value =
- (TestAllExtensions) field.getValue(TestAllExtensions.getDefaultInstance());
- assertTrue(value.hasExtension(optionalInt32Extension));
- assertEquals(Integer.valueOf(1), value.getExtension(optionalInt32Extension));
- assertFalse(value.hasExtension(optionalInt64Extension));
-
- // The field is still there, it is just unknown.
- assertTrue(value.getUnknownFields()
- .hasField(optionalInt64Extension.getDescriptor().getNumber()));
- }
-
// Help methods.
diff --git a/java/core/src/test/java/com/google/protobuf/LazyMessageLiteTest.java b/java/core/src/test/java/com/google/protobuf/LazyMessageLiteTest.java
index c8ca9b6a..968ca206 100644
--- a/java/core/src/test/java/com/google/protobuf/LazyMessageLiteTest.java
+++ b/java/core/src/test/java/com/google/protobuf/LazyMessageLiteTest.java
@@ -101,6 +101,19 @@ public class LazyMessageLiteTest extends TestCase {
assertEquals(119, outer.getRepeatedInner(0).getNum());
assertEquals(122, outer.getRepeatedInner(1).getNum());
}
+
+ public void testRepeatedMutability() throws Exception {
+ LazyMessageLite outer = LazyMessageLite.newBuilder()
+ .addRepeatedInner(LazyInnerMessageLite.newBuilder().setNum(119))
+ .addRepeatedInner(LazyInnerMessageLite.newBuilder().setNum(122))
+ .build();
+
+ outer = LazyMessageLite.parseFrom(outer.toByteArray());
+ try {
+ outer.getRepeatedInnerList().set(1, null);
+ fail();
+ } catch (UnsupportedOperationException expected) {}
+ }
public void testAddAll() {
ArrayList<LazyInnerMessageLite> inners = new ArrayList<LazyInnerMessageLite>();
diff --git a/java/core/src/test/java/com/google/protobuf/LiteTest.java b/java/core/src/test/java/com/google/protobuf/LiteTest.java
index 254beba1..538432f7 100644
--- a/java/core/src/test/java/com/google/protobuf/LiteTest.java
+++ b/java/core/src/test/java/com/google/protobuf/LiteTest.java
@@ -45,6 +45,7 @@ import com.google.protobuf.UnittestLite.TestAllTypesLite.OneofFieldCase;
import com.google.protobuf.UnittestLite.TestAllTypesLite.OptionalGroup;
import com.google.protobuf.UnittestLite.TestAllTypesLite.RepeatedGroup;
import com.google.protobuf.UnittestLite.TestAllTypesLiteOrBuilder;
+import com.google.protobuf.UnittestLite.TestHugeFieldNumbersLite;
import com.google.protobuf.UnittestLite.TestNestedExtensionLite;
import protobuf_unittest.lite_equals_and_hash.LiteEqualsAndHash.Bar;
import protobuf_unittest.lite_equals_and_hash.LiteEqualsAndHash.BarPrime;
@@ -1424,6 +1425,12 @@ public class LiteTest extends TestCase {
assertToStringEquals("", TestAllTypesLite.getDefaultInstance());
}
+ public void testToStringScalarFieldsSuffixedWithList() throws Exception {
+ assertToStringEquals("deceptively_named_list: 7", TestAllTypesLite.newBuilder()
+ .setDeceptivelyNamedList(7)
+ .build());
+ }
+
public void testToStringPrimitives() throws Exception {
TestAllTypesLite proto = TestAllTypesLite.newBuilder()
.setOptionalInt32(1)
@@ -2235,6 +2242,25 @@ public class LiteTest extends TestCase {
assertFalse(other.equals(mine));
}
+ public void testHugeFieldNumbers() throws InvalidProtocolBufferException {
+ TestHugeFieldNumbersLite message =
+ TestHugeFieldNumbersLite.newBuilder()
+ .setOptionalInt32(1)
+ .addRepeatedInt32(2)
+ .setOptionalEnum(ForeignEnumLite.FOREIGN_LITE_FOO)
+ .setOptionalString("xyz")
+ .setOptionalMessage(ForeignMessageLite.newBuilder().setC(3).build())
+ .build();
+
+ TestHugeFieldNumbersLite parsedMessage =
+ TestHugeFieldNumbersLite.parseFrom(message.toByteArray());
+ assertEquals(1, parsedMessage.getOptionalInt32());
+ assertEquals(2, parsedMessage.getRepeatedInt32(0));
+ assertEquals(ForeignEnumLite.FOREIGN_LITE_FOO, parsedMessage.getOptionalEnum());
+ assertEquals("xyz", parsedMessage.getOptionalString());
+ assertEquals(3, parsedMessage.getOptionalMessage().getC());
+ }
+
private void assertEqualsAndHashCodeAreFalse(Object o1, Object o2) {
assertFalse(o1.equals(o2));
assertFalse(o1.hashCode() == o2.hashCode());
diff --git a/java/core/src/test/java/com/google/protobuf/MapForProto2LiteTest.java b/java/core/src/test/java/com/google/protobuf/MapForProto2LiteTest.java
index 8b64fa27..0a14f584 100644
--- a/java/core/src/test/java/com/google/protobuf/MapForProto2LiteTest.java
+++ b/java/core/src/test/java/com/google/protobuf/MapForProto2LiteTest.java
@@ -501,7 +501,6 @@ public final class MapForProto2LiteTest extends TestCase {
assertEquals(54321, messageWithUnknownEnums.getInt32ToInt32Field().get(2).intValue());
}
-
public void testIterationOrder() throws Exception {
TestMap.Builder builder = TestMap.newBuilder();
setMapValues(builder);
diff --git a/java/core/src/test/java/com/google/protobuf/MapForProto2Test.java b/java/core/src/test/java/com/google/protobuf/MapForProto2Test.java
index 76bd7bd9..cfe4c453 100644
--- a/java/core/src/test/java/com/google/protobuf/MapForProto2Test.java
+++ b/java/core/src/test/java/com/google/protobuf/MapForProto2Test.java
@@ -58,26 +58,26 @@ public class MapForProto2Test extends TestCase {
builder.getMutableInt32ToInt32Field().put(1, 11);
builder.getMutableInt32ToInt32Field().put(2, 22);
builder.getMutableInt32ToInt32Field().put(3, 33);
-
+ //
builder.getMutableInt32ToStringField().put(1, "11");
builder.getMutableInt32ToStringField().put(2, "22");
builder.getMutableInt32ToStringField().put(3, "33");
-
+ //
builder.getMutableInt32ToBytesField().put(1, TestUtil.toBytes("11"));
builder.getMutableInt32ToBytesField().put(2, TestUtil.toBytes("22"));
builder.getMutableInt32ToBytesField().put(3, TestUtil.toBytes("33"));
-
+ //
builder.getMutableInt32ToEnumField().put(1, TestMap.EnumValue.FOO);
builder.getMutableInt32ToEnumField().put(2, TestMap.EnumValue.BAR);
builder.getMutableInt32ToEnumField().put(3, TestMap.EnumValue.BAZ);
-
+ //
builder.getMutableInt32ToMessageField().put(
1, MessageValue.newBuilder().setValue(11).build());
builder.getMutableInt32ToMessageField().put(
2, MessageValue.newBuilder().setValue(22).build());
builder.getMutableInt32ToMessageField().put(
3, MessageValue.newBuilder().setValue(33).build());
-
+ //
builder.getMutableStringToInt32Field().put("1", 11);
builder.getMutableStringToInt32Field().put("2", 22);
builder.getMutableStringToInt32Field().put("3", 33);
@@ -120,6 +120,7 @@ public class MapForProto2Test extends TestCase {
setMapValuesUsingAccessors(usingAccessorsBuilder);
TestMap usingAccessors = usingAccessorsBuilder.build();
assertMapValuesSet(usingAccessors);
+
assertEquals(usingAccessors, usingMutableMap);
}
@@ -169,25 +170,25 @@ public class MapForProto2Test extends TestCase {
builder.getMutableInt32ToInt32Field().put(1, 111);
builder.getMutableInt32ToInt32Field().remove(2);
builder.getMutableInt32ToInt32Field().put(4, 44);
-
+ //
builder.getMutableInt32ToStringField().put(1, "111");
builder.getMutableInt32ToStringField().remove(2);
builder.getMutableInt32ToStringField().put(4, "44");
-
+ //
builder.getMutableInt32ToBytesField().put(1, TestUtil.toBytes("111"));
builder.getMutableInt32ToBytesField().remove(2);
builder.getMutableInt32ToBytesField().put(4, TestUtil.toBytes("44"));
-
+ //
builder.getMutableInt32ToEnumField().put(1, TestMap.EnumValue.BAR);
builder.getMutableInt32ToEnumField().remove(2);
builder.getMutableInt32ToEnumField().put(4, TestMap.EnumValue.QUX);
-
+ //
builder.getMutableInt32ToMessageField().put(
1, MessageValue.newBuilder().setValue(111).build());
builder.getMutableInt32ToMessageField().remove(2);
builder.getMutableInt32ToMessageField().put(
4, MessageValue.newBuilder().setValue(44).build());
-
+ //
builder.getMutableStringToInt32Field().put("1", 111);
builder.getMutableStringToInt32Field().remove("2");
builder.getMutableStringToInt32Field().put("4", 44);
@@ -230,8 +231,9 @@ public class MapForProto2Test extends TestCase {
setMapValuesUsingAccessors(usingAccessorsBuilder);
TestMap usingAccessors = usingAccessorsBuilder.build();
assertMapValuesSet(usingAccessors);
- assertEquals(usingAccessors, usingMutableMap);
+ assertEquals(usingAccessors, usingMutableMap);
+ //
usingMutableMapBuilder = usingMutableMap.toBuilder();
updateMapValuesUsingMutableMap(usingMutableMapBuilder);
usingMutableMap = usingMutableMapBuilder.build();
@@ -335,7 +337,7 @@ public class MapForProto2Test extends TestCase {
assertEquals(newMap(1, 2), builder.getInt32ToInt32Field());
builder.getMutableInt32ToInt32Field().put(2, 3);
assertEquals(newMap(1, 2, 2, 3), builder.getInt32ToInt32Field());
-
+ //
Map<Integer, TestMap.EnumValue> enumMap = builder.getMutableInt32ToEnumField();
enumMap.put(1, TestMap.EnumValue.BAR);
assertEquals(newMap(1, TestMap.EnumValue.BAR), builder.build().getInt32ToEnumField());
@@ -350,7 +352,7 @@ public class MapForProto2Test extends TestCase {
assertEquals(
newMap(1, TestMap.EnumValue.BAR, 2, TestMap.EnumValue.FOO),
builder.getInt32ToEnumField());
-
+ //
Map<Integer, String> stringMap = builder.getMutableInt32ToStringField();
stringMap.put(1, "1");
assertEquals(newMap(1, "1"), builder.build().getInt32ToStringField());
@@ -365,7 +367,7 @@ public class MapForProto2Test extends TestCase {
assertEquals(
newMap(1, "1", 2, "2"),
builder.getInt32ToStringField());
-
+ //
Map<Integer, TestMap.MessageValue> messageMap = builder.getMutableInt32ToMessageField();
messageMap.put(1, TestMap.MessageValue.getDefaultInstance());
assertEquals(newMap(1, TestMap.MessageValue.getDefaultInstance()),
@@ -384,7 +386,7 @@ public class MapForProto2Test extends TestCase {
2, TestMap.MessageValue.getDefaultInstance()),
builder.getInt32ToMessageField());
}
-
+ //
public void testMutableMapLifecycle_collections() {
TestMap.Builder builder = TestMap.newBuilder();
Map<Integer, Integer> intMap = builder.getMutableInt32ToInt32Field();
@@ -431,18 +433,19 @@ public class MapForProto2Test extends TestCase {
assertEquals(newMap(1, 2), builder.build().getInt32ToInt32Field());
}
+
public void testGettersAndSetters() throws Exception {
TestMap.Builder builder = TestMap.newBuilder();
TestMap message = builder.build();
assertMapValuesCleared(message);
builder = message.toBuilder();
- setMapValuesUsingMutableMap(builder);
+ setMapValuesUsingAccessors(builder);
message = builder.build();
assertMapValuesSet(message);
builder = message.toBuilder();
- updateMapValuesUsingMutableMap(builder);
+ updateMapValuesUsingAccessors(builder);
message = builder.build();
assertMapValuesUpdated(message);
@@ -455,7 +458,7 @@ public class MapForProto2Test extends TestCase {
public void testPutAll() throws Exception {
TestMap.Builder sourceBuilder = TestMap.newBuilder();
- setMapValuesUsingMutableMap(sourceBuilder);
+ setMapValuesUsingAccessors(sourceBuilder);
TestMap source = sourceBuilder.build();
assertMapValuesSet(source);
@@ -507,14 +510,14 @@ public class MapForProto2Test extends TestCase {
public void testSerializeAndParse() throws Exception {
TestMap.Builder builder = TestMap.newBuilder();
- setMapValuesUsingMutableMap(builder);
+ setMapValuesUsingAccessors(builder);
TestMap message = builder.build();
assertEquals(message.getSerializedSize(), message.toByteString().size());
message = TestMap.parser().parseFrom(message.toByteString());
assertMapValuesSet(message);
builder = message.toBuilder();
- updateMapValuesUsingMutableMap(builder);
+ updateMapValuesUsingAccessors(builder);
message = builder.build();
assertEquals(message.getSerializedSize(), message.toByteString().size());
message = TestMap.parser().parseFrom(message.toByteString());
@@ -579,7 +582,7 @@ public class MapForProto2Test extends TestCase {
public void testMergeFrom() throws Exception {
TestMap.Builder builder = TestMap.newBuilder();
- setMapValuesUsingMutableMap(builder);
+ setMapValuesUsingAccessors(builder);
TestMap message = builder.build();
TestMap.Builder other = TestMap.newBuilder();
@@ -594,22 +597,22 @@ public class MapForProto2Test extends TestCase {
// We can't control the order of elements in a HashMap. The best we can do
// here is to add elements in different order.
TestMap.Builder b1 = TestMap.newBuilder();
- b1.getMutableInt32ToInt32Field().put(1, 2);
- b1.getMutableInt32ToInt32Field().put(3, 4);
- b1.getMutableInt32ToInt32Field().put(5, 6);
+ b1.putInt32ToInt32Field(1, 2);
+ b1.putInt32ToInt32Field(3, 4);
+ b1.putInt32ToInt32Field(5, 6);
TestMap m1 = b1.build();
TestMap.Builder b2 = TestMap.newBuilder();
- b2.getMutableInt32ToInt32Field().put(5, 6);
- b2.getMutableInt32ToInt32Field().put(1, 2);
- b2.getMutableInt32ToInt32Field().put(3, 4);
+ b2.putInt32ToInt32Field(5, 6);
+ b2.putInt32ToInt32Field(1, 2);
+ b2.putInt32ToInt32Field(3, 4);
TestMap m2 = b2.build();
assertEquals(m1, m2);
assertEquals(m1.hashCode(), m2.hashCode());
// Make sure we did compare map fields.
- b2.getMutableInt32ToInt32Field().put(1, 0);
+ b2.putInt32ToInt32Field(1, 0);
m2 = b2.build();
assertFalse(m1.equals(m2));
// Don't check m1.hashCode() != m2.hashCode() because it's not guaranteed
@@ -684,13 +687,11 @@ public class MapForProto2Test extends TestCase {
public void testReflectionApi() throws Exception {
// In reflection API, map fields are just repeated message fields.
- TestMap.Builder builder = TestMap.newBuilder();
- builder.getMutableInt32ToInt32Field().put(1, 2);
- builder.getMutableInt32ToInt32Field().put(3, 4);
- builder.getMutableInt32ToMessageField().put(
- 11, MessageValue.newBuilder().setValue(22).build());
- builder.getMutableInt32ToMessageField().put(
- 33, MessageValue.newBuilder().setValue(44).build());
+ TestMap.Builder builder = TestMap.newBuilder()
+ .putInt32ToInt32Field(1, 2)
+ .putInt32ToInt32Field(3, 4)
+ .putInt32ToMessageField(11, MessageValue.newBuilder().setValue(22).build())
+ .putInt32ToMessageField(33, MessageValue.newBuilder().setValue(44).build());
TestMap message = builder.build();
// Test getField(), getRepeatedFieldCount(), getRepeatedField().
@@ -760,7 +761,7 @@ public class MapForProto2Test extends TestCase {
public void testTextFormat() throws Exception {
TestMap.Builder builder = TestMap.newBuilder();
- setMapValuesUsingMutableMap(builder);
+ setMapValuesUsingAccessors(builder);
TestMap message = builder.build();
String textData = TextFormat.printToString(message);
@@ -774,7 +775,7 @@ public class MapForProto2Test extends TestCase {
public void testDynamicMessage() throws Exception {
TestMap.Builder builder = TestMap.newBuilder();
- setMapValuesUsingMutableMap(builder);
+ setMapValuesUsingAccessors(builder);
TestMap message = builder.build();
Message dynamicDefaultInstance =
@@ -819,10 +820,9 @@ public class MapForProto2Test extends TestCase {
}
public void testUnknownEnumValues() throws Exception {
- TestUnknownEnumValue.Builder builder =
- TestUnknownEnumValue.newBuilder();
- builder.getMutableInt32ToInt32Field().put(1, 1);
- builder.getMutableInt32ToInt32Field().put(2, 54321);
+ TestUnknownEnumValue.Builder builder = TestUnknownEnumValue.newBuilder()
+ .putInt32ToInt32Field(1, 1)
+ .putInt32ToInt32Field(2, 54321);
ByteString data = builder.build().toByteString();
TestMap message = TestMap.parseFrom(data);
@@ -841,26 +841,21 @@ public class MapForProto2Test extends TestCase {
assertEquals(54321, messageWithUnknownEnums.getInt32ToInt32Field().get(2).intValue());
}
-
public void testRequiredMessage() throws Exception {
TestMap.Builder builder = TestMap.newBuilder();
- builder.getMutableRequiredMessageMap().put(0,
- MessageWithRequiredFields.newBuilder().buildPartial());
+ builder.putRequiredMessageMap(0, MessageWithRequiredFields.newBuilder().buildPartial());
TestMap message = builder.buildPartial();
assertFalse(message.isInitialized());
- builder.getMutableRequiredMessageMap().put(0,
- MessageWithRequiredFields.newBuilder().setValue(1).build());
+ builder.putRequiredMessageMap(0, MessageWithRequiredFields.newBuilder().setValue(1).build());
message = builder.build();
assertTrue(message.isInitialized());
}
public void testRecursiveMap() throws Exception {
TestRecursiveMap.Builder builder = TestRecursiveMap.newBuilder();
- builder.getMutableRecursiveMapField().put(
- 1, TestRecursiveMap.newBuilder().setValue(2).build());
- builder.getMutableRecursiveMapField().put(
- 3, TestRecursiveMap.newBuilder().setValue(4).build());
+ builder.putRecursiveMapField(1, TestRecursiveMap.newBuilder().setValue(2).build());
+ builder.putRecursiveMapField(3, TestRecursiveMap.newBuilder().setValue(4).build());
ByteString data = builder.build().toByteString();
TestRecursiveMap message = TestRecursiveMap.parseFrom(data);
@@ -870,7 +865,7 @@ public class MapForProto2Test extends TestCase {
public void testIterationOrder() throws Exception {
TestMap.Builder builder = TestMap.newBuilder();
- setMapValuesUsingMutableMap(builder);
+ setMapValuesUsingAccessors(builder);
TestMap message = builder.build();
assertEquals(Arrays.asList("1", "2", "3"),
@@ -879,7 +874,7 @@ public class MapForProto2Test extends TestCase {
public void testContains() {
TestMap.Builder builder = TestMap.newBuilder();
- setMapValuesUsingMutableMap(builder);
+ setMapValuesUsingAccessors(builder);
assertMapContainsSetValues(builder);
assertMapContainsSetValues(builder.build());
}
@@ -920,7 +915,7 @@ public class MapForProto2Test extends TestCase {
TestMap.Builder builder = TestMap.newBuilder();
assertMapCounts(0, builder);
- setMapValuesUsingMutableMap(builder);
+ setMapValuesUsingAccessors(builder);
assertMapCounts(3, builder);
TestMap message = builder.build();
@@ -1091,7 +1086,7 @@ public class MapForProto2Test extends TestCase {
public void testRemove() {
TestMap.Builder builder = TestMap.newBuilder();
- setMapValuesUsingMutableMap(builder);
+ setMapValuesUsingAccessors(builder);
assertEquals(11, builder.getInt32ToInt32FieldOrThrow(1));
for (int times = 0; times < 2; times++) {
builder.removeInt32ToInt32Field(1);
@@ -1137,7 +1132,7 @@ public class MapForProto2Test extends TestCase {
map_test.Message1.Builder builder =
map_test.Message1.newBuilder();
- builder.getMutableMapField().put("key", true);
+ builder.putMapField("key", true);
map_test.Message1 message = builder.build();
Message mapEntry = (Message) message.getRepeatedField(
message.getDescriptorForType().findFieldByName("map_field"), 0);
diff --git a/java/core/src/test/java/com/google/protobuf/MapTest.java b/java/core/src/test/java/com/google/protobuf/MapTest.java
index 035a8335..81e951cc 100644
--- a/java/core/src/test/java/com/google/protobuf/MapTest.java
+++ b/java/core/src/test/java/com/google/protobuf/MapTest.java
@@ -60,26 +60,26 @@ public class MapTest extends TestCase {
builder.getMutableInt32ToInt32Field().put(1, 11);
builder.getMutableInt32ToInt32Field().put(2, 22);
builder.getMutableInt32ToInt32Field().put(3, 33);
-
+ //
builder.getMutableInt32ToStringField().put(1, "11");
builder.getMutableInt32ToStringField().put(2, "22");
builder.getMutableInt32ToStringField().put(3, "33");
-
+ //
builder.getMutableInt32ToBytesField().put(1, TestUtil.toBytes("11"));
builder.getMutableInt32ToBytesField().put(2, TestUtil.toBytes("22"));
builder.getMutableInt32ToBytesField().put(3, TestUtil.toBytes("33"));
-
+ //
builder.getMutableInt32ToEnumField().put(1, TestMap.EnumValue.FOO);
builder.getMutableInt32ToEnumField().put(2, TestMap.EnumValue.BAR);
builder.getMutableInt32ToEnumField().put(3, TestMap.EnumValue.BAZ);
-
+ //
builder.getMutableInt32ToMessageField().put(
1, MessageValue.newBuilder().setValue(11).build());
builder.getMutableInt32ToMessageField().put(
2, MessageValue.newBuilder().setValue(22).build());
builder.getMutableInt32ToMessageField().put(
3, MessageValue.newBuilder().setValue(33).build());
-
+ //
builder.getMutableStringToInt32Field().put("1", 11);
builder.getMutableStringToInt32Field().put("2", 22);
builder.getMutableStringToInt32Field().put("3", 33);
@@ -122,6 +122,7 @@ public class MapTest extends TestCase {
setMapValuesUsingAccessors(usingAccessorsBuilder);
TestMap usingAccessors = usingAccessorsBuilder.build();
assertMapValuesSet(usingAccessors);
+
assertEquals(usingAccessors, usingMutableMap);
}
@@ -171,25 +172,25 @@ public class MapTest extends TestCase {
builder.getMutableInt32ToInt32Field().put(1, 111);
builder.getMutableInt32ToInt32Field().remove(2);
builder.getMutableInt32ToInt32Field().put(4, 44);
-
+ //
builder.getMutableInt32ToStringField().put(1, "111");
builder.getMutableInt32ToStringField().remove(2);
builder.getMutableInt32ToStringField().put(4, "44");
-
+ //
builder.getMutableInt32ToBytesField().put(1, TestUtil.toBytes("111"));
builder.getMutableInt32ToBytesField().remove(2);
builder.getMutableInt32ToBytesField().put(4, TestUtil.toBytes("44"));
-
+ //
builder.getMutableInt32ToEnumField().put(1, TestMap.EnumValue.BAR);
builder.getMutableInt32ToEnumField().remove(2);
builder.getMutableInt32ToEnumField().put(4, TestMap.EnumValue.QUX);
-
+ //
builder.getMutableInt32ToMessageField().put(
1, MessageValue.newBuilder().setValue(111).build());
builder.getMutableInt32ToMessageField().remove(2);
builder.getMutableInt32ToMessageField().put(
4, MessageValue.newBuilder().setValue(44).build());
-
+ //
builder.getMutableStringToInt32Field().put("1", 111);
builder.getMutableStringToInt32Field().remove("2");
builder.getMutableStringToInt32Field().put("4", 44);
@@ -232,8 +233,9 @@ public class MapTest extends TestCase {
setMapValuesUsingAccessors(usingAccessorsBuilder);
TestMap usingAccessors = usingAccessorsBuilder.build();
assertMapValuesSet(usingAccessors);
- assertEquals(usingAccessors, usingMutableMap);
+ assertEquals(usingAccessors, usingMutableMap);
+ //
usingMutableMapBuilder = usingMutableMap.toBuilder();
updateMapValuesUsingMutableMap(usingMutableMapBuilder);
usingMutableMap = usingMutableMapBuilder.build();
@@ -337,7 +339,7 @@ public class MapTest extends TestCase {
assertEquals(newMap(1, 2), builder.getInt32ToInt32Field());
builder.getMutableInt32ToInt32Field().put(2, 3);
assertEquals(newMap(1, 2, 2, 3), builder.getInt32ToInt32Field());
-
+ //
Map<Integer, TestMap.EnumValue> enumMap = builder.getMutableInt32ToEnumField();
enumMap.put(1, TestMap.EnumValue.BAR);
assertEquals(newMap(1, TestMap.EnumValue.BAR), builder.build().getInt32ToEnumField());
@@ -352,7 +354,7 @@ public class MapTest extends TestCase {
assertEquals(
newMap(1, TestMap.EnumValue.BAR, 2, TestMap.EnumValue.FOO),
builder.getInt32ToEnumField());
-
+ //
Map<Integer, String> stringMap = builder.getMutableInt32ToStringField();
stringMap.put(1, "1");
assertEquals(newMap(1, "1"), builder.build().getInt32ToStringField());
@@ -363,11 +365,11 @@ public class MapTest extends TestCase {
// expected
}
assertEquals(newMap(1, "1"), builder.getInt32ToStringField());
- builder.getMutableInt32ToStringField().put(2, "2");
+ builder.putInt32ToStringField(2, "2");
assertEquals(
newMap(1, "1", 2, "2"),
builder.getInt32ToStringField());
-
+ //
Map<Integer, TestMap.MessageValue> messageMap = builder.getMutableInt32ToMessageField();
messageMap.put(1, TestMap.MessageValue.getDefaultInstance());
assertEquals(newMap(1, TestMap.MessageValue.getDefaultInstance()),
@@ -380,13 +382,13 @@ public class MapTest extends TestCase {
}
assertEquals(newMap(1, TestMap.MessageValue.getDefaultInstance()),
builder.getInt32ToMessageField());
- builder.getMutableInt32ToMessageField().put(2, TestMap.MessageValue.getDefaultInstance());
+ builder.putInt32ToMessageField(2, TestMap.MessageValue.getDefaultInstance());
assertEquals(
newMap(1, TestMap.MessageValue.getDefaultInstance(),
2, TestMap.MessageValue.getDefaultInstance()),
builder.getInt32ToMessageField());
}
-
+ //
public void testMutableMapLifecycle_collections() {
TestMap.Builder builder = TestMap.newBuilder();
Map<Integer, Integer> intMap = builder.getMutableInt32ToInt32Field();
@@ -433,18 +435,19 @@ public class MapTest extends TestCase {
assertEquals(newMap(1, 2), builder.build().getInt32ToInt32Field());
}
+
public void testGettersAndSetters() throws Exception {
TestMap.Builder builder = TestMap.newBuilder();
TestMap message = builder.build();
assertMapValuesCleared(message);
builder = message.toBuilder();
- setMapValuesUsingMutableMap(builder);
+ setMapValuesUsingAccessors(builder);
message = builder.build();
assertMapValuesSet(message);
builder = message.toBuilder();
- updateMapValuesUsingMutableMap(builder);
+ updateMapValuesUsingAccessors(builder);
message = builder.build();
assertMapValuesUpdated(message);
@@ -457,7 +460,7 @@ public class MapTest extends TestCase {
public void testPutAll() throws Exception {
TestMap.Builder sourceBuilder = TestMap.newBuilder();
- setMapValuesUsingMutableMap(sourceBuilder);
+ setMapValuesUsingAccessors(sourceBuilder);
TestMap source = sourceBuilder.build();
assertMapValuesSet(source);
@@ -467,15 +470,16 @@ public class MapTest extends TestCase {
}
public void testPutAllForUnknownEnumValues() throws Exception {
- TestMap.Builder sourceBuilder = TestMap.newBuilder();
- sourceBuilder.getMutableInt32ToEnumFieldValue().put(0, 0);
- sourceBuilder.getMutableInt32ToEnumFieldValue().put(1, 1);
- sourceBuilder.getMutableInt32ToEnumFieldValue().put(2, 1000); // unknown value.
- TestMap source = sourceBuilder.build();
+ TestMap source = TestMap.newBuilder()
+ .putAllInt32ToEnumFieldValue(newMap(
+ 0, 0,
+ 1, 1,
+ 2, 1000)) // unknown value.
+ .build();
- TestMap.Builder destinationBuilder = TestMap.newBuilder();
- destinationBuilder.putAllInt32ToEnumFieldValue(source.getInt32ToEnumFieldValue());
- TestMap destination = destinationBuilder.build();
+ TestMap destination = TestMap.newBuilder()
+ .putAllInt32ToEnumFieldValue(source.getInt32ToEnumFieldValue())
+ .build();
assertEquals(0, destination.getInt32ToEnumFieldValue().get(0).intValue());
assertEquals(1, destination.getInt32ToEnumFieldValue().get(1).intValue());
@@ -542,14 +546,14 @@ public class MapTest extends TestCase {
public void testSerializeAndParse() throws Exception {
TestMap.Builder builder = TestMap.newBuilder();
- setMapValuesUsingMutableMap(builder);
+ setMapValuesUsingAccessors(builder);
TestMap message = builder.build();
assertEquals(message.getSerializedSize(), message.toByteString().size());
message = TestMap.parser().parseFrom(message.toByteString());
assertMapValuesSet(message);
builder = message.toBuilder();
- updateMapValuesUsingMutableMap(builder);
+ updateMapValuesUsingAccessors(builder);
message = builder.build();
assertEquals(message.getSerializedSize(), message.toByteString().size());
message = TestMap.parser().parseFrom(message.toByteString());
@@ -614,7 +618,7 @@ public class MapTest extends TestCase {
public void testMergeFrom() throws Exception {
TestMap.Builder builder = TestMap.newBuilder();
- setMapValuesUsingMutableMap(builder);
+ setMapValuesUsingAccessors(builder);
TestMap message = builder.build();
TestMap.Builder other = TestMap.newBuilder();
@@ -628,23 +632,23 @@ public class MapTest extends TestCase {
// We can't control the order of elements in a HashMap. The best we can do
// here is to add elements in different order.
- TestMap.Builder b1 = TestMap.newBuilder();
- b1.getMutableInt32ToInt32Field().put(1, 2);
- b1.getMutableInt32ToInt32Field().put(3, 4);
- b1.getMutableInt32ToInt32Field().put(5, 6);
+ TestMap.Builder b1 = TestMap.newBuilder()
+ .putInt32ToInt32Field(1, 2)
+ .putInt32ToInt32Field(3, 4)
+ .putInt32ToInt32Field(5, 6);
TestMap m1 = b1.build();
- TestMap.Builder b2 = TestMap.newBuilder();
- b2.getMutableInt32ToInt32Field().put(5, 6);
- b2.getMutableInt32ToInt32Field().put(1, 2);
- b2.getMutableInt32ToInt32Field().put(3, 4);
+ TestMap.Builder b2 = TestMap.newBuilder()
+ .putInt32ToInt32Field(5, 6)
+ .putInt32ToInt32Field(1, 2)
+ .putInt32ToInt32Field(3, 4);
TestMap m2 = b2.build();
assertEquals(m1, m2);
assertEquals(m1.hashCode(), m2.hashCode());
// Make sure we did compare map fields.
- b2.getMutableInt32ToInt32Field().put(1, 0);
+ b2.putInt32ToInt32Field(1, 0);
m2 = b2.build();
assertFalse(m1.equals(m2));
// Don't check m1.hashCode() != m2.hashCode() because it's not guaranteed
@@ -652,7 +656,7 @@ public class MapTest extends TestCase {
// Regression test for b/18549190: if a map is a subset of the other map,
// equals() should return false.
- b2.getMutableInt32ToInt32Field().remove(1);
+ b2.removeInt32ToInt32Field(1);
m2 = b2.build();
assertFalse(m1.equals(m2));
assertFalse(m2.equals(m1));
@@ -661,20 +665,19 @@ public class MapTest extends TestCase {
public void testNestedBuilderOnChangeEventPropagation() {
TestOnChangeEventPropagation.Builder parent =
TestOnChangeEventPropagation.newBuilder();
- parent.getOptionalMessageBuilder().getMutableInt32ToInt32Field().put(1, 2);
+ parent.getOptionalMessageBuilder().putInt32ToInt32Field(1, 2);
TestOnChangeEventPropagation message = parent.build();
assertEquals(2, message.getOptionalMessage().getInt32ToInt32Field().get(1).intValue());
// Make a change using nested builder.
- parent.getOptionalMessageBuilder().getMutableInt32ToInt32Field().put(1, 3);
+ parent.getOptionalMessageBuilder().putInt32ToInt32Field(1, 3);
// Should be able to observe the change.
message = parent.build();
assertEquals(3, message.getOptionalMessage().getInt32ToInt32Field().get(1).intValue());
// Make another change using mergeFrom()
- TestMap.Builder other = TestMap.newBuilder();
- other.getMutableInt32ToInt32Field().put(1, 4);
+ TestMap.Builder other = TestMap.newBuilder().putInt32ToInt32Field(1, 4);
parent.getOptionalMessageBuilder().mergeFrom(other.build());
// Should be able to observe the change.
@@ -697,8 +700,7 @@ public class MapTest extends TestCase {
TestMap.Builder testMapBuilder = parentBuilder.getOptionalMessageBuilder();
// Create a map entry message.
- TestMap.Builder entryBuilder = TestMap.newBuilder();
- entryBuilder.getMutableInt32ToInt32Field().put(1, 1);
+ TestMap.Builder entryBuilder = TestMap.newBuilder().putInt32ToInt32Field(1, 1);
// Put the entry into the nested builder.
testMapBuilder.addRepeatedField(
@@ -709,7 +711,7 @@ public class MapTest extends TestCase {
assertEquals(1, message.getOptionalMessage().getInt32ToInt32Field().size());
// Change the entry value.
- entryBuilder.getMutableInt32ToInt32Field().put(1, 4);
+ entryBuilder.putInt32ToInt32Field(1, 4);
testMapBuilder = parentBuilder.getOptionalMessageBuilder();
testMapBuilder.setRepeatedField(
intMapField, 0, entryBuilder.getRepeatedField(intMapField, 0));
@@ -796,13 +798,11 @@ public class MapTest extends TestCase {
public void testReflectionApi() throws Exception {
// In reflection API, map fields are just repeated message fields.
- TestMap.Builder builder = TestMap.newBuilder();
- builder.getMutableInt32ToInt32Field().put(1, 2);
- builder.getMutableInt32ToInt32Field().put(3, 4);
- builder.getMutableInt32ToMessageField().put(
- 11, MessageValue.newBuilder().setValue(22).build());
- builder.getMutableInt32ToMessageField().put(
- 33, MessageValue.newBuilder().setValue(44).build());
+ TestMap.Builder builder = TestMap.newBuilder()
+ .putInt32ToInt32Field(1, 2)
+ .putInt32ToInt32Field(3, 4)
+ .putInt32ToMessageField(11, MessageValue.newBuilder().setValue(22).build())
+ .putInt32ToMessageField(33, MessageValue.newBuilder().setValue(44).build());
TestMap message = builder.build();
// Test getField(), getRepeatedFieldCount(), getRepeatedField().
@@ -872,7 +872,7 @@ public class MapTest extends TestCase {
public void testTextFormat() throws Exception {
TestMap.Builder builder = TestMap.newBuilder();
- setMapValuesUsingMutableMap(builder);
+ setMapValuesUsingAccessors(builder);
TestMap message = builder.build();
String textData = TextFormat.printToString(message);
@@ -886,7 +886,7 @@ public class MapTest extends TestCase {
public void testDynamicMessage() throws Exception {
TestMap.Builder builder = TestMap.newBuilder();
- setMapValuesUsingMutableMap(builder);
+ setMapValuesUsingAccessors(builder);
TestMap message = builder.build();
Message dynamicDefaultInstance =
@@ -931,10 +931,11 @@ public class MapTest extends TestCase {
}
public void testUnknownEnumValues() throws Exception {
- TestMap.Builder builder = TestMap.newBuilder();
- builder.getMutableInt32ToEnumFieldValue().put(0, 0);
- builder.getMutableInt32ToEnumFieldValue().put(1, 1);
- builder.getMutableInt32ToEnumFieldValue().put(2, 1000); // unknown value.
+ TestMap.Builder builder = TestMap.newBuilder()
+ .putAllInt32ToEnumFieldValue(newMap(
+ 0, 0,
+ 1, 1,
+ 2, 1000)); // unknown value.
TestMap message = builder.build();
assertEquals(TestMap.EnumValue.FOO,
@@ -957,7 +958,7 @@ public class MapTest extends TestCase {
assertEquals(1000, builder.getInt32ToEnumFieldValue().get(2).intValue());
// hashCode()/equals() should take unknown enum values into account.
- builder.getMutableInt32ToEnumFieldValue().put(2, 1001);
+ builder.putAllInt32ToEnumFieldValue(newMap(2, 1001));
TestMap message2 = builder.build();
assertFalse(message.hashCode() == message2.hashCode());
assertFalse(message.equals(message2));
@@ -971,15 +972,13 @@ public class MapTest extends TestCase {
EnumDescriptor enumDescriptor = TestMap.EnumValue.getDescriptor();
FieldDescriptor field = descriptor.findFieldByName("int32_to_enum_field");
- Map<Integer, Integer> data = new HashMap<Integer, Integer>();
- data.put(0, 0);
- data.put(1, 1);
- data.put(2, 1000); // unknown value.
+ Map<Integer, Integer> data = newMap(
+ 0, 0,
+ 1, 1,
+ 2, 1000); // unknown value
- TestMap.Builder builder = TestMap.newBuilder();
- for (Map.Entry<Integer, Integer> entry : data.entrySet()) {
- builder.getMutableInt32ToEnumFieldValue().put(entry.getKey(), entry.getValue());
- }
+ TestMap.Builder builder = TestMap.newBuilder()
+ .putAllInt32ToEnumFieldValue(data);
// Try to read unknown enum values using reflection API.
for (int i = 0; i < builder.getRepeatedFieldCount(field); i++) {
@@ -1003,7 +1002,7 @@ public class MapTest extends TestCase {
public void testIterationOrder() throws Exception {
TestMap.Builder builder = TestMap.newBuilder();
- setMapValuesUsingMutableMap(builder);
+ setMapValuesUsingAccessors(builder);
TestMap message = builder.build();
assertEquals(Arrays.asList("1", "2", "3"),
@@ -1012,7 +1011,7 @@ public class MapTest extends TestCase {
public void testGetMap() {
TestMap.Builder builder = TestMap.newBuilder();
- setMapValuesUsingMutableMap(builder);
+ setMapValuesUsingAccessors(builder);
TestMap message = builder.build();
assertEquals(
message.getStringToInt32Field(),
@@ -1033,7 +1032,7 @@ public class MapTest extends TestCase {
public void testContains() {
TestMap.Builder builder = TestMap.newBuilder();
- setMapValuesUsingMutableMap(builder);
+ setMapValuesUsingAccessors(builder);
assertMapContainsSetValues(builder);
assertMapContainsSetValues(builder.build());
}
@@ -1074,7 +1073,7 @@ public class MapTest extends TestCase {
TestMap.Builder builder = TestMap.newBuilder();
assertMapCounts(0, builder);
- setMapValuesUsingMutableMap(builder);
+ setMapValuesUsingAccessors(builder);
assertMapCounts(3, builder);
TestMap message = builder.build();
@@ -1269,7 +1268,7 @@ public class MapTest extends TestCase {
public void testRemove() {
TestMap.Builder builder = TestMap.newBuilder();
- setMapValuesUsingMutableMap(builder);
+ setMapValuesUsingAccessors(builder);
assertEquals(11, builder.getInt32ToInt32FieldOrThrow(1));
for (int times = 0; times < 2; times++) {
builder.removeInt32ToInt32Field(1);
@@ -1485,4 +1484,12 @@ public class MapTest extends TestCase {
map.put(key2, value2);
return map;
}
+
+ private static <K, V> Map<K, V> newMap(K key1, V value1, K key2, V value2, K key3, V value3) {
+ Map<K, V> map = new HashMap<K, V>();
+ map.put(key1, value1);
+ map.put(key2, value2);
+ map.put(key3, value3);
+ return map;
+ }
}
diff --git a/java/core/src/test/java/com/google/protobuf/ParserTest.java b/java/core/src/test/java/com/google/protobuf/ParserTest.java
index 7086912b..8c2e4c26 100644
--- a/java/core/src/test/java/com/google/protobuf/ParserTest.java
+++ b/java/core/src/test/java/com/google/protobuf/ParserTest.java
@@ -46,6 +46,7 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InterruptedIOException;
import junit.framework.TestCase;
/**
@@ -372,4 +373,43 @@ public class ParserTest extends TestCase {
assertEquals(3, parsingMerge.getExtensionCount(
TestParsingMergeLite.repeatedExt));
}
+
+ public void testParseDelimitedFrom_firstByteInterrupted_preservesCause() {
+ try {
+ TestUtil.getAllSet().parseDelimitedFrom(
+ new InputStream() {
+ @Override
+ public int read() throws IOException {
+ throw new InterruptedIOException();
+ }
+ });
+ fail("Expected InterruptedIOException");
+ } catch (Exception e) {
+ assertEquals(InterruptedIOException.class, e.getClass());
+ }
+ }
+
+ public void testParseDelimitedFrom_secondByteInterrupted_preservesCause() {
+ try {
+ TestUtil.getAllSet().parseDelimitedFrom(
+ new InputStream() {
+ private int i;
+
+ @Override
+ public int read() throws IOException {
+ switch (i++) {
+ case 0:
+ return 1;
+ case 1:
+ throw new InterruptedIOException();
+ default:
+ throw new AssertionError();
+ }
+ }
+ });
+ fail("Expected InterruptedIOException");
+ } catch (Exception e) {
+ assertEquals(InterruptedIOException.class, e.getClass());
+ }
+ }
}
diff --git a/java/core/src/test/java/com/google/protobuf/UnknownFieldSetLiteTest.java b/java/core/src/test/java/com/google/protobuf/UnknownFieldSetLiteTest.java
index 26ea850e..f8cb0aab 100644
--- a/java/core/src/test/java/com/google/protobuf/UnknownFieldSetLiteTest.java
+++ b/java/core/src/test/java/com/google/protobuf/UnknownFieldSetLiteTest.java
@@ -53,6 +53,14 @@ public class UnknownFieldSetLiteTest extends TestCase {
assertEquals(ByteString.EMPTY, toByteString(unknownFields));
}
+ public void testEmptyInstance() {
+ UnknownFieldSetLite instance = UnknownFieldSetLite.newInstance();
+
+ assertEquals(0, instance.getSerializedSize());
+ assertEquals(ByteString.EMPTY, toByteString(instance));
+ assertEquals(UnknownFieldSetLite.getDefaultInstance(), instance);
+ }
+
public void testMergeFieldFrom() throws IOException {
Foo foo = Foo.newBuilder()
.setValue(2)
diff --git a/java/pom.xml b/java/pom.xml
index 6789e7c1..41c9b9da 100644
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -11,7 +11,7 @@
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
- <version>3.1.0</version>
+ <version>3.2.0</version>
<packaging>pom</packaging>
<name>Protocol Buffers [Parent]</name>
diff --git a/java/util/pom.xml b/java/util/pom.xml
index 0ccfc848..ac771f6e 100644
--- a/java/util/pom.xml
+++ b/java/util/pom.xml
@@ -6,7 +6,7 @@
<parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
- <version>3.1.0</version>
+ <version>3.2.0</version>
</parent>
<artifactId>protobuf-java-util</artifactId>
diff --git a/java/util/src/main/java/com/google/protobuf/util/Durations.java b/java/util/src/main/java/com/google/protobuf/util/Durations.java
index 9333168d..46b21828 100644
--- a/java/util/src/main/java/com/google/protobuf/util/Durations.java
+++ b/java/util/src/main/java/com/google/protobuf/util/Durations.java
@@ -42,7 +42,6 @@ import static com.google.protobuf.util.Timestamps.NANOS_PER_MICROSECOND;
import static com.google.protobuf.util.Timestamps.NANOS_PER_MILLISECOND;
import static com.google.protobuf.util.Timestamps.NANOS_PER_SECOND;
-import com.google.common.collect.ComparisonChain;
import com.google.protobuf.Duration;
import java.text.ParseException;
import java.util.Comparator;
@@ -71,11 +70,8 @@ public final class Durations {
public int compare(Duration d1, Duration d2) {
checkValid(d1);
checkValid(d2);
-
- return ComparisonChain.start()
- .compare(d1.getSeconds(), d2.getSeconds())
- .compare(d1.getNanos(), d2.getNanos())
- .result();
+ int secDiff = Long.compare(d1.getSeconds(), d2.getSeconds());
+ return (secDiff != 0) ? secDiff : Integer.compare(d1.getNanos(), d2.getNanos());
}
};
diff --git a/java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java b/java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java
index b577495d..b192b53e 100644
--- a/java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java
+++ b/java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java
@@ -217,7 +217,12 @@ final class FieldMaskTree {
Message source,
Message.Builder destination,
FieldMaskUtil.MergeOptions options) {
- assert source.getDescriptorForType() == destination.getDescriptorForType();
+ if (source.getDescriptorForType() != destination.getDescriptorForType()) {
+ throw new IllegalArgumentException(
+ String.format(
+ "source (%s) and destination (%s) descriptor must be equal",
+ source.getDescriptorForType(), destination.getDescriptorForType()));
+ }
Descriptor descriptor = source.getDescriptorForType();
for (Entry<String, Node> entry : node.children.entrySet()) {
diff --git a/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java b/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java
index 6361b4ac..ac712c94 100644
--- a/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java
+++ b/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java
@@ -49,6 +49,7 @@ import com.google.protobuf.Descriptors.EnumDescriptor;
import com.google.protobuf.Descriptors.EnumValueDescriptor;
import com.google.protobuf.Descriptors.FieldDescriptor;
import com.google.protobuf.Descriptors.FileDescriptor;
+import com.google.protobuf.Descriptors.OneofDescriptor;
import com.google.protobuf.DoubleValue;
import com.google.protobuf.Duration;
import com.google.protobuf.DynamicMessage;
@@ -67,7 +68,6 @@ import com.google.protobuf.Timestamp;
import com.google.protobuf.UInt32Value;
import com.google.protobuf.UInt64Value;
import com.google.protobuf.Value;
-
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
@@ -224,7 +224,7 @@ public class JsonFormat {
* Creates a {@link Parser} with default configuration.
*/
public static Parser parser() {
- return new Parser(TypeRegistry.getEmptyTypeRegistry(), false);
+ return new Parser(TypeRegistry.getEmptyTypeRegistry(), false, Parser.DEFAULT_RECURSION_LIMIT);
}
/**
@@ -233,10 +233,15 @@ public class JsonFormat {
public static class Parser {
private final TypeRegistry registry;
private final boolean ignoringUnknownFields;
+ private final int recursionLimit;
+
+ // The default parsing recursion limit is aligned with the proto binary parser.
+ private static final int DEFAULT_RECURSION_LIMIT = 100;
- private Parser(TypeRegistry registry, boolean ignoreUnknownFields) {
+ private Parser(TypeRegistry registry, boolean ignoreUnknownFields, int recursionLimit) {
this.registry = registry;
this.ignoringUnknownFields = ignoreUnknownFields;
+ this.recursionLimit = recursionLimit;
}
/**
@@ -249,16 +254,15 @@ public class JsonFormat {
if (this.registry != TypeRegistry.getEmptyTypeRegistry()) {
throw new IllegalArgumentException("Only one registry is allowed.");
}
- return new Parser(registry, this.ignoringUnknownFields);
+ return new Parser(registry, ignoringUnknownFields, recursionLimit);
}
/**
- * Creates a new {@link Parser} configured to not throw an exception
- * when an unknown field is encountered. The new Parser clones all other
- * configurations from this Parser.
+ * Creates a new {@link Parser} configured to not throw an exception when an unknown field is
+ * encountered. The new Parser clones all other configurations from this Parser.
*/
public Parser ignoringUnknownFields() {
- return new Parser(this.registry, true);
+ return new Parser(this.registry, true, recursionLimit);
}
/**
@@ -270,7 +274,7 @@ public class JsonFormat {
public void merge(String json, Message.Builder builder) throws InvalidProtocolBufferException {
// TODO(xiaofeng): Investigate the allocation overhead and optimize for
// mobile.
- new ParserImpl(registry, ignoringUnknownFields).merge(json, builder);
+ new ParserImpl(registry, ignoringUnknownFields, recursionLimit).merge(json, builder);
}
/**
@@ -283,7 +287,12 @@ public class JsonFormat {
public void merge(Reader json, Message.Builder builder) throws IOException {
// TODO(xiaofeng): Investigate the allocation overhead and optimize for
// mobile.
- new ParserImpl(registry, ignoringUnknownFields).merge(json, builder);
+ new ParserImpl(registry, ignoringUnknownFields, recursionLimit).merge(json, builder);
+ }
+
+ // For testing only.
+ Parser usingRecursionLimit(int recursionLimit) {
+ return new Parser(registry, ignoringUnknownFields, recursionLimit);
}
}
@@ -774,12 +783,18 @@ public class JsonFormat {
if (includingDefaultValueFields) {
fieldsToPrint = new TreeMap<FieldDescriptor, Object>();
for (FieldDescriptor field : message.getDescriptorForType().getFields()) {
- if (field.isOptional()
- && field.getJavaType() == FieldDescriptor.JavaType.MESSAGE
- && !message.hasField(field)) {
- // Always skip empty optional message fields. If not we will recurse indefinitely if
- // a message has itself as a sub-field.
- continue;
+ if (field.isOptional()) {
+ if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE
+ && !message.hasField(field)){
+ // Always skip empty optional message fields. If not we will recurse indefinitely if
+ // a message has itself as a sub-field.
+ continue;
+ }
+ OneofDescriptor oneof = field.getContainingOneof();
+ if (oneof != null && !message.hasField(field)) {
+ // Skip all oneof fields except the one that is actually set
+ continue;
+ }
}
fieldsToPrint.put(field, message.getField(field));
}
@@ -1040,11 +1055,15 @@ public class JsonFormat {
private final TypeRegistry registry;
private final JsonParser jsonParser;
private final boolean ignoringUnknownFields;
+ private final int recursionLimit;
+ private int currentDepth;
- ParserImpl(TypeRegistry registry, boolean ignoreUnknownFields) {
+ ParserImpl(TypeRegistry registry, boolean ignoreUnknownFields, int recursionLimit) {
this.registry = registry;
this.ignoringUnknownFields = ignoreUnknownFields;
this.jsonParser = new JsonParser();
+ this.recursionLimit = recursionLimit;
+ this.currentDepth = 0;
}
void merge(Reader json, Message.Builder builder) throws IOException {
@@ -1715,8 +1734,13 @@ public class JsonFormat {
case MESSAGE:
case GROUP:
+ if (currentDepth >= recursionLimit) {
+ throw new InvalidProtocolBufferException("Hit recursion limit.");
+ }
+ ++currentDepth;
Message.Builder subBuilder = builder.newBuilderForField(field);
merge(json, subBuilder);
+ --currentDepth;
return subBuilder.build();
default:
diff --git a/java/util/src/main/java/com/google/protobuf/util/Timestamps.java b/java/util/src/main/java/com/google/protobuf/util/Timestamps.java
index 52b1ab98..2160e4d5 100644
--- a/java/util/src/main/java/com/google/protobuf/util/Timestamps.java
+++ b/java/util/src/main/java/com/google/protobuf/util/Timestamps.java
@@ -37,7 +37,6 @@ import static com.google.common.math.LongMath.checkedAdd;
import static com.google.common.math.LongMath.checkedMultiply;
import static com.google.common.math.LongMath.checkedSubtract;
-import com.google.common.collect.ComparisonChain;
import com.google.protobuf.Duration;
import com.google.protobuf.Timestamp;
import java.text.ParseException;
@@ -101,11 +100,8 @@ public final class Timestamps {
public int compare(Timestamp t1, Timestamp t2) {
checkValid(t1);
checkValid(t2);
-
- return ComparisonChain.start()
- .compare(t1.getSeconds(), t2.getSeconds())
- .compare(t1.getNanos(), t2.getNanos())
- .result();
+ int secDiff = Long.compare(t1.getSeconds(), t2.getSeconds());
+ return (secDiff != 0) ? secDiff : Integer.compare(t1.getNanos(), t2.getNanos());
}
};
diff --git a/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java b/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java
index 32739d44..dafd9bb5 100644
--- a/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java
+++ b/java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java
@@ -57,12 +57,15 @@ import com.google.protobuf.util.JsonTestProto.TestDuration;
import com.google.protobuf.util.JsonTestProto.TestFieldMask;
import com.google.protobuf.util.JsonTestProto.TestMap;
import com.google.protobuf.util.JsonTestProto.TestOneof;
+import com.google.protobuf.util.JsonTestProto.TestRecursive;
import com.google.protobuf.util.JsonTestProto.TestStruct;
import com.google.protobuf.util.JsonTestProto.TestTimestamp;
import com.google.protobuf.util.JsonTestProto.TestWrappers;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.util.HashMap;
+import java.util.Map;
import junit.framework.TestCase;
public class JsonFormatTest extends TestCase {
@@ -216,7 +219,9 @@ public class JsonFormatTest extends TestCase {
TestMap.Builder mapBuilder = TestMap.newBuilder();
mapBuilder.putInt32ToEnumMapValue(1, 0);
- mapBuilder.getMutableInt32ToEnumMapValue().put(2, 12345);
+ Map<Integer, Integer> mapWithInvalidValues = new HashMap<Integer, Integer>();
+ mapWithInvalidValues.put(2, 12345);
+ mapBuilder.putAllInt32ToEnumMapValue(mapWithInvalidValues);
TestMap mapMessage = mapBuilder.build();
assertEquals(
"{\n"
@@ -1140,6 +1145,7 @@ public class JsonFormatTest extends TestCase {
// Expected.
}
}
+
public void testParserIgnoringUnknownFields() throws Exception {
TestAllTypes.Builder builder = TestAllTypes.newBuilder();
String json = "{\n" + " \"unknownField\": \"XXX\"\n" + "}";
@@ -1261,6 +1267,23 @@ public class JsonFormatTest extends TestCase {
+ " }\n"
+ "}",
JsonFormat.printer().includingDefaultValueFields().print(mapMessage));
+
+ TestOneof oneofMessage = TestOneof.getDefaultInstance();
+ assertEquals("{\n}", JsonFormat.printer().print(oneofMessage));
+ assertEquals("{\n}", JsonFormat.printer().includingDefaultValueFields().print(oneofMessage));
+
+ oneofMessage = TestOneof.newBuilder().setOneofInt32(42).build();
+ assertEquals("{\n \"oneofInt32\": 42\n}",
+ JsonFormat.printer().print(oneofMessage));
+ assertEquals("{\n \"oneofInt32\": 42\n}",
+ JsonFormat.printer().includingDefaultValueFields().print(oneofMessage));
+
+ TestOneof.Builder oneofBuilder = TestOneof.newBuilder();
+ mergeFromJson("{\n" + " \"oneofNullValue\": null \n" + "}", oneofBuilder);
+ oneofMessage = oneofBuilder.build();
+ assertEquals("{\n \"oneofNullValue\": null\n}", JsonFormat.printer().print(oneofMessage));
+ assertEquals("{\n \"oneofNullValue\": null\n}",
+ JsonFormat.printer().includingDefaultValueFields().print(oneofMessage));
}
public void testPreservingProtoFieldNames() throws Exception {
@@ -1358,4 +1381,34 @@ public class JsonFormatTest extends TestCase {
Any any = builder.build();
assertEquals(0, any.getValue().size());
}
+
+ public void testRecursionLimit() throws Exception {
+ String input =
+ "{\n"
+ + " \"nested\": {\n"
+ + " \"nested\": {\n"
+ + " \"nested\": {\n"
+ + " \"nested\": {\n"
+ + " \"value\": 1234\n"
+ + " }\n"
+ + " }\n"
+ + " }\n"
+ + " }\n"
+ + "}\n";
+
+ JsonFormat.Parser parser = JsonFormat.parser();
+ TestRecursive.Builder builder = TestRecursive.newBuilder();
+ parser.merge(input, builder);
+ TestRecursive message = builder.build();
+ assertEquals(1234, message.getNested().getNested().getNested().getNested().getValue());
+
+ parser = JsonFormat.parser().usingRecursionLimit(3);
+ builder = TestRecursive.newBuilder();
+ try {
+ parser.merge(input, builder);
+ fail("Exception is expected.");
+ } catch (InvalidProtocolBufferException e) {
+ // Expected.
+ }
+ }
}
diff --git a/java/util/src/test/proto/com/google/protobuf/util/json_test.proto b/java/util/src/test/proto/com/google/protobuf/util/json_test.proto
index bd22f65a..a75338ef 100644
--- a/java/util/src/test/proto/com/google/protobuf/util/json_test.proto
+++ b/java/util/src/test/proto/com/google/protobuf/util/json_test.proto
@@ -201,3 +201,8 @@ message TestAny {
message TestCustomJsonName {
int32 value = 1 [json_name = "@value"];
}
+
+message TestRecursive {
+ int32 value = 1;
+ TestRecursive nested = 2;
+}
diff --git a/javanano/pom.xml b/javanano/pom.xml
index 6bac76c9..6cb8c17d 100644
--- a/javanano/pom.xml
+++ b/javanano/pom.xml
@@ -10,7 +10,7 @@
</parent>
<groupId>com.google.protobuf.nano</groupId>
<artifactId>protobuf-javanano</artifactId>
- <version>3.1.0</version>
+ <version>3.2.0</version>
<packaging>bundle</packaging>
<name>Protocol Buffer JavaNano API</name>
<description>
diff --git a/javanano/src/main/java/com/google/protobuf/nano/InternalNano.java b/javanano/src/main/java/com/google/protobuf/nano/InternalNano.java
index f1263df5..278368a0 100644
--- a/javanano/src/main/java/com/google/protobuf/nano/InternalNano.java
+++ b/javanano/src/main/java/com/google/protobuf/nano/InternalNano.java
@@ -67,8 +67,8 @@ public final class InternalNano {
public static final int TYPE_SINT32 = 17;
public static final int TYPE_SINT64 = 18;
- protected static final Charset UTF_8 = Charset.forName("UTF-8");
- protected static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1");
+ static final Charset UTF_8 = Charset.forName("UTF-8");
+ static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1");
private InternalNano() {}
diff --git a/javanano/src/test/java/com/google/protobuf/nano/NanoTest.java b/javanano/src/test/java/com/google/protobuf/nano/NanoTest.java
index debf7c0a..4d6e7f09 100644
--- a/javanano/src/test/java/com/google/protobuf/nano/NanoTest.java
+++ b/javanano/src/test/java/com/google/protobuf/nano/NanoTest.java
@@ -30,8 +30,11 @@
package com.google.protobuf.nano;
-import com.google.protobuf.nano.MapTestProto.TestMap;
import com.google.protobuf.nano.CodedOutputByteBufferNano;
+import com.google.protobuf.nano.EnumClassNanos.EnumClassNano;
+import com.google.protobuf.nano.EnumClassNanos.EnumClassNano.MessageScopeEnum;
+import com.google.protobuf.nano.EnumClassNanos.FileScopeEnum;
+import com.google.protobuf.nano.MapTestProto.TestMap;
import com.google.protobuf.nano.MapTestProto.TestMap.MessageValue;
import com.google.protobuf.nano.NanoAccessorsOuterClass.TestNanoAccessors;
import com.google.protobuf.nano.NanoHasOuterClass.TestAllTypesNanoHas;
diff --git a/jenkins/docker/Dockerfile b/jenkins/docker/Dockerfile
index 919a2b61..c5ee1ec0 100644
--- a/jenkins/docker/Dockerfile
+++ b/jenkins/docker/Dockerfile
@@ -132,7 +132,7 @@ ENV MVN mvn --batch-mode
RUN cd /tmp && \
git clone https://github.com/google/protobuf.git && \
cd protobuf && \
- git reset 734930f9197b7bc97c3c794c7a949fee2a08c280 && \
+ git reset bf379715c93b581eeb078cec1f0dd8a7d79df431 && \
./autogen.sh && \
./configure && \
make -j4 && \
@@ -148,7 +148,11 @@ RUN php composer-setup.php
RUN mv composer.phar /usr/bin/composer
RUN php -r "unlink('composer-setup.php');"
RUN cd /tmp && \
+ rm -rf protobuf && \
+ git clone https://github.com/google/protobuf.git && \
cd protobuf && \
+ git reset 46ae90dc5e145b12fffa7e053a908a9f3e066286 && \
+ cd php && \
ln -sfn /usr/bin/php5.5 /usr/bin/php && \
ln -sfn /usr/bin/php-config5.5 /usr/bin/php-config && \
ln -sfn /usr/bin/phpize5.5 /usr/bin/phpize && \
diff --git a/jenkins/docker32/Dockerfile b/jenkins/docker32/Dockerfile
index a36338b4..94d9a4c3 100644
--- a/jenkins/docker32/Dockerfile
+++ b/jenkins/docker32/Dockerfile
@@ -63,8 +63,8 @@ RUN mv composer.phar /usr/bin/composer
RUN php -r "unlink('composer-setup.php');"
RUN cd /tmp && \
git clone https://github.com/google/protobuf.git && \
- cd protobuf && \
- git reset 734930f9197b7bc97c3c794c7a949fee2a08c280 && \
+ cd protobuf/php && \
+ git reset 46ae90dc5e145b12fffa7e053a908a9f3e066286 && \
ln -sfn /usr/bin/php5.5 /usr/bin/php && \
ln -sfn /usr/bin/php-config5.5 /usr/bin/php-config && \
ln -sfn /usr/bin/phpize5.5 /usr/bin/phpize && \
diff --git a/js/binary/decoder.js b/js/binary/decoder.js
index 41094a36..26bf3594 100644
--- a/js/binary/decoder.js
+++ b/js/binary/decoder.js
@@ -733,6 +733,24 @@ jspb.BinaryDecoder.prototype.readZigzagVarint64 = function() {
/**
+ * Reads a signed, zigzag-encoded 64-bit varint from the binary stream and
+ * returns its valud as a string.
+ *
+ * Zigzag encoding is a modification of varint encoding that reduces the
+ * storage overhead for small negative integers - for more details on the
+ * format, see https://developers.google.com/protocol-buffers/docs/encoding
+ *
+ * @return {string} The decoded signed, zigzag-encoded 64-bit varint as a
+ * string.
+ */
+jspb.BinaryDecoder.prototype.readZigzagVarint64String = function() {
+ // TODO(haberman): write lossless 64-bit zig-zag math.
+ var value = this.readZigzagVarint64();
+ return value.toString();
+};
+
+
+/**
* Reads a raw unsigned 8-bit integer from the binary stream.
*
* @return {number} The unsigned 8-bit integer read from the binary stream.
@@ -791,6 +809,20 @@ jspb.BinaryDecoder.prototype.readUint64 = function() {
/**
+ * Reads a raw unsigned 64-bit integer from the binary stream. Note that since
+ * Javascript represents all numbers as double-precision floats, there will be
+ * precision lost if the absolute value of the integer is larger than 2^53.
+ *
+ * @return {string} The unsigned 64-bit integer read from the binary stream.
+ */
+jspb.BinaryDecoder.prototype.readUint64String = function() {
+ var bitsLow = this.readUint32();
+ var bitsHigh = this.readUint32();
+ return jspb.utils.joinUnsignedDecimalString(bitsLow, bitsHigh);
+};
+
+
+/**
* Reads a raw signed 8-bit integer from the binary stream.
*
* @return {number} The signed 8-bit integer read from the binary stream.
@@ -849,6 +881,20 @@ jspb.BinaryDecoder.prototype.readInt64 = function() {
/**
+ * Reads a raw signed 64-bit integer from the binary stream and returns it as a
+ * string.
+ *
+ * @return {string} The signed 64-bit integer read from the binary stream.
+ * Precision will be lost if the integer exceeds 2^53.
+ */
+jspb.BinaryDecoder.prototype.readInt64String = function() {
+ var bitsLow = this.readUint32();
+ var bitsHigh = this.readUint32();
+ return jspb.utils.joinSignedDecimalString(bitsLow, bitsHigh);
+};
+
+
+/**
* Reads a 32-bit floating-point number from the binary stream, using the
* temporary buffer to realign the data.
*
@@ -895,11 +941,9 @@ jspb.BinaryDecoder.prototype.readEnum = function() {
/**
* Reads and parses a UTF-8 encoded unicode string from the stream.
- * The code is inspired by maps.vectortown.parse.StreamedDataViewReader, with
- * the exception that the implementation here does not get confused if it
- * encounters characters longer than three bytes. These characters are ignored
- * though, as they are extremely rare: three UTF-8 bytes cover virtually all
- * characters in common use (http://en.wikipedia.org/wiki/UTF-8).
+ * The code is inspired by maps.vectortown.parse.StreamedDataViewReader.
+ * Supports codepoints from U+0000 up to U+10FFFF.
+ * (http://en.wikipedia.org/wiki/UTF-8).
* @param {number} length The length of the string to read.
* @return {string} The decoded string.
*/
@@ -907,30 +951,45 @@ jspb.BinaryDecoder.prototype.readString = function(length) {
var bytes = this.bytes_;
var cursor = this.cursor_;
var end = cursor + length;
- var chars = [];
+ var codeUnits = [];
while (cursor < end) {
var c = bytes[cursor++];
if (c < 128) { // Regular 7-bit ASCII.
- chars.push(c);
+ codeUnits.push(c);
} else if (c < 192) {
// UTF-8 continuation mark. We are out of sync. This
// might happen if we attempted to read a character
- // with more than three bytes.
+ // with more than four bytes.
continue;
} else if (c < 224) { // UTF-8 with two bytes.
var c2 = bytes[cursor++];
- chars.push(((c & 31) << 6) | (c2 & 63));
+ codeUnits.push(((c & 31) << 6) | (c2 & 63));
} else if (c < 240) { // UTF-8 with three bytes.
var c2 = bytes[cursor++];
var c3 = bytes[cursor++];
- chars.push(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
+ codeUnits.push(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
+ } else if (c < 248) { // UTF-8 with 4 bytes.
+ var c2 = bytes[cursor++];
+ var c3 = bytes[cursor++];
+ var c4 = bytes[cursor++];
+ // Characters written on 4 bytes have 21 bits for a codepoint.
+ // We can't fit that on 16bit characters, so we use surrogates.
+ var codepoint = ((c & 7) << 18) | ((c2 & 63) << 12) | ((c3 & 63) << 6) | (c4 & 63);
+ // Surrogates formula from wikipedia.
+ // 1. Subtract 0x10000 from codepoint
+ codepoint -= 0x10000;
+ // 2. Split this into the high 10-bit value and the low 10-bit value
+ // 3. Add 0xD800 to the high value to form the high surrogate
+ // 4. Add 0xDC00 to the low value to form the low surrogate:
+ var low = (codepoint & 1023) + 0xDC00;
+ var high = ((codepoint >> 10) & 1023) + 0xD800;
+ codeUnits.push(high, low);
}
}
-
// String.fromCharCode.apply is faster than manually appending characters on
// Chrome 25+, and generates no additional cons string garbage.
- var result = String.fromCharCode.apply(null, chars);
+ var result = String.fromCharCode.apply(null, codeUnits);
this.cursor_ = cursor;
return result;
};
diff --git a/js/binary/decoder_test.js b/js/binary/decoder_test.js
index ac312648..cb8aff96 100644
--- a/js/binary/decoder_test.js
+++ b/js/binary/decoder_test.js
@@ -210,6 +210,29 @@ describe('binaryDecoderTest', function() {
assertEquals(hashD, decoder.readFixedHash64());
});
+ /**
+ * Test encoding and decoding utf-8.
+ */
+ it('testUtf8', function() {
+ var encoder = new jspb.BinaryEncoder();
+
+ var ascii = "ASCII should work in 3, 2, 1...";
+ var utf8_two_bytes = "©";
+ var utf8_three_bytes = "❄";
+ var utf8_four_bytes = "😁";
+
+ encoder.writeString(ascii);
+ encoder.writeString(utf8_two_bytes);
+ encoder.writeString(utf8_three_bytes);
+ encoder.writeString(utf8_four_bytes);
+
+ var decoder = jspb.BinaryDecoder.alloc(encoder.end());
+
+ assertEquals(ascii, decoder.readString(ascii.length));
+ assertEquals(utf8_two_bytes, decoder.readString(utf8_two_bytes.length));
+ assertEquals(utf8_three_bytes, decoder.readString(utf8_three_bytes.length));
+ assertEquals(utf8_four_bytes, decoder.readString(utf8_four_bytes.length));
+ });
/**
* Verifies that misuse of the decoder class triggers assertions.
diff --git a/js/binary/encoder.js b/js/binary/encoder.js
index c9b0c2ae..aee33e7e 100644
--- a/js/binary/encoder.js
+++ b/js/binary/encoder.js
@@ -100,6 +100,24 @@ jspb.BinaryEncoder.prototype.writeSplitVarint64 = function(lowBits, highBits) {
/**
+ * Encodes a 64-bit integer in 32:32 split representation into its wire-format
+ * fixed representation and stores it in the buffer.
+ * @param {number} lowBits The low 32 bits of the int.
+ * @param {number} highBits The high 32 bits of the int.
+ */
+jspb.BinaryEncoder.prototype.writeSplitFixed64 = function(lowBits, highBits) {
+ goog.asserts.assert(lowBits == Math.floor(lowBits));
+ goog.asserts.assert(highBits == Math.floor(highBits));
+ goog.asserts.assert((lowBits >= 0) &&
+ (lowBits < jspb.BinaryConstants.TWO_TO_32));
+ goog.asserts.assert((highBits >= 0) &&
+ (highBits < jspb.BinaryConstants.TWO_TO_32));
+ this.writeUint32(lowBits);
+ this.writeUint32(highBits);
+};
+
+
+/**
* Encodes a 32-bit unsigned integer into its wire-format varint representation
* and stores it in the buffer.
* @param {number} value The integer to convert.
@@ -208,6 +226,18 @@ jspb.BinaryEncoder.prototype.writeZigzagVarint64 = function(value) {
/**
+ * Encodes a JavaScript decimal string into its wire-format, zigzag-encoded
+ * varint representation and stores it in the buffer. Integers not representable
+ * in 64 bits will be truncated.
+ * @param {string} value The integer to convert.
+ */
+jspb.BinaryEncoder.prototype.writeZigzagVarint64String = function(value) {
+ // TODO(haberman): write lossless 64-bit zig-zag math.
+ this.writeZigzagVarint64(parseInt(value, 10));
+};
+
+
+/**
* Writes a 8-bit unsigned integer to the buffer. Numbers outside the range
* [0,2^8) will be truncated.
* @param {number} value The value to write.
@@ -314,8 +344,21 @@ jspb.BinaryEncoder.prototype.writeInt64 = function(value) {
goog.asserts.assert((value >= -jspb.BinaryConstants.TWO_TO_63) &&
(value < jspb.BinaryConstants.TWO_TO_63));
jspb.utils.splitInt64(value);
- this.writeUint32(jspb.utils.split64Low);
- this.writeUint32(jspb.utils.split64High);
+ this.writeSplitFixed64(jspb.utils.split64Low, jspb.utils.split64High);
+};
+
+
+/**
+ * Writes a 64-bit integer decimal strings to the buffer. Numbers outside the
+ * range [-2^63,2^63) will be truncated.
+ * @param {string} value The value to write.
+ */
+jspb.BinaryEncoder.prototype.writeInt64String = function(value) {
+ goog.asserts.assert(value == Math.floor(value));
+ goog.asserts.assert((value >= -jspb.BinaryConstants.TWO_TO_63) &&
+ (value < jspb.BinaryConstants.TWO_TO_63));
+ jspb.utils.splitHash64(jspb.utils.decimalStringToHash64(value));
+ this.writeSplitFixed64(jspb.utils.split64Low, jspb.utils.split64High);
};
@@ -410,18 +453,35 @@ jspb.BinaryEncoder.prototype.writeFixedHash64 = function(hash) {
jspb.BinaryEncoder.prototype.writeString = function(value) {
var oldLength = this.buffer_.length;
- // UTF16 to UTF8 conversion loop swiped from goog.crypt.stringToUtf8ByteArray.
for (var i = 0; i < value.length; i++) {
+
var c = value.charCodeAt(i);
+
if (c < 128) {
this.buffer_.push(c);
} else if (c < 2048) {
this.buffer_.push((c >> 6) | 192);
this.buffer_.push((c & 63) | 128);
- } else {
- this.buffer_.push((c >> 12) | 224);
- this.buffer_.push(((c >> 6) & 63) | 128);
- this.buffer_.push((c & 63) | 128);
+ } else if (c < 65536) {
+ // Look for surrogates
+ if (c >= 0xD800 && c <= 0xDBFF && i + 1 < value.length) {
+ var second = value.charCodeAt(i + 1);
+ if (second >= 0xDC00 && second <= 0xDFFF) { // low surrogate
+ // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
+ c = (c - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
+
+ this.buffer_.push((c >> 18) | 240);
+ this.buffer_.push(((c >> 12) & 63 ) | 128);
+ this.buffer_.push(((c >> 6) & 63) | 128);
+ this.buffer_.push((c & 63) | 128);
+ i++;
+ }
+ }
+ else {
+ this.buffer_.push((c >> 12) | 224);
+ this.buffer_.push(((c >> 6) & 63) | 128);
+ this.buffer_.push((c & 63) | 128);
+ }
}
}
diff --git a/js/binary/message_test.js b/js/binary/message_test.js
new file mode 100644
index 00000000..4edc666b
--- /dev/null
+++ b/js/binary/message_test.js
@@ -0,0 +1,60 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Test suite is written using Jasmine -- see http://jasmine.github.io/
+
+goog.setTestOnly();
+
+goog.require('goog.testing.asserts');
+
+// CommonJS-LoadFromFile: test_pb proto.jspb.test
+goog.require('proto.jspb.test.Deeply.Nested.Message');
+
+// CommonJS-LoadFromFile: test2_pb proto.jspb.test
+goog.require('proto.jspb.test.ForeignNestedFieldMessage');
+
+describe('Message test suite', function() {
+ // Verify that we can successfully use a field referring to a nested message
+ // from a different .proto file.
+ it('testForeignNestedMessage', function() {
+ var msg = new proto.jspb.test.ForeignNestedFieldMessage();
+ var nested = new proto.jspb.test.Deeply.Nested.Message();
+ nested.setCount(5);
+ msg.setDeeplyNestedMessage(nested);
+ assertEquals(5, msg.getDeeplyNestedMessage().getCount());
+
+ // After a serialization-deserialization round trip we should get back the
+ // same data we started with.
+ var serialized = msg.serializeBinary();
+ var deserialized =
+ proto.jspb.test.ForeignNestedFieldMessage.deserializeBinary(serialized);
+ assertEquals(5, deserialized.getDeeplyNestedMessage().getCount());
+ });
+});
diff --git a/js/binary/proto_test.js b/js/binary/proto_test.js
index 26e1d30f..f86dc645 100644
--- a/js/binary/proto_test.js
+++ b/js/binary/proto_test.js
@@ -32,6 +32,7 @@
goog.require('goog.crypt.base64');
goog.require('goog.testing.asserts');
+goog.require('jspb.BinaryWriter');
goog.require('jspb.Message');
// CommonJS-LoadFromFile: ../testbinary_pb proto.jspb.test
@@ -87,6 +88,9 @@ goog.require('proto.jspb.test.extendRepeatedStringList');
goog.require('proto.jspb.test.extendRepeatedUint32List');
goog.require('proto.jspb.test.extendRepeatedUint64List');
+// CommonJS-LoadFromFile: ../node_modules/google-protobuf/google/protobuf/any_pb proto.google.protobuf
+goog.require('proto.google.protobuf.Any');
+
var suite = {};
@@ -194,8 +198,6 @@ function bytesCompare(arr, expected) {
* @param {proto.jspb.test.TestAllTypes} copy
*/
function checkAllFields(original, copy) {
- assertTrue(jspb.Message.equals(original, copy));
-
assertEquals(copy.getOptionalInt32(), -42);
assertEquals(copy.getOptionalInt64(), -0x7fffffff00000000);
assertEquals(copy.getOptionalUint32(), 0x80000000);
@@ -270,6 +272,9 @@ function checkAllFields(original, copy) {
assertElementsEquals(copy.getPackedRepeatedFloatList(), [1.5]);
assertElementsEquals(copy.getPackedRepeatedDoubleList(), [-1.5]);
+
+ // Check last so we get more granular errors first.
+ assertTrue(jspb.Message.equals(original, copy));
}
@@ -625,4 +630,36 @@ describe('protoBinaryTest', function() {
var decoded = proto.jspb.test.TestExtendable.deserializeBinary(encoded);
checkExtensions(decoded);
});
+
+ /**
+ * Tests that unknown extensions don't cause deserialization failure.
+ */
+ it('testUnknownExtension', function() {
+ var msg = new proto.jspb.test.TestExtendable();
+ fillExtensions(msg);
+ var writer = new jspb.BinaryWriter();
+ writer.writeBool((1 << 29) - 1, true);
+ proto.jspb.test.TestExtendable.serializeBinaryToWriter(msg, writer);
+ var encoded = writer.getResultBuffer();
+ var decoded = proto.jspb.test.TestExtendable.deserializeBinary(encoded);
+ checkExtensions(decoded);
+ });
+
+ it('testAnyWellKnownType', function() {
+ var any = new proto.google.protobuf.Any();
+ var msg = new proto.jspb.test.TestAllTypes();
+
+ fillAllFields(msg);
+
+ any.pack(msg.serializeBinary(), 'jspb.test.TestAllTypes');
+
+ assertEquals('type.googleapis.com/jspb.test.TestAllTypes',
+ any.getTypeUrl());
+
+ var msg2 = any.unpack(
+ proto.jspb.test.TestAllTypes.deserializeBinary,
+ 'jspb.test.TestAllTypes');
+
+ checkAllFields(msg, msg2);
+ });
});
diff --git a/js/binary/reader.js b/js/binary/reader.js
index 15f90432..8c5a4e88 100644
--- a/js/binary/reader.js
+++ b/js/binary/reader.js
@@ -744,6 +744,20 @@ jspb.BinaryReader.prototype.readSint64 = function() {
/**
+ * Reads a signed zigzag-encoded 64-bit integer field from the binary stream,
+ * or throws an error if the next field in the stream is not of the correct
+ * wire type.
+ *
+ * @return {string} The value of the signed 64-bit integer field as a decimal string.
+ */
+jspb.BinaryReader.prototype.readSint64String = function() {
+ goog.asserts.assert(
+ this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
+ return this.decoder_.readZigzagVarint64String();
+};
+
+
+/**
* Reads an unsigned 32-bit fixed-length integer fiield from the binary stream,
* or throws an error if the next field in the stream is not of the correct
* wire type.
@@ -772,11 +786,28 @@ jspb.BinaryReader.prototype.readFixed64 = function() {
/**
+ * Reads a signed 64-bit integer field from the binary stream as a string, or
+ * throws an error if the next field in the stream is not of the correct wire
+ * type.
+ *
+ * Returns the value as a string.
+ *
+ * @return {string} The value of the unsigned 64-bit integer field as a decimal
+ * string.
+ */
+jspb.BinaryReader.prototype.readFixed64String = function() {
+ goog.asserts.assert(
+ this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED64);
+ return this.decoder_.readUint64String();
+};
+
+
+/**
* Reads a signed 32-bit fixed-length integer fiield from the binary stream, or
* throws an error if the next field in the stream is not of the correct wire
* type.
*
- * @return {number} The value of the double field.
+ * @return {number} The value of the signed 32-bit integer field.
*/
jspb.BinaryReader.prototype.readSfixed32 = function() {
goog.asserts.assert(
@@ -786,11 +817,26 @@ jspb.BinaryReader.prototype.readSfixed32 = function() {
/**
+ * Reads a signed 32-bit fixed-length integer fiield from the binary stream, or
+ * throws an error if the next field in the stream is not of the correct wire
+ * type.
+ *
+ * @return {string} The value of the signed 32-bit integer field as a decimal
+ * string.
+ */
+jspb.BinaryReader.prototype.readSfixed32String = function() {
+ goog.asserts.assert(
+ this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED32);
+ return this.decoder_.readInt32().toString();
+};
+
+
+/**
* Reads a signed 64-bit fixed-length integer fiield from the binary stream, or
* throws an error if the next field in the stream is not of the correct wire
* type.
*
- * @return {number} The value of the float field.
+ * @return {number} The value of the sfixed64 field.
*/
jspb.BinaryReader.prototype.readSfixed64 = function() {
goog.asserts.assert(
@@ -800,6 +846,22 @@ jspb.BinaryReader.prototype.readSfixed64 = function() {
/**
+ * Reads a signed 64-bit fixed-length integer fiield from the binary stream, or
+ * throws an error if the next field in the stream is not of the correct wire
+ * type.
+ *
+ * Returns the value as a string.
+ *
+ * @return {string} The value of the sfixed64 field as a decimal string.
+ */
+jspb.BinaryReader.prototype.readSfixed64String = function() {
+ goog.asserts.assert(
+ this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED64);
+ return this.decoder_.readInt64String();
+};
+
+
+/**
* Reads a 32-bit floating-point field from the binary stream, or throws an
* error if the next field in the stream is not of the correct wire type.
*
@@ -1028,6 +1090,16 @@ jspb.BinaryReader.prototype.readPackedSint64 = function() {
/**
+ * Reads a packed sint64 field, which consists of a length header and a list of
+ * zigzag varints. Returns a list of strings.
+ * @return {!Array.<string>}
+ */
+jspb.BinaryReader.prototype.readPackedSint64String = function() {
+ return this.readPackedField_(this.decoder_.readZigzagVarint64String);
+};
+
+
+/**
* Reads a packed fixed32 field, which consists of a length header and a list
* of unsigned 32-bit ints.
* @return {!Array.<number>}
@@ -1048,6 +1120,16 @@ jspb.BinaryReader.prototype.readPackedFixed64 = function() {
/**
+ * Reads a packed fixed64 field, which consists of a length header and a list
+ * of unsigned 64-bit ints. Returns a list of strings.
+ * @return {!Array.<number>}
+ */
+jspb.BinaryReader.prototype.readPackedFixed64String = function() {
+ return this.readPackedField_(this.decoder_.readUint64String);
+};
+
+
+/**
* Reads a packed sfixed32 field, which consists of a length header and a list
* of 32-bit ints.
* @return {!Array.<number>}
@@ -1068,6 +1150,16 @@ jspb.BinaryReader.prototype.readPackedSfixed64 = function() {
/**
+ * Reads a packed sfixed64 field, which consists of a length header and a list
+ * of 64-bit ints. Returns a list of strings.
+ * @return {!Array.<string>}
+ */
+jspb.BinaryReader.prototype.readPackedSfixed64String = function() {
+ return this.readPackedField_(this.decoder_.readInt64String);
+};
+
+
+/**
* Reads a packed float field, which consists of a length header and a list of
* floats.
* @return {!Array.<number>}
diff --git a/js/binary/utils.js b/js/binary/utils.js
index 51405553..bbf99cdf 100644
--- a/js/binary/utils.js
+++ b/js/binary/utils.js
@@ -618,6 +618,16 @@ jspb.utils.decimalStringToHash64 = function(dec) {
/**
+ * Converts a signed or unsigned decimal string into two 32-bit halves, and
+ * stores them in the temp variables listed above.
+ * @param {string} value The decimal string to convert.
+ */
+jspb.utils.splitDecimalString = function(value) {
+ jspb.utils.splitHash64(jspb.utils.decimalStringToHash64(value));
+};
+
+
+/**
* Converts an 8-character hash string into its hexadecimal representation.
* @param {string} hash
* @return {string}
diff --git a/js/binary/writer.js b/js/binary/writer.js
index 3eb2f1bd..c3009dbb 100644
--- a/js/binary/writer.js
+++ b/js/binary/writer.js
@@ -435,6 +435,20 @@ jspb.BinaryWriter.prototype.writeZigzagVarint64_ = function(field, value) {
/**
+ * Writes a zigzag varint field to the buffer without range checking.
+ * @param {number} field The field number.
+ * @param {string?} value The value to write.
+ * @private
+ */
+jspb.BinaryWriter.prototype.writeZigzagVarint64String_ = function(
+ field, value) {
+ if (value == null) return;
+ this.writeFieldHeader_(field, jspb.BinaryConstants.WireType.VARINT);
+ this.encoder_.writeZigzagVarint64String(value);
+};
+
+
+/**
* Writes an int32 field to the buffer. Numbers outside the range [-2^31,2^31)
* will be truncated.
* @param {number} field The field number.
@@ -575,6 +589,20 @@ jspb.BinaryWriter.prototype.writeSint64 = function(field, value) {
/**
+ * Writes a sint64 field to the buffer. Numbers outside the range [-2^63,2^63)
+ * will be truncated.
+ * @param {number} field The field number.
+ * @param {string?} value The decimal string to write.
+ */
+jspb.BinaryWriter.prototype.writeSint64String = function(field, value) {
+ if (value == null) return;
+ goog.asserts.assert((value >= -jspb.BinaryConstants.TWO_TO_63) &&
+ (value < jspb.BinaryConstants.TWO_TO_63));
+ this.writeZigzagVarint64String_(field, value);
+};
+
+
+/**
* Writes a fixed32 field to the buffer. Numbers outside the range [0,2^32)
* will be truncated.
* @param {number} field The field number.
@@ -605,6 +633,19 @@ jspb.BinaryWriter.prototype.writeFixed64 = function(field, value) {
/**
+ * Writes a fixed64 field (with value as a string) to the buffer.
+ * @param {number} field The field number.
+ * @param {string?} value The value to write.
+ */
+jspb.BinaryWriter.prototype.writeFixed64String = function(field, value) {
+ if (value == null) return;
+ var num = jspb.arith.UInt64.fromString(value);
+ this.writeFieldHeader_(field, jspb.BinaryConstants.WireType.FIXED64);
+ this.encoder_.writeSplitFixed64(num.lo, num.hi);
+};
+
+
+/**
* Writes a sfixed32 field to the buffer. Numbers outside the range
* [-2^31,2^31) will be truncated.
* @param {number} field The field number.
@@ -635,6 +676,20 @@ jspb.BinaryWriter.prototype.writeSfixed64 = function(field, value) {
/**
+ * Writes a sfixed64 string field to the buffer. Numbers outside the range
+ * [-2^63,2^63) will be truncated.
+ * @param {number} field The field number.
+ * @param {string?} value The value to write.
+ */
+jspb.BinaryWriter.prototype.writeSfixed64String = function(field, value) {
+ if (value == null) return;
+ var num = jspb.arith.Int64.fromString(value);
+ this.writeFieldHeader_(field, jspb.BinaryConstants.WireType.FIXED64);
+ this.encoder_.writeSplitFixed64(num.lo, num.hi);
+};
+
+
+/**
* Writes a single-precision floating point field to the buffer. Numbers
* requiring more than 32 bits of precision will be truncated.
* @param {number} field The field number.
@@ -796,28 +851,11 @@ jspb.BinaryWriter.prototype.writeVarintHash64 = function(field, value) {
/**
- * Writes an array of numbers to the buffer as a repeated varint field.
+ * Writes an array of numbers to the buffer as a repeated 32-bit int field.
* @param {number} field The field number.
* @param {?Array.<number>} value The array of ints to write.
- * @private
*/
-jspb.BinaryWriter.prototype.writeRepeatedUnsignedVarint32_ =
- function(field, value) {
- if (value == null) return;
- for (var i = 0; i < value.length; i++) {
- this.writeUnsignedVarint32_(field, value[i]);
- }
-};
-
-
-/**
- * Writes an array of numbers to the buffer as a repeated varint field.
- * @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
- * @private
- */
-jspb.BinaryWriter.prototype.writeRepeatedSignedVarint32_ =
- function(field, value) {
+jspb.BinaryWriter.prototype.writeRepeatedInt32 = function(field, value) {
if (value == null) return;
for (var i = 0; i < value.length; i++) {
this.writeSignedVarint32_(field, value[i]);
@@ -826,28 +864,25 @@ jspb.BinaryWriter.prototype.writeRepeatedSignedVarint32_ =
/**
- * Writes an array of numbers to the buffer as a repeated varint field.
+ * Writes an array of numbers formatted as strings to the buffer as a repeated
+ * 32-bit int field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
- * @private
+ * @param {?Array.<string>} value The array of ints to write.
*/
-jspb.BinaryWriter.prototype.writeRepeatedUnsignedVarint64_ =
- function(field, value) {
+jspb.BinaryWriter.prototype.writeRepeatedInt32String = function(field, value) {
if (value == null) return;
for (var i = 0; i < value.length; i++) {
- this.writeUnsignedVarint64_(field, value[i]);
+ this.writeInt32String(field, value[i]);
}
};
/**
- * Writes an array of numbers to the buffer as a repeated varint field.
+ * Writes an array of numbers to the buffer as a repeated 64-bit int field.
* @param {number} field The field number.
* @param {?Array.<number>} value The array of ints to write.
- * @private
*/
-jspb.BinaryWriter.prototype.writeRepeatedSignedVarint64_ =
- function(field, value) {
+jspb.BinaryWriter.prototype.writeRepeatedInt64 = function(field, value) {
if (value == null) return;
for (var i = 0; i < value.length; i++) {
this.writeSignedVarint64_(field, value[i]);
@@ -856,147 +891,112 @@ jspb.BinaryWriter.prototype.writeRepeatedSignedVarint64_ =
/**
- * Writes an array of numbers to the buffer as a repeated zigzag field.
+ * Writes an array of numbers formatted as strings to the buffer as a repeated
+ * 64-bit int field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
- * @private
+ * @param {?Array.<string>} value The array of ints to write.
*/
-jspb.BinaryWriter.prototype.writeRepeatedZigzag32_ = function(field, value) {
+jspb.BinaryWriter.prototype.writeRepeatedInt64String = function(field, value) {
if (value == null) return;
for (var i = 0; i < value.length; i++) {
- this.writeZigzagVarint32_(field, value[i]);
+ this.writeInt64String(field, value[i]);
}
};
/**
- * Writes an array of numbers to the buffer as a repeated zigzag field.
+ * Writes an array numbers to the buffer as a repeated unsigned 32-bit int
+ * field.
* @param {number} field The field number.
* @param {?Array.<number>} value The array of ints to write.
- * @private
*/
-jspb.BinaryWriter.prototype.writeRepeatedZigzag_ = function(field, value) {
+jspb.BinaryWriter.prototype.writeRepeatedUint32 = function(field, value) {
if (value == null) return;
for (var i = 0; i < value.length; i++) {
- this.writeZigzagVarint64_(field, value[i]);
+ this.writeUnsignedVarint32_(field, value[i]);
}
};
/**
- * Writes an array of numbers to the buffer as a repeated 32-bit int field.
- * @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
- */
-jspb.BinaryWriter.prototype.writeRepeatedInt32 =
- jspb.BinaryWriter.prototype.writeRepeatedSignedVarint32_;
-
-
-/**
* Writes an array of numbers formatted as strings to the buffer as a repeated
- * 32-bit int field.
+ * unsigned 32-bit int field.
* @param {number} field The field number.
* @param {?Array.<string>} value The array of ints to write.
*/
-jspb.BinaryWriter.prototype.writeRepeatedInt32String =
- function(field, value) {
+jspb.BinaryWriter.prototype.writeRepeatedUint32String = function(field, value) {
if (value == null) return;
for (var i = 0; i < value.length; i++) {
- this.writeInt32String(field, value[i]);
+ this.writeUint32String(field, value[i]);
}
};
/**
- * Writes an array of numbers to the buffer as a repeated 64-bit int field.
+ * Writes an array numbers to the buffer as a repeated unsigned 64-bit int
+ * field.
* @param {number} field The field number.
* @param {?Array.<number>} value The array of ints to write.
*/
-jspb.BinaryWriter.prototype.writeRepeatedInt64 =
- jspb.BinaryWriter.prototype.writeRepeatedSignedVarint64_;
-
-
-/**
- * Writes an array of numbers formatted as strings to the buffer as a repeated
- * 64-bit int field.
- * @param {number} field The field number.
- * @param {?Array.<string>} value The array of ints to write.
- */
-jspb.BinaryWriter.prototype.writeRepeatedInt64String =
- function(field, value) {
+jspb.BinaryWriter.prototype.writeRepeatedUint64 = function(field, value) {
if (value == null) return;
for (var i = 0; i < value.length; i++) {
- this.writeInt64String(field, value[i]);
+ this.writeUnsignedVarint64_(field, value[i]);
}
};
/**
- * Writes an array numbers to the buffer as a repeated unsigned 32-bit int
- * field.
- * @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
- */
-jspb.BinaryWriter.prototype.writeRepeatedUint32 =
- jspb.BinaryWriter.prototype.writeRepeatedUnsignedVarint32_;
-
-
-/**
* Writes an array of numbers formatted as strings to the buffer as a repeated
- * unsigned 32-bit int field.
+ * unsigned 64-bit int field.
* @param {number} field The field number.
* @param {?Array.<string>} value The array of ints to write.
*/
-jspb.BinaryWriter.prototype.writeRepeatedUint32String =
- function(field, value) {
+jspb.BinaryWriter.prototype.writeRepeatedUint64String = function(field, value) {
if (value == null) return;
for (var i = 0; i < value.length; i++) {
- this.writeUint32String(field, value[i]);
+ this.writeUint64String(field, value[i]);
}
};
/**
- * Writes an array numbers to the buffer as a repeated unsigned 64-bit int
- * field.
+ * Writes an array numbers to the buffer as a repeated signed 32-bit int field.
* @param {number} field The field number.
* @param {?Array.<number>} value The array of ints to write.
*/
-jspb.BinaryWriter.prototype.writeRepeatedUint64 =
- jspb.BinaryWriter.prototype.writeRepeatedUnsignedVarint64_;
-
-
-/**
- * Writes an array of numbers formatted as strings to the buffer as a repeated
- * unsigned 64-bit int field.
- * @param {number} field The field number.
- * @param {?Array.<string>} value The array of ints to write.
- */
-jspb.BinaryWriter.prototype.writeRepeatedUint64String =
- function(field, value) {
+jspb.BinaryWriter.prototype.writeRepeatedSint32 = function(field, value) {
if (value == null) return;
for (var i = 0; i < value.length; i++) {
- this.writeUint64String(field, value[i]);
+ this.writeZigzagVarint32_(field, value[i]);
}
};
/**
- * Writes an array numbers to the buffer as a repeated signed 32-bit int field.
+ * Writes an array numbers to the buffer as a repeated signed 64-bit int field.
* @param {number} field The field number.
* @param {?Array.<number>} value The array of ints to write.
*/
-jspb.BinaryWriter.prototype.writeRepeatedSint32 =
- jspb.BinaryWriter.prototype.writeRepeatedZigzag32_;
+jspb.BinaryWriter.prototype.writeRepeatedSint64 = function(field, value) {
+ if (value == null) return;
+ for (var i = 0; i < value.length; i++) {
+ this.writeZigzagVarint64_(field, value[i]);
+ }
+};
/**
* Writes an array numbers to the buffer as a repeated signed 64-bit int field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array.<string>} value The array of ints to write.
*/
-jspb.BinaryWriter.prototype.writeRepeatedSint64 =
- jspb.BinaryWriter.prototype.writeRepeatedZigzag_;
+jspb.BinaryWriter.prototype.writeRepeatedSint64String = function(field, value) {
+ if (value == null) return;
+ for (var i = 0; i < value.length; i++) {
+ this.writeZigzagVarint64String_(field, value[i]);
+ }
+};
/**
@@ -1028,6 +1028,21 @@ jspb.BinaryWriter.prototype.writeRepeatedFixed64 = function(field, value) {
/**
+ * Writes an array of numbers to the buffer as a repeated fixed64 field. This
+ * works for both signed and unsigned fixed64s.
+ * @param {number} field The field number.
+ * @param {?Array.<string>} value The array of decimal strings to write.
+ */
+jspb.BinaryWriter.prototype.writeRepeatedFixed64String = function(
+ field, value) {
+ if (value == null) return;
+ for (var i = 0; i < value.length; i++) {
+ this.writeFixed64String(field, value[i]);
+ }
+};
+
+
+/**
* Writes an array of numbers to the buffer as a repeated sfixed32 field.
* @param {number} field The field number.
* @param {?Array.<number>} value The array of ints to write.
@@ -1054,6 +1069,20 @@ jspb.BinaryWriter.prototype.writeRepeatedSfixed64 = function(field, value) {
/**
+ * Writes an array of decimal strings to the buffer as a repeated sfixed64
+ * field.
+ * @param {number} field The field number.
+ * @param {?Array.<string>} value The array of decimal strings to write.
+ */
+jspb.BinaryWriter.prototype.writeRepeatedSfixed64String = function(field, value) {
+ if (value == null) return;
+ for (var i = 0; i < value.length; i++) {
+ this.writeSfixed64String(field, value[i]);
+ }
+};
+
+
+/**
* Writes an array of numbers to the buffer as a repeated float field.
* @param {number} field The field number.
* @param {?Array.<number>} value The array of ints to write.
@@ -1203,151 +1232,127 @@ jspb.BinaryWriter.prototype.writeRepeatedVarintHash64 =
/**
- * Writes an array of numbers to the buffer as a packed varint field.
+ * Writes an array of numbers to the buffer as a packed 32-bit int field.
* @param {number} field The field number.
* @param {?Array.<number>} value The array of ints to write.
- * @private
*/
-jspb.BinaryWriter.prototype.writePackedUnsignedVarint32_ = function(
- field, value) {
+jspb.BinaryWriter.prototype.writePackedInt32 = function(field, value) {
if (value == null || !value.length) return;
var bookmark = this.beginDelimited_(field);
for (var i = 0; i < value.length; i++) {
- this.encoder_.writeUnsignedVarint32(value[i]);
+ this.encoder_.writeSignedVarint32(value[i]);
}
this.endDelimited_(bookmark);
};
/**
- * Writes an array of numbers to the buffer as a packed varint field.
- * @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
- * @private
+ * Writes an array of numbers represented as strings to the buffer as a packed
+ * 32-bit int field.
+ * @param {number} field
+ * @param {?Array.<string>} value
*/
-jspb.BinaryWriter.prototype.writePackedSignedVarint32_ = function(
- field, value) {
+jspb.BinaryWriter.prototype.writePackedInt32String = function(field, value) {
if (value == null || !value.length) return;
var bookmark = this.beginDelimited_(field);
for (var i = 0; i < value.length; i++) {
- this.encoder_.writeSignedVarint32(value[i]);
+ this.encoder_.writeSignedVarint32(parseInt(value[i], 10));
}
this.endDelimited_(bookmark);
};
/**
- * Writes an array of numbers to the buffer as a packed varint field.
+ * Writes an array of numbers to the buffer as a packed 64-bit int field.
* @param {number} field The field number.
* @param {?Array.<number>} value The array of ints to write.
- * @private
*/
-jspb.BinaryWriter.prototype.writePackedUnsignedVarint64_ = function(
- field, value) {
+jspb.BinaryWriter.prototype.writePackedInt64 = function(field, value) {
if (value == null || !value.length) return;
var bookmark = this.beginDelimited_(field);
for (var i = 0; i < value.length; i++) {
- this.encoder_.writeUnsignedVarint64(value[i]);
+ this.encoder_.writeSignedVarint64(value[i]);
}
this.endDelimited_(bookmark);
};
/**
- * Writes an array of numbers to the buffer as a packed varint field.
- * @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
- * @private
+ * Writes an array of numbers represented as strings to the buffer as a packed
+ * 64-bit int field.
+ * @param {number} field
+ * @param {?Array.<string>} value
*/
-jspb.BinaryWriter.prototype.writePackedSignedVarint64_ = function(
- field, value) {
+jspb.BinaryWriter.prototype.writePackedInt64String = function(field, value) {
if (value == null || !value.length) return;
var bookmark = this.beginDelimited_(field);
for (var i = 0; i < value.length; i++) {
- this.encoder_.writeSignedVarint64(value[i]);
+ var num = jspb.arith.Int64.fromString(value[i]);
+ this.encoder_.writeSplitVarint64(num.lo, num.hi);
}
this.endDelimited_(bookmark);
};
/**
- * Writes an array of numbers to the buffer as a packed zigzag field.
+ * Writes an array numbers to the buffer as a packed unsigned 32-bit int field.
* @param {number} field The field number.
* @param {?Array.<number>} value The array of ints to write.
- * @private
*/
-jspb.BinaryWriter.prototype.writePackedZigzag32_ = function(field, value) {
+jspb.BinaryWriter.prototype.writePackedUint32 = function(field, value) {
if (value == null || !value.length) return;
var bookmark = this.beginDelimited_(field);
for (var i = 0; i < value.length; i++) {
- this.encoder_.writeZigzagVarint32(value[i]);
+ this.encoder_.writeUnsignedVarint32(value[i]);
}
this.endDelimited_(bookmark);
};
/**
- * Writes an array of numbers to the buffer as a packed zigzag field.
- * @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
- * @private
+ * Writes an array of numbers represented as strings to the buffer as a packed
+ * unsigned 32-bit int field.
+ * @param {number} field
+ * @param {?Array.<string>} value
*/
-jspb.BinaryWriter.prototype.writePackedZigzag64_ = function(field, value) {
+jspb.BinaryWriter.prototype.writePackedUint32String =
+ function(field, value) {
if (value == null || !value.length) return;
var bookmark = this.beginDelimited_(field);
for (var i = 0; i < value.length; i++) {
- this.encoder_.writeZigzagVarint64(value[i]);
+ this.encoder_.writeUnsignedVarint32(parseInt(value[i], 10));
}
this.endDelimited_(bookmark);
};
/**
- * Writes an array of numbers to the buffer as a packed 32-bit int field.
+ * Writes an array numbers to the buffer as a packed unsigned 64-bit int field.
* @param {number} field The field number.
* @param {?Array.<number>} value The array of ints to write.
*/
-jspb.BinaryWriter.prototype.writePackedInt32 =
- jspb.BinaryWriter.prototype.writePackedSignedVarint32_;
-
-
-/**
- * Writes an array of numbers represented as strings to the buffer as a packed
- * 32-bit int field.
- * @param {number} field
- * @param {?Array.<string>} value
- */
-jspb.BinaryWriter.prototype.writePackedInt32String = function(field, value) {
+jspb.BinaryWriter.prototype.writePackedUint64 = function(field, value) {
if (value == null || !value.length) return;
var bookmark = this.beginDelimited_(field);
for (var i = 0; i < value.length; i++) {
- this.encoder_.writeSignedVarint32(parseInt(value[i], 10));
+ this.encoder_.writeUnsignedVarint64(value[i]);
}
this.endDelimited_(bookmark);
};
/**
- * Writes an array of numbers to the buffer as a packed 64-bit int field.
- * @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
- */
-jspb.BinaryWriter.prototype.writePackedInt64 =
- jspb.BinaryWriter.prototype.writePackedSignedVarint64_;
-
-
-/**
* Writes an array of numbers represented as strings to the buffer as a packed
- * 64-bit int field.
+ * unsigned 64-bit int field.
* @param {number} field
* @param {?Array.<string>} value
*/
-jspb.BinaryWriter.prototype.writePackedInt64String =
+jspb.BinaryWriter.prototype.writePackedUint64String =
function(field, value) {
if (value == null || !value.length) return;
var bookmark = this.beginDelimited_(field);
for (var i = 0; i < value.length; i++) {
- var num = jspb.arith.Int64.fromString(value[i]);
+ var num = jspb.arith.UInt64.fromString(value[i]);
this.encoder_.writeSplitVarint64(num.lo, num.hi);
}
this.endDelimited_(bookmark);
@@ -1355,74 +1360,50 @@ jspb.BinaryWriter.prototype.writePackedInt64String =
/**
- * Writes an array numbers to the buffer as a packed unsigned 32-bit int field.
+ * Writes an array numbers to the buffer as a packed signed 32-bit int field.
* @param {number} field The field number.
* @param {?Array.<number>} value The array of ints to write.
*/
-jspb.BinaryWriter.prototype.writePackedUint32 =
- jspb.BinaryWriter.prototype.writePackedUnsignedVarint32_;
-
-
-/**
- * Writes an array of numbers represented as strings to the buffer as a packed
- * unsigned 32-bit int field.
- * @param {number} field
- * @param {?Array.<string>} value
- */
-jspb.BinaryWriter.prototype.writePackedUint32String =
- function(field, value) {
+jspb.BinaryWriter.prototype.writePackedSint32 = function(field, value) {
if (value == null || !value.length) return;
var bookmark = this.beginDelimited_(field);
for (var i = 0; i < value.length; i++) {
- this.encoder_.writeUnsignedVarint32(parseInt(value[i], 10));
+ this.encoder_.writeZigzagVarint32(value[i]);
}
this.endDelimited_(bookmark);
};
/**
- * Writes an array numbers to the buffer as a packed unsigned 64-bit int field.
+ * Writes an array of numbers to the buffer as a packed signed 64-bit int field.
* @param {number} field The field number.
* @param {?Array.<number>} value The array of ints to write.
*/
-jspb.BinaryWriter.prototype.writePackedUint64 =
- jspb.BinaryWriter.prototype.writePackedUnsignedVarint64_;
-
-
-/**
- * Writes an array of numbers represented as strings to the buffer as a packed
- * unsigned 64-bit int field.
- * @param {number} field
- * @param {?Array.<string>} value
- */
-jspb.BinaryWriter.prototype.writePackedUint64String =
- function(field, value) {
+jspb.BinaryWriter.prototype.writePackedSint64 = function(field, value) {
if (value == null || !value.length) return;
var bookmark = this.beginDelimited_(field);
for (var i = 0; i < value.length; i++) {
- var num = jspb.arith.UInt64.fromString(value[i]);
- this.encoder_.writeSplitVarint64(num.lo, num.hi);
+ this.encoder_.writeZigzagVarint64(value[i]);
}
this.endDelimited_(bookmark);
};
/**
- * Writes an array numbers to the buffer as a packed signed 32-bit int field.
+ * Writes an array of decimal strings to the buffer as a packed signed 64-bit
+ * int field.
* @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
+ * @param {?Array.<string>} value The array of decimal strings to write.
*/
-jspb.BinaryWriter.prototype.writePackedSint32 =
- jspb.BinaryWriter.prototype.writePackedZigzag32_;
-
-
-/**
- * Writes an array numbers to the buffer as a packed signed 64-bit int field.
- * @param {number} field The field number.
- * @param {?Array.<number>} value The array of ints to write.
- */
-jspb.BinaryWriter.prototype.writePackedSint64 =
- jspb.BinaryWriter.prototype.writePackedZigzag64_;
+jspb.BinaryWriter.prototype.writePackedSint64String = function(field, value) {
+ if (value == null || !value.length) return;
+ var bookmark = this.beginDelimited_(field);
+ for (var i = 0; i < value.length; i++) {
+ // TODO(haberman): make lossless
+ this.encoder_.writeZigzagVarint64(parseInt(value[i], 10));
+ }
+ this.endDelimited_(bookmark);
+};
/**
@@ -1456,6 +1437,23 @@ jspb.BinaryWriter.prototype.writePackedFixed64 = function(field, value) {
/**
+ * Writes an array of numbers represented as strings to the buffer as a packed
+ * fixed64 field.
+ * @param {number} field The field number.
+ * @param {?Array.<string>} value The array of strings to write.
+ */
+jspb.BinaryWriter.prototype.writePackedFixed64String = function(field, value) {
+ if (value == null || !value.length) return;
+ this.writeFieldHeader_(field, jspb.BinaryConstants.WireType.DELIMITED);
+ this.encoder_.writeUnsignedVarint32(value.length * 8);
+ for (var i = 0; i < value.length; i++) {
+ var num = jspb.arith.UInt64.fromString(value[i]);
+ this.encoder_.writeSplitFixed64(num.lo, num.hi);
+ }
+};
+
+
+/**
* Writes an array of numbers to the buffer as a packed sfixed32 field.
* @param {number} field The field number.
* @param {?Array.<number>} value The array of ints to write.
@@ -1486,6 +1484,21 @@ jspb.BinaryWriter.prototype.writePackedSfixed64 = function(field, value) {
/**
+ * Writes an array of numbers to the buffer as a packed sfixed64 field.
+ * @param {number} field The field number.
+ * @param {?Array.<string>} value The array of decimal strings to write.
+ */
+jspb.BinaryWriter.prototype.writePackedSfixed64String = function(field, value) {
+ if (value == null || !value.length) return;
+ this.writeFieldHeader_(field, jspb.BinaryConstants.WireType.DELIMITED);
+ this.encoder_.writeUnsignedVarint32(value.length * 8);
+ for (var i = 0; i < value.length; i++) {
+ this.encoder_.writeInt64String(value[i]);
+ }
+};
+
+
+/**
* Writes an array of numbers to the buffer as a packed float field.
* @param {number} field The field number.
* @param {?Array.<number>} value The array of ints to write.
diff --git a/js/commonjs/export.js b/js/commonjs/export.js
index 2403b1a4..1eaab5d5 100644
--- a/js/commonjs/export.js
+++ b/js/commonjs/export.js
@@ -24,3 +24,4 @@ exports.ExtensionFieldBinaryInfo = jspb.ExtensionFieldBinaryInfo;
exports.exportSymbol = goog.exportSymbol;
exports.inherits = goog.inherits;
exports.object = {extend: goog.object.extend};
+exports.typeOf = goog.typeOf;
diff --git a/js/commonjs/export_testdeps.js b/js/commonjs/export_testdeps.js
index 59c77ca2..174c61e6 100644
--- a/js/commonjs/export_testdeps.js
+++ b/js/commonjs/export_testdeps.js
@@ -12,6 +12,7 @@ goog.require('jspb.arith.Int64');
goog.require('jspb.arith.UInt64');
goog.require('jspb.BinaryEncoder');
goog.require('jspb.BinaryDecoder');
+goog.require('jspb.BinaryWriter');
goog.require('jspb.utils');
exports.goog = goog;
diff --git a/js/gulpfile.js b/js/gulpfile.js
index cca99131..5f1b1d93 100644
--- a/js/gulpfile.js
+++ b/js/gulpfile.js
@@ -24,7 +24,7 @@ var wellKnownTypes = [
];
gulp.task('genproto_closure', function (cb) {
- exec(protoc + ' --js_out=library=testproto_libs,binary:. -I ../src -I . *.proto ../src/google/protobuf/descriptor.proto',
+ exec(protoc + ' --js_out=library=testproto_libs,binary:. -I ../src -I . *.proto && ' + protoc + ' --js_out=one_output_file_per_input_file,binary:. -I ../src -I . ' + wellKnownTypes.join(' '),
function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
@@ -33,7 +33,7 @@ gulp.task('genproto_closure', function (cb) {
});
gulp.task('genproto_commonjs', function (cb) {
- exec('mkdir -p commonjs_out && ' + protoc + ' --js_out=import_style=commonjs,binary:commonjs_out -I ../src -I commonjs -I . *.proto commonjs/test*/*.proto ../src/google/protobuf/descriptor.proto',
+ exec('mkdir -p commonjs_out && ' + protoc + ' --js_out=import_style=commonjs,binary:commonjs_out -I ../src -I commonjs -I . *.proto commonjs/test*/*.proto ' + wellKnownTypes.join(' '),
function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
@@ -42,7 +42,7 @@ gulp.task('genproto_commonjs', function (cb) {
});
gulp.task('genproto_commonjs_wellknowntypes', function (cb) {
- exec('mkdir -p commonjs_out/node_modules/google-protobuf && ' + protoc + ' --js_out=import_style=commonjs,binary:commonjs_out/node_modules/google-protobuf -I ../src ../src/google/protobuf/descriptor.proto',
+ exec('mkdir -p commonjs_out/node_modules/google-protobuf && ' + protoc + ' --js_out=import_style=commonjs,binary:commonjs_out/node_modules/google-protobuf -I ../src ' + wellKnownTypes.join(' '),
function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
diff --git a/js/jasmine.json b/js/jasmine.json
index f83c54c0..093f1579 100644
--- a/js/jasmine.json
+++ b/js/jasmine.json
@@ -7,6 +7,9 @@
"helpers": [
"node_modules/google-closure-library/closure/goog/bootstrap/nodejs.js",
"node_loader.js",
- "deps.js"
+ "deps.js",
+ "google/protobuf/any.js",
+ "google/protobuf/struct.js",
+ "google/protobuf/timestamp.js"
]
}
diff --git a/js/map.js b/js/map.js
index 0f8401c4..4f562dbc 100644
--- a/js/map.js
+++ b/js/map.js
@@ -131,25 +131,90 @@ jspb.Map.prototype.toArray = function() {
/**
- * Helper: return an iterator over an array.
+ * Returns the map formatted as an array of key-value pairs, suitable for the
+ * toObject() form of a message.
+ *
+ * @param {boolean=} includeInstance Whether to include the JSPB instance for
+ * transitional soy proto support: http://goto/soy-param-migration
+ * @param {!function((boolean|undefined),!V):!Object=} valueToObject
+ * The static toObject() method, if V is a message type.
+ * @return {!Array<!Array<!Object>>}
+ */
+jspb.Map.prototype.toObject = function(includeInstance, valueToObject) {
+ var rawArray = this.toArray();
+ var entries = [];
+ for (var i = 0; i < rawArray.length; i++) {
+ var entry = this.map_[rawArray[i][0].toString()];
+ this.wrapEntry_(entry);
+ var valueWrapper = /** @type {!V|undefined} */ (entry.valueWrapper);
+ if (valueWrapper) {
+ goog.asserts.assert(valueToObject);
+ entries.push([entry.key, valueToObject(includeInstance, valueWrapper)]);
+ } else {
+ entries.push([entry.key, entry.value]);
+ }
+ }
+ return entries;
+};
+
+
+/**
+ * Returns a Map from the given array of key-value pairs when the values are of
+ * message type. The values in the array must match the format returned by their
+ * message type's toObject() method.
+ *
+ * @template K, V
+ * @param {!Array<!Array<!Object>>} entries
+ * @param {!function(new:V)|function(new:V,?)} valueCtor
+ * The constructor for type V.
+ * @param {!function(!Object):V} valueFromObject
+ * The fromObject function for type V.
+ * @return {!jspb.Map<K, V>}
+ */
+jspb.Map.fromObject = function(entries, valueCtor, valueFromObject) {
+ var result = new jspb.Map([], valueCtor);
+ for (var i = 0; i < entries.length; i++) {
+ var key = entries[i][0];
+ var value = valueFromObject(entries[i][1]);
+ result.set(key, value);
+ }
+ return result;
+};
+
+
+/**
+ * Helper: an IteratorIterable over an array.
* @template T
* @param {!Array<T>} arr the array
- * @return {!Iterator<T>} an iterator
+ * @implements {IteratorIterable<T>}
+ * @constructor @struct
* @private
*/
-jspb.Map.arrayIterator_ = function(arr) {
- var idx = 0;
- return /** @type {!Iterator} */ ({
- next: function() {
- if (idx < arr.length) {
- return { done: false, value: arr[idx++] };
- } else {
- return { done: true };
- }
- }
- });
+jspb.Map.ArrayIteratorIterable_ = function(arr) {
+ /** @type {number} @private */
+ this.idx_ = 0;
+
+ /** @const @private */
+ this.arr_ = arr;
+};
+
+
+/** @override @final */
+jspb.Map.ArrayIteratorIterable_.prototype.next = function() {
+ if (this.idx_ < this.arr_.length) {
+ return {done: false, value: this.arr_[this.idx_++]};
+ } else {
+ return {done: true, value: undefined};
+ }
};
+if (typeof(Symbol) != 'undefined') {
+ /** @override */
+ jspb.Map.ArrayIteratorIterable_.prototype[Symbol.iterator] = function() {
+ return this;
+ };
+}
+
/**
* Returns the map's length (number of key/value pairs).
@@ -193,7 +258,7 @@ jspb.Map.prototype.del = function(key) {
* to help out Angular 1.x users. Still evaluating whether this is the best
* option.
*
- * @return {!Array<K|V>}
+ * @return {!Array<!Array<K|V>>}
*/
jspb.Map.prototype.getEntryList = function() {
var entries = [];
@@ -208,10 +273,9 @@ jspb.Map.prototype.getEntryList = function() {
/**
- * Returns an iterator over [key, value] pairs in the map.
+ * Returns an iterator-iterable over [key, value] pairs in the map.
* Closure compiler sadly doesn't support tuples, ie. Iterator<[K,V]>.
- * @return {!Iterator<!Array<K|V>>}
- * The iterator
+ * @return {!IteratorIterable<!Array<K|V>>} The iterator-iterable.
*/
jspb.Map.prototype.entries = function() {
var entries = [];
@@ -221,13 +285,13 @@ jspb.Map.prototype.entries = function() {
var entry = this.map_[strKeys[i]];
entries.push([entry.key, this.wrapEntry_(entry)]);
}
- return jspb.Map.arrayIterator_(entries);
+ return new jspb.Map.ArrayIteratorIterable_(entries);
};
/**
- * Returns an iterator over keys in the map.
- * @return {!Iterator<K>} The iterator
+ * Returns an iterator-iterable over keys in the map.
+ * @return {!IteratorIterable<K>} The iterator-iterable.
*/
jspb.Map.prototype.keys = function() {
var keys = [];
@@ -237,13 +301,13 @@ jspb.Map.prototype.keys = function() {
var entry = this.map_[strKeys[i]];
keys.push(entry.key);
}
- return jspb.Map.arrayIterator_(keys);
+ return new jspb.Map.ArrayIteratorIterable_(keys);
};
/**
- * Returns an iterator over values in the map.
- * @return {!Iterator<V>} The iterator
+ * Returns an iterator-iterable over values in the map.
+ * @return {!IteratorIterable<V>} The iterator-iterable.
*/
jspb.Map.prototype.values = function() {
var values = [];
@@ -253,7 +317,7 @@ jspb.Map.prototype.values = function() {
var entry = this.map_[strKeys[i]];
values.push(this.wrapEntry_(entry));
}
- return jspb.Map.arrayIterator_(values);
+ return new jspb.Map.ArrayIteratorIterable_(values);
};
diff --git a/js/maps_test.js b/js/maps_test.js
index 0d442f4f..e8dd2f21 100755
--- a/js/maps_test.js
+++ b/js/maps_test.js
@@ -262,6 +262,7 @@ function makeTests(msgInfo, submessageCtor, suffix) {
});
}
+
/**
* Exercises the lazy map<->underlying array sync.
*/
@@ -287,15 +288,63 @@ function makeTests(msgInfo, submessageCtor, suffix) {
var a = msg.toArray();
assertEquals(a[0], entries); // retains original reference
});
+
+ /**
+ * Returns IteratorIterables for entries(), keys() and values().
+ */
+ it('testIteratorIterables' + suffix, function() {
+ var msg = new msgInfo.constructor();
+ var m = msg.getMapStringStringMap();
+ m.set('key1', 'value1');
+ m.set('key2', 'value2');
+ var entryIterator = m.entries();
+ assertElementsEquals(entryIterator.next().value, ['key1', 'value1']);
+ assertElementsEquals(entryIterator.next().value, ['key2', 'value2']);
+ assertEquals(entryIterator.next().done, true);
+
+ if (typeof(Symbol) != 'undefined') {
+ var entryIterable = m.entries()[Symbol.iterator]();
+ assertElementsEquals(entryIterable.next().value, ['key1', 'value1']);
+ assertElementsEquals(entryIterable.next().value, ['key2', 'value2']);
+ assertEquals(entryIterable.next().done, true);
+ }
+
+ var keyIterator = m.keys();
+ assertEquals(keyIterator.next().value, 'key1');
+ assertEquals(keyIterator.next().value, 'key2');
+ assertEquals(keyIterator.next().done, true);
+
+ if (typeof(Symbol) != 'undefined') {
+ var keyIterable = m.keys()[Symbol.iterator]();
+ assertEquals(keyIterable.next().value, 'key1');
+ assertEquals(keyIterable.next().value, 'key2');
+ assertEquals(keyIterable.next().done, true);
+ }
+ var valueIterator = m.values();
+ assertEquals(valueIterator.next().value, 'value1');
+ assertEquals(valueIterator.next().value, 'value2');
+ assertEquals(valueIterator.next().done, true);
+
+ if (typeof(Symbol) != 'undefined') {
+ var valueIterable = m.values()[Symbol.iterator]();
+ assertEquals(valueIterable.next().value, 'value1');
+ assertEquals(valueIterable.next().value, 'value2');
+ assertEquals(valueIterable.next().done, true);
+ }
+ });
}
describe('mapsTest', function() {
- makeTests({
- constructor: proto.jspb.test.TestMapFields,
- deserializeBinary: proto.jspb.test.TestMapFields.deserializeBinary
- }, proto.jspb.test.MapValueMessage, "_Binary");
- makeTests({
- constructor: proto.jspb.test.TestMapFieldsNoBinary,
- deserializeBinary: null
- }, proto.jspb.test.MapValueMessageNoBinary, "_NoBinary");
+ makeTests(
+ {
+ constructor: proto.jspb.test.TestMapFields,
+ deserializeBinary: proto.jspb.test.TestMapFields.deserializeBinary
+ },
+ proto.jspb.test.MapValueMessage, '_Binary');
+ makeTests(
+ {
+ constructor: proto.jspb.test.TestMapFieldsNoBinary,
+ deserializeBinary: null
+ },
+ proto.jspb.test.MapValueMessageNoBinary, '_NoBinary');
});
diff --git a/js/message.js b/js/message.js
index 8def763e..05d34e9d 100644
--- a/js/message.js
+++ b/js/message.js
@@ -175,6 +175,22 @@ goog.define('jspb.Message.GENERATE_FROM_OBJECT', !goog.DISALLOW_TEST_ONLY_CODE);
/**
+ * @define {boolean} Whether to generate toString methods for objects. Turn
+ * this off if you do use toString in your project and want to trim it from
+ * compiled JS.
+ */
+goog.define('jspb.Message.GENERATE_TO_STRING', true);
+
+
+/**
+ * @define {boolean} Whether arrays passed to initialize() can be assumed to be
+ * local (e.g. not from another iframe) and thus safely classified with
+ * instanceof Array.
+ */
+goog.define('jspb.Message.ASSUME_LOCAL_ARRAYS', false);
+
+
+/**
* @define {boolean} Turning on this flag does NOT change the behavior of JSPB
* and only affects private internal state. It may, however, break some
* tests that use naive deeply-equals algorithms, because using a proto
@@ -364,6 +380,18 @@ jspb.Message.EMPTY_LIST_SENTINEL_ = goog.DEBUG && Object.freeze ?
/**
+ * Returns true if the provided argument is an array.
+ * @param {*} o The object to classify as array or not.
+ * @return {boolean} True if the provided object is an array.
+ * @private
+ */
+jspb.Message.isArray_ = function(o) {
+ return jspb.Message.ASSUME_LOCAL_ARRAYS ? o instanceof Array :
+ goog.isArray(o);
+};
+
+
+/**
* Ensures that the array contains an extension object if necessary.
* If the array contains an extension object in its last position, then the
* object is kept in place and its position is used as the pivot. If not, then
@@ -383,8 +411,8 @@ jspb.Message.materializeExtensionObject_ = function(msg, suggestedPivot) {
// the object is not an array, since arrays are valid field values.
// NOTE(lukestebbing): We avoid looking at .length to avoid a JIT bug
// in Safari on iOS 8. See the description of CL/86511464 for details.
- if (obj && typeof obj == 'object' && !goog.isArray(obj) &&
- !(jspb.Message.SUPPORTS_UINT8ARRAY_ && obj instanceof Uint8Array)) {
+ if (obj && typeof obj == 'object' && !jspb.Message.isArray_(obj) &&
+ !(jspb.Message.SUPPORTS_UINT8ARRAY_ && obj instanceof Uint8Array)) {
msg.pivot_ = foundIndex - msg.arrayIndexOffset_;
msg.extensionObject_ = obj;
return;
@@ -550,11 +578,11 @@ jspb.Message.serializeBinaryExtensions = function(proto, writer, extensions,
jspb.Message.readBinaryExtension = function(msg, reader, extensions,
getExtensionFn, setExtensionFn) {
var binaryFieldInfo = extensions[reader.getFieldNumber()];
- var fieldInfo = binaryFieldInfo.fieldInfo;
if (!binaryFieldInfo) {
reader.skipField();
return;
}
+ var fieldInfo = binaryFieldInfo.fieldInfo;
if (!binaryFieldInfo.binaryReaderFn) {
throw new Error('Deserializing extension whose generated code does not ' +
'support binary format');
@@ -972,7 +1000,8 @@ jspb.Message.wrapRepeatedField_ = function(msg, ctor, fieldNumber) {
* Sets a proto field and syncs it to the backing array.
* @param {!jspb.Message} msg A jspb proto.
* @param {number} fieldNumber The field number.
- * @param {jspb.Message|undefined} value A new value for this proto field.
+ * @param {?jspb.Message|?jspb.Map|undefined} value A new value for this proto
+ * field.
* @protected
*/
jspb.Message.setWrapperField = function(msg, fieldNumber, value) {
@@ -1139,6 +1168,7 @@ jspb.Message.prototype.toArray = function() {
+if (jspb.Message.GENERATE_TO_STRING) {
/**
* Creates a string representation of the internal data array of this proto.
@@ -1151,6 +1181,7 @@ jspb.Message.prototype.toString = function() {
return this.array.toString();
};
+}
/**
* Gets the value of the extension field from the extended object.
diff --git a/js/message_test.js b/js/message_test.js
index b0a0a72e..a2c5763d 100644
--- a/js/message_test.js
+++ b/js/message_test.js
@@ -39,6 +39,9 @@ goog.require('goog.userAgent');
// CommonJS-LoadFromFile: google-protobuf jspb
goog.require('jspb.Message');
+// CommonJS-LoadFromFile: test8_pb proto.jspb.exttest.nested
+goog.require('proto.jspb.exttest.nested.TestOuterMessage');
+
// CommonJS-LoadFromFile: test5_pb proto.jspb.exttest.beta
goog.require('proto.jspb.exttest.beta.floatingStrField');
@@ -586,6 +589,14 @@ describe('Message test suite', function() {
assertNotUndefined(proto.jspb.exttest.beta.floatingStrField);
});
+ it('testNestedExtensions', function() {
+ var extendable = new proto.jspb.exttest.nested.TestNestedExtensionsMessage();
+ var extension = new proto.jspb.exttest.nested.TestOuterMessage.NestedExtensionMessage(['s1']);
+ extendable.setExtension(proto.jspb.exttest.nested.TestOuterMessage.innerExtension, extension);
+ assertObjectEquals(extension,
+ extendable.getExtension(proto.jspb.exttest.nested.TestOuterMessage.innerExtension));
+ });
+
it('testToObject_extendedObject', function() {
var extension1 = new proto.jspb.test.IsExtension(['ext1field']);
var extension2 = new proto.jspb.test.Simple1(['str', ['s1', 's2'], true]);
@@ -1040,18 +1051,4 @@ describe('Message test suite', function() {
assertNan(message.getDefaultDoubleField());
});
- // Verify that we can successfully use a field referring to a nested message
- // from a different .proto file.
- it('testForeignNestedMessage', function() {
- var msg = new proto.jspb.test.ForeignNestedFieldMessage();
- var nested = new proto.jspb.test.Deeply.Nested.Message();
- nested.setCount(5);
- msg.setDeeplyNestedMessage(nested);
-
- // After a serialization-deserialization round trip we should get back the
- // same data we started with.
- var serialized = msg.serializeBinary();
- var deserialized = proto.jspb.test.ForeignNestedFieldMessage.deserializeBinary(serialized);
- assertEquals(5, deserialized.getDeeplyNestedMessage().getCount());
- });
});
diff --git a/js/package.json b/js/package.json
index ee4181ff..dd6373de 100644
--- a/js/package.json
+++ b/js/package.json
@@ -1,6 +1,6 @@
{
"name": "google-protobuf",
- "version": "3.1.0",
+ "version": "3.2.0",
"description": "Protocol Buffers for JavaScript",
"main": "google-protobuf.js",
"files": [
@@ -22,5 +22,5 @@
"url": "https://github.com/google/protobuf/tree/master/js"
},
"author": "Google Protocol Buffers Team",
- "license": "Apache-2.0"
+ "license" : "BSD-3-Clause"
}
diff --git a/js/proto3_test.js b/js/proto3_test.js
index 3c929eff..81d6de2f 100644
--- a/js/proto3_test.js
+++ b/js/proto3_test.js
@@ -38,6 +38,12 @@ goog.require('proto.jspb.test.ForeignMessage');
goog.require('proto.jspb.test.Proto3Enum');
goog.require('proto.jspb.test.TestProto3');
+// CommonJS-LoadFromFile: google/protobuf/timestamp_pb proto.google.protobuf
+goog.require('proto.google.protobuf.Timestamp');
+
+// CommonJS-LoadFromFile: google/protobuf/struct_pb proto.google.protobuf
+goog.require('proto.google.protobuf.Struct');
+
var BYTES = new Uint8Array([1, 2, 8, 9]);
var BYTES_B64 = goog.crypt.base64.encodeByteArray(BYTES);
@@ -326,4 +332,36 @@ describe('proto3Test', function() {
assertTrue(bytesCompare(msg.getOptionalBytes(), BYTES));
});
+
+ it('testTimestampWellKnownType', function() {
+ var msg = new proto.google.protobuf.Timestamp();
+ msg.fromDate(new Date(123456789));
+ assertEquals(123456, msg.getSeconds());
+ assertEquals(789000000, msg.getNanos());
+ var date = msg.toDate();
+ assertEquals(123456789, date.getTime());
+ });
+
+ it('testStructWellKnownType', function() {
+ var jsObj = {
+ abc: "def",
+ number: 12345.678,
+ nullKey: null,
+ boolKey: true,
+ listKey: [1, null, true, false, "abc"],
+ structKey: {foo: "bar", somenum: 123},
+ complicatedKey: [{xyz: {abc: [3, 4, null, false]}}, "zzz"]
+ };
+
+ var struct = proto.google.protobuf.Struct.fromJavaScript(jsObj);
+ var jsObj2 = struct.toJavaScript();
+
+ assertEquals("def", jsObj2.abc);
+ assertEquals(12345.678, jsObj2.number);
+ assertEquals(null, jsObj2.nullKey);
+ assertEquals(true, jsObj2.boolKey);
+ assertEquals("abc", jsObj2.listKey[4]);
+ assertEquals("bar", jsObj2.structKey.foo);
+ assertEquals(4, jsObj2.complicatedKey[0].xyz.abc[1]);
+ });
});
diff --git a/js/test.proto b/js/test.proto
index db238e1a..2be5b8c1 100644
--- a/js/test.proto
+++ b/js/test.proto
@@ -234,7 +234,9 @@ message TestEndsWithBytes {
optional bytes data = 2;
}
+
message TestMapFieldsNoBinary {
+
map<string, string> map_string_string = 1;
map<string, int32> map_string_int32 = 2;
map<string, int64> map_string_int64 = 3;
@@ -258,6 +260,7 @@ enum MapValueEnumNoBinary {
}
message MapValueMessageNoBinary {
+
optional int32 foo = 1;
}
diff --git a/js/test8.proto b/js/test8.proto
new file mode 100644
index 00000000..2ae80dab
--- /dev/null
+++ b/js/test8.proto
@@ -0,0 +1,50 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto2";
+
+option java_package = "com.google.apps.jspb.proto";
+option java_multiple_files = true;
+
+package jspb.exttest.nested;
+
+message TestNestedExtensionsMessage {
+ optional int32 intfield = 1;
+ extensions 100 to max;
+}
+
+message TestOuterMessage {
+ message NestedExtensionMessage {
+ optional string ext1 = 1;
+ }
+ extend TestNestedExtensionsMessage {
+ optional NestedExtensionMessage inner_extension = 100;
+ }
+}
diff --git a/m4/ax_cxx_compile_stdcxx.m4 b/m4/ax_cxx_compile_stdcxx.m4
new file mode 100644
index 00000000..b61fcb63
--- /dev/null
+++ b/m4/ax_cxx_compile_stdcxx.m4
@@ -0,0 +1,982 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional])
+#
+# DESCRIPTION
+#
+# Check for baseline language coverage in the compiler for the specified
+# version of the C++ standard. If necessary, add switches to CXX and
+# CXXCPP to enable support. VERSION may be '11' (for the C++11 standard)
+# or '14' (for the C++14 standard).
+#
+# The second argument, if specified, indicates whether you insist on an
+# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
+# -std=c++11). If neither is specified, you get whatever works, with
+# preference for an extended mode.
+#
+# The third argument, if specified 'mandatory' or if left unspecified,
+# indicates that baseline support for the specified C++ standard is
+# required and that the macro should error out if no mode with that
+# support is found. If specified 'optional', then configuration proceeds
+# regardless, after defining HAVE_CXX${VERSION} if and only if a
+# supporting mode is found.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
+# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
+# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
+# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
+# Copyright (c) 2015 Paul Norman <penorman@mac.com>
+# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
+# Copyright (c) 2016 Krzesimir Nowak <qdlacz@gmail.com>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 6
+
+dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
+dnl (serial version number 13).
+
+AX_REQUIRE_DEFINED([AC_MSG_WARN])
+AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
+ m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"],
+ [$1], [14], [ax_cxx_compile_alternatives="14 1y"],
+ [$1], [17], [ax_cxx_compile_alternatives="17 1z"],
+ [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl
+ m4_if([$2], [], [],
+ [$2], [ext], [],
+ [$2], [noext], [],
+ [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl
+ m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true],
+ [$3], [mandatory], [ax_cxx_compile_cxx$1_required=true],
+ [$3], [optional], [ax_cxx_compile_cxx$1_required=false],
+ [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])])
+ AC_LANG_PUSH([C++])dnl
+ ac_success=no
+ AC_CACHE_CHECK(whether $CXX supports C++$1 features by default,
+ ax_cv_cxx_compile_cxx$1,
+ [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
+ [ax_cv_cxx_compile_cxx$1=yes],
+ [ax_cv_cxx_compile_cxx$1=no])])
+ if test x$ax_cv_cxx_compile_cxx$1 = xyes; then
+ ac_success=yes
+ fi
+
+ m4_if([$2], [noext], [], [dnl
+ if test x$ac_success = xno; then
+ for alternative in ${ax_cxx_compile_alternatives}; do
+ switch="-std=gnu++${alternative}"
+ cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
+ AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
+ $cachevar,
+ [ac_save_CXX="$CXX"
+ CXX="$CXX $switch"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
+ [eval $cachevar=yes],
+ [eval $cachevar=no])
+ CXX="$ac_save_CXX"])
+ if eval test x\$$cachevar = xyes; then
+ CXX="$CXX $switch"
+ if test -n "$CXXCPP" ; then
+ CXXCPP="$CXXCPP $switch"
+ fi
+ ac_success=yes
+ break
+ fi
+ done
+ fi])
+
+ m4_if([$2], [ext], [], [dnl
+ if test x$ac_success = xno; then
+ dnl HP's aCC needs +std=c++11 according to:
+ dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf
+ dnl Cray's crayCC needs "-h std=c++11"
+ for alternative in ${ax_cxx_compile_alternatives}; do
+ for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
+ cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
+ AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
+ $cachevar,
+ [ac_save_CXX="$CXX"
+ CXX="$CXX $switch"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
+ [eval $cachevar=yes],
+ [eval $cachevar=no])
+ CXX="$ac_save_CXX"])
+ if eval test x\$$cachevar = xyes; then
+ CXX="$CXX $switch"
+ if test -n "$CXXCPP" ; then
+ CXXCPP="$CXXCPP $switch"
+ fi
+ ac_success=yes
+ break
+ fi
+ done
+ if test x$ac_success = xyes; then
+ break
+ fi
+ done
+ fi])
+ AC_LANG_POP([C++])
+ if test x$ax_cxx_compile_cxx$1_required = xtrue; then
+ if test x$ac_success = xno; then
+ AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.])
+ fi
+ fi
+ if test x$ac_success = xno; then
+ HAVE_CXX$1=0
+ AC_MSG_NOTICE([No compiler with C++$1 support was found])
+ else
+ HAVE_CXX$1=1
+ AC_DEFINE(HAVE_CXX$1,1,
+ [define if the compiler supports basic C++$1 syntax])
+ fi
+ AC_SUBST(HAVE_CXX$1)
+ m4_if([$1], [17], [AC_MSG_WARN([C++17 is not yet standardized, so the checks may change in incompatible ways anytime])])
+])
+
+
+dnl Test body for checking C++11 support
+
+m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11],
+ _AX_CXX_COMPILE_STDCXX_testbody_new_in_11
+)
+
+
+dnl Test body for checking C++14 support
+
+m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14],
+ _AX_CXX_COMPILE_STDCXX_testbody_new_in_11
+ _AX_CXX_COMPILE_STDCXX_testbody_new_in_14
+)
+
+m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17],
+ _AX_CXX_COMPILE_STDCXX_testbody_new_in_11
+ _AX_CXX_COMPILE_STDCXX_testbody_new_in_14
+ _AX_CXX_COMPILE_STDCXX_testbody_new_in_17
+)
+
+dnl Tests for new features in C++11
+
+m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[
+
+// If the compiler admits that it is not ready for C++11, why torture it?
+// Hopefully, this will speed up the test.
+
+#ifndef __cplusplus
+
+#error "This is not a C++ compiler"
+
+#elif __cplusplus < 201103L
+
+#error "This is not a C++11 compiler"
+
+#else
+
+namespace cxx11
+{
+
+ namespace test_static_assert
+ {
+
+ template <typename T>
+ struct check
+ {
+ static_assert(sizeof(int) <= sizeof(T), "not big enough");
+ };
+
+ }
+
+ namespace test_final_override
+ {
+
+ struct Base
+ {
+ virtual void f() {}
+ };
+
+ struct Derived : public Base
+ {
+ virtual void f() override {}
+ };
+
+ }
+
+ namespace test_double_right_angle_brackets
+ {
+
+ template < typename T >
+ struct check {};
+
+ typedef check<void> single_type;
+ typedef check<check<void>> double_type;
+ typedef check<check<check<void>>> triple_type;
+ typedef check<check<check<check<void>>>> quadruple_type;
+
+ }
+
+ namespace test_decltype
+ {
+
+ int
+ f()
+ {
+ int a = 1;
+ decltype(a) b = 2;
+ return a + b;
+ }
+
+ }
+
+ namespace test_type_deduction
+ {
+
+ template < typename T1, typename T2 >
+ struct is_same
+ {
+ static const bool value = false;
+ };
+
+ template < typename T >
+ struct is_same<T, T>
+ {
+ static const bool value = true;
+ };
+
+ template < typename T1, typename T2 >
+ auto
+ add(T1 a1, T2 a2) -> decltype(a1 + a2)
+ {
+ return a1 + a2;
+ }
+
+ int
+ test(const int c, volatile int v)
+ {
+ static_assert(is_same<int, decltype(0)>::value == true, "");
+ static_assert(is_same<int, decltype(c)>::value == false, "");
+ static_assert(is_same<int, decltype(v)>::value == false, "");
+ auto ac = c;
+ auto av = v;
+ auto sumi = ac + av + 'x';
+ auto sumf = ac + av + 1.0;
+ static_assert(is_same<int, decltype(ac)>::value == true, "");
+ static_assert(is_same<int, decltype(av)>::value == true, "");
+ static_assert(is_same<int, decltype(sumi)>::value == true, "");
+ static_assert(is_same<int, decltype(sumf)>::value == false, "");
+ static_assert(is_same<int, decltype(add(c, v))>::value == true, "");
+ return (sumf > 0.0) ? sumi : add(c, v);
+ }
+
+ }
+
+ namespace test_noexcept
+ {
+
+ int f() { return 0; }
+ int g() noexcept { return 0; }
+
+ static_assert(noexcept(f()) == false, "");
+ static_assert(noexcept(g()) == true, "");
+
+ }
+
+ namespace test_constexpr
+ {
+
+ template < typename CharT >
+ unsigned long constexpr
+ strlen_c_r(const CharT *const s, const unsigned long acc) noexcept
+ {
+ return *s ? strlen_c_r(s + 1, acc + 1) : acc;
+ }
+
+ template < typename CharT >
+ unsigned long constexpr
+ strlen_c(const CharT *const s) noexcept
+ {
+ return strlen_c_r(s, 0UL);
+ }
+
+ static_assert(strlen_c("") == 0UL, "");
+ static_assert(strlen_c("1") == 1UL, "");
+ static_assert(strlen_c("example") == 7UL, "");
+ static_assert(strlen_c("another\0example") == 7UL, "");
+
+ }
+
+ namespace test_rvalue_references
+ {
+
+ template < int N >
+ struct answer
+ {
+ static constexpr int value = N;
+ };
+
+ answer<1> f(int&) { return answer<1>(); }
+ answer<2> f(const int&) { return answer<2>(); }
+ answer<3> f(int&&) { return answer<3>(); }
+
+ void
+ test()
+ {
+ int i = 0;
+ const int c = 0;
+ static_assert(decltype(f(i))::value == 1, "");
+ static_assert(decltype(f(c))::value == 2, "");
+ static_assert(decltype(f(0))::value == 3, "");
+ }
+
+ }
+
+ namespace test_uniform_initialization
+ {
+
+ struct test
+ {
+ static const int zero {};
+ static const int one {1};
+ };
+
+ static_assert(test::zero == 0, "");
+ static_assert(test::one == 1, "");
+
+ }
+
+ namespace test_lambdas
+ {
+
+ void
+ test1()
+ {
+ auto lambda1 = [](){};
+ auto lambda2 = lambda1;
+ lambda1();
+ lambda2();
+ }
+
+ int
+ test2()
+ {
+ auto a = [](int i, int j){ return i + j; }(1, 2);
+ auto b = []() -> int { return '0'; }();
+ auto c = [=](){ return a + b; }();
+ auto d = [&](){ return c; }();
+ auto e = [a, &b](int x) mutable {
+ const auto identity = [](int y){ return y; };
+ for (auto i = 0; i < a; ++i)
+ a += b--;
+ return x + identity(a + b);
+ }(0);
+ return a + b + c + d + e;
+ }
+
+ int
+ test3()
+ {
+ const auto nullary = [](){ return 0; };
+ const auto unary = [](int x){ return x; };
+ using nullary_t = decltype(nullary);
+ using unary_t = decltype(unary);
+ const auto higher1st = [](nullary_t f){ return f(); };
+ const auto higher2nd = [unary](nullary_t f1){
+ return [unary, f1](unary_t f2){ return f2(unary(f1())); };
+ };
+ return higher1st(nullary) + higher2nd(nullary)(unary);
+ }
+
+ }
+
+ namespace test_variadic_templates
+ {
+
+ template <int...>
+ struct sum;
+
+ template <int N0, int... N1toN>
+ struct sum<N0, N1toN...>
+ {
+ static constexpr auto value = N0 + sum<N1toN...>::value;
+ };
+
+ template <>
+ struct sum<>
+ {
+ static constexpr auto value = 0;
+ };
+
+ static_assert(sum<>::value == 0, "");
+ static_assert(sum<1>::value == 1, "");
+ static_assert(sum<23>::value == 23, "");
+ static_assert(sum<1, 2>::value == 3, "");
+ static_assert(sum<5, 5, 11>::value == 21, "");
+ static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, "");
+
+ }
+
+ // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
+ // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function
+ // because of this.
+ namespace test_template_alias_sfinae
+ {
+
+ struct foo {};
+
+ template<typename T>
+ using member = typename T::member_type;
+
+ template<typename T>
+ void func(...) {}
+
+ template<typename T>
+ void func(member<T>*) {}
+
+ void test();
+
+ void test() { func<foo>(0); }
+
+ }
+
+} // namespace cxx11
+
+#endif // __cplusplus >= 201103L
+
+]])
+
+
+dnl Tests for new features in C++14
+
+m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[
+
+// If the compiler admits that it is not ready for C++14, why torture it?
+// Hopefully, this will speed up the test.
+
+#ifndef __cplusplus
+
+#error "This is not a C++ compiler"
+
+#elif __cplusplus < 201402L
+
+#error "This is not a C++14 compiler"
+
+#else
+
+namespace cxx14
+{
+
+ namespace test_polymorphic_lambdas
+ {
+
+ int
+ test()
+ {
+ const auto lambda = [](auto&&... args){
+ const auto istiny = [](auto x){
+ return (sizeof(x) == 1UL) ? 1 : 0;
+ };
+ const int aretiny[] = { istiny(args)... };
+ return aretiny[0];
+ };
+ return lambda(1, 1L, 1.0f, '1');
+ }
+
+ }
+
+ namespace test_binary_literals
+ {
+
+ constexpr auto ivii = 0b0000000000101010;
+ static_assert(ivii == 42, "wrong value");
+
+ }
+
+ namespace test_generalized_constexpr
+ {
+
+ template < typename CharT >
+ constexpr unsigned long
+ strlen_c(const CharT *const s) noexcept
+ {
+ auto length = 0UL;
+ for (auto p = s; *p; ++p)
+ ++length;
+ return length;
+ }
+
+ static_assert(strlen_c("") == 0UL, "");
+ static_assert(strlen_c("x") == 1UL, "");
+ static_assert(strlen_c("test") == 4UL, "");
+ static_assert(strlen_c("another\0test") == 7UL, "");
+
+ }
+
+ namespace test_lambda_init_capture
+ {
+
+ int
+ test()
+ {
+ auto x = 0;
+ const auto lambda1 = [a = x](int b){ return a + b; };
+ const auto lambda2 = [a = lambda1(x)](){ return a; };
+ return lambda2();
+ }
+
+ }
+
+ namespace test_digit_separators
+ {
+
+ constexpr auto ten_million = 100'000'000;
+ static_assert(ten_million == 100000000, "");
+
+ }
+
+ namespace test_return_type_deduction
+ {
+
+ auto f(int& x) { return x; }
+ decltype(auto) g(int& x) { return x; }
+
+ template < typename T1, typename T2 >
+ struct is_same
+ {
+ static constexpr auto value = false;
+ };
+
+ template < typename T >
+ struct is_same<T, T>
+ {
+ static constexpr auto value = true;
+ };
+
+ int
+ test()
+ {
+ auto x = 0;
+ static_assert(is_same<int, decltype(f(x))>::value, "");
+ static_assert(is_same<int&, decltype(g(x))>::value, "");
+ return x;
+ }
+
+ }
+
+} // namespace cxx14
+
+#endif // __cplusplus >= 201402L
+
+]])
+
+
+dnl Tests for new features in C++17
+
+m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[
+
+// If the compiler admits that it is not ready for C++17, why torture it?
+// Hopefully, this will speed up the test.
+
+#ifndef __cplusplus
+
+#error "This is not a C++ compiler"
+
+#elif __cplusplus <= 201402L
+
+#error "This is not a C++17 compiler"
+
+#else
+
+#if defined(__clang__)
+ #define REALLY_CLANG
+#else
+ #if defined(__GNUC__)
+ #define REALLY_GCC
+ #endif
+#endif
+
+#include <initializer_list>
+#include <utility>
+#include <type_traits>
+
+namespace cxx17
+{
+
+#if !defined(REALLY_CLANG)
+ namespace test_constexpr_lambdas
+ {
+
+ // TODO: test it with clang++ from git
+
+ constexpr int foo = [](){return 42;}();
+
+ }
+#endif // !defined(REALLY_CLANG)
+
+ namespace test::nested_namespace::definitions
+ {
+
+ }
+
+ namespace test_fold_expression
+ {
+
+ template<typename... Args>
+ int multiply(Args... args)
+ {
+ return (args * ... * 1);
+ }
+
+ template<typename... Args>
+ bool all(Args... args)
+ {
+ return (args && ...);
+ }
+
+ }
+
+ namespace test_extended_static_assert
+ {
+
+ static_assert (true);
+
+ }
+
+ namespace test_auto_brace_init_list
+ {
+
+ auto foo = {5};
+ auto bar {5};
+
+ static_assert(std::is_same<std::initializer_list<int>, decltype(foo)>::value);
+ static_assert(std::is_same<int, decltype(bar)>::value);
+ }
+
+ namespace test_typename_in_template_template_parameter
+ {
+
+ template<template<typename> typename X> struct D;
+
+ }
+
+ namespace test_fallthrough_nodiscard_maybe_unused_attributes
+ {
+
+ int f1()
+ {
+ return 42;
+ }
+
+ [[nodiscard]] int f2()
+ {
+ [[maybe_unused]] auto unused = f1();
+
+ switch (f1())
+ {
+ case 17:
+ f1();
+ [[fallthrough]];
+ case 42:
+ f1();
+ }
+ return f1();
+ }
+
+ }
+
+ namespace test_extended_aggregate_initialization
+ {
+
+ struct base1
+ {
+ int b1, b2 = 42;
+ };
+
+ struct base2
+ {
+ base2() {
+ b3 = 42;
+ }
+ int b3;
+ };
+
+ struct derived : base1, base2
+ {
+ int d;
+ };
+
+ derived d1 {{1, 2}, {}, 4}; // full initialization
+ derived d2 {{}, {}, 4}; // value-initialized bases
+
+ }
+
+ namespace test_general_range_based_for_loop
+ {
+
+ struct iter
+ {
+ int i;
+
+ int& operator* ()
+ {
+ return i;
+ }
+
+ const int& operator* () const
+ {
+ return i;
+ }
+
+ iter& operator++()
+ {
+ ++i;
+ return *this;
+ }
+ };
+
+ struct sentinel
+ {
+ int i;
+ };
+
+ bool operator== (const iter& i, const sentinel& s)
+ {
+ return i.i == s.i;
+ }
+
+ bool operator!= (const iter& i, const sentinel& s)
+ {
+ return !(i == s);
+ }
+
+ struct range
+ {
+ iter begin() const
+ {
+ return {0};
+ }
+
+ sentinel end() const
+ {
+ return {5};
+ }
+ };
+
+ void f()
+ {
+ range r {};
+
+ for (auto i : r)
+ {
+ [[maybe_unused]] auto v = i;
+ }
+ }
+
+ }
+
+ namespace test_lambda_capture_asterisk_this_by_value
+ {
+
+ struct t
+ {
+ int i;
+ int foo()
+ {
+ return [*this]()
+ {
+ return i;
+ }();
+ }
+ };
+
+ }
+
+ namespace test_enum_class_construction
+ {
+
+ enum class byte : unsigned char
+ {};
+
+ byte foo {42};
+
+ }
+
+ namespace test_constexpr_if
+ {
+
+ template <bool cond>
+ int f ()
+ {
+ if constexpr(cond)
+ {
+ return 13;
+ }
+ else
+ {
+ return 42;
+ }
+ }
+
+ }
+
+ namespace test_selection_statement_with_initializer
+ {
+
+ int f()
+ {
+ return 13;
+ }
+
+ int f2()
+ {
+ if (auto i = f(); i > 0)
+ {
+ return 3;
+ }
+
+ switch (auto i = f(); i + 4)
+ {
+ case 17:
+ return 2;
+
+ default:
+ return 1;
+ }
+ }
+
+ }
+
+#if !defined(REALLY_CLANG)
+ namespace test_template_argument_deduction_for_class_templates
+ {
+
+ // TODO: test it with clang++ from git
+
+ template <typename T1, typename T2>
+ struct pair
+ {
+ pair (T1 p1, T2 p2)
+ : m1 {p1},
+ m2 {p2}
+ {}
+
+ T1 m1;
+ T2 m2;
+ };
+
+ void f()
+ {
+ [[maybe_unused]] auto p = pair{13, 42u};
+ }
+
+ }
+#endif // !defined(REALLY_CLANG)
+
+ namespace test_non_type_auto_template_parameters
+ {
+
+ template <auto n>
+ struct B
+ {};
+
+ B<5> b1;
+ B<'a'> b2;
+
+ }
+
+#if !defined(REALLY_CLANG)
+ namespace test_structured_bindings
+ {
+
+ // TODO: test it with clang++ from git
+
+ int arr[2] = { 1, 2 };
+ std::pair<int, int> pr = { 1, 2 };
+
+ auto f1() -> int(&)[2]
+ {
+ return arr;
+ }
+
+ auto f2() -> std::pair<int, int>&
+ {
+ return pr;
+ }
+
+ struct S
+ {
+ int x1 : 2;
+ volatile double y1;
+ };
+
+ S f3()
+ {
+ return {};
+ }
+
+ auto [ x1, y1 ] = f1();
+ auto& [ xr1, yr1 ] = f1();
+ auto [ x2, y2 ] = f2();
+ auto& [ xr2, yr2 ] = f2();
+ const auto [ x3, y3 ] = f3();
+
+ }
+#endif // !defined(REALLY_CLANG)
+
+#if !defined(REALLY_CLANG)
+ namespace test_exception_spec_type_system
+ {
+
+ // TODO: test it with clang++ from git
+
+ struct Good {};
+ struct Bad {};
+
+ void g1() noexcept;
+ void g2();
+
+ template<typename T>
+ Bad
+ f(T*, T*);
+
+ template<typename T1, typename T2>
+ Good
+ f(T1*, T2*);
+
+ static_assert (std::is_same_v<Good, decltype(f(g1, g2))>);
+
+ }
+#endif // !defined(REALLY_CLANG)
+
+ namespace test_inline_variables
+ {
+
+ template<class T> void f(T)
+ {}
+
+ template<class T> inline T g(T)
+ {
+ return T{};
+ }
+
+ template<> inline void f<>(int)
+ {}
+
+ template<> int g<>(int)
+ {
+ return 5;
+ }
+
+ }
+
+} // namespace cxx17
+
+#endif // __cplusplus <= 201402L
+
+]])
diff --git a/m4/ax_prog_cc_for_build.m4 b/m4/ax_prog_cc_for_build.m4
new file mode 100644
index 00000000..77fd346a
--- /dev/null
+++ b/m4/ax_prog_cc_for_build.m4
@@ -0,0 +1,125 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_prog_cc_for_build.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_PROG_CC_FOR_BUILD
+#
+# DESCRIPTION
+#
+# This macro searches for a C compiler that generates native executables,
+# that is a C compiler that surely is not a cross-compiler. This can be
+# useful if you have to generate source code at compile-time like for
+# example GCC does.
+#
+# The macro sets the CC_FOR_BUILD and CPP_FOR_BUILD macros to anything
+# needed to compile or link (CC_FOR_BUILD) and preprocess (CPP_FOR_BUILD).
+# The value of these variables can be overridden by the user by specifying
+# a compiler with an environment variable (like you do for standard CC).
+#
+# It also sets BUILD_EXEEXT and BUILD_OBJEXT to the executable and object
+# file extensions for the build platform, and GCC_FOR_BUILD to `yes' if
+# the compiler we found is GCC. All these variables but GCC_FOR_BUILD are
+# substituted in the Makefile.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Paolo Bonzini <bonzini@gnu.org>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 8
+
+AU_ALIAS([AC_PROG_CC_FOR_BUILD], [AX_PROG_CC_FOR_BUILD])
+AC_DEFUN([AX_PROG_CC_FOR_BUILD], [dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_PROG_CPP])dnl
+AC_REQUIRE([AC_EXEEXT])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+
+dnl Use the standard macros, but make them use other variable names
+dnl
+pushdef([ac_cv_prog_CPP], ac_cv_build_prog_CPP)dnl
+pushdef([ac_cv_prog_gcc], ac_cv_build_prog_gcc)dnl
+pushdef([ac_cv_prog_cc_works], ac_cv_build_prog_cc_works)dnl
+pushdef([ac_cv_prog_cc_cross], ac_cv_build_prog_cc_cross)dnl
+pushdef([ac_cv_prog_cc_g], ac_cv_build_prog_cc_g)dnl
+pushdef([ac_cv_exeext], ac_cv_build_exeext)dnl
+pushdef([ac_cv_objext], ac_cv_build_objext)dnl
+pushdef([ac_exeext], ac_build_exeext)dnl
+pushdef([ac_objext], ac_build_objext)dnl
+pushdef([CC], CC_FOR_BUILD)dnl
+pushdef([CPP], CPP_FOR_BUILD)dnl
+pushdef([CFLAGS], CFLAGS_FOR_BUILD)dnl
+pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl
+pushdef([LDFLAGS], LDFLAGS_FOR_BUILD)dnl
+pushdef([host], build)dnl
+pushdef([host_alias], build_alias)dnl
+pushdef([host_cpu], build_cpu)dnl
+pushdef([host_vendor], build_vendor)dnl
+pushdef([host_os], build_os)dnl
+pushdef([ac_cv_host], ac_cv_build)dnl
+pushdef([ac_cv_host_alias], ac_cv_build_alias)dnl
+pushdef([ac_cv_host_cpu], ac_cv_build_cpu)dnl
+pushdef([ac_cv_host_vendor], ac_cv_build_vendor)dnl
+pushdef([ac_cv_host_os], ac_cv_build_os)dnl
+pushdef([ac_cpp], ac_build_cpp)dnl
+pushdef([ac_compile], ac_build_compile)dnl
+pushdef([ac_link], ac_build_link)dnl
+
+save_cross_compiling=$cross_compiling
+save_ac_tool_prefix=$ac_tool_prefix
+cross_compiling=no
+ac_tool_prefix=
+
+AC_PROG_CC
+AC_PROG_CPP
+AC_EXEEXT
+
+ac_tool_prefix=$save_ac_tool_prefix
+cross_compiling=$save_cross_compiling
+
+dnl Restore the old definitions
+dnl
+popdef([ac_link])dnl
+popdef([ac_compile])dnl
+popdef([ac_cpp])dnl
+popdef([ac_cv_host_os])dnl
+popdef([ac_cv_host_vendor])dnl
+popdef([ac_cv_host_cpu])dnl
+popdef([ac_cv_host_alias])dnl
+popdef([ac_cv_host])dnl
+popdef([host_os])dnl
+popdef([host_vendor])dnl
+popdef([host_cpu])dnl
+popdef([host_alias])dnl
+popdef([host])dnl
+popdef([LDFLAGS])dnl
+popdef([CPPFLAGS])dnl
+popdef([CFLAGS])dnl
+popdef([CPP])dnl
+popdef([CC])dnl
+popdef([ac_objext])dnl
+popdef([ac_exeext])dnl
+popdef([ac_cv_objext])dnl
+popdef([ac_cv_exeext])dnl
+popdef([ac_cv_prog_cc_g])dnl
+popdef([ac_cv_prog_cc_cross])dnl
+popdef([ac_cv_prog_cc_works])dnl
+popdef([ac_cv_prog_gcc])dnl
+popdef([ac_cv_prog_CPP])dnl
+
+dnl Finally, set Makefile variables
+dnl
+BUILD_EXEEXT=$ac_build_exeext
+BUILD_OBJEXT=$ac_build_objext
+AC_SUBST(BUILD_EXEEXT)dnl
+AC_SUBST(BUILD_OBJEXT)dnl
+AC_SUBST([CFLAGS_FOR_BUILD])dnl
+AC_SUBST([CPPFLAGS_FOR_BUILD])dnl
+AC_SUBST([LDFLAGS_FOR_BUILD])dnl
+])
diff --git a/m4/ax_prog_cxx_for_build.m4 b/m4/ax_prog_cxx_for_build.m4
new file mode 100644
index 00000000..8cc0f73c
--- /dev/null
+++ b/m4/ax_prog_cxx_for_build.m4
@@ -0,0 +1,110 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_prog_cxx_for_build.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_PROG_CXX_FOR_BUILD
+#
+# DESCRIPTION
+#
+# This macro searches for a C++ compiler that generates native
+# executables, that is a C++ compiler that surely is not a cross-compiler.
+# This can be useful if you have to generate source code at compile-time
+# like for example GCC does.
+#
+# The macro sets the CXX_FOR_BUILD and CXXCPP_FOR_BUILD macros to anything
+# needed to compile or link (CXX_FOR_BUILD) and preprocess
+# (CXXCPP_FOR_BUILD). The value of these variables can be overridden by
+# the user by specifying a compiler with an environment variable (like you
+# do for standard CXX).
+#
+# LICENSE
+#
+# Copyright (c) 2008 Paolo Bonzini <bonzini@gnu.org>
+# Copyright (c) 2012 Avionic Design GmbH
+#
+# Based on the AX_PROG_CC_FOR_BUILD macro by Paolo Bonzini.
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 2
+
+AU_ALIAS([AC_PROG_CXX_FOR_BUILD], [AX_PROG_CXX_FOR_BUILD])
+AC_DEFUN([AX_PROG_CXX_FOR_BUILD], [dnl
+AC_REQUIRE([AX_PROG_CC_FOR_BUILD])dnl
+AC_REQUIRE([AC_PROG_CXX])dnl
+AC_REQUIRE([AC_PROG_CXXCPP])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+
+dnl Use the standard macros, but make them use other variable names
+dnl
+pushdef([ac_cv_prog_CXXCPP], ac_cv_build_prog_CXXCPP)dnl
+pushdef([ac_cv_prog_gxx], ac_cv_build_prog_gxx)dnl
+pushdef([ac_cv_prog_cxx_works], ac_cv_build_prog_cxx_works)dnl
+pushdef([ac_cv_prog_cxx_cross], ac_cv_build_prog_cxx_cross)dnl
+pushdef([ac_cv_prog_cxx_g], ac_cv_build_prog_cxx_g)dnl
+pushdef([CXX], CXX_FOR_BUILD)dnl
+pushdef([CXXCPP], CXXCPP_FOR_BUILD)dnl
+pushdef([CXXFLAGS], CXXFLAGS_FOR_BUILD)dnl
+pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl
+pushdef([CXXCPPFLAGS], CXXCPPFLAGS_FOR_BUILD)dnl
+pushdef([host], build)dnl
+pushdef([host_alias], build_alias)dnl
+pushdef([host_cpu], build_cpu)dnl
+pushdef([host_vendor], build_vendor)dnl
+pushdef([host_os], build_os)dnl
+pushdef([ac_cv_host], ac_cv_build)dnl
+pushdef([ac_cv_host_alias], ac_cv_build_alias)dnl
+pushdef([ac_cv_host_cpu], ac_cv_build_cpu)dnl
+pushdef([ac_cv_host_vendor], ac_cv_build_vendor)dnl
+pushdef([ac_cv_host_os], ac_cv_build_os)dnl
+pushdef([ac_cxxcpp], ac_build_cxxcpp)dnl
+pushdef([ac_compile], ac_build_compile)dnl
+pushdef([ac_link], ac_build_link)dnl
+
+save_cross_compiling=$cross_compiling
+save_ac_tool_prefix=$ac_tool_prefix
+cross_compiling=no
+ac_tool_prefix=
+
+AC_PROG_CXX
+AC_PROG_CXXCPP
+
+ac_tool_prefix=$save_ac_tool_prefix
+cross_compiling=$save_cross_compiling
+
+dnl Restore the old definitions
+dnl
+popdef([ac_link])dnl
+popdef([ac_compile])dnl
+popdef([ac_cxxcpp])dnl
+popdef([ac_cv_host_os])dnl
+popdef([ac_cv_host_vendor])dnl
+popdef([ac_cv_host_cpu])dnl
+popdef([ac_cv_host_alias])dnl
+popdef([ac_cv_host])dnl
+popdef([host_os])dnl
+popdef([host_vendor])dnl
+popdef([host_cpu])dnl
+popdef([host_alias])dnl
+popdef([host])dnl
+popdef([CXXCPPFLAGS])dnl
+popdef([CPPFLAGS])dnl
+popdef([CXXFLAGS])dnl
+popdef([CXXCPP])dnl
+popdef([CXX])dnl
+popdef([ac_cv_prog_cxx_g])dnl
+popdef([ac_cv_prog_cxx_cross])dnl
+popdef([ac_cv_prog_cxx_works])dnl
+popdef([ac_cv_prog_gxx])dnl
+popdef([ac_cv_prog_CXXCPP])dnl
+
+dnl Finally, set Makefile variables
+dnl
+AC_SUBST([CXXFLAGS_FOR_BUILD])dnl
+AC_SUBST([CXXCPPFLAGS_FOR_BUILD])dnl
+])
diff --git a/objectivec/DevTools/compile_testing_protos.sh b/objectivec/DevTools/compile_testing_protos.sh
index 6cc32da9..d7f3f605 100755
--- a/objectivec/DevTools/compile_testing_protos.sh
+++ b/objectivec/DevTools/compile_testing_protos.sh
@@ -134,6 +134,8 @@ done
compile_protos \
--proto_path="objectivec/Tests" \
objectivec/Tests/unittest_cycle.proto \
+ objectivec/Tests/unittest_deprecated.proto \
+ objectivec/Tests/unittest_deprecated_file.proto \
objectivec/Tests/unittest_extension_chain_a.proto \
objectivec/Tests/unittest_extension_chain_b.proto \
objectivec/Tests/unittest_extension_chain_c.proto \
diff --git a/objectivec/DevTools/full_mac_build.sh b/objectivec/DevTools/full_mac_build.sh
index 7b335618..ea9fd273 100755
--- a/objectivec/DevTools/full_mac_build.sh
+++ b/objectivec/DevTools/full_mac_build.sh
@@ -45,6 +45,8 @@ OPTIONS:
Skip the invoke of Xcode to test the runtime on OS X.
--skip-objc-conformance
Skip the Objective C conformance tests (run on OS X).
+ --xcode-quiet
+ Pass -quiet to xcodebuild.
EOF
}
@@ -83,6 +85,7 @@ DO_XCODE_OSX_TESTS=yes
DO_XCODE_DEBUG=yes
DO_XCODE_RELEASE=yes
DO_OBJC_CONFORMANCE_TESTS=yes
+XCODE_QUIET=no
while [[ $# != 0 ]]; do
case "${1}" in
-h | --help )
@@ -124,6 +127,9 @@ while [[ $# != 0 ]]; do
--skip-objc-conformance )
DO_OBJC_CONFORMANCE_TESTS=no
;;
+ --xcode-quiet )
+ XCODE_QUIET=yes
+ ;;
-*)
echo "ERROR: Unknown option: ${1}" 1>&2
printUsage
@@ -217,17 +223,21 @@ if ! objectivec/DevTools/pddm.py --dry-run objectivec/*.[hm] objectivec/Tests/*.
exit 1
fi
+readonly XCODE_VERSION_LINE="$(xcodebuild -version | grep Xcode\ )"
+readonly XCODE_VERSION="${XCODE_VERSION_LINE/Xcode /}" # drop the prefix.
+
if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then
XCODEBUILD_TEST_BASE_IOS=(
xcodebuild
-project objectivec/ProtocolBuffers_iOS.xcodeproj
-scheme ProtocolBuffers
)
+ if [[ "${XCODE_QUIET}" == "yes" ]] ; then
+ XCODEBUILD_TEST_BASE_IOS+=( -quiet )
+ fi
# Don't need to worry about form factors or retina/non retina;
# just pick a mix of OS Versions and 32/64 bit.
# NOTE: Different Xcode have different simulated hardware/os support.
- readonly XCODE_VERSION_LINE="$(xcodebuild -version | grep Xcode\ )"
- readonly XCODE_VERSION="${XCODE_VERSION_LINE/Xcode /}" # drop the prefix.
case "${XCODE_VERSION}" in
6.* )
echo "ERROR: Xcode 6.3/6.4 no longer supported for building, please use 8.0 or higher." 1>&2
@@ -247,6 +257,22 @@ if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then
-destination "platform=iOS Simulator,name=iPad Pro (9.7 inch),OS=10.0" # 64bit
)
;;
+ 8.1* )
+ XCODEBUILD_TEST_BASE_IOS+=(
+ -destination "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit
+ -destination "platform=iOS Simulator,name=iPhone 7,OS=10.1" # 64bit
+ -destination "platform=iOS Simulator,name=iPad 2,OS=8.1" # 32bit
+ -destination "platform=iOS Simulator,name=iPad Pro (9.7 inch),OS=10.1" # 64bit
+ )
+ ;;
+ 8.2* )
+ XCODEBUILD_TEST_BASE_IOS+=(
+ -destination "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit
+ -destination "platform=iOS Simulator,name=iPhone 7,OS=10.2" # 64bit
+ -destination "platform=iOS Simulator,name=iPad 2,OS=8.1" # 32bit
+ -destination "platform=iOS Simulator,name=iPad Pro (9.7 inch),OS=10.2" # 64bit
+ )
+ ;;
* )
echo "Time to update the simulator targets for Xcode ${XCODE_VERSION}"
exit 2
@@ -271,8 +297,9 @@ if [[ "${DO_XCODE_OSX_TESTS}" == "yes" ]] ; then
# Since the ObjC 2.0 Runtime is required, 32bit OS X isn't supported.
-destination "platform=OS X,arch=x86_64" # 64bit
)
- readonly XCODE_VERSION_LINE="$(xcodebuild -version | grep Xcode\ )"
- readonly XCODE_VERSION="${XCODE_VERSION_LINE/Xcode /}" # drop the prefix.
+ if [[ "${XCODE_QUIET}" == "yes" ]] ; then
+ XCODEBUILD_TEST_BASE_OSX+=( -quiet )
+ fi
case "${XCODE_VERSION}" in
6.* )
echo "ERROR: Xcode 6.3/6.4 no longer supported for building, please use 8.0 or higher." 1>&2
diff --git a/objectivec/GPBArray.h b/objectivec/GPBArray.h
index 781cfb6f..638b2882 100644
--- a/objectivec/GPBArray.h
+++ b/objectivec/GPBArray.h
@@ -96,7 +96,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized GPBInt32Array with a copy of the values.
**/
-- (instancetype)initWithValues:(const int32_t [])values
+- (instancetype)initWithValues:(const int32_t [__nullable])values
count:(NSUInteger)count;
/**
@@ -161,7 +161,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param values The values to add to this array.
* @param count The number of elements to add.
**/
-- (void)addValues:(const int32_t [])values count:(NSUInteger)count;
+- (void)addValues:(const int32_t [__nullable])values count:(NSUInteger)count;
/**
* Adds the values from the given array to this array.
@@ -268,7 +268,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized GPBUInt32Array with a copy of the values.
**/
-- (instancetype)initWithValues:(const uint32_t [])values
+- (instancetype)initWithValues:(const uint32_t [__nullable])values
count:(NSUInteger)count;
/**
@@ -333,7 +333,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param values The values to add to this array.
* @param count The number of elements to add.
**/
-- (void)addValues:(const uint32_t [])values count:(NSUInteger)count;
+- (void)addValues:(const uint32_t [__nullable])values count:(NSUInteger)count;
/**
* Adds the values from the given array to this array.
@@ -440,7 +440,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized GPBInt64Array with a copy of the values.
**/
-- (instancetype)initWithValues:(const int64_t [])values
+- (instancetype)initWithValues:(const int64_t [__nullable])values
count:(NSUInteger)count;
/**
@@ -505,7 +505,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param values The values to add to this array.
* @param count The number of elements to add.
**/
-- (void)addValues:(const int64_t [])values count:(NSUInteger)count;
+- (void)addValues:(const int64_t [__nullable])values count:(NSUInteger)count;
/**
* Adds the values from the given array to this array.
@@ -612,7 +612,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized GPBUInt64Array with a copy of the values.
**/
-- (instancetype)initWithValues:(const uint64_t [])values
+- (instancetype)initWithValues:(const uint64_t [__nullable])values
count:(NSUInteger)count;
/**
@@ -677,7 +677,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param values The values to add to this array.
* @param count The number of elements to add.
**/
-- (void)addValues:(const uint64_t [])values count:(NSUInteger)count;
+- (void)addValues:(const uint64_t [__nullable])values count:(NSUInteger)count;
/**
* Adds the values from the given array to this array.
@@ -784,7 +784,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized GPBFloatArray with a copy of the values.
**/
-- (instancetype)initWithValues:(const float [])values
+- (instancetype)initWithValues:(const float [__nullable])values
count:(NSUInteger)count;
/**
@@ -849,7 +849,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param values The values to add to this array.
* @param count The number of elements to add.
**/
-- (void)addValues:(const float [])values count:(NSUInteger)count;
+- (void)addValues:(const float [__nullable])values count:(NSUInteger)count;
/**
* Adds the values from the given array to this array.
@@ -956,7 +956,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized GPBDoubleArray with a copy of the values.
**/
-- (instancetype)initWithValues:(const double [])values
+- (instancetype)initWithValues:(const double [__nullable])values
count:(NSUInteger)count;
/**
@@ -1021,7 +1021,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param values The values to add to this array.
* @param count The number of elements to add.
**/
-- (void)addValues:(const double [])values count:(NSUInteger)count;
+- (void)addValues:(const double [__nullable])values count:(NSUInteger)count;
/**
* Adds the values from the given array to this array.
@@ -1128,7 +1128,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized GPBBoolArray with a copy of the values.
**/
-- (instancetype)initWithValues:(const BOOL [])values
+- (instancetype)initWithValues:(const BOOL [__nullable])values
count:(NSUInteger)count;
/**
@@ -1193,7 +1193,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param values The values to add to this array.
* @param count The number of elements to add.
**/
-- (void)addValues:(const BOOL [])values count:(NSUInteger)count;
+- (void)addValues:(const BOOL [__nullable])values count:(NSUInteger)count;
/**
* Adds the values from the given array to this array.
@@ -1325,7 +1325,7 @@ NS_ASSUME_NONNULL_BEGIN
* @return A newly initialized GPBEnumArray with a copy of the values.
**/
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValues:(const int32_t [])values
+ rawValues:(const int32_t [__nullable])values
count:(NSUInteger)count;
/**
@@ -1435,7 +1435,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param values The values to add to this array.
* @param count The number of elements to add.
**/
-- (void)addValues:(const int32_t [])values count:(NSUInteger)count;
+- (void)addValues:(const int32_t [__nullable])values count:(NSUInteger)count;
/**
@@ -1486,7 +1486,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param values Array containing the raw enum values to add to this array.
* @param count The number of raw values to add.
**/
-- (void)addRawValues:(const int32_t [])values count:(NSUInteger)count;
+- (void)addRawValues:(const int32_t [__nullable])values count:(NSUInteger)count;
/**
* Inserts a raw enum value at the given index.
@@ -1574,7 +1574,7 @@ NS_ASSUME_NONNULL_END
//%
//%/**
//% * Creates and initializes a GPB##NAME##Array with the single element given.
-//% *
+//% *
//% * @param value The value to be placed in the array.
//% *
//% * @return A newly instanced GPB##NAME##Array with value in it.
@@ -1600,7 +1600,7 @@ NS_ASSUME_NONNULL_END
//% **/
//%+ (instancetype)arrayWithCapacity:(NSUInteger)count;
//%
-//%/**
+//%/**
//% * @return A newly initialized and empty GPB##NAME##Array.
//% **/
//%- (instancetype)init NS_DESIGNATED_INITIALIZER;
@@ -1613,7 +1613,7 @@ NS_ASSUME_NONNULL_END
//% *
//% * @return A newly initialized GPB##NAME##Array with a copy of the values.
//% **/
-//%- (instancetype)initWithValues:(const TYPE [])values
+//%- (instancetype)initWithValues:(const TYPE [__nullable])values
//% count:(NSUInteger)count;
//%
//%/**
@@ -1730,7 +1730,7 @@ NS_ASSUME_NONNULL_END
//% * @return A newly initialized GPB##NAME##Array with a copy of the values.
//% **/
//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
-//% rawValues:(const TYPE [])values
+//% rawValues:(const TYPE [__nullable])values
//% count:(NSUInteger)count;
//%
//%/**
@@ -1773,7 +1773,7 @@ NS_ASSUME_NONNULL_END
//%
//%/**
//% * Enumerates the values on this array with the given block.
-//% *
+//% *
//% * @param block The block to enumerate with.
//% * **value**: The current value being enumerated.
//% * **idx**: The index of the current value.
@@ -1827,7 +1827,7 @@ NS_ASSUME_NONNULL_END
//% * Enumerates the values on this array with the given block.
//% *
//% * @param opts Options to control the enumeration.
-//% * @param block The block to enumerate with.
+//% * @param block The block to enumerate with.
//% * **value**: The current value being enumerated.
//% * **idx**: The index of the current value.
//% * **stop**: A pointer to a boolean that when set stops the enumeration.
@@ -1849,7 +1849,7 @@ NS_ASSUME_NONNULL_END
//% * @param values The values to add to this array.
//% * @param count The number of elements to add.
//% **/
-//%- (void)addValues:(const TYPE [])values count:(NSUInteger)count;
+//%- (void)addValues:(const TYPE [__nullable])values count:(NSUInteger)count;
//%
//%ARRAY_EXTRA_MUTABLE_METHODS1_##HELPER_NAME(NAME, TYPE)
//%/**
@@ -1939,7 +1939,7 @@ NS_ASSUME_NONNULL_END
//% * @param values Array containing the raw enum values to add to this array.
//% * @param count The number of raw values to add.
//% **/
-//%- (void)addRawValues:(const TYPE [])values count:(NSUInteger)count;
+//%- (void)addRawValues:(const TYPE [__nullable])values count:(NSUInteger)count;
//%
//%/**
//% * Inserts a raw enum value at the given index.
diff --git a/objectivec/GPBArray.m b/objectivec/GPBArray.m
index ae57747d..f401631d 100644
--- a/objectivec/GPBArray.m
+++ b/objectivec/GPBArray.m
@@ -2519,14 +2519,14 @@ static BOOL ArrayDefault_IsValidValue(int32_t value) {
- (id)copyWithZone:(NSZone *)zone {
if (_array == nil) {
- _array = [[NSMutableArray alloc] init];
+ return [[NSMutableArray allocWithZone:zone] init];
}
return [_array copyWithZone:zone];
}
- (id)mutableCopyWithZone:(NSZone *)zone {
if (_array == nil) {
- _array = [[NSMutableArray alloc] init];
+ return [[NSMutableArray allocWithZone:zone] init];
}
return [_array mutableCopyWithZone:zone];
}
diff --git a/objectivec/GPBBootstrap.h b/objectivec/GPBBootstrap.h
index f14dd8aa..ed53ae7c 100644
--- a/objectivec/GPBBootstrap.h
+++ b/objectivec/GPBBootstrap.h
@@ -62,7 +62,11 @@
*
* ```
* GPB_ENUM_FWD_DECLARE(Foo_Enum)
- * @property (nonatomic) Foo_Enum value;
+ *
+ * @interface BarClass : NSObject
+ * @property (nonatomic) enum Foo_Enum value;
+ * - (void)bazMethod:(enum Foo_Enum):value;
+ * @end
* ```
**/
#define GPB_ENUM_FWD_DECLARE(X) enum X : int32_t
diff --git a/objectivec/GPBDictionary.h b/objectivec/GPBDictionary.h
index 4b2b9ff3..9d674150 100644
--- a/objectivec/GPBDictionary.h
+++ b/objectivec/GPBDictionary.h
@@ -84,8 +84,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithUInt32s:(const uint32_t [])values
- forKeys:(const uint32_t [])keys
++ (instancetype)dictionaryWithUInt32s:(const uint32_t [__nullable])values
+ forKeys:(const uint32_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -117,8 +117,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithUInt32s:(const uint32_t [])values
- forKeys:(const uint32_t [])keys
+- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
+ forKeys:(const uint32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -228,8 +228,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithInt32s:(const int32_t [])values
- forKeys:(const uint32_t [])keys
++ (instancetype)dictionaryWithInt32s:(const int32_t [__nullable])values
+ forKeys:(const uint32_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -261,8 +261,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithInt32s:(const int32_t [])values
- forKeys:(const uint32_t [])keys
+- (instancetype)initWithInt32s:(const int32_t [__nullable])values
+ forKeys:(const uint32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -372,8 +372,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithUInt64s:(const uint64_t [])values
- forKeys:(const uint32_t [])keys
++ (instancetype)dictionaryWithUInt64s:(const uint64_t [__nullable])values
+ forKeys:(const uint32_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -405,8 +405,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithUInt64s:(const uint64_t [])values
- forKeys:(const uint32_t [])keys
+- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
+ forKeys:(const uint32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -516,8 +516,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithInt64s:(const int64_t [])values
- forKeys:(const uint32_t [])keys
++ (instancetype)dictionaryWithInt64s:(const int64_t [__nullable])values
+ forKeys:(const uint32_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -549,8 +549,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithInt64s:(const int64_t [])values
- forKeys:(const uint32_t [])keys
+- (instancetype)initWithInt64s:(const int64_t [__nullable])values
+ forKeys:(const uint32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -660,8 +660,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithBools:(const BOOL [])values
- forKeys:(const uint32_t [])keys
++ (instancetype)dictionaryWithBools:(const BOOL [__nullable])values
+ forKeys:(const uint32_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -693,8 +693,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithBools:(const BOOL [])values
- forKeys:(const uint32_t [])keys
+- (instancetype)initWithBools:(const BOOL [__nullable])values
+ forKeys:(const uint32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -804,8 +804,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithFloats:(const float [])values
- forKeys:(const uint32_t [])keys
++ (instancetype)dictionaryWithFloats:(const float [__nullable])values
+ forKeys:(const uint32_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -837,8 +837,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithFloats:(const float [])values
- forKeys:(const uint32_t [])keys
+- (instancetype)initWithFloats:(const float [__nullable])values
+ forKeys:(const uint32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -948,8 +948,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithDoubles:(const double [])values
- forKeys:(const uint32_t [])keys
++ (instancetype)dictionaryWithDoubles:(const double [__nullable])values
+ forKeys:(const uint32_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -981,8 +981,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithDoubles:(const double [])values
- forKeys:(const uint32_t [])keys
+- (instancetype)initWithDoubles:(const double [__nullable])values
+ forKeys:(const uint32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -1107,8 +1107,8 @@ NS_ASSUME_NONNULL_BEGIN
* @return A newly instanced dictionary with the keys and values in it.
**/
+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValues:(const int32_t [])values
- forKeys:(const uint32_t [])keys
+ rawValues:(const int32_t [__nullable])values
+ forKeys:(const uint32_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -1153,8 +1153,8 @@ NS_ASSUME_NONNULL_BEGIN
* @return A newly initialized dictionary with the keys and values in it.
**/
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValues:(const int32_t [])values
- forKeys:(const uint32_t [])keys
+ rawValues:(const int32_t [__nullable])values
+ forKeys:(const uint32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -1318,8 +1318,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithObjects:(const ObjectType GPB_UNSAFE_UNRETAINED [])objects
- forKeys:(const uint32_t [])keys
++ (instancetype)dictionaryWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
+ forKeys:(const uint32_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -1351,8 +1351,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithObjects:(const ObjectType GPB_UNSAFE_UNRETAINED [])objects
- forKeys:(const uint32_t [])keys
+- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
+ forKeys:(const uint32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -1461,8 +1461,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithUInt32s:(const uint32_t [])values
- forKeys:(const int32_t [])keys
++ (instancetype)dictionaryWithUInt32s:(const uint32_t [__nullable])values
+ forKeys:(const int32_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -1494,8 +1494,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithUInt32s:(const uint32_t [])values
- forKeys:(const int32_t [])keys
+- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
+ forKeys:(const int32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -1605,8 +1605,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithInt32s:(const int32_t [])values
- forKeys:(const int32_t [])keys
++ (instancetype)dictionaryWithInt32s:(const int32_t [__nullable])values
+ forKeys:(const int32_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -1638,8 +1638,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithInt32s:(const int32_t [])values
- forKeys:(const int32_t [])keys
+- (instancetype)initWithInt32s:(const int32_t [__nullable])values
+ forKeys:(const int32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -1749,8 +1749,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithUInt64s:(const uint64_t [])values
- forKeys:(const int32_t [])keys
++ (instancetype)dictionaryWithUInt64s:(const uint64_t [__nullable])values
+ forKeys:(const int32_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -1782,8 +1782,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithUInt64s:(const uint64_t [])values
- forKeys:(const int32_t [])keys
+- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
+ forKeys:(const int32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -1893,8 +1893,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithInt64s:(const int64_t [])values
- forKeys:(const int32_t [])keys
++ (instancetype)dictionaryWithInt64s:(const int64_t [__nullable])values
+ forKeys:(const int32_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -1926,8 +1926,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithInt64s:(const int64_t [])values
- forKeys:(const int32_t [])keys
+- (instancetype)initWithInt64s:(const int64_t [__nullable])values
+ forKeys:(const int32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -2037,8 +2037,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithBools:(const BOOL [])values
- forKeys:(const int32_t [])keys
++ (instancetype)dictionaryWithBools:(const BOOL [__nullable])values
+ forKeys:(const int32_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -2070,8 +2070,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithBools:(const BOOL [])values
- forKeys:(const int32_t [])keys
+- (instancetype)initWithBools:(const BOOL [__nullable])values
+ forKeys:(const int32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -2181,8 +2181,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithFloats:(const float [])values
- forKeys:(const int32_t [])keys
++ (instancetype)dictionaryWithFloats:(const float [__nullable])values
+ forKeys:(const int32_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -2214,8 +2214,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithFloats:(const float [])values
- forKeys:(const int32_t [])keys
+- (instancetype)initWithFloats:(const float [__nullable])values
+ forKeys:(const int32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -2325,8 +2325,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithDoubles:(const double [])values
- forKeys:(const int32_t [])keys
++ (instancetype)dictionaryWithDoubles:(const double [__nullable])values
+ forKeys:(const int32_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -2358,8 +2358,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithDoubles:(const double [])values
- forKeys:(const int32_t [])keys
+- (instancetype)initWithDoubles:(const double [__nullable])values
+ forKeys:(const int32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -2484,8 +2484,8 @@ NS_ASSUME_NONNULL_BEGIN
* @return A newly instanced dictionary with the keys and values in it.
**/
+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValues:(const int32_t [])values
- forKeys:(const int32_t [])keys
+ rawValues:(const int32_t [__nullable])values
+ forKeys:(const int32_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -2530,8 +2530,8 @@ NS_ASSUME_NONNULL_BEGIN
* @return A newly initialized dictionary with the keys and values in it.
**/
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValues:(const int32_t [])values
- forKeys:(const int32_t [])keys
+ rawValues:(const int32_t [__nullable])values
+ forKeys:(const int32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -2695,8 +2695,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithObjects:(const ObjectType GPB_UNSAFE_UNRETAINED [])objects
- forKeys:(const int32_t [])keys
++ (instancetype)dictionaryWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
+ forKeys:(const int32_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -2728,8 +2728,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithObjects:(const ObjectType GPB_UNSAFE_UNRETAINED [])objects
- forKeys:(const int32_t [])keys
+- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
+ forKeys:(const int32_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -2838,8 +2838,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithUInt32s:(const uint32_t [])values
- forKeys:(const uint64_t [])keys
++ (instancetype)dictionaryWithUInt32s:(const uint32_t [__nullable])values
+ forKeys:(const uint64_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -2871,8 +2871,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithUInt32s:(const uint32_t [])values
- forKeys:(const uint64_t [])keys
+- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
+ forKeys:(const uint64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -2982,8 +2982,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithInt32s:(const int32_t [])values
- forKeys:(const uint64_t [])keys
++ (instancetype)dictionaryWithInt32s:(const int32_t [__nullable])values
+ forKeys:(const uint64_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -3015,8 +3015,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithInt32s:(const int32_t [])values
- forKeys:(const uint64_t [])keys
+- (instancetype)initWithInt32s:(const int32_t [__nullable])values
+ forKeys:(const uint64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -3126,8 +3126,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithUInt64s:(const uint64_t [])values
- forKeys:(const uint64_t [])keys
++ (instancetype)dictionaryWithUInt64s:(const uint64_t [__nullable])values
+ forKeys:(const uint64_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -3159,8 +3159,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithUInt64s:(const uint64_t [])values
- forKeys:(const uint64_t [])keys
+- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
+ forKeys:(const uint64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -3270,8 +3270,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithInt64s:(const int64_t [])values
- forKeys:(const uint64_t [])keys
++ (instancetype)dictionaryWithInt64s:(const int64_t [__nullable])values
+ forKeys:(const uint64_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -3303,8 +3303,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithInt64s:(const int64_t [])values
- forKeys:(const uint64_t [])keys
+- (instancetype)initWithInt64s:(const int64_t [__nullable])values
+ forKeys:(const uint64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -3414,8 +3414,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithBools:(const BOOL [])values
- forKeys:(const uint64_t [])keys
++ (instancetype)dictionaryWithBools:(const BOOL [__nullable])values
+ forKeys:(const uint64_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -3447,8 +3447,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithBools:(const BOOL [])values
- forKeys:(const uint64_t [])keys
+- (instancetype)initWithBools:(const BOOL [__nullable])values
+ forKeys:(const uint64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -3558,8 +3558,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithFloats:(const float [])values
- forKeys:(const uint64_t [])keys
++ (instancetype)dictionaryWithFloats:(const float [__nullable])values
+ forKeys:(const uint64_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -3591,8 +3591,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithFloats:(const float [])values
- forKeys:(const uint64_t [])keys
+- (instancetype)initWithFloats:(const float [__nullable])values
+ forKeys:(const uint64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -3702,8 +3702,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithDoubles:(const double [])values
- forKeys:(const uint64_t [])keys
++ (instancetype)dictionaryWithDoubles:(const double [__nullable])values
+ forKeys:(const uint64_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -3735,8 +3735,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithDoubles:(const double [])values
- forKeys:(const uint64_t [])keys
+- (instancetype)initWithDoubles:(const double [__nullable])values
+ forKeys:(const uint64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -3861,8 +3861,8 @@ NS_ASSUME_NONNULL_BEGIN
* @return A newly instanced dictionary with the keys and values in it.
**/
+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValues:(const int32_t [])values
- forKeys:(const uint64_t [])keys
+ rawValues:(const int32_t [__nullable])values
+ forKeys:(const uint64_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -3907,8 +3907,8 @@ NS_ASSUME_NONNULL_BEGIN
* @return A newly initialized dictionary with the keys and values in it.
**/
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValues:(const int32_t [])values
- forKeys:(const uint64_t [])keys
+ rawValues:(const int32_t [__nullable])values
+ forKeys:(const uint64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -4072,8 +4072,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithObjects:(const ObjectType GPB_UNSAFE_UNRETAINED [])objects
- forKeys:(const uint64_t [])keys
++ (instancetype)dictionaryWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
+ forKeys:(const uint64_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -4105,8 +4105,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithObjects:(const ObjectType GPB_UNSAFE_UNRETAINED [])objects
- forKeys:(const uint64_t [])keys
+- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
+ forKeys:(const uint64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -4215,8 +4215,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithUInt32s:(const uint32_t [])values
- forKeys:(const int64_t [])keys
++ (instancetype)dictionaryWithUInt32s:(const uint32_t [__nullable])values
+ forKeys:(const int64_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -4248,8 +4248,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithUInt32s:(const uint32_t [])values
- forKeys:(const int64_t [])keys
+- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
+ forKeys:(const int64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -4359,8 +4359,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithInt32s:(const int32_t [])values
- forKeys:(const int64_t [])keys
++ (instancetype)dictionaryWithInt32s:(const int32_t [__nullable])values
+ forKeys:(const int64_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -4392,8 +4392,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithInt32s:(const int32_t [])values
- forKeys:(const int64_t [])keys
+- (instancetype)initWithInt32s:(const int32_t [__nullable])values
+ forKeys:(const int64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -4503,8 +4503,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithUInt64s:(const uint64_t [])values
- forKeys:(const int64_t [])keys
++ (instancetype)dictionaryWithUInt64s:(const uint64_t [__nullable])values
+ forKeys:(const int64_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -4536,8 +4536,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithUInt64s:(const uint64_t [])values
- forKeys:(const int64_t [])keys
+- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
+ forKeys:(const int64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -4647,8 +4647,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithInt64s:(const int64_t [])values
- forKeys:(const int64_t [])keys
++ (instancetype)dictionaryWithInt64s:(const int64_t [__nullable])values
+ forKeys:(const int64_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -4680,8 +4680,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithInt64s:(const int64_t [])values
- forKeys:(const int64_t [])keys
+- (instancetype)initWithInt64s:(const int64_t [__nullable])values
+ forKeys:(const int64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -4791,8 +4791,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithBools:(const BOOL [])values
- forKeys:(const int64_t [])keys
++ (instancetype)dictionaryWithBools:(const BOOL [__nullable])values
+ forKeys:(const int64_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -4824,8 +4824,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithBools:(const BOOL [])values
- forKeys:(const int64_t [])keys
+- (instancetype)initWithBools:(const BOOL [__nullable])values
+ forKeys:(const int64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -4935,8 +4935,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithFloats:(const float [])values
- forKeys:(const int64_t [])keys
++ (instancetype)dictionaryWithFloats:(const float [__nullable])values
+ forKeys:(const int64_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -4968,8 +4968,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithFloats:(const float [])values
- forKeys:(const int64_t [])keys
+- (instancetype)initWithFloats:(const float [__nullable])values
+ forKeys:(const int64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -5079,8 +5079,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithDoubles:(const double [])values
- forKeys:(const int64_t [])keys
++ (instancetype)dictionaryWithDoubles:(const double [__nullable])values
+ forKeys:(const int64_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -5112,8 +5112,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithDoubles:(const double [])values
- forKeys:(const int64_t [])keys
+- (instancetype)initWithDoubles:(const double [__nullable])values
+ forKeys:(const int64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -5238,8 +5238,8 @@ NS_ASSUME_NONNULL_BEGIN
* @return A newly instanced dictionary with the keys and values in it.
**/
+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValues:(const int32_t [])values
- forKeys:(const int64_t [])keys
+ rawValues:(const int32_t [__nullable])values
+ forKeys:(const int64_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -5284,8 +5284,8 @@ NS_ASSUME_NONNULL_BEGIN
* @return A newly initialized dictionary with the keys and values in it.
**/
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValues:(const int32_t [])values
- forKeys:(const int64_t [])keys
+ rawValues:(const int32_t [__nullable])values
+ forKeys:(const int64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -5449,8 +5449,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithObjects:(const ObjectType GPB_UNSAFE_UNRETAINED [])objects
- forKeys:(const int64_t [])keys
++ (instancetype)dictionaryWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
+ forKeys:(const int64_t [__nullable])keys
count:(NSUInteger)count;
/**
@@ -5482,8 +5482,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithObjects:(const ObjectType GPB_UNSAFE_UNRETAINED [])objects
- forKeys:(const int64_t [])keys
+- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
+ forKeys:(const int64_t [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -5592,8 +5592,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithUInt32s:(const uint32_t [])values
- forKeys:(const BOOL [])keys
++ (instancetype)dictionaryWithUInt32s:(const uint32_t [__nullable])values
+ forKeys:(const BOOL [__nullable])keys
count:(NSUInteger)count;
/**
@@ -5625,8 +5625,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithUInt32s:(const uint32_t [])values
- forKeys:(const BOOL [])keys
+- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
+ forKeys:(const BOOL [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -5736,8 +5736,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithInt32s:(const int32_t [])values
- forKeys:(const BOOL [])keys
++ (instancetype)dictionaryWithInt32s:(const int32_t [__nullable])values
+ forKeys:(const BOOL [__nullable])keys
count:(NSUInteger)count;
/**
@@ -5769,8 +5769,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithInt32s:(const int32_t [])values
- forKeys:(const BOOL [])keys
+- (instancetype)initWithInt32s:(const int32_t [__nullable])values
+ forKeys:(const BOOL [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -5880,8 +5880,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithUInt64s:(const uint64_t [])values
- forKeys:(const BOOL [])keys
++ (instancetype)dictionaryWithUInt64s:(const uint64_t [__nullable])values
+ forKeys:(const BOOL [__nullable])keys
count:(NSUInteger)count;
/**
@@ -5913,8 +5913,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithUInt64s:(const uint64_t [])values
- forKeys:(const BOOL [])keys
+- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
+ forKeys:(const BOOL [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -6024,8 +6024,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithInt64s:(const int64_t [])values
- forKeys:(const BOOL [])keys
++ (instancetype)dictionaryWithInt64s:(const int64_t [__nullable])values
+ forKeys:(const BOOL [__nullable])keys
count:(NSUInteger)count;
/**
@@ -6057,8 +6057,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithInt64s:(const int64_t [])values
- forKeys:(const BOOL [])keys
+- (instancetype)initWithInt64s:(const int64_t [__nullable])values
+ forKeys:(const BOOL [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -6168,8 +6168,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithBools:(const BOOL [])values
- forKeys:(const BOOL [])keys
++ (instancetype)dictionaryWithBools:(const BOOL [__nullable])values
+ forKeys:(const BOOL [__nullable])keys
count:(NSUInteger)count;
/**
@@ -6201,8 +6201,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithBools:(const BOOL [])values
- forKeys:(const BOOL [])keys
+- (instancetype)initWithBools:(const BOOL [__nullable])values
+ forKeys:(const BOOL [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -6312,8 +6312,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithFloats:(const float [])values
- forKeys:(const BOOL [])keys
++ (instancetype)dictionaryWithFloats:(const float [__nullable])values
+ forKeys:(const BOOL [__nullable])keys
count:(NSUInteger)count;
/**
@@ -6345,8 +6345,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithFloats:(const float [])values
- forKeys:(const BOOL [])keys
+- (instancetype)initWithFloats:(const float [__nullable])values
+ forKeys:(const BOOL [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -6456,8 +6456,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithDoubles:(const double [])values
- forKeys:(const BOOL [])keys
++ (instancetype)dictionaryWithDoubles:(const double [__nullable])values
+ forKeys:(const BOOL [__nullable])keys
count:(NSUInteger)count;
/**
@@ -6489,8 +6489,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithDoubles:(const double [])values
- forKeys:(const BOOL [])keys
+- (instancetype)initWithDoubles:(const double [__nullable])values
+ forKeys:(const BOOL [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -6615,8 +6615,8 @@ NS_ASSUME_NONNULL_BEGIN
* @return A newly instanced dictionary with the keys and values in it.
**/
+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValues:(const int32_t [])values
- forKeys:(const BOOL [])keys
+ rawValues:(const int32_t [__nullable])values
+ forKeys:(const BOOL [__nullable])keys
count:(NSUInteger)count;
/**
@@ -6661,8 +6661,8 @@ NS_ASSUME_NONNULL_BEGIN
* @return A newly initialized dictionary with the keys and values in it.
**/
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValues:(const int32_t [])values
- forKeys:(const BOOL [])keys
+ rawValues:(const int32_t [__nullable])values
+ forKeys:(const BOOL [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -6826,8 +6826,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithObjects:(const ObjectType GPB_UNSAFE_UNRETAINED [])objects
- forKeys:(const BOOL [])keys
++ (instancetype)dictionaryWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
+ forKeys:(const BOOL [__nullable])keys
count:(NSUInteger)count;
/**
@@ -6859,8 +6859,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithObjects:(const ObjectType GPB_UNSAFE_UNRETAINED [])objects
- forKeys:(const BOOL [])keys
+- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
+ forKeys:(const BOOL [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -6969,8 +6969,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithUInt32s:(const uint32_t [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
++ (instancetype)dictionaryWithUInt32s:(const uint32_t [__nullable])values
+ forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
count:(NSUInteger)count;
/**
@@ -7002,8 +7002,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithUInt32s:(const uint32_t [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
+- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
+ forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -7113,8 +7113,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithInt32s:(const int32_t [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
++ (instancetype)dictionaryWithInt32s:(const int32_t [__nullable])values
+ forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
count:(NSUInteger)count;
/**
@@ -7146,8 +7146,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithInt32s:(const int32_t [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
+- (instancetype)initWithInt32s:(const int32_t [__nullable])values
+ forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -7257,8 +7257,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithUInt64s:(const uint64_t [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
++ (instancetype)dictionaryWithUInt64s:(const uint64_t [__nullable])values
+ forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
count:(NSUInteger)count;
/**
@@ -7290,8 +7290,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithUInt64s:(const uint64_t [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
+- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
+ forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -7401,8 +7401,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithInt64s:(const int64_t [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
++ (instancetype)dictionaryWithInt64s:(const int64_t [__nullable])values
+ forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
count:(NSUInteger)count;
/**
@@ -7434,8 +7434,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithInt64s:(const int64_t [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
+- (instancetype)initWithInt64s:(const int64_t [__nullable])values
+ forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -7545,8 +7545,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithBools:(const BOOL [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
++ (instancetype)dictionaryWithBools:(const BOOL [__nullable])values
+ forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
count:(NSUInteger)count;
/**
@@ -7578,8 +7578,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithBools:(const BOOL [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
+- (instancetype)initWithBools:(const BOOL [__nullable])values
+ forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -7689,8 +7689,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithFloats:(const float [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
++ (instancetype)dictionaryWithFloats:(const float [__nullable])values
+ forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
count:(NSUInteger)count;
/**
@@ -7722,8 +7722,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithFloats:(const float [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
+- (instancetype)initWithFloats:(const float [__nullable])values
+ forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -7833,8 +7833,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly instanced dictionary with the keys and values in it.
**/
-+ (instancetype)dictionaryWithDoubles:(const double [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
++ (instancetype)dictionaryWithDoubles:(const double [__nullable])values
+ forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
count:(NSUInteger)count;
/**
@@ -7866,8 +7866,8 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A newly initialized dictionary with a copy of the values and keys.
**/
-- (instancetype)initWithDoubles:(const double [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
+- (instancetype)initWithDoubles:(const double [__nullable])values
+ forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -7992,8 +7992,8 @@ NS_ASSUME_NONNULL_BEGIN
* @return A newly instanced dictionary with the keys and values in it.
**/
+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValues:(const int32_t [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
+ rawValues:(const int32_t [__nullable])values
+ forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
count:(NSUInteger)count;
/**
@@ -8038,8 +8038,8 @@ NS_ASSUME_NONNULL_BEGIN
* @return A newly initialized dictionary with the keys and values in it.
**/
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
- rawValues:(const int32_t [])values
- forKeys:(const NSString * GPB_UNSAFE_UNRETAINED [])keys
+ rawValues:(const int32_t [__nullable])values
+ forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
/**
@@ -8195,19 +8195,19 @@ NS_ASSUME_NONNULL_END
//%PDDM-DEFINE VALUE_FOR_KEY_POD(KEY_TYPE, VALUE_TYPE, VNAME)
//%/**
//% * Gets the value for the given key.
-//% *
+//% *
//% * @param value Pointer into which the value will be set, if found.
//% * @param key Key under which the value is stored, if present.
-//% *
+//% *
//% * @return YES if the key was found and the value was copied, NO otherwise.
//% **/
//%- (BOOL)get##VNAME##:(nullable VALUE_TYPE *)value forKey:(KEY_TYPE)key;
//%PDDM-DEFINE VALUE_FOR_KEY_OBJECT(KEY_TYPE, VALUE_TYPE, VNAME)
//%/**
//% * Fetches the object stored under the given key.
-//% *
+//% *
//% * @param key Key under which the value is stored, if present.
-//% *
+//% *
//% * @return The object if found, nil otherwise.
//% **/
//%- (VALUE_TYPE)objectForKey:(KEY_TYPE)key;
@@ -8218,7 +8218,7 @@ NS_ASSUME_NONNULL_END
//%PDDM-DEFINE ARRAY_ARG_MODIFIEREnum()
// Nothing
//%PDDM-DEFINE ARRAY_ARG_MODIFIEROBJECT()
-//%GPB_UNSAFE_UNRETAINED ##
+//%__nonnull GPB_UNSAFE_UNRETAINED ##
//%PDDM-DEFINE DICTIONARY_CLASS_DECLPOD(KEY_NAME, VALUE_NAME, VALUE_TYPE)
//%GPB##KEY_NAME##VALUE_NAME##Dictionary
//%PDDM-DEFINE DICTIONARY_CLASS_DECLEnum(KEY_NAME, VALUE_NAME, VALUE_TYPE)
@@ -8231,7 +8231,7 @@ NS_ASSUME_NONNULL_END
//%/**
//% * Class used for map fields of <##KEY_TYPE##, ##VALUE_TYPE##>
//% * values. This performs better than boxing into NSNumbers in NSDictionaries.
-//% *
+//% *
//% * @note This class is not meant to be subclassed.
//% **/
//%@interface DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) : NSObject <NSCopying>
@@ -8246,10 +8246,10 @@ NS_ASSUME_NONNULL_END
//%
//%/**
//% * Creates and initializes a dictionary with the single entry given.
-//% *
+//% *
//% * @param ##VNAME_VAR The value to be placed in the dictionary.
//% * @param key ##VNAME_VAR$S## The key under which to store the value.
-//% *
+//% *
//% * @return A newly instanced dictionary with the key and value in it.
//% **/
//%+ (instancetype)dictionaryWith##VNAME##:(VALUE_TYPE)##VNAME_VAR
@@ -8257,23 +8257,23 @@ NS_ASSUME_NONNULL_END
//%
//%/**
//% * Creates and initializes a dictionary with the entries given.
-//% *
+//% *
//% * @param ##VNAME_VAR##s The values to be placed in the dictionary.
//% * @param keys ##VNAME_VAR$S## The keys under which to store the values.
//% * @param count ##VNAME_VAR$S## The number of entries to store in the dictionary.
-//% *
+//% *
//% * @return A newly instanced dictionary with the keys and values in it.
//% **/
-//%+ (instancetype)dictionaryWith##VNAME##s:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[])##VNAME_VAR##s
-//% ##VNAME$S## forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[])keys
+//%+ (instancetype)dictionaryWith##VNAME##s:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[__nullable])##VNAME_VAR##s
+//% ##VNAME$S## forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[__nullable])keys
//% ##VNAME$S## count:(NSUInteger)count;
//%
//%/**
//% * Creates and initializes a dictionary with the entries from the given.
//% * dictionary.
-//% *
+//% *
//% * @param dictionary Dictionary containing the entries to add to the dictionary.
-//% *
+//% *
//% * @return A newly instanced dictionary with the entries from the given
//% * dictionary in it.
//% **/
@@ -8281,40 +8281,40 @@ NS_ASSUME_NONNULL_END
//%
//%/**
//% * Creates and initializes a dictionary with the given capacity.
-//% *
+//% *
//% * @param numItems Capacity needed for the dictionary.
-//% *
+//% *
//% * @return A newly instanced dictionary with the given capacity.
//% **/
//%+ (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
//%
//%/**
//% * Initializes this dictionary, copying the given values and keys.
-//% *
+//% *
//% * @param ##VNAME_VAR##s The values to be placed in this dictionary.
//% * @param keys ##VNAME_VAR$S## The keys under which to store the values.
//% * @param count ##VNAME_VAR$S## The number of elements to copy into the dictionary.
-//% *
+//% *
//% * @return A newly initialized dictionary with a copy of the values and keys.
//% **/
-//%- (instancetype)initWith##VNAME##s:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[])##VNAME_VAR##s
-//% ##VNAME$S## forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[])keys
+//%- (instancetype)initWith##VNAME##s:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[__nullable])##VNAME_VAR##s
+//% ##VNAME$S## forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[__nullable])keys
//% ##VNAME$S## count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
//%
//%/**
//% * Initializes this dictionary, copying the entries from the given dictionary.
-//% *
+//% *
//% * @param dictionary Dictionary containing the entries to add to this dictionary.
-//% *
+//% *
//% * @return A newly initialized dictionary with the entries of the given dictionary.
//% **/
//%- (instancetype)initWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary;
//%
//%/**
//% * Initializes this dictionary with the requested capacity.
-//% *
+//% *
//% * @param numItems Number of items needed for this dictionary.
-//% *
+//% *
//% * @return A newly initialized dictionary with the requested capacity.
//% **/
//%- (instancetype)initWithCapacity:(NSUInteger)numItems;
@@ -8323,7 +8323,7 @@ NS_ASSUME_NONNULL_END
//%
//%/**
//% * Adds the keys and values from another dictionary.
-//% *
+//% *
//% * @param otherDictionary Dictionary containing entries to be added to this
//% * dictionary.
//% **/
@@ -8342,7 +8342,7 @@ NS_ASSUME_NONNULL_END
//%/**
//% * Class used for map fields of <##KEY_TYPE##, ##VALUE_TYPE##>
//% * values. This performs better than boxing into NSNumbers in NSDictionaries.
-//% *
+//% *
//% * @note This class is not meant to be subclassed.
//% **/
//%@interface GPB##KEY_NAME##VALUE_NAME##Dictionary : NSObject <NSCopying>
@@ -8359,20 +8359,20 @@ NS_ASSUME_NONNULL_END
//%
//%/**
//% * Creates and initializes a dictionary with the given validation function.
-//% *
+//% *
//% * @param func The enum validation function for the dictionary.
-//% *
+//% *
//% * @return A newly instanced dictionary.
//% **/
//%+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func;
//%
//%/**
//% * Creates and initializes a dictionary with the single entry given.
-//% *
+//% *
//% * @param func The enum validation function for the dictionary.
//% * @param rawValue The raw enum value to be placed in the dictionary.
//% * @param key The key under which to store the value.
-//% *
+//% *
//% * @return A newly instanced dictionary with the key and value in it.
//% **/
//%+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
@@ -8381,25 +8381,25 @@ NS_ASSUME_NONNULL_END
//%
//%/**
//% * Creates and initializes a dictionary with the entries given.
-//% *
+//% *
//% * @param func The enum validation function for the dictionary.
//% * @param values The raw enum values values to be placed in the dictionary.
//% * @param keys The keys under which to store the values.
//% * @param count The number of entries to store in the dictionary.
-//% *
+//% *
//% * @return A newly instanced dictionary with the keys and values in it.
//% **/
//%+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
-//% rawValues:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[])values
-//% forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[])keys
+//% rawValues:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[__nullable])values
+//% forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[__nullable])keys
//% count:(NSUInteger)count;
//%
//%/**
//% * Creates and initializes a dictionary with the entries from the given.
//% * dictionary.
-//% *
+//% *
//% * @param dictionary Dictionary containing the entries to add to the dictionary.
-//% *
+//% *
//% * @return A newly instanced dictionary with the entries from the given
//% * dictionary in it.
//% **/
@@ -8407,10 +8407,10 @@ NS_ASSUME_NONNULL_END
//%
//%/**
//% * Creates and initializes a dictionary with the given capacity.
-//% *
+//% *
//% * @param func The enum validation function for the dictionary.
//% * @param numItems Capacity needed for the dictionary.
-//% *
+//% *
//% * @return A newly instanced dictionary with the given capacity.
//% **/
//%+ (instancetype)dictionaryWithValidationFunction:(nullable GPBEnumValidationFunc)func
@@ -8418,34 +8418,34 @@ NS_ASSUME_NONNULL_END
//%
//%/**
//% * Initializes a dictionary with the given validation function.
-//% *
+//% *
//% * @param func The enum validation function for the dictionary.
-//% *
+//% *
//% * @return A newly initialized dictionary.
//% **/
//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
//%
//%/**
//% * Initializes a dictionary with the entries given.
-//% *
+//% *
//% * @param func The enum validation function for the dictionary.
//% * @param values The raw enum values values to be placed in the dictionary.
//% * @param keys The keys under which to store the values.
//% * @param count The number of entries to store in the dictionary.
-//% *
+//% *
//% * @return A newly initialized dictionary with the keys and values in it.
//% **/
//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
-//% rawValues:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[])values
-//% forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[])keys
+//% rawValues:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[__nullable])values
+//% forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[__nullable])keys
//% count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
//%
//%/**
//% * Initializes a dictionary with the entries from the given.
//% * dictionary.
-//% *
+//% *
//% * @param dictionary Dictionary containing the entries to add to the dictionary.
-//% *
+//% *
//% * @return A newly initialized dictionary with the entries from the given
//% * dictionary in it.
//% **/
@@ -8453,10 +8453,10 @@ NS_ASSUME_NONNULL_END
//%
//%/**
//% * Initializes a dictionary with the given capacity.
-//% *
+//% *
//% * @param func The enum validation function for the dictionary.
//% * @param numItems Capacity needed for the dictionary.
-//% *
+//% *
//% * @return A newly initialized dictionary with the given capacity.
//% **/
//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
@@ -8470,23 +8470,23 @@ NS_ASSUME_NONNULL_END
//%
//%/**
//% * Gets the raw enum value for the given key.
-//% *
+//% *
//% * @note This method bypass the validationFunc to enable the access of values that
//% * were not known at the time the binary was compiled.
-//% *
+//% *
//% * @param rawValue Pointer into which the value will be set, if found.
//% * @param key Key under which the value is stored, if present.
-//% *
+//% *
//% * @return YES if the key was found and the value was copied, NO otherwise.
//% **/
//%- (BOOL)getRawValue:(nullable VALUE_TYPE *)rawValue forKey:(KEY_TYPE##KisP$S##KisP)key;
//%
//%/**
//% * Enumerates the keys and values on this dictionary with the given block.
-//% *
+//% *
//% * @note This method bypass the validationFunc to enable the access of values that
//% * were not known at the time the binary was compiled.
-//% *
+//% *
//% * @param block The block to enumerate with.
//% * **key**: The key for the current entry.
//% * **rawValue**: The value for the current entry
@@ -8497,10 +8497,10 @@ NS_ASSUME_NONNULL_END
//%
//%/**
//% * Adds the keys and raw enum values from another dictionary.
-//% *
+//% *
//% * @note This method bypass the validationFunc to enable the setting of values that
//% * were not known at the time the binary was compiled.
-//% *
+//% *
//% * @param otherDictionary Dictionary containing entries to be added to this
//% * dictionary.
//% **/
@@ -8521,7 +8521,7 @@ NS_ASSUME_NONNULL_END
//%
//%/**
//% * Enumerates the keys and values on this dictionary with the given block.
-//% *
+//% *
//% * @param block The block to enumerate with.
//% * **key**: ##VNAME_VAR$S## The key for the current entry.
//% * **VNAME_VAR**: The value for the current entry
@@ -8533,7 +8533,7 @@ NS_ASSUME_NONNULL_END
//%PDDM-DEFINE DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR)
//%/**
//% * Sets the value for the given key.
-//% *
+//% *
//% * @param ##VNAME_VAR The value to set.
//% * @param key ##VNAME_VAR$S## The key under which to store the value.
//% **/
@@ -8541,7 +8541,7 @@ NS_ASSUME_NONNULL_END
//%DICTIONARY_EXTRA_MUTABLE_METHODS_##VHELPER(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE)
//%/**
//% * Removes the entry for the given key.
-//% *
+//% *
//% * @param aKey Key to be removed from this dictionary.
//% **/
//%- (void)remove##VNAME##ForKey:(KEY_TYPE##KisP$S##KisP)aKey;
@@ -8559,10 +8559,10 @@ NS_ASSUME_NONNULL_END
//%
//%/**
//% * Sets the raw enum value for the given key.
-//% *
+//% *
//% * @note This method bypass the validationFunc to enable the setting of values that
//% * were not known at the time the binary was compiled.
-//% *
+//% *
//% * @param rawValue The raw enum value to set.
//% * @param key The key under which to store the raw enum value.
//% **/
diff --git a/objectivec/GPBDictionary.m b/objectivec/GPBDictionary.m
index fd8bd1ce..1c67c680 100644
--- a/objectivec/GPBDictionary.m
+++ b/objectivec/GPBDictionary.m
@@ -13579,22 +13579,26 @@ void GPBDictionaryReadEntry(id mapDictionary,
- (id)copyWithZone:(NSZone *)zone {
if (_dictionary == nil) {
- _dictionary = [[NSMutableDictionary alloc] init];
+ return [[NSMutableDictionary allocWithZone:zone] init];
}
return [_dictionary copyWithZone:zone];
}
- (id)mutableCopyWithZone:(NSZone *)zone {
if (_dictionary == nil) {
- _dictionary = [[NSMutableDictionary alloc] init];
+ return [[NSMutableDictionary allocWithZone:zone] init];
}
return [_dictionary mutableCopyWithZone:zone];
}
+// Not really needed, but subscripting is likely common enough it doesn't hurt
+// to ensure it goes directly to the real NSMutableDictionary.
- (id)objectForKeyedSubscript:(id)key {
return [_dictionary objectForKeyedSubscript:key];
}
+// Not really needed, but subscripting is likely common enough it doesn't hurt
+// to ensure it goes directly to the real NSMutableDictionary.
- (void)setObject:(id)obj forKeyedSubscript:(id<NSCopying>)key {
if (_dictionary == nil) {
_dictionary = [[NSMutableDictionary alloc] init];
diff --git a/objectivec/GPBMessage.m b/objectivec/GPBMessage.m
index 4a6f0612..9660f1ed 100644
--- a/objectivec/GPBMessage.m
+++ b/objectivec/GPBMessage.m
@@ -1023,9 +1023,11 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
if (arrayOrMap) {
if (field.fieldType == GPBFieldTypeRepeated) {
if (GPBFieldDataTypeIsObject(field)) {
- GPBAutocreatedArray *autoArray = arrayOrMap;
- if (autoArray->_autocreator == self) {
- autoArray->_autocreator = nil;
+ if ([arrayOrMap isKindOfClass:[GPBAutocreatedArray class]]) {
+ GPBAutocreatedArray *autoArray = arrayOrMap;
+ if (autoArray->_autocreator == self) {
+ autoArray->_autocreator = nil;
+ }
}
} else {
// Type doesn't matter, it is a GPB*Array.
@@ -1037,9 +1039,11 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
} else {
if ((field.mapKeyDataType == GPBDataTypeString) &&
GPBFieldDataTypeIsObject(field)) {
- GPBAutocreatedDictionary *autoDict = arrayOrMap;
- if (autoDict->_autocreator == self) {
- autoDict->_autocreator = nil;
+ if ([arrayOrMap isKindOfClass:[GPBAutocreatedDictionary class]]) {
+ GPBAutocreatedDictionary *autoDict = arrayOrMap;
+ if (autoDict->_autocreator == self) {
+ autoDict->_autocreator = nil;
+ }
}
} else {
// Type doesn't matter, it is a GPB*Dictionary.
diff --git a/objectivec/GPBUtilities.h b/objectivec/GPBUtilities.h
index 52e7d2e0..5464dfb3 100644
--- a/objectivec/GPBUtilities.h
+++ b/objectivec/GPBUtilities.h
@@ -392,6 +392,11 @@ void GPBSetMessageMapField(GPBMessage *self,
**/
NSData *GPBEmptyNSData(void) __attribute__((pure));
+/**
+ * Drops the `unknownFields` from the given message and from all sub message.
+ **/
+void GPBMessageDropUnknownFieldsRecursively(GPBMessage *message);
+
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
diff --git a/objectivec/GPBUtilities.m b/objectivec/GPBUtilities.m
index d4538598..1843478c 100644
--- a/objectivec/GPBUtilities.m
+++ b/objectivec/GPBUtilities.m
@@ -58,6 +58,125 @@ NSData *GPBEmptyNSData(void) {
return defaultNSData;
}
+void GPBMessageDropUnknownFieldsRecursively(GPBMessage *initialMessage) {
+ if (!initialMessage) {
+ return;
+ }
+
+ // Use an array as a list to process to avoid recursion.
+ NSMutableArray *todo = [NSMutableArray arrayWithObject:initialMessage];
+
+ while (todo.count) {
+ GPBMessage *msg = todo.lastObject;
+ [todo removeLastObject];
+
+ // Clear unknowns.
+ msg.unknownFields = nil;
+
+ // Handle the message fields.
+ GPBDescriptor *descriptor = [[msg class] descriptor];
+ for (GPBFieldDescriptor *field in descriptor->fields_) {
+ if (!GPBFieldDataTypeIsMessage(field)) {
+ continue;
+ }
+ switch (field.fieldType) {
+ case GPBFieldTypeSingle:
+ if (GPBGetHasIvarField(msg, field)) {
+ GPBMessage *fieldMessage = GPBGetObjectIvarWithFieldNoAutocreate(msg, field);
+ [todo addObject:fieldMessage];
+ }
+ break;
+
+ case GPBFieldTypeRepeated: {
+ NSArray *fieldMessages = GPBGetObjectIvarWithFieldNoAutocreate(msg, field);
+ if (fieldMessages.count) {
+ [todo addObjectsFromArray:fieldMessages];
+ }
+ break;
+ }
+
+ case GPBFieldTypeMap: {
+ id rawFieldMap = GPBGetObjectIvarWithFieldNoAutocreate(msg, field);
+ switch (field.mapKeyDataType) {
+ case GPBDataTypeBool:
+ [(GPBBoolObjectDictionary*)rawFieldMap enumerateKeysAndObjectsUsingBlock:^(
+ BOOL key, id _Nonnull object, BOOL * _Nonnull stop) {
+ #pragma unused(key, stop)
+ [todo addObject:object];
+ }];
+ break;
+ case GPBDataTypeFixed32:
+ case GPBDataTypeUInt32:
+ [(GPBUInt32ObjectDictionary*)rawFieldMap enumerateKeysAndObjectsUsingBlock:^(
+ uint32_t key, id _Nonnull object, BOOL * _Nonnull stop) {
+ #pragma unused(key, stop)
+ [todo addObject:object];
+ }];
+ break;
+ case GPBDataTypeInt32:
+ case GPBDataTypeSFixed32:
+ case GPBDataTypeSInt32:
+ [(GPBInt32ObjectDictionary*)rawFieldMap enumerateKeysAndObjectsUsingBlock:^(
+ int32_t key, id _Nonnull object, BOOL * _Nonnull stop) {
+ #pragma unused(key, stop)
+ [todo addObject:object];
+ }];
+ break;
+ case GPBDataTypeFixed64:
+ case GPBDataTypeUInt64:
+ [(GPBUInt64ObjectDictionary*)rawFieldMap enumerateKeysAndObjectsUsingBlock:^(
+ uint64_t key, id _Nonnull object, BOOL * _Nonnull stop) {
+ #pragma unused(key, stop)
+ [todo addObject:object];
+ }];
+ break;
+ case GPBDataTypeInt64:
+ case GPBDataTypeSFixed64:
+ case GPBDataTypeSInt64:
+ [(GPBInt64ObjectDictionary*)rawFieldMap enumerateKeysAndObjectsUsingBlock:^(
+ int64_t key, id _Nonnull object, BOOL * _Nonnull stop) {
+ #pragma unused(key, stop)
+ [todo addObject:object];
+ }];
+ break;
+ case GPBDataTypeString:
+ [(NSDictionary*)rawFieldMap enumerateKeysAndObjectsUsingBlock:^(
+ NSString * _Nonnull key, GPBMessage * _Nonnull obj, BOOL * _Nonnull stop) {
+ #pragma unused(key, stop)
+ [todo addObject:obj];
+ }];
+ break;
+ case GPBDataTypeFloat:
+ case GPBDataTypeDouble:
+ case GPBDataTypeEnum:
+ case GPBDataTypeBytes:
+ case GPBDataTypeGroup:
+ case GPBDataTypeMessage:
+ NSCAssert(NO, @"Aren't valid key types.");
+ }
+ break;
+ } // switch(field.mapKeyDataType)
+ } // switch(field.fieldType)
+ } // for(fields)
+
+ // Handle any extensions holding messages.
+ for (GPBExtensionDescriptor *extension in [msg extensionsCurrentlySet]) {
+ if (!GPBDataTypeIsMessage(extension.dataType)) {
+ continue;
+ }
+ if (extension.isRepeated) {
+ NSArray *extMessages = [msg getExtension:extension];
+ [todo addObjectsFromArray:extMessages];
+ } else {
+ GPBMessage *extMessage = [msg getExtension:extension];
+ [todo addObject:extMessage];
+ }
+ } // for(extensionsCurrentlySet)
+
+ } // while(todo.count)
+}
+
+
// -- About Version Checks --
// There's actually 3 places these checks all come into play:
// 1. When the generated source is compile into .o files, the header check
@@ -408,9 +527,11 @@ void GPBSetRetainedObjectIvarWithFieldInternal(GPBMessage *self,
if (field.fieldType == GPBFieldTypeRepeated) {
// If the old array was autocreated by us, then clear it.
if (GPBDataTypeIsObject(fieldType)) {
- GPBAutocreatedArray *autoArray = oldValue;
- if (autoArray->_autocreator == self) {
- autoArray->_autocreator = nil;
+ if ([oldValue isKindOfClass:[GPBAutocreatedArray class]]) {
+ GPBAutocreatedArray *autoArray = oldValue;
+ if (autoArray->_autocreator == self) {
+ autoArray->_autocreator = nil;
+ }
}
} else {
// Type doesn't matter, it is a GPB*Array.
@@ -423,9 +544,11 @@ void GPBSetRetainedObjectIvarWithFieldInternal(GPBMessage *self,
// If the old map was autocreated by us, then clear it.
if ((field.mapKeyDataType == GPBDataTypeString) &&
GPBDataTypeIsObject(fieldType)) {
- GPBAutocreatedDictionary *autoDict = oldValue;
- if (autoDict->_autocreator == self) {
- autoDict->_autocreator = nil;
+ if ([oldValue isKindOfClass:[GPBAutocreatedDictionary class]]) {
+ GPBAutocreatedDictionary *autoDict = oldValue;
+ if (autoDict->_autocreator == self) {
+ autoDict->_autocreator = nil;
+ }
}
} else {
// Type doesn't matter, it is a GPB*Dictionary.
diff --git a/objectivec/GPBWellKnownTypes.h b/objectivec/GPBWellKnownTypes.h
index 90d96c6f..04df4178 100644
--- a/objectivec/GPBWellKnownTypes.h
+++ b/objectivec/GPBWellKnownTypes.h
@@ -112,16 +112,27 @@ typedef NS_ENUM(NSInteger, GPBWellKnownTypesErrorCode) {
* @note: Not all second/nanos combinations can be represented in a
* NSTimeInterval, so getting this could be a lossy transform.
**/
-@property(nonatomic, readwrite) NSTimeInterval timeIntervalSince1970;
+@property(nonatomic, readwrite) NSTimeInterval timeInterval;
/**
* Initializes a GPBDuration with the given NSTimeInterval.
*
- * @param timeIntervalSince1970 Time interval to configure the GPBDuration with.
+ * @param timeInterval Time interval to configure the GPBDuration with.
*
* @return A newly initialized GPBDuration.
**/
-- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970;
+- (instancetype)initWithTimeInterval:(NSTimeInterval)timeInterval;
+
+// These next two methods are deprecated because GBPDuration has no need of a
+// "base" time. The older methods were about symmetry with GBPTimestamp, but
+// the unix epoch usage is too confusing.
+
+/** Deprecated, use timeInterval instead. */
+@property(nonatomic, readwrite) NSTimeInterval timeIntervalSince1970
+ __attribute__((deprecated("Use timeInterval")));
+/** Deprecated, use initWithTimeInterval: instead. */
+- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970
+ __attribute__((deprecated("Use initWithTimeInterval:")));
@end
diff --git a/objectivec/GPBWellKnownTypes.m b/objectivec/GPBWellKnownTypes.m
index ed798a2e..2808afeb 100644
--- a/objectivec/GPBWellKnownTypes.m
+++ b/objectivec/GPBWellKnownTypes.m
@@ -41,15 +41,25 @@ NSString *const GPBWellKnownTypesErrorDomain =
static NSString *kTypePrefixGoogleApisCom = @"type.googleapis.com/";
-static NSTimeInterval TimeIntervalSince1970FromSecondsAndNanos(int64_t seconds,
- int32_t nanos) {
+static NSTimeInterval TimeIntervalFromSecondsAndNanos(int64_t seconds,
+ int32_t nanos) {
return seconds + (NSTimeInterval)nanos / 1e9;
}
-static int32_t SecondsAndNanosFromTimeIntervalSince1970(NSTimeInterval time,
- int64_t *outSeconds) {
+static int32_t SecondsAndNanosFromTimeInterval(NSTimeInterval time,
+ int64_t *outSeconds,
+ BOOL nanosMustBePositive) {
NSTimeInterval seconds;
NSTimeInterval nanos = modf(time, &seconds);
+
+ if (nanosMustBePositive && (nanos < 0)) {
+ // Per Timestamp.proto, nanos is non-negative and "Negative second values with
+ // fractions must still have non-negative nanos values that count forward in
+ // time. Must be from 0 to 999,999,999 inclusive."
+ --seconds;
+ nanos = 1.0 + nanos;
+ }
+
nanos *= 1e9;
*outSeconds = (int64_t)seconds;
return (int32_t)nanos;
@@ -88,8 +98,8 @@ static NSString *ParseTypeFromURL(NSString *typeURLString) {
- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 {
if ((self = [super init])) {
int64_t seconds;
- int32_t nanos = SecondsAndNanosFromTimeIntervalSince1970(
- timeIntervalSince1970, &seconds);
+ int32_t nanos = SecondsAndNanosFromTimeInterval(
+ timeIntervalSince1970, &seconds, YES);
self.seconds = seconds;
self.nanos = nanos;
}
@@ -105,13 +115,13 @@ static NSString *ParseTypeFromURL(NSString *typeURLString) {
}
- (NSTimeInterval)timeIntervalSince1970 {
- return TimeIntervalSince1970FromSecondsAndNanos(self.seconds, self.nanos);
+ return TimeIntervalFromSecondsAndNanos(self.seconds, self.nanos);
}
- (void)setTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 {
int64_t seconds;
int32_t nanos =
- SecondsAndNanosFromTimeIntervalSince1970(timeIntervalSince1970, &seconds);
+ SecondsAndNanosFromTimeInterval(timeIntervalSince1970, &seconds, YES);
self.seconds = seconds;
self.nanos = nanos;
}
@@ -122,29 +132,41 @@ static NSString *ParseTypeFromURL(NSString *typeURLString) {
@implementation GPBDuration (GBPWellKnownTypes)
-- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 {
+- (instancetype)initWithTimeInterval:(NSTimeInterval)timeInterval {
if ((self = [super init])) {
int64_t seconds;
- int32_t nanos = SecondsAndNanosFromTimeIntervalSince1970(
- timeIntervalSince1970, &seconds);
+ int32_t nanos = SecondsAndNanosFromTimeInterval(
+ timeInterval, &seconds, NO);
self.seconds = seconds;
self.nanos = nanos;
}
return self;
}
-- (NSTimeInterval)timeIntervalSince1970 {
- return TimeIntervalSince1970FromSecondsAndNanos(self.seconds, self.nanos);
+- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 {
+ return [self initWithTimeInterval:timeIntervalSince1970];
}
-- (void)setTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 {
+- (NSTimeInterval)timeInterval {
+ return TimeIntervalFromSecondsAndNanos(self.seconds, self.nanos);
+}
+
+- (void)setTimeInterval:(NSTimeInterval)timeInterval {
int64_t seconds;
int32_t nanos =
- SecondsAndNanosFromTimeIntervalSince1970(timeIntervalSince1970, &seconds);
+ SecondsAndNanosFromTimeInterval(timeInterval, &seconds, NO);
self.seconds = seconds;
self.nanos = nanos;
}
+- (NSTimeInterval)timeIntervalSince1970 {
+ return self.timeInterval;
+}
+
+- (void)setTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 {
+ self.timeInterval = timeIntervalSince1970;
+}
+
@end
#pragma mark - GPBAny
diff --git a/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj b/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj
index 7ce5d54f..919d0076 100644
--- a/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj
+++ b/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj
@@ -57,6 +57,7 @@
F47476E51D21A524007C7B1A /* Duration.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B4248D41A92826400BC1EC6 /* Duration.pbobjc.m */; };
F47476E61D21A524007C7B1A /* Timestamp.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B4248D61A92826400BC1EC6 /* Timestamp.pbobjc.m */; };
F4B51B1E1BBC610700744318 /* GPBObjectiveCPlusPlusTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4B51B1D1BBC610700744318 /* GPBObjectiveCPlusPlusTest.mm */; };
+ F4C4B9E41E1D976300D3B61D /* GPBDictionaryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F4C4B9E21E1D974F00D3B61D /* GPBDictionaryTests.m */; };
F4E675971B21D0000054530B /* Any.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675871B21D0000054530B /* Any.pbobjc.m */; };
F4E675991B21D0000054530B /* Api.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675891B21D0000054530B /* Api.pbobjc.m */; };
F4E6759B1B21D0000054530B /* Empty.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E6758B1B21D0000054530B /* Empty.pbobjc.m */; };
@@ -187,6 +188,7 @@
F4B6B8B21A9CCBDA00892426 /* GPBUnknownFieldSet_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBUnknownFieldSet_PackagePrivate.h; sourceTree = "<group>"; };
F4B6B8B61A9CD1DE00892426 /* GPBExtensionInternals.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBExtensionInternals.h; sourceTree = "<group>"; };
F4B6B8B81A9CD1DE00892426 /* GPBRootObject_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBRootObject_PackagePrivate.h; sourceTree = "<group>"; };
+ F4C4B9E21E1D974F00D3B61D /* GPBDictionaryTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBDictionaryTests.m; sourceTree = "<group>"; };
F4CF31701B162ED800BD9B06 /* unittest_objc_startup.proto */ = {isa = PBXFileReference; lastKnownFileType = text; path = unittest_objc_startup.proto; sourceTree = "<group>"; };
F4E675861B21D0000054530B /* Any.pbobjc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Any.pbobjc.h; path = google/protobuf/Any.pbobjc.h; sourceTree = "<group>"; };
F4E675871B21D0000054530B /* Any.pbobjc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Any.pbobjc.m; path = google/protobuf/Any.pbobjc.m; sourceTree = "<group>"; };
@@ -393,6 +395,7 @@
7461B69D0F94FDF800A0C422 /* GPBCodedOuputStreamTests.m */,
5102DABB1891A052002037B6 /* GPBConcurrencyTests.m */,
F4353D1C1AB8822D005A6198 /* GPBDescriptorTests.m */,
+ F4C4B9E21E1D974F00D3B61D /* GPBDictionaryTests.m */,
F4353D2C1AC06F10005A6198 /* GPBDictionaryTests.pddm */,
F4353D2D1AC06F10005A6198 /* GPBDictionaryTests+Bool.m */,
F4353D2E1AC06F10005A6198 /* GPBDictionaryTests+Int32.m */,
@@ -677,6 +680,7 @@
F4353D371AC06F10005A6198 /* GPBDictionaryTests+String.m in Sources */,
F4353D381AC06F10005A6198 /* GPBDictionaryTests+UInt32.m in Sources */,
8BBEA4B7147C727D00C4ADB7 /* GPBUtilitiesTests.m in Sources */,
+ F4C4B9E41E1D976300D3B61D /* GPBDictionaryTests.m in Sources */,
8BBEA4B8147C727D00C4ADB7 /* GPBWireFormatTests.m in Sources */,
8BD3981F14BE59D70081D629 /* GPBUnittestProtos.m in Sources */,
8B8B615D17DF7056002EE618 /* GPBARCUnittestProtos.m in Sources */,
diff --git a/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj b/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj
index 5f599719..64fc45c0 100644
--- a/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj
+++ b/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj
@@ -65,6 +65,7 @@
F47476E91D21A537007C7B1A /* Duration.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B4248DE1A929C7D00BC1EC6 /* Duration.pbobjc.m */; };
F47476EA1D21A537007C7B1A /* Timestamp.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B4248E01A929C7D00BC1EC6 /* Timestamp.pbobjc.m */; };
F4B51B1C1BBC5C7100744318 /* GPBObjectiveCPlusPlusTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4B51B1B1BBC5C7100744318 /* GPBObjectiveCPlusPlusTest.mm */; };
+ F4C4B9E71E1D97BF00D3B61D /* GPBDictionaryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F4C4B9E51E1D97BB00D3B61D /* GPBDictionaryTests.m */; };
F4E675D01B21D1620054530B /* Any.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675B71B21D1440054530B /* Any.pbobjc.m */; };
F4E675D11B21D1620054530B /* Api.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675B91B21D1440054530B /* Api.pbobjc.m */; };
F4E675D21B21D1620054530B /* Empty.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E675BC1B21D1440054530B /* Empty.pbobjc.m */; };
@@ -209,6 +210,7 @@
F4B6B8B11A9CCBBB00892426 /* GPBUnknownFieldSet_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBUnknownFieldSet_PackagePrivate.h; sourceTree = "<group>"; };
F4B6B8B31A9CD1C600892426 /* GPBExtensionInternals.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBExtensionInternals.h; sourceTree = "<group>"; };
F4B6B8B51A9CD1C600892426 /* GPBRootObject_PackagePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPBRootObject_PackagePrivate.h; sourceTree = "<group>"; };
+ F4C4B9E51E1D97BB00D3B61D /* GPBDictionaryTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBDictionaryTests.m; sourceTree = "<group>"; };
F4CF31711B162EF500BD9B06 /* unittest_objc_startup.proto */ = {isa = PBXFileReference; lastKnownFileType = text; path = unittest_objc_startup.proto; sourceTree = "<group>"; };
F4E675B61B21D1440054530B /* Any.pbobjc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Any.pbobjc.h; path = google/protobuf/Any.pbobjc.h; sourceTree = "<group>"; };
F4E675B71B21D1440054530B /* Any.pbobjc.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = Any.pbobjc.m; path = google/protobuf/Any.pbobjc.m; sourceTree = "<group>"; };
@@ -431,6 +433,7 @@
7461B69D0F94FDF800A0C422 /* GPBCodedOuputStreamTests.m */,
5102DABB1891A052002037B6 /* GPBConcurrencyTests.m */,
F4353D1E1AB88243005A6198 /* GPBDescriptorTests.m */,
+ F4C4B9E51E1D97BB00D3B61D /* GPBDictionaryTests.m */,
F4353D3A1AC06F31005A6198 /* GPBDictionaryTests.pddm */,
F4353D3B1AC06F31005A6198 /* GPBDictionaryTests+Bool.m */,
F4353D3C1AC06F31005A6198 /* GPBDictionaryTests+Int32.m */,
@@ -773,6 +776,7 @@
F4353D451AC06F31005A6198 /* GPBDictionaryTests+String.m in Sources */,
F4353D461AC06F31005A6198 /* GPBDictionaryTests+UInt32.m in Sources */,
8BBEA4B7147C727D00C4ADB7 /* GPBUtilitiesTests.m in Sources */,
+ F4C4B9E71E1D97BF00D3B61D /* GPBDictionaryTests.m in Sources */,
8BBEA4B8147C727D00C4ADB7 /* GPBWireFormatTests.m in Sources */,
8BD3981F14BE59D70081D629 /* GPBUnittestProtos.m in Sources */,
8B8B615D17DF7056002EE618 /* GPBARCUnittestProtos.m in Sources */,
diff --git a/objectivec/README.md b/objectivec/README.md
index 06118349..7226f0b9 100644
--- a/objectivec/README.md
+++ b/objectivec/README.md
@@ -44,7 +44,7 @@ Add `objectivec/\*.h` & `objectivec/\*.m` except for
If the target is using ARC, remember to turn off ARC (`-fno-objc-arc`) for the
`.m` files.
-The files generated by `protoc` for the `*.proto` files (`\*.pbobjc.h' and
+The files generated by `protoc` for the `*.proto` files (`\*.pbobjc.h` and
`\*.pbobjc.m`) are then also added to the target.
Usage
diff --git a/objectivec/Tests/GPBARCUnittestProtos.m b/objectivec/Tests/GPBARCUnittestProtos.m
index 28d2396c..29f6ccf6 100644
--- a/objectivec/Tests/GPBARCUnittestProtos.m
+++ b/objectivec/Tests/GPBARCUnittestProtos.m
@@ -42,6 +42,8 @@
#import "google/protobuf/Unittest.pbobjc.h"
#import "google/protobuf/UnittestCustomOptions.pbobjc.h"
#import "google/protobuf/UnittestCycle.pbobjc.h"
+#import "google/protobuf/UnittestDeprecated.pbobjc.h"
+#import "google/protobuf/UnittestDeprecatedFile.pbobjc.h"
#import "google/protobuf/UnittestDropUnknownFields.pbobjc.h"
#import "google/protobuf/UnittestEmbedOptimizeFor.pbobjc.h"
#import "google/protobuf/UnittestEmpty.pbobjc.h"
diff --git a/objectivec/Tests/GPBArrayTests.m b/objectivec/Tests/GPBArrayTests.m
index 0fb15e40..31f75501 100644
--- a/objectivec/Tests/GPBArrayTests.m
+++ b/objectivec/Tests/GPBArrayTests.m
@@ -32,6 +32,7 @@
#import <XCTest/XCTest.h>
#import "GPBArray.h"
+#import "GPBArray_PackagePrivate.h"
#import "GPBTestUtilities.h"
@@ -3436,3 +3437,175 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
}
@end
+
+#pragma mark - GPBAutocreatedArray Tests
+
+// These are hand written tests to double check some behaviors of the
+// GPBAutocreatedArray.
+
+// NOTE: GPBAutocreatedArray is private to the library, users of the library
+// should never have to directly deal with this class.
+
+@interface GPBAutocreatedArrayTests : XCTestCase
+@end
+
+@implementation GPBAutocreatedArrayTests
+
+- (void)testEquality {
+ GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
+
+ XCTAssertTrue([array isEqual:@[]]);
+ XCTAssertTrue([array isEqualToArray:@[]]);
+
+ XCTAssertFalse([array isEqual:@[ @"foo" ]]);
+ XCTAssertFalse([array isEqualToArray:@[ @"foo" ]]);
+
+ [array addObject:@"foo"];
+
+ XCTAssertFalse([array isEqual:@[]]);
+ XCTAssertFalse([array isEqualToArray:@[]]);
+ XCTAssertTrue([array isEqual:@[ @"foo" ]]);
+ XCTAssertTrue([array isEqualToArray:@[ @"foo" ]]);
+ XCTAssertFalse([array isEqual:@[ @"bar" ]]);
+ XCTAssertFalse([array isEqualToArray:@[ @"bar" ]]);
+
+ GPBAutocreatedArray *array2 = [[GPBAutocreatedArray alloc] init];
+
+ XCTAssertFalse([array isEqual:array2]);
+ XCTAssertFalse([array isEqualToArray:array2]);
+
+ [array2 addObject:@"bar"];
+ XCTAssertFalse([array isEqual:array2]);
+ XCTAssertFalse([array isEqualToArray:array2]);
+
+ [array2 replaceObjectAtIndex:0 withObject:@"foo"];
+ XCTAssertTrue([array isEqual:array2]);
+ XCTAssertTrue([array isEqualToArray:array2]);
+
+ [array2 release];
+ [array release];
+}
+
+- (void)testCopy {
+ {
+ GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
+
+ NSArray *cpy = [array copy];
+ XCTAssertTrue(cpy != array); // Ptr compare
+ XCTAssertTrue([cpy isKindOfClass:[NSArray class]]);
+ XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedArray class]]);
+ XCTAssertEqual(cpy.count, (NSUInteger)0);
+
+ NSArray *cpy2 = [array copy];
+ XCTAssertTrue(cpy2 != array); // Ptr compare
+ // Can't compare cpy and cpy2 because NSArray has a singleton empty
+ // array it uses, so the ptrs are the same.
+ XCTAssertTrue([cpy2 isKindOfClass:[NSArray class]]);
+ XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedArray class]]);
+ XCTAssertEqual(cpy2.count, (NSUInteger)0);
+
+ [cpy2 release];
+ [cpy release];
+ [array release];
+ }
+
+ {
+ GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
+
+ NSMutableArray *cpy = [array mutableCopy];
+ XCTAssertTrue(cpy != array); // Ptr compare
+ XCTAssertTrue([cpy isKindOfClass:[NSMutableArray class]]);
+ XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedArray class]]);
+ XCTAssertEqual(cpy.count, (NSUInteger)0);
+
+ NSMutableArray *cpy2 = [array mutableCopy];
+ XCTAssertTrue(cpy2 != array); // Ptr compare
+ XCTAssertTrue(cpy2 != cpy); // Ptr compare
+ XCTAssertTrue([cpy2 isKindOfClass:[NSMutableArray class]]);
+ XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedArray class]]);
+ XCTAssertEqual(cpy2.count, (NSUInteger)0);
+
+ [cpy2 release];
+ [cpy release];
+ [array release];
+ }
+
+ {
+ GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
+ [array addObject:@"foo"];
+ [array addObject:@"bar"];
+
+ NSArray *cpy = [array copy];
+ XCTAssertTrue(cpy != array); // Ptr compare
+ XCTAssertTrue([cpy isKindOfClass:[NSArray class]]);
+ XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedArray class]]);
+ XCTAssertEqual(cpy.count, (NSUInteger)2);
+ XCTAssertEqualObjects(cpy[0], @"foo");
+ XCTAssertEqualObjects(cpy[1], @"bar");
+
+ NSArray *cpy2 = [array copy];
+ XCTAssertTrue(cpy2 != array); // Ptr compare
+ XCTAssertTrue(cpy2 != cpy); // Ptr compare
+ XCTAssertTrue([cpy2 isKindOfClass:[NSArray class]]);
+ XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedArray class]]);
+ XCTAssertEqual(cpy2.count, (NSUInteger)2);
+ XCTAssertEqualObjects(cpy2[0], @"foo");
+ XCTAssertEqualObjects(cpy2[1], @"bar");
+
+ [cpy2 release];
+ [cpy release];
+ [array release];
+ }
+
+ {
+ GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
+ [array addObject:@"foo"];
+ [array addObject:@"bar"];
+
+ NSMutableArray *cpy = [array mutableCopy];
+ XCTAssertTrue(cpy != array); // Ptr compare
+ XCTAssertTrue([cpy isKindOfClass:[NSArray class]]);
+ XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedArray class]]);
+ XCTAssertEqual(cpy.count, (NSUInteger)2);
+ XCTAssertEqualObjects(cpy[0], @"foo");
+ XCTAssertEqualObjects(cpy[1], @"bar");
+
+ NSMutableArray *cpy2 = [array mutableCopy];
+ XCTAssertTrue(cpy2 != array); // Ptr compare
+ XCTAssertTrue(cpy2 != cpy); // Ptr compare
+ XCTAssertTrue([cpy2 isKindOfClass:[NSArray class]]);
+ XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedArray class]]);
+ XCTAssertEqual(cpy2.count, (NSUInteger)2);
+ XCTAssertEqualObjects(cpy2[0], @"foo");
+ XCTAssertEqualObjects(cpy2[1], @"bar");
+
+ [cpy2 release];
+ [cpy release];
+ [array release];
+ }
+}
+
+- (void)testIndexedSubscriptSupport {
+ // The base NSArray/NSMutableArray behaviors for *IndexedSubscript methods
+ // should still work via the methods that one has to override to make an
+ // NSMutableArray subclass. i.e. - this should "just work" and if these
+ // crash/fail, then something is wrong in how NSMutableArray is subclassed.
+
+ GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
+
+ [array addObject:@"foo"];
+ [array addObject:@"bar"];
+ XCTAssertEqual(array.count, (NSUInteger)2);
+ XCTAssertEqualObjects(array[0], @"foo");
+ XCTAssertEqualObjects(array[1], @"bar");
+ array[0] = @"foo2";
+ array[2] = @"baz";
+ XCTAssertEqual(array.count, (NSUInteger)3);
+ XCTAssertEqualObjects(array[0], @"foo2");
+ XCTAssertEqualObjects(array[1], @"bar");
+ XCTAssertEqualObjects(array[2], @"baz");
+
+ [array release];
+}
+
+@end
diff --git a/objectivec/Tests/GPBDictionaryTests.m b/objectivec/Tests/GPBDictionaryTests.m
new file mode 100644
index 00000000..52b4b328
--- /dev/null
+++ b/objectivec/Tests/GPBDictionaryTests.m
@@ -0,0 +1,186 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2017 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#import <Foundation/Foundation.h>
+#import <XCTest/XCTest.h>
+
+#import "GPBDictionary.h"
+#import "GPBDictionary_PackagePrivate.h"
+
+#import "GPBTestUtilities.h"
+
+#pragma mark - GPBAutocreatedDictionary Tests
+
+// These are hand written tests to double check some behaviors of the
+// GPBAutocreatedDictionary. The GPBDictionary+[type]Tests files are generate
+// tests.
+
+// NOTE: GPBAutocreatedDictionary is private to the library, users of the
+// library should never have to directly deal with this class.
+
+@interface GPBAutocreatedDictionaryTests : XCTestCase
+@end
+
+@implementation GPBAutocreatedDictionaryTests
+
+- (void)testEquality {
+ GPBAutocreatedDictionary *dict = [[GPBAutocreatedDictionary alloc] init];
+
+ XCTAssertTrue([dict isEqual:@{}]);
+ XCTAssertTrue([dict isEqualToDictionary:@{}]);
+
+ XCTAssertFalse([dict isEqual:@{ @"foo" : @"bar" }]);
+ XCTAssertFalse([dict isEqualToDictionary:@{ @"foo" : @"bar" }]);
+
+ [dict setObject:@"bar" forKey:@"foo"];
+
+ XCTAssertFalse([dict isEqual:@{}]);
+ XCTAssertFalse([dict isEqualToDictionary:@{}]);
+ XCTAssertTrue([dict isEqual:@{ @"foo" : @"bar" }]);
+ XCTAssertTrue([dict isEqualToDictionary:@{ @"foo" : @"bar" }]);
+ XCTAssertFalse([dict isEqual:@{ @"bar" : @"baz" }]);
+ XCTAssertFalse([dict isEqualToDictionary:@{ @"bar" : @"baz" }]);
+
+ GPBAutocreatedDictionary *dict2 = [[GPBAutocreatedDictionary alloc] init];
+
+ XCTAssertFalse([dict isEqual:dict2]);
+ XCTAssertFalse([dict isEqualToDictionary:dict2]);
+
+ [dict2 setObject:@"mumble" forKey:@"foo"];
+ XCTAssertFalse([dict isEqual:dict2]);
+ XCTAssertFalse([dict isEqualToDictionary:dict2]);
+
+ [dict2 setObject:@"bar" forKey:@"foo"];
+ XCTAssertTrue([dict isEqual:dict2]);
+ XCTAssertTrue([dict isEqualToDictionary:dict2]);
+
+ [dict2 release];
+ [dict release];
+}
+
+- (void)testCopy {
+ {
+ GPBAutocreatedDictionary *dict = [[GPBAutocreatedDictionary alloc] init];
+
+ NSDictionary *cpy = [dict copy];
+ XCTAssertTrue(cpy != dict); // Ptr compare
+ XCTAssertTrue([cpy isKindOfClass:[NSDictionary class]]);
+ XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedDictionary class]]);
+ XCTAssertEqual(cpy.count, (NSUInteger)0);
+
+ NSDictionary *cpy2 = [dict copy];
+ XCTAssertTrue(cpy2 != dict); // Ptr compare
+ XCTAssertTrue(cpy2 != cpy); // Ptr compare
+ XCTAssertTrue([cpy2 isKindOfClass:[NSDictionary class]]);
+ XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedDictionary class]]);
+ XCTAssertEqual(cpy2.count, (NSUInteger)0);
+
+ [cpy2 release];
+ [cpy release];
+ [dict release];
+ }
+
+ {
+ GPBAutocreatedDictionary *dict = [[GPBAutocreatedDictionary alloc] init];
+
+ NSMutableDictionary *cpy = [dict mutableCopy];
+ XCTAssertTrue(cpy != dict); // Ptr compare
+ XCTAssertTrue([cpy isKindOfClass:[NSMutableDictionary class]]);
+ XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedDictionary class]]);
+ XCTAssertEqual(cpy.count, (NSUInteger)0);
+
+ NSMutableDictionary *cpy2 = [dict mutableCopy];
+ XCTAssertTrue(cpy2 != dict); // Ptr compare
+ XCTAssertTrue(cpy2 != cpy); // Ptr compare
+ XCTAssertTrue([cpy2 isKindOfClass:[NSMutableDictionary class]]);
+ XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedDictionary class]]);
+ XCTAssertEqual(cpy2.count, (NSUInteger)0);
+
+ [cpy2 release];
+ [cpy release];
+ [dict release];
+ }
+
+ {
+ GPBAutocreatedDictionary *dict = [[GPBAutocreatedDictionary alloc] init];
+ dict[@"foo"] = @"bar";
+ dict[@"baz"] = @"mumble";
+
+ NSDictionary *cpy = [dict copy];
+ XCTAssertTrue(cpy != dict); // Ptr compare
+ XCTAssertTrue([cpy isKindOfClass:[NSDictionary class]]);
+ XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedDictionary class]]);
+ XCTAssertEqual(cpy.count, (NSUInteger)2);
+ XCTAssertEqualObjects(cpy[@"foo"], @"bar");
+ XCTAssertEqualObjects(cpy[@"baz"], @"mumble");
+
+ NSDictionary *cpy2 = [dict copy];
+ XCTAssertTrue(cpy2 != dict); // Ptr compare
+ XCTAssertTrue(cpy2 != cpy); // Ptr compare
+ XCTAssertTrue([cpy2 isKindOfClass:[NSDictionary class]]);
+ XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedDictionary class]]);
+ XCTAssertEqual(cpy2.count, (NSUInteger)2);
+ XCTAssertEqualObjects(cpy2[@"foo"], @"bar");
+ XCTAssertEqualObjects(cpy2[@"baz"], @"mumble");
+
+ [cpy2 release];
+ [cpy release];
+ [dict release];
+ }
+
+ {
+ GPBAutocreatedDictionary *dict = [[GPBAutocreatedDictionary alloc] init];
+ dict[@"foo"] = @"bar";
+ dict[@"baz"] = @"mumble";
+
+ NSMutableDictionary *cpy = [dict mutableCopy];
+ XCTAssertTrue(cpy != dict); // Ptr compare
+ XCTAssertTrue([cpy isKindOfClass:[NSMutableDictionary class]]);
+ XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedDictionary class]]);
+ XCTAssertEqual(cpy.count, (NSUInteger)2);
+ XCTAssertEqualObjects(cpy[@"foo"], @"bar");
+ XCTAssertEqualObjects(cpy[@"baz"], @"mumble");
+
+ NSMutableDictionary *cpy2 = [dict mutableCopy];
+ XCTAssertTrue(cpy2 != dict); // Ptr compare
+ XCTAssertTrue(cpy2 != cpy); // Ptr compare
+ XCTAssertTrue([cpy2 isKindOfClass:[NSMutableDictionary class]]);
+ XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedDictionary class]]);
+ XCTAssertEqual(cpy2.count, (NSUInteger)2);
+ XCTAssertEqualObjects(cpy2[@"foo"], @"bar");
+ XCTAssertEqualObjects(cpy2[@"baz"], @"mumble");
+
+ [cpy2 release];
+ [cpy release];
+ [dict release];
+ }
+}
+
+@end
diff --git a/objectivec/Tests/GPBMessageTests.m b/objectivec/Tests/GPBMessageTests.m
index a3c5a6b4..c15535c5 100644
--- a/objectivec/Tests/GPBMessageTests.m
+++ b/objectivec/Tests/GPBMessageTests.m
@@ -1082,6 +1082,20 @@
[repeatedStringArray release];
}
+- (void)testSetOverAutocreatedArrayAndSetAgain {
+ // Ensure when dealing with replacing an array it is handled being either
+ // an autocreated one or a straight NSArray.
+
+ // The real test here is that nothing crashes while doing the work.
+ TestAllTypes *message = [TestAllTypes message];
+ [message.repeatedStringArray addObject:@"foo"];
+ XCTAssertEqual(message.repeatedStringArray_Count, (NSUInteger)1);
+ message.repeatedStringArray = [NSMutableArray arrayWithObjects:@"bar", @"bar2", nil];
+ XCTAssertEqual(message.repeatedStringArray_Count, (NSUInteger)2);
+ message.repeatedStringArray = [NSMutableArray arrayWithObject:@"baz"];
+ XCTAssertEqual(message.repeatedStringArray_Count, (NSUInteger)1);
+}
+
- (void)testReplaceAutocreatedArray {
// Replacing array should orphan the old one and cause its creator to become
// visible.
@@ -1281,6 +1295,23 @@
[strToStr release];
}
+- (void)testSetOverAutocreatedMapAndSetAgain {
+ // Ensure when dealing with replacing a map it is handled being either
+ // an autocreated one or a straight NSDictionary.
+
+ // The real test here is that nothing crashes while doing the work.
+ TestRecursiveMessageWithRepeatedField *message =
+ [TestRecursiveMessageWithRepeatedField message];
+ message.strToStr[@"foo"] = @"bar";
+ XCTAssertEqual(message.strToStr_Count, (NSUInteger)1);
+ message.strToStr =
+ [NSMutableDictionary dictionaryWithObjectsAndKeys:@"bar", @"key1", @"baz", @"key2", nil];
+ XCTAssertEqual(message.strToStr_Count, (NSUInteger)2);
+ message.strToStr =
+ [NSMutableDictionary dictionaryWithObject:@"baz" forKey:@"mumble"];
+ XCTAssertEqual(message.strToStr_Count, (NSUInteger)1);
+}
+
- (void)testReplaceAutocreatedMap {
// Replacing map should orphan the old one and cause its creator to become
// visible.
diff --git a/objectivec/Tests/GPBUnittestProtos.m b/objectivec/Tests/GPBUnittestProtos.m
index 8d2948bf..756bd99e 100644
--- a/objectivec/Tests/GPBUnittestProtos.m
+++ b/objectivec/Tests/GPBUnittestProtos.m
@@ -43,6 +43,8 @@
#import "google/protobuf/UnittestArena.pbobjc.m"
#import "google/protobuf/UnittestCustomOptions.pbobjc.m"
#import "google/protobuf/UnittestCycle.pbobjc.m"
+#import "google/protobuf/UnittestDeprecated.pbobjc.m"
+#import "google/protobuf/UnittestDeprecatedFile.pbobjc.m"
#import "google/protobuf/UnittestDropUnknownFields.pbobjc.m"
#import "google/protobuf/UnittestEmbedOptimizeFor.pbobjc.m"
#import "google/protobuf/UnittestEmpty.pbobjc.m"
diff --git a/objectivec/Tests/GPBUtilitiesTests.m b/objectivec/Tests/GPBUtilitiesTests.m
index dfaca660..2e206a54 100644
--- a/objectivec/Tests/GPBUtilitiesTests.m
+++ b/objectivec/Tests/GPBUtilitiesTests.m
@@ -39,6 +39,7 @@
#import "GPBDescriptor.h"
#import "GPBDescriptor_PackagePrivate.h"
#import "GPBMessage.h"
+#import "GPBUnknownField_PackagePrivate.h"
#import "google/protobuf/MapUnittest.pbobjc.h"
#import "google/protobuf/Unittest.pbobjc.h"
@@ -197,4 +198,203 @@
}
}
+// Helper to make an unknown field set with something in it.
+static GPBUnknownFieldSet *UnknownFieldsSetHelper(int num) {
+ GPBUnknownFieldSet *result =
+ [[[GPBUnknownFieldSet alloc] init] autorelease];
+
+ GPBUnknownField *field =
+ [[[GPBUnknownField alloc] initWithNumber:num] autorelease];
+ [field addVarint:num];
+ [result addField:field];
+
+ return result;
+}
+
+- (void)testDropMessageUnknownFieldsRecursively {
+ TestAllExtensions *message = [TestAllExtensions message];
+
+ // Give it unknownFields.
+ message.unknownFields = UnknownFieldsSetHelper(777);
+
+ // Given it extensions that include a message with unknown fields of its own.
+ {
+ // Int
+ [message setExtension:[UnittestRoot optionalInt32Extension] value:@5];
+
+ // Group
+ OptionalGroup_extension *optionalGroup = [OptionalGroup_extension message];
+ optionalGroup.a = 123;
+ optionalGroup.unknownFields = UnknownFieldsSetHelper(779);
+ [message setExtension:[UnittestRoot optionalGroupExtension]
+ value:optionalGroup];
+
+ // Message
+ TestAllTypes_NestedMessage *nestedMessage =
+ [TestAllTypes_NestedMessage message];
+ nestedMessage.bb = 456;
+ nestedMessage.unknownFields = UnknownFieldsSetHelper(778);
+ [message setExtension:[UnittestRoot optionalNestedMessageExtension]
+ value:nestedMessage];
+
+ // Repeated Group
+ RepeatedGroup_extension *repeatedGroup =
+ [[RepeatedGroup_extension alloc] init];
+ repeatedGroup.a = 567;
+ repeatedGroup.unknownFields = UnknownFieldsSetHelper(780);
+ [message addExtension:[UnittestRoot repeatedGroupExtension]
+ value:repeatedGroup];
+ [repeatedGroup release];
+
+ // Repeated Message
+ nestedMessage = [[TestAllTypes_NestedMessage alloc] init];
+ nestedMessage.bb = 678;
+ nestedMessage.unknownFields = UnknownFieldsSetHelper(781);
+ [message addExtension:[UnittestRoot repeatedNestedMessageExtension]
+ value:nestedMessage];
+ [nestedMessage release];
+ }
+
+ // Confirm everything is there.
+
+ XCTAssertNotNil(message);
+ XCTAssertNotNil(message.unknownFields);
+ XCTAssertTrue([message hasExtension:[UnittestRoot optionalInt32Extension]]);
+
+ {
+ XCTAssertTrue([message hasExtension:[UnittestRoot optionalGroupExtension]]);
+ OptionalGroup_extension *optionalGroup =
+ [message getExtension:[UnittestRoot optionalGroupExtension]];
+ XCTAssertNotNil(optionalGroup);
+ XCTAssertEqual(optionalGroup.a, 123);
+ XCTAssertNotNil(optionalGroup.unknownFields);
+ }
+
+ {
+ XCTAssertTrue([message hasExtension:[UnittestRoot optionalNestedMessageExtension]]);
+ TestAllTypes_NestedMessage *nestedMessage =
+ [message getExtension:[UnittestRoot optionalNestedMessageExtension]];
+ XCTAssertNotNil(nestedMessage);
+ XCTAssertEqual(nestedMessage.bb, 456);
+ XCTAssertNotNil(nestedMessage.unknownFields);
+ }
+
+ {
+ XCTAssertTrue([message hasExtension:[UnittestRoot repeatedGroupExtension]]);
+ NSArray *repeatedGroups = [message getExtension:[UnittestRoot repeatedGroupExtension]];
+ XCTAssertEqual(repeatedGroups.count, (NSUInteger)1);
+ RepeatedGroup_extension *repeatedGroup = repeatedGroups.firstObject;
+ XCTAssertNotNil(repeatedGroup);
+ XCTAssertEqual(repeatedGroup.a, 567);
+ XCTAssertNotNil(repeatedGroup.unknownFields);
+ }
+
+ {
+ XCTAssertTrue([message hasExtension:[UnittestRoot repeatedNestedMessageExtension]]);
+ NSArray *repeatedNestedMessages = [message getExtension:[UnittestRoot repeatedNestedMessageExtension]];
+ XCTAssertEqual(repeatedNestedMessages.count, (NSUInteger)1);
+ TestAllTypes_NestedMessage *repeatedNestedMessage = repeatedNestedMessages.firstObject;
+ XCTAssertNotNil(repeatedNestedMessage);
+ XCTAssertEqual(repeatedNestedMessage.bb, 678);
+ XCTAssertNotNil(repeatedNestedMessage.unknownFields);
+ }
+
+ // Drop them.
+ GPBMessageDropUnknownFieldsRecursively(message);
+
+ // Confirm unknowns are gone from within the messages.
+
+ XCTAssertNotNil(message);
+ XCTAssertNil(message.unknownFields);
+ XCTAssertTrue([message hasExtension:[UnittestRoot optionalInt32Extension]]);
+
+ {
+ XCTAssertTrue([message hasExtension:[UnittestRoot optionalGroupExtension]]);
+ OptionalGroup_extension *optionalGroup =
+ [message getExtension:[UnittestRoot optionalGroupExtension]];
+ XCTAssertNotNil(optionalGroup);
+ XCTAssertEqual(optionalGroup.a, 123);
+ XCTAssertNil(optionalGroup.unknownFields);
+ }
+
+ {
+ XCTAssertTrue([message hasExtension:[UnittestRoot optionalNestedMessageExtension]]);
+ TestAllTypes_NestedMessage *nestedMessage =
+ [message getExtension:[UnittestRoot optionalNestedMessageExtension]];
+ XCTAssertNotNil(nestedMessage);
+ XCTAssertEqual(nestedMessage.bb, 456);
+ XCTAssertNil(nestedMessage.unknownFields);
+ }
+
+ {
+ XCTAssertTrue([message hasExtension:[UnittestRoot repeatedGroupExtension]]);
+ NSArray *repeatedGroups = [message getExtension:[UnittestRoot repeatedGroupExtension]];
+ XCTAssertEqual(repeatedGroups.count, (NSUInteger)1);
+ RepeatedGroup_extension *repeatedGroup = repeatedGroups.firstObject;
+ XCTAssertNotNil(repeatedGroup);
+ XCTAssertEqual(repeatedGroup.a, 567);
+ XCTAssertNil(repeatedGroup.unknownFields);
+ }
+
+ {
+ XCTAssertTrue([message hasExtension:[UnittestRoot repeatedNestedMessageExtension]]);
+ NSArray *repeatedNestedMessages = [message getExtension:[UnittestRoot repeatedNestedMessageExtension]];
+ XCTAssertEqual(repeatedNestedMessages.count, (NSUInteger)1);
+ TestAllTypes_NestedMessage *repeatedNestedMessage = repeatedNestedMessages.firstObject;
+ XCTAssertNotNil(repeatedNestedMessage);
+ XCTAssertEqual(repeatedNestedMessage.bb, 678);
+ XCTAssertNil(repeatedNestedMessage.unknownFields);
+ }
+
+}
+
+- (void)testDropMessageUnknownFieldsRecursively_Maps {
+ TestMap *message = [TestMap message];
+
+ {
+ ForeignMessage *foreignMessage = [ForeignMessage message];
+ foreignMessage.unknownFields = UnknownFieldsSetHelper(100);
+ [message.mapInt32ForeignMessage setObject:foreignMessage forKey:100];
+
+ foreignMessage = [ForeignMessage message];
+ foreignMessage.unknownFields = UnknownFieldsSetHelper(101);
+ [message.mapStringForeignMessage setObject:foreignMessage forKey:@"101"];
+ }
+
+ // Confirm everything is there.
+
+ XCTAssertNotNil(message);
+
+ {
+ ForeignMessage *foreignMessage = [message.mapInt32ForeignMessage objectForKey:100];
+ XCTAssertNotNil(foreignMessage);
+ XCTAssertNotNil(foreignMessage.unknownFields);
+ }
+
+ {
+ ForeignMessage *foreignMessage = [message.mapStringForeignMessage objectForKey:@"101"];
+ XCTAssertNotNil(foreignMessage);
+ XCTAssertNotNil(foreignMessage.unknownFields);
+ }
+
+ GPBMessageDropUnknownFieldsRecursively(message);
+
+ // Confirm unknowns are gone from within the messages.
+
+ XCTAssertNotNil(message);
+
+ {
+ ForeignMessage *foreignMessage = [message.mapInt32ForeignMessage objectForKey:100];
+ XCTAssertNotNil(foreignMessage);
+ XCTAssertNil(foreignMessage.unknownFields);
+ }
+
+ {
+ ForeignMessage *foreignMessage = [message.mapStringForeignMessage objectForKey:@"101"];
+ XCTAssertNotNil(foreignMessage);
+ XCTAssertNil(foreignMessage.unknownFields);
+ }
+
+}
+
@end
diff --git a/objectivec/Tests/GPBWellKnownTypesTest.m b/objectivec/Tests/GPBWellKnownTypesTest.m
index 041841dd..592d5afd 100644
--- a/objectivec/Tests/GPBWellKnownTypesTest.m
+++ b/objectivec/Tests/GPBWellKnownTypesTest.m
@@ -32,11 +32,9 @@
#import <XCTest/XCTest.h>
+#import "GPBTestUtilities.h"
#import "google/protobuf/AnyTest.pbobjc.h"
-// A basically random interval into the future for testing with.
-static const NSTimeInterval kFutureOffsetInterval = 15000;
-
// Nanosecond time accuracy
static const NSTimeInterval kTimeAccuracy = 1e-9;
@@ -46,59 +44,117 @@ static const NSTimeInterval kTimeAccuracy = 1e-9;
@implementation WellKnownTypesTest
- (void)testTimeStamp {
- // Test Creation.
- NSDate *date = [NSDate date];
- GPBTimestamp *timeStamp = [[GPBTimestamp alloc] initWithDate:date];
- NSDate *timeStampDate = timeStamp.date;
-
- // Comparing timeIntervals instead of directly comparing dates because date
- // equality requires the time intervals to be exactly the same, and the
- // timeintervals go through a bit of floating point error as they are
- // converted back and forth from the internal representation.
- XCTAssertEqualWithAccuracy(date.timeIntervalSince1970,
- timeStampDate.timeIntervalSince1970,
- kTimeAccuracy);
-
- NSTimeInterval time = [date timeIntervalSince1970];
- GPBTimestamp *timeStamp2 =
- [[GPBTimestamp alloc] initWithTimeIntervalSince1970:time];
- NSTimeInterval durationTime = timeStamp2.timeIntervalSince1970;
- XCTAssertEqualWithAccuracy(time, durationTime, kTimeAccuracy);
- [timeStamp release];
-
- // Test Mutation.
- date = [NSDate dateWithTimeIntervalSinceNow:kFutureOffsetInterval];
- timeStamp2.date = date;
- timeStampDate = timeStamp2.date;
- XCTAssertEqualWithAccuracy(date.timeIntervalSince1970,
- timeStampDate.timeIntervalSince1970,
- kTimeAccuracy);
-
- time = date.timeIntervalSince1970;
- timeStamp2.timeIntervalSince1970 = time;
- durationTime = timeStamp2.timeIntervalSince1970;
- XCTAssertEqualWithAccuracy(time, durationTime, kTimeAccuracy);
- [timeStamp2 release];
+ // Test negative and positive values.
+ NSTimeInterval values[] = {
+ -428027599.483999967, -1234567.0, -0.5, 0, 0.75, 54321.0, 2468086,483999967
+ };
+ for (size_t i = 0; i < GPBARRAYSIZE(values); ++i) {
+ NSTimeInterval value = values[i];
+
+ // Test Creation - date.
+ NSDate *date = [NSDate dateWithTimeIntervalSince1970:value];
+ GPBTimestamp *timeStamp = [[GPBTimestamp alloc] initWithDate:date];
+
+ XCTAssertGreaterThanOrEqual(timeStamp.nanos, 0,
+ @"Offset %f - Date: %@", (double)value, date);
+ XCTAssertLessThan(timeStamp.nanos, 1e9,
+ @"Offset %f - Date: %@", (double)value, date);
+
+ // Comparing timeIntervals instead of directly comparing dates because date
+ // equality requires the time intervals to be exactly the same, and the
+ // timeintervals go through a bit of floating point error as they are
+ // converted back and forth from the internal representation.
+ XCTAssertEqualWithAccuracy(value, timeStamp.date.timeIntervalSince1970,
+ kTimeAccuracy,
+ @"Offset %f - Date: %@", (double)value, date);
+ [timeStamp release];
+
+ // Test Creation - timeIntervalSince1970.
+ timeStamp = [[GPBTimestamp alloc] initWithTimeIntervalSince1970:value];
+
+ XCTAssertGreaterThanOrEqual(timeStamp.nanos, 0,
+ @"Offset %f - Date: %@", (double)value, date);
+ XCTAssertLessThan(timeStamp.nanos, 1e9,
+ @"Offset %f - Date: %@", (double)value, date);
+
+ XCTAssertEqualWithAccuracy(value, timeStamp.timeIntervalSince1970,
+ kTimeAccuracy,
+ @"Offset %f - Date: %@", (double)value, date);
+ [timeStamp release];
+
+ // Test Mutation - date.
+ timeStamp = [[GPBTimestamp alloc] init];
+ timeStamp.date = date;
+
+ XCTAssertGreaterThanOrEqual(timeStamp.nanos, 0,
+ @"Offset %f - Date: %@", (double)value, date);
+ XCTAssertLessThan(timeStamp.nanos, 1e9,
+ @"Offset %f - Date: %@", (double)value, date);
+
+ XCTAssertEqualWithAccuracy(value, timeStamp.date.timeIntervalSince1970,
+ kTimeAccuracy,
+ @"Offset %f - Date: %@", (double)value, date);
+ [timeStamp release];
+
+ // Test Mutation - timeIntervalSince1970.
+ timeStamp = [[GPBTimestamp alloc] init];
+ timeStamp.timeIntervalSince1970 = value;
+
+ XCTAssertGreaterThanOrEqual(timeStamp.nanos, 0,
+ @"Offset %f - Date: %@", (double)value, date);
+ XCTAssertLessThan(timeStamp.nanos, 1e9,
+ @"Offset %f - Date: %@", (double)value, date);
+
+ XCTAssertEqualWithAccuracy(value, timeStamp.date.timeIntervalSince1970,
+ kTimeAccuracy,
+ @"Offset %f - Date: %@", (double)value, date);
+
+ [timeStamp release];
+ }
}
- (void)testDuration {
- // Test Creation.
- NSTimeInterval time = [[NSDate date] timeIntervalSince1970];
- GPBDuration *duration =
- [[GPBDuration alloc] initWithTimeIntervalSince1970:time];
- NSTimeInterval durationTime = duration.timeIntervalSince1970;
- XCTAssertEqualWithAccuracy(time, durationTime, kTimeAccuracy);
- [duration release];
-
- // Test Mutation.
- GPBDuration *duration2 =
- [[GPBDuration alloc] initWithTimeIntervalSince1970:time];
- NSDate *date = [NSDate dateWithTimeIntervalSinceNow:kFutureOffsetInterval];
- time = date.timeIntervalSince1970;
- duration2.timeIntervalSince1970 = time;
- durationTime = duration2.timeIntervalSince1970;
- XCTAssertEqualWithAccuracy(time, durationTime, kTimeAccuracy);
- [duration2 release];
+ // Test negative and positive values.
+ NSTimeInterval values[] = { -1000.0001, -500.0, -0.5, 0, 0.75, 1000.0, 2000.0002 };
+ for (size_t i = 0; i < GPBARRAYSIZE(values); ++i) {
+ NSTimeInterval value = values[i];
+
+ // Test Creation.
+ GPBDuration *duration =
+ [[GPBDuration alloc] initWithTimeInterval:value];
+ XCTAssertEqualWithAccuracy(value, duration.timeInterval, kTimeAccuracy,
+ @"For interval %f", (double)value);
+ if (value > 0) {
+ XCTAssertGreaterThanOrEqual(duration.seconds, 0,
+ @"For interval %f", (double)value);
+ XCTAssertGreaterThanOrEqual(duration.nanos, 0,
+ @"For interval %f", (double)value);
+ } else {
+ XCTAssertLessThanOrEqual(duration.seconds, 0,
+ @"For interval %f", (double)value);
+ XCTAssertLessThanOrEqual(duration.nanos, 0,
+ @"For interval %f", (double)value);
+ }
+ [duration release];
+
+ // Test Mutation.
+ duration = [[GPBDuration alloc] init];
+ duration.timeInterval = value;
+ XCTAssertEqualWithAccuracy(value, duration.timeInterval, kTimeAccuracy,
+ @"For interval %f", (double)value);
+ if (value > 0) {
+ XCTAssertGreaterThanOrEqual(duration.seconds, 0,
+ @"For interval %f", (double)value);
+ XCTAssertGreaterThanOrEqual(duration.nanos, 0,
+ @"For interval %f", (double)value);
+ } else {
+ XCTAssertLessThanOrEqual(duration.seconds, 0,
+ @"For interval %f", (double)value);
+ XCTAssertLessThanOrEqual(duration.nanos, 0,
+ @"For interval %f", (double)value);
+ }
+ [duration release];
+ }
}
- (void)testAnyHelpers {
diff --git a/objectivec/Tests/unittest_deprecated.proto b/objectivec/Tests/unittest_deprecated.proto
new file mode 100644
index 00000000..96a52bbb
--- /dev/null
+++ b/objectivec/Tests/unittest_deprecated.proto
@@ -0,0 +1,95 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto2";
+
+package protobuf_deprecated;
+option objc_class_prefix = "Dep";
+
+//
+// This file is like unittest_deprecated_file.proto, but uses message, enum,
+// enum value, and field level deprecation.
+//
+// The source generated from this file needs to be inspect to confirm it has
+// all of the expected annotations. It also will be compiled into the unittest
+// and that compile should be clean without errors.
+//
+
+// Mix of field types marked as deprecated.
+message Msg1 {
+ extensions 100 to max;
+
+ optional string string_field = 1 [deprecated=true];
+ required int32 int_field = 2 [deprecated=true];
+ repeated fixed32 fixed_field = 3 [deprecated=true];
+ optional Msg1 msg_field = 4 [deprecated=true];
+}
+
+// Mix of extension field types marked as deprecated.
+extend Msg1 {
+ optional string string_ext_field = 101 [deprecated=true];
+ optional int32 int_ext_field = 102 [deprecated=true];
+ repeated fixed32 fixed_ext_field = 103 [deprecated=true];
+ optional Msg1 msg_ext_field = 104 [deprecated=true];
+}
+
+// Mix of extension field types (scoped to a message) marked as deprecated.
+message Msg1A {
+ extend Msg1 {
+ optional string string_ext2_field = 201 [deprecated=true];
+ optional int32 int_ext2_field = 202 [deprecated=true];
+ repeated fixed32 fixed_ext2_field = 203 [deprecated=true];
+ optional Msg1 msg_ext2_field = 204 [deprecated=true];
+ }
+}
+
+// Enum value marked as deprecated.
+enum Enum1 {
+ ENUM1_ONE = 1;
+ ENUM1_TWO = 2;
+ ENUM1_THREE = 3 [deprecated=true];
+}
+
+// Message marked as deprecated.
+message Msg2 {
+ option deprecated = true;
+
+ optional string string_field = 1;
+ required int32 int_field = 2;
+ repeated fixed32 fixed_field = 3;
+}
+
+// Enum marked as deprecated.
+enum Enum2 {
+ option deprecated = true;
+
+ ENUM2_ONE = 1;
+ ENUM2_TWO = 2;
+ ENUM2_THREE = 3;
+}
diff --git a/objectivec/Tests/unittest_deprecated_file.proto b/objectivec/Tests/unittest_deprecated_file.proto
new file mode 100644
index 00000000..ef92e7de
--- /dev/null
+++ b/objectivec/Tests/unittest_deprecated_file.proto
@@ -0,0 +1,76 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2016 Google Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto2";
+
+package protobuf_deprecated_file;
+option objc_class_prefix = "FileDep";
+
+//
+// This file is like unittest_deprecated.proto, but does NOT use message, enum,
+// enum value, or field level deprecation; instead it uses the file level option
+// to mark everything.
+//
+// The source generated from this file needs to be inspect to confirm it has
+// all of the expected annotations. It also will be compiled into the unittest
+// and that compile should be clean without errors.
+//
+option deprecated = true;
+
+// Message to catch the deprecation.
+message Msg1 {
+ extensions 100 to max;
+
+ optional string string_field = 1;
+}
+
+// Mix of extension field types to catch the deprecation.
+extend Msg1 {
+ optional string string_ext_field = 101;
+ optional int32 int_ext_field = 102;
+ repeated fixed32 fixed_ext_field = 103;
+ optional Msg1 msg_ext_field = 104;
+}
+
+// Mix of extension field types (scoped to a message) to catch the deprecation.
+message Msg1A {
+ extend Msg1 {
+ optional string string_ext2_field = 201;
+ optional int32 int_ext2_field = 202;
+ repeated fixed32 fixed_ext2_field = 203;
+ optional Msg1 msg_ext2_field = 204;
+ }
+}
+
+// Enum to catch the deprecation.
+enum Enum1 {
+ ENUM1_ONE = 1;
+ ENUM1_TWO = 2;
+ ENUM1_THREE = 3;
+}
diff --git a/objectivec/google/protobuf/Type.pbobjc.h b/objectivec/google/protobuf/Type.pbobjc.h
index 06e75480..17986970 100644
--- a/objectivec/google/protobuf/Type.pbobjc.h
+++ b/objectivec/google/protobuf/Type.pbobjc.h
@@ -411,10 +411,20 @@ typedef GPB_ENUM(GPBOption_FieldNumber) {
**/
@interface GPBOption : GPBMessage
-/** The option's name. For example, `"java_package"`. */
+/**
+ * The option's name. For protobuf built-in options (options defined in
+ * descriptor.proto), this is the short name. For example, `"map_entry"`.
+ * For custom options, it should be the fully-qualified name. For example,
+ * `"google.api.http"`.
+ **/
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
-/** The option's value. For example, `"com.google.protobuf"`. */
+/**
+ * The option's value packed in an Any message. If the value is a primitive,
+ * the corresponding wrapper type defined in google/protobuf/wrappers.proto
+ * should be used. If the value is an enum, it should be stored as an int32
+ * value using the google.protobuf.Int32Value type.
+ **/
@property(nonatomic, readwrite, strong, null_resettable) GPBAny *value;
/** Test to see if @c value has been set. */
@property(nonatomic, readwrite) BOOL hasValue;
diff --git a/php/README.md b/php/README.md
index ec92d329..cebeb3e5 100644
--- a/php/README.md
+++ b/php/README.md
@@ -80,8 +80,6 @@ protoc --php_out=out_dir test.proto
## Usage
-For general guide:
- https://developers.google.com/protocol-buffers/phptutorial/
For generated code:
https://developers.google.com/protocol-buffers/docs/reference/php-generated
diff --git a/php/composer.json b/php/composer.json
new file mode 100644
index 00000000..3dae2865
--- /dev/null
+++ b/php/composer.json
@@ -0,0 +1,27 @@
+{
+ "name": "google/protobuf",
+ "type": "library",
+ "description": "proto library for PHP",
+ "keywords": ["proto"],
+ "homepage": "https://developers.google.com/protocol-buffers/",
+ "license": "BSD-3-Clause",
+ "require": {
+ "php": ">=5.5.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": ">=4.8.0"
+ },
+ "autoload": {
+ "psr-4": {
+ "Foo\\": "tests/generated/Foo",
+ "Bar\\": "tests/generated/Bar",
+ "Google\\Protobuf\\": "tests/generated/Google/Protobuf",
+ "Google\\Protobuf\\Internal\\": "src/Google/Protobuf/Internal",
+ "GPBMetadata\\": "tests/generated/GPBMetadata",
+ "GPBMetadata\\Google\\Protobuf\\Internal\\": "src/GPBMetadata/Google/Protobuf/Internal"
+ },
+ "files": [
+ "src/Google/Protobuf/descriptor.php"
+ ]
+ }
+}
diff --git a/php/ext/google/protobuf/def.c b/php/ext/google/protobuf/def.c
index 5a8c3c25..32b158e2 100644
--- a/php/ext/google/protobuf/def.c
+++ b/php/ext/google/protobuf/def.c
@@ -209,14 +209,14 @@ static void init_generated_pool_once(TSRMLS_D) {
static void descriptor_pool_init_c_instance(DescriptorPool *pool TSRMLS_DC) {
zend_object_std_init(&pool->std, descriptor_pool_type TSRMLS_CC);
- pool->symtab = upb_symtab_new(&pool->symtab);
+ pool->symtab = upb_symtab_new();
ALLOC_HASHTABLE(pool->pending_list);
zend_hash_init(pool->pending_list, 1, NULL, ZVAL_PTR_DTOR, 0);
}
static void descriptor_pool_free_c(DescriptorPool *pool TSRMLS_DC) {
- upb_symtab_unref(pool->symtab, &pool->symtab);
+ upb_symtab_free(pool->symtab);
zend_hash_destroy(pool->pending_list);
FREE_HASHTABLE(pool->pending_list);
@@ -257,6 +257,11 @@ static void convert_to_class_name_inplace(char *class_name,
bool first_char = false;
size_t pkg_name_len = package_name == NULL ? 0 : strlen(package_name);
+ // In php, class name cannot be Empty.
+ if (strcmp("google.protobuf.Empty", fullname) == 0) {
+ fullname = "google.protobuf.GPBEmpty";
+ }
+
if (pkg_name_len == 0) {
strcpy(class_name, fullname);
} else {
@@ -330,9 +335,11 @@ PHP_METHOD(DescriptorPool, internalAddGeneratedFile) {
upb_msgdef_mapentry(upb_downcast_msgdef(def))) { \
break; \
} \
- /* Prepend '.' to package name to make it absolute. */ \
+ /* Prepend '.' to package name to make it absolute. In the 5 additional \
+ * bytes allocated, one for '.', one for trailing 0, and 3 for 'GPB' if \
+ * given message is google.protobuf.Empty.*/ \
const char *fullname = upb_##def_type_lower##_fullname(def_type_lower); \
- char *klass_name = ecalloc(sizeof(char), 2 + strlen(fullname)); \
+ char *klass_name = ecalloc(sizeof(char), 5 + strlen(fullname)); \
convert_to_class_name_inplace(klass_name, fullname, \
upb_filedef_package(files[0])); \
zend_class_entry **pce; \
@@ -391,10 +398,22 @@ static void descriptor_free_c(Descriptor *self TSRMLS_DC) {
if (self->fill_method) {
upb_pbdecodermethod_unref(self->fill_method, &self->fill_method);
}
+ if (self->json_fill_method) {
+ upb_json_parsermethod_unref(self->json_fill_method,
+ &self->json_fill_method);
+ }
if (self->pb_serialize_handlers) {
upb_handlers_unref(self->pb_serialize_handlers,
&self->pb_serialize_handlers);
}
+ if (self->json_serialize_handlers) {
+ upb_handlers_unref(self->json_serialize_handlers,
+ &self->json_serialize_handlers);
+ }
+ if (self->json_serialize_handlers_preserve) {
+ upb_handlers_unref(self->json_serialize_handlers_preserve,
+ &self->json_serialize_handlers_preserve);
+ }
}
static void descriptor_init_c_instance(Descriptor *desc TSRMLS_DC) {
@@ -404,7 +423,10 @@ static void descriptor_init_c_instance(Descriptor *desc TSRMLS_DC) {
desc->klass = NULL;
desc->fill_handlers = NULL;
desc->fill_method = NULL;
+ desc->json_fill_method = NULL;
desc->pb_serialize_handlers = NULL;
+ desc->json_serialize_handlers = NULL;
+ desc->json_serialize_handlers_preserve = NULL;
}
// -----------------------------------------------------------------------------
diff --git a/php/ext/google/protobuf/encode_decode.c b/php/ext/google/protobuf/encode_decode.c
index eafe1ae8..57fc81d3 100644
--- a/php/ext/google/protobuf/encode_decode.c
+++ b/php/ext/google/protobuf/encode_decode.c
@@ -103,6 +103,7 @@ static void stackenv_uninit(stackenv* se);
// Callback invoked by upb if any error occurs during parsing or serialization.
static bool env_error_func(void* ud, const upb_status* status) {
+ char err_msg[100] = "";
stackenv* se = ud;
// Free the env -- zend_error will longjmp up the stack past the
// encode/decode function so it would not otherwise have been freed.
@@ -110,7 +111,9 @@ static bool env_error_func(void* ud, const upb_status* status) {
// TODO(teboring): have a way to verify that this is actually a parse error,
// instead of just throwing "parse error" unconditionally.
- zend_error(E_ERROR, se->php_error_template, upb_status_errmsg(status));
+ sprintf(err_msg, se->php_error_template, upb_status_errmsg(status));
+ TSRMLS_FETCH();
+ zend_throw_exception(NULL, err_msg, 0 TSRMLS_CC);
// Never reached.
return false;
}
@@ -675,7 +678,7 @@ static void add_handlers_for_singular_field(upb_handlers *h,
case UPB_TYPE_INT64:
case UPB_TYPE_UINT64:
case UPB_TYPE_DOUBLE:
- upb_shim_set(h, f, offset, -1);
+ upb_msg_setscalarhandler(h, f, offset, -1);
break;
case UPB_TYPE_STRING:
case UPB_TYPE_BYTES: {
@@ -866,6 +869,14 @@ static const upb_pbdecodermethod *msgdef_decodermethod(Descriptor* desc) {
return desc->fill_method;
}
+static const upb_json_parsermethod *msgdef_jsonparsermethod(Descriptor* desc) {
+ if (desc->json_fill_method == NULL) {
+ desc->json_fill_method =
+ upb_json_parsermethod_new(desc->msgdef, &desc->json_fill_method);
+ }
+ return desc->json_fill_method;
+}
+
// -----------------------------------------------------------------------------
// Serializing.
// -----------------------------------------------------------------------------
@@ -883,8 +894,8 @@ static void putsubmsg(zval* submsg, const upb_fielddef* f, upb_sink* sink,
static void putarray(zval* array, const upb_fielddef* f, upb_sink* sink,
int depth TSRMLS_DC);
-static void putmap(zval* map, const upb_fielddef* f, upb_sink* sink, int depth
- TSRMLS_DC);
+static void putmap(zval* map, const upb_fielddef* f, upb_sink* sink,
+ int depth TSRMLS_DC);
static upb_selector_t getsel(const upb_fielddef* f, upb_handlertype_t type) {
upb_selector_t ret;
@@ -961,10 +972,13 @@ static void putmap(zval* map, const upb_fielddef* f, upb_sink* sink,
const upb_fielddef* key_field;
const upb_fielddef* value_field;
MapIter it;
- int len;
+ int len, size;
- if (map == NULL) return;
- self = UNBOX(Map, map);
+ assert(map != NULL);
+ Map* intern =
+ (Map*)zend_object_store_get_object(map TSRMLS_CC);
+ size = upb_strtable_count(&intern->table);
+ if (size == 0) return;
upb_sink_startseq(sink, getsel(f, UPB_HANDLER_STARTSEQ), &subsink);
@@ -1197,6 +1211,25 @@ static const upb_handlers* msgdef_pb_serialize_handlers(Descriptor* desc) {
return desc->pb_serialize_handlers;
}
+static const upb_handlers* msgdef_json_serialize_handlers(
+ Descriptor* desc, bool preserve_proto_fieldnames) {
+ if (preserve_proto_fieldnames) {
+ if (desc->json_serialize_handlers == NULL) {
+ desc->json_serialize_handlers =
+ upb_json_printer_newhandlers(
+ desc->msgdef, true, &desc->json_serialize_handlers);
+ }
+ return desc->json_serialize_handlers;
+ } else {
+ if (desc->json_serialize_handlers_preserve == NULL) {
+ desc->json_serialize_handlers_preserve =
+ upb_json_printer_newhandlers(
+ desc->msgdef, false, &desc->json_serialize_handlers_preserve);
+ }
+ return desc->json_serialize_handlers_preserve;
+ }
+}
+
// -----------------------------------------------------------------------------
// PHP encode/decode methods
// -----------------------------------------------------------------------------
@@ -1255,3 +1288,69 @@ PHP_METHOD(Message, decode) {
stackenv_uninit(&se);
}
}
+
+PHP_METHOD(Message, jsonEncode) {
+ zval* php_descriptor = get_ce_obj(Z_OBJCE_P(getThis()));
+ Descriptor* desc =
+ (Descriptor*)zend_object_store_get_object(php_descriptor TSRMLS_CC);
+
+ zend_bool preserve_proto_fieldnames = false;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b",
+ &preserve_proto_fieldnames) == FAILURE) {
+ return;
+ }
+
+ stringsink sink;
+ stringsink_init(&sink);
+
+ {
+ const upb_handlers* serialize_handlers =
+ msgdef_json_serialize_handlers(desc, preserve_proto_fieldnames);
+ upb_json_printer* printer;
+ stackenv se;
+
+ stackenv_init(&se, "Error occurred during encoding: %s");
+ printer = upb_json_printer_create(&se.env, serialize_handlers, &sink.sink);
+
+ putmsg(getThis(), desc, upb_json_printer_input(printer), 0 TSRMLS_CC);
+
+ RETVAL_STRINGL(sink.ptr, sink.len, 1);
+
+ stackenv_uninit(&se);
+ stringsink_uninit(&sink);
+ }
+}
+
+PHP_METHOD(Message, jsonDecode) {
+ zval* php_descriptor = get_ce_obj(Z_OBJCE_P(getThis()));
+ Descriptor* desc =
+ (Descriptor*)zend_object_store_get_object(php_descriptor TSRMLS_CC);
+ MessageHeader* msg = zend_object_store_get_object(getThis() TSRMLS_CC);
+
+ char *data = NULL;
+ int data_len;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data, &data_len) ==
+ FAILURE) {
+ return;
+ }
+
+ // TODO(teboring): Check and respect string encoding. If not UTF-8, we need to
+ // convert, because string handlers pass data directly to message string
+ // fields.
+
+ // TODO(teboring): Clear message.
+
+ {
+ const upb_json_parsermethod* method = msgdef_jsonparsermethod(desc);
+ stackenv se;
+ upb_sink sink;
+ upb_json_parser* parser;
+ stackenv_init(&se, "Error occurred during parsing: %s");
+
+ upb_sink_reset(&sink, get_fill_handlers(desc), msg);
+ parser = upb_json_parser_create(&se.env, method, &sink);
+ upb_bufsrc_putbuf(data, data_len, upb_json_parser_input(parser));
+
+ stackenv_uninit(&se);
+ }
+}
diff --git a/php/ext/google/protobuf/message.c b/php/ext/google/protobuf/message.c
index cb46031e..46da9024 100644
--- a/php/ext/google/protobuf/message.c
+++ b/php/ext/google/protobuf/message.c
@@ -30,6 +30,7 @@
#include <php.h>
#include <stdlib.h>
+#include <ext/json/php_json.h>
#include "protobuf.h"
@@ -37,10 +38,15 @@ static zend_class_entry* message_type;
zend_object_handlers* message_handlers;
static zend_function_entry message_methods[] = {
+ PHP_ME(Message, clear, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Message, encode, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Message, decode, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Message, jsonEncode, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Message, jsonDecode, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Message, readOneof, NULL, ZEND_ACC_PROTECTED)
PHP_ME(Message, writeOneof, NULL, ZEND_ACC_PROTECTED)
+ PHP_ME(Message, whichOneof, NULL, ZEND_ACC_PROTECTED)
+ PHP_ME(Message, __construct, NULL, ZEND_ACC_PROTECTED)
{NULL, NULL, NULL}
};
@@ -52,6 +58,8 @@ static zval* message_get_property(zval* object, zval* member, int type,
const zend_literal* key TSRMLS_DC);
static zval** message_get_property_ptr_ptr(zval* object, zval* member, int type,
const zend_literal* key TSRMLS_DC);
+static HashTable* message_get_properties(zval* object TSRMLS_DC);
+static HashTable* message_get_gc(zval* object, zval*** table, int* n TSRMLS_DC);
static zend_object_value message_create(zend_class_entry* ce TSRMLS_DC);
static void message_free(void* object TSRMLS_DC);
@@ -72,6 +80,8 @@ void message_init(TSRMLS_D) {
message_handlers->write_property = message_set_property;
message_handlers->read_property = message_get_property;
message_handlers->get_property_ptr_ptr = message_get_property_ptr_ptr;
+ message_handlers->get_properties = message_get_properties;
+ message_handlers->get_gc = message_get_gc;
}
static void message_set_property(zval* object, zval* member, zval* value,
@@ -142,6 +152,17 @@ static zval** message_get_property_ptr_ptr(zval* object, zval* member, int type,
return NULL;
}
+static HashTable* message_get_properties(zval* object TSRMLS_DC) {
+ return NULL;
+}
+
+static HashTable* message_get_gc(zval* object, zval*** table, int* n TSRMLS_DC) {
+ zend_object* zobj = Z_OBJ_P(object);
+ *table = zobj->properties_table;
+ *n = zobj->ce->default_properties_count;
+ return NULL;
+}
+
// -----------------------------------------------------------------------------
// C Message Utilities
// -----------------------------------------------------------------------------
@@ -177,8 +198,8 @@ static zend_object_value message_create(zend_class_entry* ce TSRMLS_DC) {
zend_object_std_init(&msg->std, ce TSRMLS_CC);
object_properties_init(&msg->std, ce);
- layout_init(desc->layout, message_data(msg), msg->std.properties_table
- TSRMLS_CC);
+ layout_init(desc->layout, message_data(msg),
+ msg->std.properties_table TSRMLS_CC);
return_value.handle = zend_objects_store_put(
msg, (zend_objects_store_dtor_t)zend_objects_destroy_object, message_free,
@@ -210,6 +231,35 @@ void build_class_from_descriptor(zval* php_descriptor TSRMLS_DC) {
// PHP Methods
// -----------------------------------------------------------------------------
+// At the first time the message is created, the class entry hasn't been
+// modified. As a result, the first created instance will be a normal zend
+// object. Here, we manually modify it to our message in such a case.
+PHP_METHOD(Message, __construct) {
+ if (Z_OBJVAL_P(getThis()).handlers != message_handlers) {
+ zend_class_entry* ce = Z_OBJCE_P(getThis());
+ zval_dtor(getThis());
+ Z_OBJVAL_P(getThis()) = message_create(ce TSRMLS_CC);
+ }
+}
+
+PHP_METHOD(Message, clear) {
+ MessageHeader* msg =
+ (MessageHeader*)zend_object_store_get_object(getThis() TSRMLS_CC);
+ Descriptor* desc = msg->descriptor;
+ zend_class_entry* ce = desc->klass;
+ int i;
+
+ for (i = 0; i < msg->std.ce->default_properties_count; i++) {
+ zval_ptr_dtor(&msg->std.properties_table[i]);
+ }
+ efree(msg->std.properties_table);
+
+ zend_object_std_init(&msg->std, ce TSRMLS_CC);
+ object_properties_init(&msg->std, ce);
+ layout_init(desc->layout, message_data(msg),
+ msg->std.properties_table TSRMLS_CC);
+}
+
PHP_METHOD(Message, readOneof) {
long index;
@@ -246,3 +296,22 @@ PHP_METHOD(Message, writeOneof) {
layout_set(msg->descriptor->layout, msg, field, value TSRMLS_CC);
}
+
+PHP_METHOD(Message, whichOneof) {
+ char* oneof_name;
+ int length;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &oneof_name,
+ &length) == FAILURE) {
+ return;
+ }
+
+ MessageHeader* msg =
+ (MessageHeader*)zend_object_store_get_object(getThis() TSRMLS_CC);
+
+ const upb_oneofdef* oneof =
+ upb_msgdef_ntoo(msg->descriptor->msgdef, oneof_name, length);
+ const char* oneof_case_name = layout_get_oneof_case(
+ msg->descriptor->layout, message_data(msg), oneof TSRMLS_CC);
+ RETURN_STRING(oneof_case_name, 1);
+}
diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml
index 01aad411..3067bdbb 100644
--- a/php/ext/google/protobuf/package.xml
+++ b/php/ext/google/protobuf/package.xml
@@ -10,11 +10,11 @@
<email>protobuf-opensource@google.com</email>
<active>yes</active>
</lead>
- <date>2016-09-23</date>
+ <date>2017-01-13</date>
<time>16:06:07</time>
<version>
- <release>3.1.0a1</release>
- <api>3.1.0a1</api>
+ <release>3.2.0a1</release>
+ <api>3.2.0a1</api>
</version>
<stability>
<release>alpha</release>
@@ -22,7 +22,7 @@
</stability>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
<notes>
-First alpha release.
+Second alpha release.
</notes>
<contents>
<dir baseinstalldir="/" name="/">
@@ -71,5 +71,21 @@ First alpha release.
First alpha release
</notes>
</release>
+ <release>
+ <version>
+ <release>3.2.0a1</release>
+ <api>3.2.0a1</api>
+ </version>
+ <stability>
+ <release>alpha</release>
+ <api>alpha</api>
+ </stability>
+ <date>2017-01-13</date>
+ <time>16:06:07</time>
+ <license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
+ <notes>
+Second alpha release.
+ </notes>
+ </release>
</changelog>
</package>
diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h
index fb5879dc..d4737fb9 100644
--- a/php/ext/google/protobuf/protobuf.h
+++ b/php/ext/google/protobuf/protobuf.h
@@ -37,7 +37,7 @@
#include "upb.h"
#define PHP_PROTOBUF_EXTNAME "protobuf"
-#define PHP_PROTOBUF_VERSION "3.1.0a1"
+#define PHP_PROTOBUF_VERSION "3.2.0a1"
#define MAX_LENGTH_OF_INT64 20
#define SIZEOF_INT64 8
@@ -122,7 +122,10 @@ struct Descriptor {
zend_class_entry* klass; // begins as NULL
const upb_handlers* fill_handlers;
const upb_pbdecodermethod* fill_method;
+ const upb_json_parsermethod* json_fill_method;
const upb_handlers* pb_serialize_handlers;
+ const upb_handlers* json_serialize_handlers;
+ const upb_handlers* json_serialize_handlers_preserve;
};
extern zend_class_entry* descriptor_type;
@@ -231,16 +234,21 @@ struct MessageHeader {
};
MessageLayout* create_layout(const upb_msgdef* msgdef);
-void layout_init(MessageLayout* layout, void* storage, zval** properties_table
- TSRMLS_DC);
+void layout_init(MessageLayout* layout, void* storage,
+ zval** properties_table TSRMLS_DC);
zval* layout_get(MessageLayout* layout, const void* storage,
const upb_fielddef* field, zval** cache TSRMLS_DC);
void layout_set(MessageLayout* layout, MessageHeader* header,
const upb_fielddef* field, zval* val TSRMLS_DC);
+const char* layout_get_oneof_case(MessageLayout* layout, const void* storage,
+ const upb_oneofdef* oneof TSRMLS_DC);
void free_layout(MessageLayout* layout);
+PHP_METHOD(Message, clear);
PHP_METHOD(Message, readOneof);
PHP_METHOD(Message, writeOneof);
+PHP_METHOD(Message, whichOneof);
+PHP_METHOD(Message, __construct);
// -----------------------------------------------------------------------------
// Encode / Decode.
@@ -257,6 +265,8 @@ const upb_pbdecodermethod *new_fillmsg_decodermethod(Descriptor *desc,
PHP_METHOD(Message, encode);
PHP_METHOD(Message, decode);
+PHP_METHOD(Message, jsonEncode);
+PHP_METHOD(Message, jsonDecode);
// -----------------------------------------------------------------------------
// Type check / conversion.
diff --git a/php/ext/google/protobuf/storage.c b/php/ext/google/protobuf/storage.c
index 1d25a91b..5e05b935 100644
--- a/php/ext/google/protobuf/storage.c
+++ b/php/ext/google/protobuf/storage.c
@@ -248,13 +248,30 @@ void native_slot_get_default(upb_fieldtype_t type, zval** cache TSRMLS_DC) {
CASE(DOUBLE, DOUBLE)
CASE(BOOL, BOOL)
CASE(INT32, LONG)
- CASE(INT64, LONG)
CASE(UINT32, LONG)
- CASE(UINT64, LONG)
CASE(ENUM, LONG)
#undef CASE
+#if SIZEOF_LONG == 4
+#define CASE(upb_type) \
+ case UPB_TYPE_##upb_type: { \
+ SEPARATE_ZVAL_IF_NOT_REF(cache); \
+ ZVAL_STRING(*cache, "0", 1); \
+ return; \
+ }
+#else
+#define CASE(upb_type) \
+ case UPB_TYPE_##upb_type: { \
+ SEPARATE_ZVAL_IF_NOT_REF(cache); \
+ ZVAL_LONG(*cache, 0); \
+ return; \
+ }
+#endif
+CASE(UINT64)
+CASE(INT64)
+#undef CASE
+
case UPB_TYPE_STRING:
case UPB_TYPE_BYTES: {
SEPARATE_ZVAL_IF_NOT_REF(cache);
@@ -458,8 +475,8 @@ void free_layout(MessageLayout* layout) {
FREE(layout);
}
-void layout_init(MessageLayout* layout, void* storage, zval** properties_table
- TSRMLS_DC) {
+void layout_init(MessageLayout* layout, void* storage,
+ zval** properties_table TSRMLS_DC) {
int i;
upb_msg_field_iter it;
for (upb_msg_field_begin(&it, layout->msgdef), i = 0; !upb_msg_field_done(&it);
@@ -479,9 +496,10 @@ void layout_init(MessageLayout* layout, void* storage, zval** properties_table
DEREF(memory, zval**) = property_ptr;
} else if (upb_fielddef_label(field) == UPB_LABEL_REPEATED) {
zval_ptr_dtor(property_ptr);
- repeated_field_create_with_type(repeated_field_type, field, property_ptr
- TSRMLS_CC);
+ repeated_field_create_with_type(repeated_field_type, field,
+ property_ptr TSRMLS_CC);
DEREF(memory, zval**) = property_ptr;
+ property_ptr = NULL;
} else {
native_slot_init(upb_fielddef_type(field), memory, property_ptr);
}
@@ -527,7 +545,7 @@ zval* layout_get(MessageLayout* layout, const void* storage,
}
void layout_set(MessageLayout* layout, MessageHeader* header,
- const upb_fielddef* field, zval* val TSRMLS_DC) {
+ const upb_fielddef* field, zval* val TSRMLS_DC) {
void* storage = message_data(header);
void* memory = slot_memory(layout, storage, field);
uint32_t* oneof_case = slot_oneof_case(layout, storage, field);
@@ -582,3 +600,22 @@ void layout_set(MessageLayout* layout, MessageHeader* header,
native_slot_set(type, ce, value_memory(field, memory), val TSRMLS_CC);
}
}
+
+const char* layout_get_oneof_case(MessageLayout* layout, const void* storage,
+ const upb_oneofdef* oneof TSRMLS_DC) {
+ upb_oneof_iter i;
+ const upb_fielddef* first_field;
+
+ // Oneof is guaranteed to have at least one field. Get the first field.
+ for(upb_oneof_begin(&i, oneof); !upb_oneof_done(&i); upb_oneof_next(&i)) {
+ first_field = upb_oneof_iter_field(&i);
+ break;
+ }
+
+ uint32_t* oneof_case = slot_oneof_case(layout, storage, first_field);
+ if (*oneof_case == 0) {
+ return "";
+ }
+ const upb_fielddef* field = upb_oneofdef_itof(oneof, *oneof_case);
+ return upb_fielddef_name(field);
+}
diff --git a/php/ext/google/protobuf/upb.c b/php/ext/google/protobuf/upb.c
index 98daafc0..e0c56f8e 100644
--- a/php/ext/google/protobuf/upb.c
+++ b/php/ext/google/protobuf/upb.c
@@ -1,33 +1,4 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+// Amalgamated source file
#include "upb.h"
@@ -150,21 +121,6 @@ bool upb_def_setfullname(upb_def *def, const char *fullname, upb_status *s) {
const upb_filedef *upb_def_file(const upb_def *d) { return d->file; }
-upb_def *upb_def_dup(const upb_def *def, const void *o) {
- switch (def->type) {
- case UPB_DEF_MSG:
- return upb_msgdef_upcast_mutable(
- upb_msgdef_dup(upb_downcast_msgdef(def), o));
- case UPB_DEF_FIELD:
- return upb_fielddef_upcast_mutable(
- upb_fielddef_dup(upb_downcast_fielddef(def), o));
- case UPB_DEF_ENUM:
- return upb_enumdef_upcast_mutable(
- upb_enumdef_dup(upb_downcast_enumdef(def), o));
- default: UPB_ASSERT(false); return NULL;
- }
-}
-
static bool upb_def_init(upb_def *def, upb_deftype_t type,
const struct upb_refcounted_vtbl *vtbl,
const void *owner) {
@@ -311,6 +267,7 @@ static bool assign_msg_indices(upb_msgdef *m, upb_status *s) {
/* Sort fields. upb internally relies on UPB_TYPE_MESSAGE fields having the
* lowest indexes, but we do not publicly guarantee this. */
upb_msg_field_iter j;
+ upb_msg_oneof_iter k;
int i;
uint32_t selector;
int n = upb_msgdef_numfields(m);
@@ -395,6 +352,13 @@ static bool assign_msg_indices(upb_msgdef *m, upb_status *s) {
#undef TRY
#endif
+ for(upb_msg_oneof_begin(&k, m), i = 0;
+ !upb_msg_oneof_done(&k);
+ upb_msg_oneof_next(&k), i++) {
+ upb_oneofdef *o = upb_msg_iter_oneof(&k);
+ o->index = i;
+ }
+
upb_gfree(fields);
return true;
}
@@ -512,21 +476,6 @@ err2:
return NULL;
}
-upb_enumdef *upb_enumdef_dup(const upb_enumdef *e, const void *owner) {
- upb_enum_iter i;
- upb_enumdef *new_e = upb_enumdef_new(owner);
- if (!new_e) return NULL;
- for(upb_enum_begin(&i, e); !upb_enum_done(&i); upb_enum_next(&i)) {
- bool success = upb_enumdef_addval(
- new_e, upb_enum_iter_name(&i),upb_enum_iter_number(&i), NULL);
- if (!success) {
- upb_enumdef_unref(new_e, owner);
- return NULL;
- }
- }
- return new_e;
-}
-
bool upb_enumdef_freeze(upb_enumdef *e, upb_status *status) {
upb_def *d = upb_enumdef_upcast_mutable(e);
return upb_def_freeze(&d, 1, status);
@@ -761,7 +710,8 @@ upb_fielddef *upb_fielddef_new(const void *o) {
return f;
}
-upb_fielddef *upb_fielddef_dup(const upb_fielddef *f, const void *owner) {
+static upb_fielddef *upb_fielddef_dup(const upb_fielddef *f,
+ const void *owner) {
const char *srcname;
upb_fielddef *newf = upb_fielddef_new(owner);
if (!newf) return NULL;
@@ -1476,7 +1426,9 @@ err2:
return NULL;
}
-upb_msgdef *upb_msgdef_dup(const upb_msgdef *m, const void *owner) {
+static upb_oneofdef *upb_oneofdef_dup(const upb_oneofdef *o, const void *owner);
+
+static upb_msgdef *upb_msgdef_dup(const upb_msgdef *m, const void *owner) {
bool ok;
upb_msg_field_iter i;
upb_msg_oneof_iter o;
@@ -1812,7 +1764,8 @@ err2:
return NULL;
}
-upb_oneofdef *upb_oneofdef_dup(const upb_oneofdef *o, const void *owner) {
+static upb_oneofdef *upb_oneofdef_dup(const upb_oneofdef *o,
+ const void *owner) {
bool ok;
upb_oneof_iter i;
upb_oneofdef *newo = upb_oneofdef_new(owner);
@@ -1861,6 +1814,10 @@ int upb_oneofdef_numfields(const upb_oneofdef *o) {
return upb_strtable_count(&o->ntof);
}
+uint32_t upb_oneofdef_index(const upb_oneofdef *o) {
+ return o->index;
+}
+
bool upb_oneofdef_addfield(upb_oneofdef *o, upb_fielddef *f,
const void *ref_donor,
upb_status *s) {
@@ -2156,6 +2113,354 @@ bool upb_filedef_adddep(upb_filedef *f, const upb_filedef *dep) {
return false;
}
}
+
+void upb_symtab_free(upb_symtab *s) {
+ upb_strtable_iter i;
+ upb_strtable_begin(&i, &s->symtab);
+ for (; !upb_strtable_done(&i); upb_strtable_next(&i)) {
+ const upb_def *def = upb_value_getptr(upb_strtable_iter_value(&i));
+ upb_def_unref(def, s);
+ }
+ upb_strtable_uninit(&s->symtab);
+ upb_gfree(s);
+}
+
+upb_symtab *upb_symtab_new() {
+ upb_symtab *s = upb_gmalloc(sizeof(*s));
+ if (!s) {
+ return NULL;
+ }
+
+ upb_strtable_init(&s->symtab, UPB_CTYPE_PTR);
+ return s;
+}
+
+const upb_def *upb_symtab_lookup(const upb_symtab *s, const char *sym) {
+ upb_value v;
+ upb_def *ret = upb_strtable_lookup(&s->symtab, sym, &v) ?
+ upb_value_getptr(v) : NULL;
+ return ret;
+}
+
+const upb_msgdef *upb_symtab_lookupmsg(const upb_symtab *s, const char *sym) {
+ upb_value v;
+ upb_def *def = upb_strtable_lookup(&s->symtab, sym, &v) ?
+ upb_value_getptr(v) : NULL;
+ return def ? upb_dyncast_msgdef(def) : NULL;
+}
+
+const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym) {
+ upb_value v;
+ upb_def *def = upb_strtable_lookup(&s->symtab, sym, &v) ?
+ upb_value_getptr(v) : NULL;
+ return def ? upb_dyncast_enumdef(def) : NULL;
+}
+
+/* Given a symbol and the base symbol inside which it is defined, find the
+ * symbol's definition in t. */
+static upb_def *upb_resolvename(const upb_strtable *t,
+ const char *base, const char *sym) {
+ if(strlen(sym) == 0) return NULL;
+ if(sym[0] == '.') {
+ /* Symbols starting with '.' are absolute, so we do a single lookup.
+ * Slice to omit the leading '.' */
+ upb_value v;
+ return upb_strtable_lookup(t, sym + 1, &v) ? upb_value_getptr(v) : NULL;
+ } else {
+ /* Remove components from base until we find an entry or run out.
+ * TODO: This branch is totally broken, but currently not used. */
+ (void)base;
+ UPB_ASSERT(false);
+ return NULL;
+ }
+}
+
+const upb_def *upb_symtab_resolve(const upb_symtab *s, const char *base,
+ const char *sym) {
+ upb_def *ret = upb_resolvename(&s->symtab, base, sym);
+ return ret;
+}
+
+/* TODO(haberman): we need a lot more testing of error conditions. */
+static bool symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
+ void *ref_donor, upb_refcounted *freeze_also,
+ upb_status *status) {
+ size_t i;
+ size_t add_n;
+ size_t freeze_n;
+ upb_strtable_iter iter;
+ upb_refcounted **add_objs = NULL;
+ upb_def **add_defs = NULL;
+ size_t add_objs_size;
+ upb_strtable addtab;
+
+ if (n == 0 && !freeze_also) {
+ return true;
+ }
+
+ if (!upb_strtable_init(&addtab, UPB_CTYPE_PTR)) {
+ upb_status_seterrmsg(status, "out of memory");
+ return false;
+ }
+
+ /* Add new defs to our "add" set. */
+ for (i = 0; i < n; i++) {
+ upb_def *def = defs[i];
+ const char *fullname;
+ upb_fielddef *f;
+
+ if (upb_def_isfrozen(def)) {
+ upb_status_seterrmsg(status, "added defs must be mutable");
+ goto err;
+ }
+ UPB_ASSERT(!upb_def_isfrozen(def));
+ fullname = upb_def_fullname(def);
+ if (!fullname) {
+ upb_status_seterrmsg(
+ status, "Anonymous defs cannot be added to a symtab");
+ goto err;
+ }
+
+ f = upb_dyncast_fielddef_mutable(def);
+
+ if (f) {
+ if (!upb_fielddef_containingtypename(f)) {
+ upb_status_seterrmsg(status,
+ "Standalone fielddefs must have a containing type "
+ "(extendee) name set");
+ goto err;
+ }
+ } else {
+ if (upb_strtable_lookup(&addtab, fullname, NULL)) {
+ upb_status_seterrf(status, "Conflicting defs named '%s'", fullname);
+ goto err;
+ }
+ if (upb_strtable_lookup(&s->symtab, fullname, NULL)) {
+ upb_status_seterrf(status, "Symtab already has a def named '%s'",
+ fullname);
+ goto err;
+ }
+ upb_def_donateref(def, ref_donor, s);
+ if (!upb_strtable_insert(&addtab, fullname, upb_value_ptr(def)))
+ goto oom_err;
+ def->came_from_user = true;
+ }
+ }
+
+ /* Add standalone fielddefs (ie. extensions) to the appropriate messages.
+ * If the appropriate message only exists in the existing symtab, duplicate
+ * it so we have a mutable copy we can add the fields to. */
+ for (i = 0; i < n; i++) {
+ upb_def *def = defs[i];
+ upb_fielddef *f = upb_dyncast_fielddef_mutable(def);
+ const char *msgname;
+ upb_value v;
+ upb_msgdef *m;
+
+ if (!f) continue;
+ msgname = upb_fielddef_containingtypename(f);
+ /* We validated this earlier in this function. */
+ UPB_ASSERT(msgname);
+
+ /* If the extendee name is absolutely qualified, move past the initial ".".
+ * TODO(haberman): it is not obvious what it would mean if this was not
+ * absolutely qualified. */
+ if (msgname[0] == '.') {
+ msgname++;
+ }
+
+ if (upb_strtable_lookup(&addtab, msgname, &v)) {
+ /* Extendee is in the set of defs the user asked us to add. */
+ m = upb_value_getptr(v);
+ } else {
+ /* Need to find and dup the extendee from the existing symtab. */
+ const upb_msgdef *frozen_m = upb_symtab_lookupmsg(s, msgname);
+ if (!frozen_m) {
+ upb_status_seterrf(status,
+ "Tried to extend message %s that does not exist "
+ "in this SymbolTable.",
+ msgname);
+ goto err;
+ }
+ m = upb_msgdef_dup(frozen_m, s);
+ if (!m) goto oom_err;
+ if (!upb_strtable_insert(&addtab, msgname, upb_value_ptr(m))) {
+ upb_msgdef_unref(m, s);
+ goto oom_err;
+ }
+ }
+
+ if (!upb_msgdef_addfield(m, f, ref_donor, status)) {
+ goto err;
+ }
+ }
+
+ /* Now using the table, resolve symbolic references for subdefs. */
+ upb_strtable_begin(&iter, &addtab);
+ for (; !upb_strtable_done(&iter); upb_strtable_next(&iter)) {
+ const char *base;
+ upb_def *def = upb_value_getptr(upb_strtable_iter_value(&iter));
+ upb_msgdef *m = upb_dyncast_msgdef_mutable(def);
+ upb_msg_field_iter j;
+
+ if (!m) continue;
+ /* Type names are resolved relative to the message in which they appear. */
+ base = upb_msgdef_fullname(m);
+
+ for(upb_msg_field_begin(&j, m);
+ !upb_msg_field_done(&j);
+ upb_msg_field_next(&j)) {
+ upb_fielddef *f = upb_msg_iter_field(&j);
+ const char *name = upb_fielddef_subdefname(f);
+ if (name && !upb_fielddef_subdef(f)) {
+ /* Try the lookup in the current set of to-be-added defs first. If not
+ * there, try existing defs. */
+ upb_def *subdef = upb_resolvename(&addtab, base, name);
+ if (subdef == NULL) {
+ subdef = upb_resolvename(&s->symtab, base, name);
+ }
+ if (subdef == NULL) {
+ upb_status_seterrf(
+ status, "couldn't resolve name '%s' in message '%s'", name, base);
+ goto err;
+ } else if (!upb_fielddef_setsubdef(f, subdef, status)) {
+ goto err;
+ }
+ }
+ }
+ }
+
+ /* We need an array of the defs in addtab, for passing to
+ * upb_refcounted_freeze(). */
+ add_objs_size = upb_strtable_count(&addtab);
+ if (freeze_also) {
+ add_objs_size++;
+ }
+
+ add_defs = upb_gmalloc(sizeof(void*) * add_objs_size);
+ if (add_defs == NULL) goto oom_err;
+ upb_strtable_begin(&iter, &addtab);
+ for (add_n = 0; !upb_strtable_done(&iter); upb_strtable_next(&iter)) {
+ add_defs[add_n++] = upb_value_getptr(upb_strtable_iter_value(&iter));
+ }
+
+ /* Validate defs. */
+ if (!_upb_def_validate(add_defs, add_n, status)) {
+ goto err;
+ }
+
+ /* Cheat a little and give the array a new type.
+ * This is probably undefined behavior, but this code will be deleted soon. */
+ add_objs = (upb_refcounted**)add_defs;
+
+ freeze_n = add_n;
+ if (freeze_also) {
+ add_objs[freeze_n++] = freeze_also;
+ }
+
+ if (!upb_refcounted_freeze(add_objs, freeze_n, status,
+ UPB_MAX_MESSAGE_DEPTH * 2)) {
+ goto err;
+ }
+
+ /* This must be delayed until all errors have been detected, since error
+ * recovery code uses this table to cleanup defs. */
+ upb_strtable_uninit(&addtab);
+
+ /* TODO(haberman) we don't properly handle errors after this point (like
+ * OOM in upb_strtable_insert() below). */
+ for (i = 0; i < add_n; i++) {
+ upb_def *def = (upb_def*)add_objs[i];
+ const char *name = upb_def_fullname(def);
+ upb_value v;
+ bool success;
+
+ if (upb_strtable_remove(&s->symtab, name, &v)) {
+ const upb_def *def = upb_value_getptr(v);
+ upb_def_unref(def, s);
+ }
+ success = upb_strtable_insert(&s->symtab, name, upb_value_ptr(def));
+ UPB_ASSERT(success == true);
+ }
+ upb_gfree(add_defs);
+ return true;
+
+oom_err:
+ upb_status_seterrmsg(status, "out of memory");
+err: {
+ /* We need to donate the refs back. */
+ upb_strtable_begin(&iter, &addtab);
+ for (; !upb_strtable_done(&iter); upb_strtable_next(&iter)) {
+ upb_def *def = upb_value_getptr(upb_strtable_iter_value(&iter));
+ upb_def_donateref(def, s, ref_donor);
+ }
+ }
+ upb_strtable_uninit(&addtab);
+ upb_gfree(add_defs);
+ UPB_ASSERT(!upb_ok(status));
+ return false;
+}
+
+bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
+ void *ref_donor, upb_status *status) {
+ return symtab_add(s, defs, n, ref_donor, NULL, status);
+}
+
+bool upb_symtab_addfile(upb_symtab *s, upb_filedef *file, upb_status *status) {
+ size_t n;
+ size_t i;
+ upb_def **defs;
+ bool ret;
+
+ n = upb_filedef_defcount(file);
+ defs = upb_gmalloc(sizeof(*defs) * n);
+
+ if (defs == NULL) {
+ upb_status_seterrmsg(status, "Out of memory");
+ return false;
+ }
+
+ for (i = 0; i < n; i++) {
+ defs[i] = upb_filedef_mutabledef(file, i);
+ }
+
+ ret = symtab_add(s, defs, n, NULL, upb_filedef_upcast_mutable(file), status);
+
+ upb_gfree(defs);
+ return ret;
+}
+
+/* Iteration. */
+
+static void advance_to_matching(upb_symtab_iter *iter) {
+ if (iter->type == UPB_DEF_ANY)
+ return;
+
+ while (!upb_strtable_done(&iter->iter) &&
+ iter->type != upb_symtab_iter_def(iter)->type) {
+ upb_strtable_next(&iter->iter);
+ }
+}
+
+void upb_symtab_begin(upb_symtab_iter *iter, const upb_symtab *s,
+ upb_deftype_t type) {
+ upb_strtable_begin(&iter->iter, &s->symtab);
+ iter->type = type;
+ advance_to_matching(iter);
+}
+
+void upb_symtab_next(upb_symtab_iter *iter) {
+ upb_strtable_next(&iter->iter);
+ advance_to_matching(iter);
+}
+
+bool upb_symtab_done(const upb_symtab_iter *iter) {
+ return upb_strtable_done(&iter->iter);
+}
+
+const upb_def *upb_symtab_iter_def(const upb_symtab_iter *iter) {
+ return upb_value_getptr(upb_strtable_iter_value(&iter->iter));
+}
/*
** TODO(haberman): it's unclear whether a lot of the consistency checks should
** UPB_ASSERT() or return false.
@@ -2851,6 +3156,1216 @@ bool upb_byteshandler_setendstr(upb_byteshandler *h,
h->table[UPB_ENDSTR_SELECTOR].attr.handler_data_ = d;
return true;
}
+
+
+static bool is_power_of_two(size_t val) {
+ return (val & (val - 1)) == 0;
+}
+
+/* Align up to the given power of 2. */
+static size_t align_up(size_t val, size_t align) {
+ UPB_ASSERT(is_power_of_two(align));
+ return (val + align - 1) & ~(align - 1);
+}
+
+static size_t div_round_up(size_t n, size_t d) {
+ return (n + d - 1) / d;
+}
+
+bool upb_fieldtype_mapkeyok(upb_fieldtype_t type) {
+ return type == UPB_TYPE_BOOL || type == UPB_TYPE_INT32 ||
+ type == UPB_TYPE_UINT32 || type == UPB_TYPE_INT64 ||
+ type == UPB_TYPE_UINT64 || type == UPB_TYPE_STRING;
+}
+
+void *upb_array_pack(const upb_array *arr, void *p, size_t *ofs, size_t size);
+void *upb_map_pack(const upb_map *map, void *p, size_t *ofs, size_t size);
+
+#define CHARPTR_AT(msg, ofs) ((char*)msg + ofs)
+#define ENCODE_MAX_NESTING 64
+#define CHECK_TRUE(x) if (!(x)) { return false; }
+
+/** upb_msgval ****************************************************************/
+
+#define upb_alignof(t) offsetof(struct { char c; t x; }, x)
+
+/* These functions will generate real memcpy() calls on ARM sadly, because
+ * the compiler assumes they might not be aligned. */
+
+static upb_msgval upb_msgval_read(const void *p, size_t ofs,
+ uint8_t size) {
+ upb_msgval val;
+ p = (char*)p + ofs;
+ memcpy(&val, p, size);
+ return val;
+}
+
+static void upb_msgval_write(void *p, size_t ofs, upb_msgval val,
+ uint8_t size) {
+ p = (char*)p + ofs;
+ memcpy(p, &val, size);
+}
+
+static size_t upb_msgval_sizeof(upb_fieldtype_t type) {
+ switch (type) {
+ case UPB_TYPE_DOUBLE:
+ case UPB_TYPE_INT64:
+ case UPB_TYPE_UINT64:
+ return 8;
+ case UPB_TYPE_ENUM:
+ case UPB_TYPE_INT32:
+ case UPB_TYPE_UINT32:
+ case UPB_TYPE_FLOAT:
+ return 4;
+ case UPB_TYPE_BOOL:
+ return 1;
+ case UPB_TYPE_BYTES:
+ case UPB_TYPE_MESSAGE:
+ return sizeof(void*);
+ case UPB_TYPE_STRING:
+ return sizeof(char*) + sizeof(size_t);
+ }
+ UPB_UNREACHABLE();
+}
+
+static uint8_t upb_msg_fieldsize(const upb_fielddef *f) {
+ if (upb_fielddef_isseq(f)) {
+ return sizeof(void*);
+ } else {
+ return upb_msgval_sizeof(upb_fielddef_type(f));
+ }
+}
+
+/* TODO(haberman): this is broken right now because upb_msgval can contain
+ * a char* / size_t pair, which is too big for a upb_value. To fix this
+ * we'll probably need to dynamically allocate a upb_msgval and store a
+ * pointer to that in the tables for extensions/maps. */
+static upb_value upb_toval(upb_msgval val) {
+ upb_value ret;
+ UPB_UNUSED(val);
+ memset(&ret, 0, sizeof(upb_value)); /* XXX */
+ return ret;
+}
+
+static upb_msgval upb_msgval_fromval(upb_value val) {
+ upb_msgval ret;
+ UPB_UNUSED(val);
+ memset(&ret, 0, sizeof(upb_msgval)); /* XXX */
+ return ret;
+}
+
+static upb_ctype_t upb_fieldtotabtype(upb_fieldtype_t type) {
+ switch (type) {
+ case UPB_TYPE_FLOAT: return UPB_CTYPE_FLOAT;
+ case UPB_TYPE_DOUBLE: return UPB_CTYPE_DOUBLE;
+ case UPB_TYPE_BOOL: return UPB_CTYPE_BOOL;
+ case UPB_TYPE_BYTES:
+ case UPB_TYPE_MESSAGE:
+ case UPB_TYPE_STRING: return UPB_CTYPE_CONSTPTR;
+ case UPB_TYPE_ENUM:
+ case UPB_TYPE_INT32: return UPB_CTYPE_INT32;
+ case UPB_TYPE_UINT32: return UPB_CTYPE_UINT32;
+ case UPB_TYPE_INT64: return UPB_CTYPE_INT64;
+ case UPB_TYPE_UINT64: return UPB_CTYPE_UINT64;
+ default: UPB_ASSERT(false); return 0;
+ }
+}
+
+static upb_msgval upb_msgval_fromdefault(const upb_fielddef *f) {
+ /* TODO(haberman): improve/optimize this (maybe use upb_msgval in fielddef) */
+ switch (upb_fielddef_type(f)) {
+ case UPB_TYPE_FLOAT:
+ return upb_msgval_float(upb_fielddef_defaultfloat(f));
+ case UPB_TYPE_DOUBLE:
+ return upb_msgval_double(upb_fielddef_defaultdouble(f));
+ case UPB_TYPE_BOOL:
+ return upb_msgval_bool(upb_fielddef_defaultbool(f));
+ case UPB_TYPE_STRING:
+ case UPB_TYPE_BYTES: {
+ size_t len;
+ const char *ptr = upb_fielddef_defaultstr(f, &len);
+ return upb_msgval_str(ptr, len);
+ }
+ case UPB_TYPE_MESSAGE:
+ return upb_msgval_msg(NULL);
+ case UPB_TYPE_ENUM:
+ case UPB_TYPE_INT32:
+ return upb_msgval_int32(upb_fielddef_defaultint32(f));
+ case UPB_TYPE_UINT32:
+ return upb_msgval_uint32(upb_fielddef_defaultuint32(f));
+ case UPB_TYPE_INT64:
+ return upb_msgval_int64(upb_fielddef_defaultint64(f));
+ case UPB_TYPE_UINT64:
+ return upb_msgval_uint64(upb_fielddef_defaultuint64(f));
+ default:
+ UPB_ASSERT(false);
+ return upb_msgval_msg(NULL);
+ }
+}
+
+
+/** upb_msglayout *************************************************************/
+
+struct upb_msglayout {
+ upb_msgfactory *factory;
+ const upb_msgdef *msgdef;
+ size_t size;
+ size_t extdict_offset;
+ void *default_msg;
+ uint32_t *field_offsets;
+ uint32_t *case_offsets;
+ uint32_t *hasbits;
+ bool has_extdict;
+ uint8_t align;
+};
+
+static void upb_msg_checkfield(const upb_msglayout *l, const upb_fielddef *f) {
+ UPB_ASSERT(l->msgdef == upb_fielddef_containingtype(f));
+}
+
+static void upb_msglayout_free(upb_msglayout *l) {
+ upb_gfree(l->default_msg);
+ upb_gfree(l);
+}
+
+const upb_msgdef *upb_msglayout_msgdef(const upb_msglayout *l) {
+ return l->msgdef;
+}
+
+static size_t upb_msglayout_place(upb_msglayout *l, size_t size) {
+ size_t ret;
+
+ l->size = align_up(l->size, size);
+ l->align = align_up(l->align, size);
+ ret = l->size;
+ l->size += size;
+ return ret;
+}
+
+static uint32_t upb_msglayout_offset(const upb_msglayout *l,
+ const upb_fielddef *f) {
+ return l->field_offsets[upb_fielddef_index(f)];
+}
+
+static uint32_t upb_msglayout_hasbit(const upb_msglayout *l,
+ const upb_fielddef *f) {
+ return l->hasbits[upb_fielddef_index(f)];
+}
+
+static bool upb_msglayout_initdefault(upb_msglayout *l) {
+ const upb_msgdef *m = l->msgdef;
+ upb_msg_field_iter it;
+
+ if (upb_msgdef_syntax(m) == UPB_SYNTAX_PROTO2 && l->size) {
+ /* Allocate default message and set default values in it. */
+ l->default_msg = upb_gmalloc(l->size);
+ if (!l->default_msg) {
+ return false;
+ }
+
+ memset(l->default_msg, 0, l->size);
+
+ for (upb_msg_field_begin(&it, m); !upb_msg_field_done(&it);
+ upb_msg_field_next(&it)) {
+ const upb_fielddef* f = upb_msg_iter_field(&it);
+
+ if (upb_fielddef_containingoneof(f)) {
+ continue;
+ }
+
+ if (!upb_fielddef_isstring(f) &&
+ !upb_fielddef_issubmsg(f) &&
+ !upb_fielddef_isseq(f)) {
+ upb_msg_set(l->default_msg, f, upb_msgval_fromdefault(f), l);
+ }
+ }
+ }
+
+ return true;
+}
+
+static upb_msglayout *upb_msglayout_new(const upb_msgdef *m) {
+ upb_msg_field_iter it;
+ upb_msg_oneof_iter oit;
+ upb_msglayout *l;
+ size_t hasbit;
+ size_t array_size = upb_msgdef_numfields(m) + upb_msgdef_numoneofs(m);
+
+ if (upb_msgdef_syntax(m) == UPB_SYNTAX_PROTO2) {
+ array_size += upb_msgdef_numfields(m); /* hasbits. */
+ }
+
+ l = upb_gmalloc(sizeof(*l) + (sizeof(uint32_t) * array_size));
+ if (!l) return NULL;
+
+ memset(l, 0, sizeof(*l));
+
+ l->msgdef = m;
+ l->align = 1;
+ l->field_offsets = (uint32_t*)CHARPTR_AT(l, sizeof(*l));
+ l->case_offsets = l->field_offsets + upb_msgdef_numfields(m);
+ l->hasbits = l->case_offsets + upb_msgdef_numoneofs(m);
+
+ /* Allocate data offsets in three stages:
+ *
+ * 1. hasbits.
+ * 2. regular fields.
+ * 3. oneof fields.
+ *
+ * OPT: There is a lot of room for optimization here to minimize the size.
+ */
+
+ /* Allocate hasbits. Start at sizeof(void*) for upb_alloc*. */
+ for (upb_msg_field_begin(&it, m), hasbit = sizeof(void*) * 8;
+ !upb_msg_field_done(&it);
+ upb_msg_field_next(&it)) {
+ const upb_fielddef* f = upb_msg_iter_field(&it);
+
+ if (upb_fielddef_haspresence(f) && !upb_fielddef_containingoneof(f)) {
+ l->hasbits[upb_fielddef_index(f)] = hasbit++;
+ }
+ }
+
+ /* Account for space used by hasbits. */
+ l->size = div_round_up(hasbit, 8);
+
+ /* Allocate non-oneof fields. */
+ for (upb_msg_field_begin(&it, m); !upb_msg_field_done(&it);
+ upb_msg_field_next(&it)) {
+ const upb_fielddef* f = upb_msg_iter_field(&it);
+ size_t field_size = upb_msg_fieldsize(f);
+ size_t index = upb_fielddef_index(f);
+
+
+ if (upb_fielddef_containingoneof(f)) {
+ /* Oneofs are handled separately below. */
+ continue;
+ }
+
+ l->field_offsets[index] = upb_msglayout_place(l, field_size);
+ }
+
+ /* Allocate oneof fields. Each oneof field consists of a uint32 for the case
+ * and space for the actual data. */
+ for (upb_msg_oneof_begin(&oit, m); !upb_msg_oneof_done(&oit);
+ upb_msg_oneof_next(&oit)) {
+ const upb_oneofdef* oneof = upb_msg_iter_oneof(&oit);
+ upb_oneof_iter fit;
+ size_t case_size = sizeof(uint32_t); /* Could potentially optimize this. */
+ size_t field_size = 0;
+ size_t case_offset;
+ size_t val_offset;
+
+ /* Calculate field size: the max of all field sizes. */
+ for (upb_oneof_begin(&fit, oneof);
+ !upb_oneof_done(&fit);
+ upb_oneof_next(&fit)) {
+ const upb_fielddef* f = upb_oneof_iter_field(&fit);
+ field_size = UPB_MAX(field_size, upb_msg_fieldsize(f));
+ }
+
+ /* Align and allocate case offset. */
+ case_offset = upb_msglayout_place(l, case_size);
+ val_offset = upb_msglayout_place(l, field_size);
+
+ l->case_offsets[upb_oneofdef_index(oneof)] = case_offset;
+
+ /* Assign all fields in the oneof this same offset. */
+ for (upb_oneof_begin(&fit, oneof); !upb_oneof_done(&fit);
+ upb_oneof_next(&fit)) {
+ const upb_fielddef* f = upb_oneof_iter_field(&fit);
+ l->field_offsets[upb_fielddef_index(f)] = val_offset;
+ }
+ }
+
+ /* Size of the entire structure should be a multiple of its greatest
+ * alignment. */
+ l->size = align_up(l->size, l->align);
+
+ if (upb_msglayout_initdefault(l)) {
+ return l;
+ } else {
+ upb_msglayout_free(l);
+ return NULL;
+ }
+}
+
+upb_msgfactory *upb_msglayout_factory(const upb_msglayout *layout) {
+ return layout->factory;
+}
+
+
+/** upb_msgfactory ************************************************************/
+
+struct upb_msgfactory {
+ const upb_symtab *symtab; /* We own a ref. */
+ upb_inttable layouts;
+ upb_inttable mergehandlers;
+};
+
+upb_msgfactory *upb_msgfactory_new(const upb_symtab *symtab) {
+ upb_msgfactory *ret = upb_gmalloc(sizeof(*ret));
+
+ ret->symtab = symtab;
+ upb_inttable_init(&ret->layouts, UPB_CTYPE_PTR);
+ upb_inttable_init(&ret->mergehandlers, UPB_CTYPE_CONSTPTR);
+
+ return ret;
+}
+
+void upb_msgfactory_free(upb_msgfactory *f) {
+ upb_inttable_iter i;
+ upb_inttable_begin(&i, &f->layouts);
+ for(; !upb_inttable_done(&i); upb_inttable_next(&i)) {
+ upb_msglayout *l = upb_value_getptr(upb_inttable_iter_value(&i));
+ upb_msglayout_free(l);
+ }
+
+ upb_inttable_begin(&i, &f->mergehandlers);
+ for(; !upb_inttable_done(&i); upb_inttable_next(&i)) {
+ const upb_handlers *h = upb_value_getconstptr(upb_inttable_iter_value(&i));
+ upb_handlers_unref(h, f);
+ }
+
+ upb_inttable_uninit(&f->layouts);
+ upb_inttable_uninit(&f->mergehandlers);
+ upb_gfree(f);
+}
+
+const upb_symtab *upb_msgfactory_symtab(const upb_msgfactory *f) {
+ return f->symtab;
+}
+
+const upb_msglayout *upb_msgfactory_getlayout(upb_msgfactory *f,
+ const upb_msgdef *m) {
+ upb_value v;
+ UPB_ASSERT(upb_symtab_lookupmsg(f->symtab, upb_msgdef_fullname(m)) == m);
+ UPB_ASSERT(!upb_msgdef_mapentry(m));
+
+ if (upb_inttable_lookupptr(&f->layouts, m, &v)) {
+ UPB_ASSERT(upb_value_getptr(v));
+ return upb_value_getptr(v);
+ } else {
+ upb_msgfactory *mutable_f = (void*)f;
+ upb_msglayout *l = upb_msglayout_new(m);
+ upb_inttable_insertptr(&mutable_f->layouts, m, upb_value_ptr(l));
+ UPB_ASSERT(l);
+ l->factory = f;
+ return l;
+ }
+}
+
+/* Our handlers that we don't expose externally. */
+
+void *upb_msg_startstr(void *msg, const void *hd, size_t size_hint) {
+ uint32_t ofs = (uintptr_t)hd;
+ /* We pass NULL here because we know we can get away with it. */
+ upb_alloc *alloc = upb_msg_alloc(msg, NULL);
+ upb_msgval val;
+ UPB_UNUSED(size_hint);
+
+ val = upb_msgval_read(msg, ofs, upb_msgval_sizeof(UPB_TYPE_STRING));
+
+ upb_free(alloc, (void*)val.str.ptr);
+ val.str.ptr = NULL;
+ val.str.len = 0;
+
+ upb_msgval_write(msg, ofs, val, upb_msgval_sizeof(UPB_TYPE_STRING));
+ return msg;
+}
+
+size_t upb_msg_str(void *msg, const void *hd, const char *ptr, size_t size,
+ const upb_bufhandle *handle) {
+ uint32_t ofs = (uintptr_t)hd;
+ /* We pass NULL here because we know we can get away with it. */
+ upb_alloc *alloc = upb_msg_alloc(msg, NULL);
+ upb_msgval val;
+ size_t newsize;
+ UPB_UNUSED(handle);
+
+ val = upb_msgval_read(msg, ofs, upb_msgval_sizeof(UPB_TYPE_STRING));
+
+ newsize = val.str.len + size;
+ val.str.ptr = upb_realloc(alloc, (void*)val.str.ptr, val.str.len, newsize);
+
+ if (!val.str.ptr) {
+ return false;
+ }
+
+ memcpy((char*)val.str.ptr + val.str.len, ptr, size);
+ val.str.len = newsize;
+ upb_msgval_write(msg, ofs, val, upb_msgval_sizeof(UPB_TYPE_STRING));
+ return size;
+}
+
+static void callback(const void *closure, upb_handlers *h) {
+ upb_msgfactory *factory = (upb_msgfactory*)closure;
+ const upb_msgdef *md = upb_handlers_msgdef(h);
+ const upb_msglayout* layout = upb_msgfactory_getlayout(factory, md);
+ upb_msg_field_iter i;
+ UPB_UNUSED(factory);
+
+ for(upb_msg_field_begin(&i, md);
+ !upb_msg_field_done(&i);
+ upb_msg_field_next(&i)) {
+ const upb_fielddef *f = upb_msg_iter_field(&i);
+ size_t offset = upb_msglayout_offset(layout, f);
+ upb_handlerattr attr = UPB_HANDLERATTR_INITIALIZER;
+ upb_handlerattr_sethandlerdata(&attr, (void*)offset);
+
+ if (upb_fielddef_isseq(f)) {
+ } else if (upb_fielddef_isstring(f)) {
+ upb_handlers_setstartstr(h, f, upb_msg_startstr, &attr);
+ upb_handlers_setstring(h, f, upb_msg_str, &attr);
+ } else {
+ upb_msg_setscalarhandler(
+ h, f, offset, upb_msglayout_hasbit(layout, f));
+ }
+ }
+}
+
+const upb_handlers *upb_msgfactory_getmergehandlers(upb_msgfactory *f,
+ const upb_msgdef *m) {
+ upb_msgfactory *mutable_f = (void*)f;
+
+ /* TODO(haberman): properly cache these. */
+ const upb_handlers *ret = upb_handlers_newfrozen(m, f, callback, f);
+ upb_inttable_push(&mutable_f->mergehandlers, upb_value_constptr(ret));
+
+ return ret;
+}
+
+const upb_visitorplan *upb_msgfactory_getvisitorplan(upb_msgfactory *f,
+ const upb_handlers *h) {
+ const upb_msgdef *md = upb_handlers_msgdef(h);
+ return (const upb_visitorplan*)upb_msgfactory_getlayout(f, md);
+}
+
+
+/** upb_visitor ***************************************************************/
+
+struct upb_visitor {
+ const upb_msglayout *layout;
+ upb_sink *sink;
+};
+
+static upb_selector_t getsel2(const upb_fielddef *f, upb_handlertype_t type) {
+ upb_selector_t ret;
+ bool ok = upb_handlers_getselector(f, type, &ret);
+ UPB_ASSERT(ok);
+ return ret;
+}
+
+static bool upb_visitor_hasfield(const upb_msg *msg, const upb_fielddef *f,
+ const upb_msglayout *layout) {
+ if (upb_fielddef_isseq(f)) {
+ return upb_msgval_getarr(upb_msg_get(msg, f, layout)) != NULL;
+ } else if (upb_msgdef_syntax(upb_fielddef_containingtype(f)) ==
+ UPB_SYNTAX_PROTO2) {
+ return upb_msg_has(msg, f, layout);
+ } else {
+ upb_msgval val = upb_msg_get(msg, f, layout);
+ switch (upb_fielddef_type(f)) {
+ case UPB_TYPE_FLOAT:
+ return upb_msgval_getfloat(val) != 0;
+ case UPB_TYPE_DOUBLE:
+ return upb_msgval_getdouble(val) != 0;
+ case UPB_TYPE_BOOL:
+ return upb_msgval_getbool(val);
+ case UPB_TYPE_ENUM:
+ case UPB_TYPE_INT32:
+ return upb_msgval_getint32(val) != 0;
+ case UPB_TYPE_UINT32:
+ return upb_msgval_getuint32(val) != 0;
+ case UPB_TYPE_INT64:
+ return upb_msgval_getint64(val) != 0;
+ case UPB_TYPE_UINT64:
+ return upb_msgval_getuint64(val) != 0;
+ case UPB_TYPE_STRING:
+ case UPB_TYPE_BYTES:
+ return upb_msgval_getstr(val) && upb_msgval_getstrlen(val) > 0;
+ case UPB_TYPE_MESSAGE:
+ return upb_msgval_getmsg(val) != NULL;
+ }
+ UPB_UNREACHABLE();
+ }
+}
+
+static bool upb_visitor_visitmsg2(const upb_msg *msg,
+ const upb_msglayout *layout, upb_sink *sink,
+ int depth) {
+ const upb_msgdef *md = upb_msglayout_msgdef(layout);
+ upb_msg_field_iter i;
+ upb_status status;
+
+ upb_sink_startmsg(sink);
+
+ /* Protect against cycles (possible because users may freely reassign message
+ * and repeated fields) by imposing a maximum recursion depth. */
+ if (depth > ENCODE_MAX_NESTING) {
+ return false;
+ }
+
+ for (upb_msg_field_begin(&i, md);
+ !upb_msg_field_done(&i);
+ upb_msg_field_next(&i)) {
+ upb_fielddef *f = upb_msg_iter_field(&i);
+ upb_msgval val;
+
+ if (!upb_visitor_hasfield(msg, f, layout)) {
+ continue;
+ }
+
+ val = upb_msg_get(msg, f, layout);
+
+ if (upb_fielddef_isseq(f)) {
+ const upb_array *arr = upb_msgval_getarr(val);
+ UPB_ASSERT(arr);
+ /* TODO: putary(ary, f, sink, depth);*/
+ } else if (upb_fielddef_issubmsg(f)) {
+ const upb_map *map = upb_msgval_getmap(val);
+ UPB_ASSERT(map);
+ /* TODO: putmap(map, f, sink, depth);*/
+ } else if (upb_fielddef_isstring(f)) {
+ /* TODO putstr(); */
+ } else {
+ upb_selector_t sel = getsel2(f, upb_handlers_getprimitivehandlertype(f));
+ UPB_ASSERT(upb_fielddef_isprimitive(f));
+
+ switch (upb_fielddef_type(f)) {
+ case UPB_TYPE_FLOAT:
+ CHECK_TRUE(upb_sink_putfloat(sink, sel, upb_msgval_getfloat(val)));
+ break;
+ case UPB_TYPE_DOUBLE:
+ CHECK_TRUE(
+ upb_sink_putdouble(sink, sel, upb_msgval_getdouble(val)));
+ break;
+ case UPB_TYPE_BOOL:
+ CHECK_TRUE(upb_sink_putbool(sink, sel, upb_msgval_getbool(val)));
+ break;
+ case UPB_TYPE_ENUM:
+ case UPB_TYPE_INT32:
+ CHECK_TRUE(upb_sink_putint32(sink, sel, upb_msgval_getint32(val)));
+ break;
+ case UPB_TYPE_UINT32:
+ CHECK_TRUE(
+ upb_sink_putuint32(sink, sel, upb_msgval_getuint32(val)));
+ break;
+ case UPB_TYPE_INT64:
+ CHECK_TRUE(upb_sink_putint64(sink, sel, upb_msgval_getint64(val)));
+ break;
+ case UPB_TYPE_UINT64:
+ CHECK_TRUE(
+ upb_sink_putuint64(sink, sel, upb_msgval_getuint64(val)));
+ break;
+ case UPB_TYPE_STRING:
+ case UPB_TYPE_BYTES:
+ case UPB_TYPE_MESSAGE:
+ UPB_UNREACHABLE();
+ }
+ }
+ }
+
+ upb_sink_endmsg(sink, &status);
+ return true;
+}
+
+upb_visitor *upb_visitor_create(upb_env *e, const upb_visitorplan *vp,
+ upb_sink *output) {
+ upb_visitor *visitor = upb_env_malloc(e, sizeof(*visitor));
+ visitor->layout = (const upb_msglayout*)vp;
+ visitor->sink = output;
+ return visitor;
+}
+
+bool upb_visitor_visitmsg(upb_visitor *visitor, const upb_msg *msg) {
+ return upb_visitor_visitmsg2(msg, visitor->layout, visitor->sink, 0);
+}
+
+
+/** upb_msg *******************************************************************/
+
+/* If we always read/write as a consistent type to each address, this shouldn't
+ * violate aliasing.
+ */
+#define DEREF(msg, ofs, type) *(type*)CHARPTR_AT(msg, ofs)
+
+static upb_inttable *upb_msg_trygetextdict(const upb_msg *msg,
+ const upb_msglayout *l) {
+ return l->has_extdict ? DEREF(msg, l->extdict_offset, upb_inttable*) : NULL;
+}
+
+static upb_inttable *upb_msg_getextdict(upb_msg *msg,
+ const upb_msglayout *l,
+ upb_alloc *a) {
+ upb_inttable *ext_dict;
+ UPB_ASSERT(l->has_extdict);
+
+ ext_dict = upb_msg_trygetextdict(msg, l);
+
+ if (!ext_dict) {
+ ext_dict = upb_malloc(a, sizeof(upb_inttable));
+
+ if (!ext_dict) {
+ return NULL;
+ }
+
+ /* Use an 8-byte type to ensure all bytes are copied. */
+ if (!upb_inttable_init2(ext_dict, UPB_CTYPE_INT64, a)) {
+ upb_free(a, ext_dict);
+ return NULL;
+ }
+
+ DEREF(msg, l->extdict_offset, upb_inttable*) = ext_dict;
+ }
+
+ return ext_dict;
+}
+
+static uint32_t upb_msg_getoneofint(const upb_msg *msg,
+ const upb_oneofdef *o,
+ const upb_msglayout *l) {
+ size_t oneof_ofs = l->case_offsets[upb_oneofdef_index(o)];
+ return DEREF(msg, oneof_ofs, uint8_t);
+}
+
+static void upb_msg_setoneofcase(const upb_msg *msg,
+ const upb_oneofdef *o,
+ const upb_msglayout *l,
+ uint32_t val) {
+ size_t oneof_ofs = l->case_offsets[upb_oneofdef_index(o)];
+ DEREF(msg, oneof_ofs, uint8_t) = val;
+}
+
+
+static bool upb_msg_oneofis(const upb_msg *msg, const upb_msglayout *l,
+ const upb_oneofdef *o, const upb_fielddef *f) {
+ return upb_msg_getoneofint(msg, o, l) == upb_fielddef_number(f);
+}
+
+size_t upb_msg_sizeof(const upb_msglayout *l) { return l->size; }
+
+void upb_msg_init(upb_msg *msg, const upb_msglayout *l, upb_alloc *a) {
+ if (l->default_msg) {
+ memcpy(msg, l->default_msg, l->size);
+ } else {
+ memset(msg, 0, l->size);
+ }
+
+ /* Set arena pointer. */
+ memcpy(msg, &a, sizeof(a));
+}
+
+void upb_msg_uninit(upb_msg *msg, const upb_msglayout *l) {
+ upb_inttable *ext_dict = upb_msg_trygetextdict(msg, l);
+ if (ext_dict) {
+ upb_inttable_uninit2(ext_dict, upb_msg_alloc(msg, l));
+ }
+}
+
+upb_msg *upb_msg_new(const upb_msglayout *l, upb_alloc *a) {
+ upb_msg *msg = upb_malloc(a, upb_msg_sizeof(l));
+
+ if (msg) {
+ upb_msg_init(msg, l, a);
+ }
+
+ return msg;
+}
+
+void upb_msg_free(upb_msg *msg, const upb_msglayout *l) {
+ upb_msg_uninit(msg, l);
+ upb_free(upb_msg_alloc(msg, l), msg);
+}
+
+upb_alloc *upb_msg_alloc(const upb_msg *msg, const upb_msglayout *l) {
+ upb_alloc *alloc;
+ UPB_UNUSED(l);
+ memcpy(&alloc, msg, sizeof(alloc));
+ return alloc;
+}
+
+bool upb_msg_has(const upb_msg *msg,
+ const upb_fielddef *f,
+ const upb_msglayout *l) {
+ const upb_oneofdef *o;
+ upb_msg_checkfield(l, f);
+ UPB_ASSERT(upb_fielddef_haspresence(f));
+
+ if (upb_fielddef_isextension(f)) {
+ /* Extensions are set when they are present in the extension dict. */
+ upb_inttable *ext_dict = upb_msg_trygetextdict(msg, l);
+ upb_value v;
+ return ext_dict != NULL &&
+ upb_inttable_lookup32(ext_dict, upb_fielddef_number(f), &v);
+ } else if ((o = upb_fielddef_containingoneof(f)) != NULL) {
+ /* Oneofs are set when the oneof number is set to this field. */
+ return upb_msg_getoneofint(msg, o, l) == upb_fielddef_number(f);
+ } else {
+ /* Other fields are set when their hasbit is set. */
+ uint32_t hasbit = l->hasbits[upb_fielddef_index(f)];
+ return DEREF(msg, hasbit / 8, char) | (1 << (hasbit % 8));
+ }
+}
+
+upb_msgval upb_msg_get(const upb_msg *msg, const upb_fielddef *f,
+ const upb_msglayout *l) {
+ upb_msg_checkfield(l, f);
+
+ if (upb_fielddef_isextension(f)) {
+ upb_inttable *ext_dict = upb_msg_trygetextdict(msg, l);
+ upb_value val;
+ if (upb_inttable_lookup32(ext_dict, upb_fielddef_number(f), &val)) {
+ return upb_msgval_fromval(val);
+ } else {
+ return upb_msgval_fromdefault(f);
+ }
+ } else {
+ size_t ofs = l->field_offsets[upb_fielddef_index(f)];
+ const upb_oneofdef *o = upb_fielddef_containingoneof(f);
+ upb_msgval ret;
+
+ if (o && !upb_msg_oneofis(msg, l, o, f)) {
+ /* Oneof defaults can't come from the message because the memory is reused
+ * by all types in the oneof. */
+ return upb_msgval_fromdefault(f);
+ }
+
+ ret = upb_msgval_read(msg, ofs, upb_msg_fieldsize(f));
+ return ret;
+ }
+}
+
+bool upb_msg_set(upb_msg *msg,
+ const upb_fielddef *f,
+ upb_msgval val,
+ const upb_msglayout *l) {
+ upb_alloc *a = upb_msg_alloc(msg, l);
+ upb_msg_checkfield(l, f);
+
+ if (upb_fielddef_isextension(f)) {
+ /* TODO(haberman): introduce table API that can do this in one call. */
+ upb_inttable *ext = upb_msg_getextdict(msg, l, a);
+ upb_value val2 = upb_toval(val);
+ if (!upb_inttable_replace(ext, upb_fielddef_number(f), val2) &&
+ !upb_inttable_insert2(ext, upb_fielddef_number(f), val2, a)) {
+ return false;
+ }
+ } else {
+ size_t ofs = l->field_offsets[upb_fielddef_index(f)];
+ const upb_oneofdef *o = upb_fielddef_containingoneof(f);
+
+ if (o) {
+ upb_msg_setoneofcase(msg, o, l, upb_fielddef_number(f));
+ }
+
+ upb_msgval_write(msg, ofs, val, upb_msg_fieldsize(f));
+ }
+ return true;
+}
+
+
+/** upb_array *****************************************************************/
+
+struct upb_array {
+ upb_fieldtype_t type;
+ uint8_t element_size;
+ void *data; /* Each element is element_size. */
+ size_t len; /* Measured in elements. */
+ size_t size; /* Measured in elements. */
+ upb_alloc *alloc;
+};
+
+#define DEREF_ARR(arr, i, type) ((type*)arr->data)[i]
+
+size_t upb_array_sizeof(upb_fieldtype_t type) {
+ UPB_UNUSED(type);
+ return sizeof(upb_array);
+}
+
+void upb_array_init(upb_array *arr, upb_fieldtype_t type, upb_alloc *alloc) {
+ arr->type = type;
+ arr->data = NULL;
+ arr->len = 0;
+ arr->size = 0;
+ arr->element_size = upb_msgval_sizeof(type);
+ arr->alloc = alloc;
+}
+
+void upb_array_uninit(upb_array *arr) {
+ upb_free(arr->alloc, arr->data);
+}
+
+upb_array *upb_array_new(upb_fieldtype_t type, upb_alloc *a) {
+ upb_array *ret = upb_malloc(a, upb_array_sizeof(type));
+
+ if (ret) {
+ upb_array_init(ret, type, a);
+ }
+
+ return ret;
+}
+
+void upb_array_free(upb_array *arr) {
+ upb_array_uninit(arr);
+ upb_free(arr->alloc, arr);
+}
+
+size_t upb_array_size(const upb_array *arr) {
+ return arr->len;
+}
+
+upb_fieldtype_t upb_array_type(const upb_array *arr) {
+ return arr->type;
+}
+
+upb_msgval upb_array_get(const upb_array *arr, size_t i) {
+ UPB_ASSERT(i < arr->len);
+ return upb_msgval_read(arr->data, i * arr->element_size, arr->element_size);
+}
+
+bool upb_array_set(upb_array *arr, size_t i, upb_msgval val) {
+ UPB_ASSERT(i <= arr->len);
+
+ if (i == arr->len) {
+ /* Extending the array. */
+
+ if (i == arr->size) {
+ /* Need to reallocate. */
+ size_t new_size = UPB_MAX(arr->size * 2, 8);
+ size_t new_bytes = new_size * arr->element_size;
+ size_t old_bytes = arr->size * arr->element_size;
+ upb_msgval *new_data =
+ upb_realloc(arr->alloc, arr->data, old_bytes, new_bytes);
+
+ if (!new_data) {
+ return false;
+ }
+
+ arr->data = new_data;
+ arr->size = new_size;
+ }
+
+ arr->len = i + 1;
+ }
+
+ upb_msgval_write(arr->data, i * arr->element_size, val, arr->element_size);
+ return true;
+}
+
+
+/** upb_map *******************************************************************/
+
+struct upb_map {
+ upb_fieldtype_t key_type;
+ upb_fieldtype_t val_type;
+ /* We may want to optimize this to use inttable where possible, for greater
+ * efficiency and lower memory footprint. */
+ upb_strtable strtab;
+ upb_alloc *alloc;
+};
+
+static void upb_map_tokey(upb_fieldtype_t type, upb_msgval *key,
+ const char **out_key, size_t *out_len) {
+ switch (type) {
+ case UPB_TYPE_STRING:
+ /* Point to string data of the input key. */
+ *out_key = key->str.ptr;
+ *out_len = key->str.len;
+ return;
+ case UPB_TYPE_BOOL:
+ case UPB_TYPE_INT32:
+ case UPB_TYPE_UINT32:
+ case UPB_TYPE_INT64:
+ case UPB_TYPE_UINT64:
+ /* Point to the key itself. XXX: big-endian. */
+ *out_key = (const char*)key;
+ *out_len = upb_msgval_sizeof(type);
+ return;
+ case UPB_TYPE_BYTES:
+ case UPB_TYPE_DOUBLE:
+ case UPB_TYPE_ENUM:
+ case UPB_TYPE_FLOAT:
+ case UPB_TYPE_MESSAGE:
+ break; /* Cannot be a map key. */
+ }
+ UPB_UNREACHABLE();
+}
+
+static upb_msgval upb_map_fromkey(upb_fieldtype_t type, const char *key,
+ size_t len) {
+ switch (type) {
+ case UPB_TYPE_STRING:
+ return upb_msgval_str(key, len);
+ case UPB_TYPE_BOOL:
+ case UPB_TYPE_INT32:
+ case UPB_TYPE_UINT32:
+ case UPB_TYPE_INT64:
+ case UPB_TYPE_UINT64:
+ return upb_msgval_read(key, 0, upb_msgval_sizeof(type));
+ case UPB_TYPE_BYTES:
+ case UPB_TYPE_DOUBLE:
+ case UPB_TYPE_ENUM:
+ case UPB_TYPE_FLOAT:
+ case UPB_TYPE_MESSAGE:
+ break; /* Cannot be a map key. */
+ }
+ UPB_UNREACHABLE();
+}
+
+size_t upb_map_sizeof(upb_fieldtype_t ktype, upb_fieldtype_t vtype) {
+ /* Size does not currently depend on key/value type. */
+ UPB_UNUSED(ktype);
+ UPB_UNUSED(vtype);
+ return sizeof(upb_map);
+}
+
+bool upb_map_init(upb_map *map, upb_fieldtype_t ktype, upb_fieldtype_t vtype,
+ upb_alloc *a) {
+ upb_ctype_t vtabtype = upb_fieldtotabtype(vtype);
+ UPB_ASSERT(upb_fieldtype_mapkeyok(ktype));
+ map->key_type = ktype;
+ map->val_type = vtype;
+ map->alloc = a;
+
+ if (!upb_strtable_init2(&map->strtab, vtabtype, a)) {
+ return false;
+ }
+
+ return true;
+}
+
+void upb_map_uninit(upb_map *map) {
+ upb_strtable_uninit2(&map->strtab, map->alloc);
+}
+
+upb_map *upb_map_new(upb_fieldtype_t ktype, upb_fieldtype_t vtype,
+ upb_alloc *a) {
+ upb_map *map = upb_malloc(a, upb_map_sizeof(ktype, vtype));
+
+ if (!map) {
+ return NULL;
+ }
+
+ if (!upb_map_init(map, ktype, vtype, a)) {
+ return NULL;
+ }
+
+ return map;
+}
+
+void upb_map_free(upb_map *map) {
+ upb_map_uninit(map);
+ upb_free(map->alloc, map);
+}
+
+size_t upb_map_size(const upb_map *map) {
+ return upb_strtable_count(&map->strtab);
+}
+
+upb_fieldtype_t upb_map_keytype(const upb_map *map) {
+ return map->key_type;
+}
+
+upb_fieldtype_t upb_map_valuetype(const upb_map *map) {
+ return map->val_type;
+}
+
+bool upb_map_get(const upb_map *map, upb_msgval key, upb_msgval *val) {
+ upb_value tabval;
+ const char *key_str;
+ size_t key_len;
+ bool ret;
+
+ upb_map_tokey(map->key_type, &key, &key_str, &key_len);
+ ret = upb_strtable_lookup2(&map->strtab, key_str, key_len, &tabval);
+ if (ret) {
+ memcpy(val, &tabval, sizeof(tabval));
+ }
+
+ return ret;
+}
+
+bool upb_map_set(upb_map *map, upb_msgval key, upb_msgval val,
+ upb_msgval *removed) {
+ const char *key_str;
+ size_t key_len;
+ upb_value tabval = upb_toval(val);
+ upb_value removedtabval;
+ upb_alloc *a = map->alloc;
+
+ upb_map_tokey(map->key_type, &key, &key_str, &key_len);
+
+ /* TODO(haberman): add overwrite operation to minimize number of lookups. */
+ if (upb_strtable_lookup2(&map->strtab, key_str, key_len, NULL)) {
+ upb_strtable_remove3(&map->strtab, key_str, key_len, &removedtabval, a);
+ memcpy(&removed, &removedtabval, sizeof(removed));
+ }
+
+ return upb_strtable_insert3(&map->strtab, key_str, key_len, tabval, a);
+}
+
+bool upb_map_del(upb_map *map, upb_msgval key) {
+ const char *key_str;
+ size_t key_len;
+ upb_alloc *a = map->alloc;
+
+ upb_map_tokey(map->key_type, &key, &key_str, &key_len);
+ return upb_strtable_remove3(&map->strtab, key_str, key_len, NULL, a);
+}
+
+
+/** upb_mapiter ***************************************************************/
+
+struct upb_mapiter {
+ upb_strtable_iter iter;
+ upb_fieldtype_t key_type;
+};
+
+size_t upb_mapiter_sizeof() {
+ return sizeof(upb_mapiter);
+}
+
+void upb_mapiter_begin(upb_mapiter *i, const upb_map *map) {
+ upb_strtable_begin(&i->iter, &map->strtab);
+ i->key_type = map->key_type;
+}
+
+upb_mapiter *upb_mapiter_new(const upb_map *t, upb_alloc *a) {
+ upb_mapiter *ret = upb_malloc(a, upb_mapiter_sizeof());
+
+ if (!ret) {
+ return NULL;
+ }
+
+ upb_mapiter_begin(ret, t);
+ return ret;
+}
+
+void upb_mapiter_free(upb_mapiter *i, upb_alloc *a) {
+ upb_free(a, i);
+}
+
+void upb_mapiter_next(upb_mapiter *i) {
+ upb_strtable_next(&i->iter);
+}
+
+bool upb_mapiter_done(const upb_mapiter *i) {
+ return upb_strtable_done(&i->iter);
+}
+
+upb_msgval upb_mapiter_key(const upb_mapiter *i) {
+ return upb_map_fromkey(i->key_type, upb_strtable_iter_key(&i->iter),
+ upb_strtable_iter_keylength(&i->iter));
+}
+
+upb_msgval upb_mapiter_value(const upb_mapiter *i) {
+ return upb_msgval_fromval(upb_strtable_iter_value(&i->iter));
+}
+
+void upb_mapiter_setdone(upb_mapiter *i) {
+ upb_strtable_iter_setdone(&i->iter);
+}
+
+bool upb_mapiter_isequal(const upb_mapiter *i1, const upb_mapiter *i2) {
+ return upb_strtable_iter_isequal(&i1->iter, &i2->iter);
+}
+
+
+/** Handlers for upb_msg ******************************************************/
+
+typedef struct {
+ size_t offset;
+ int32_t hasbit;
+} upb_msg_handlerdata;
+
+/* Fallback implementation if the handler is not specialized by the producer. */
+#define MSG_WRITER(type, ctype) \
+ bool upb_msg_set ## type (void *c, const void *hd, ctype val) { \
+ uint8_t *m = c; \
+ const upb_msg_handlerdata *d = hd; \
+ if (d->hasbit > 0) \
+ *(uint8_t*)&m[d->hasbit / 8] |= 1 << (d->hasbit % 8); \
+ *(ctype*)&m[d->offset] = val; \
+ return true; \
+ } \
+
+MSG_WRITER(double, double)
+MSG_WRITER(float, float)
+MSG_WRITER(int32, int32_t)
+MSG_WRITER(int64, int64_t)
+MSG_WRITER(uint32, uint32_t)
+MSG_WRITER(uint64, uint64_t)
+MSG_WRITER(bool, bool)
+
+bool upb_msg_setscalarhandler(upb_handlers *h, const upb_fielddef *f,
+ size_t offset, int32_t hasbit) {
+ upb_handlerattr attr = UPB_HANDLERATTR_INITIALIZER;
+ bool ok;
+
+ upb_msg_handlerdata *d = upb_gmalloc(sizeof(*d));
+ if (!d) return false;
+ d->offset = offset;
+ d->hasbit = hasbit;
+
+ upb_handlerattr_sethandlerdata(&attr, d);
+ upb_handlerattr_setalwaysok(&attr, true);
+ upb_handlers_addcleanup(h, d, upb_gfree);
+
+#define TYPE(u, l) \
+ case UPB_TYPE_##u: \
+ ok = upb_handlers_set##l(h, f, upb_msg_set##l, &attr); break;
+
+ ok = false;
+
+ switch (upb_fielddef_type(f)) {
+ TYPE(INT64, int64);
+ TYPE(INT32, int32);
+ TYPE(ENUM, int32);
+ TYPE(UINT64, uint64);
+ TYPE(UINT32, uint32);
+ TYPE(DOUBLE, double);
+ TYPE(FLOAT, float);
+ TYPE(BOOL, bool);
+ default: UPB_ASSERT(false); break;
+ }
+#undef TYPE
+
+ upb_handlerattr_uninit(&attr);
+ return ok;
+}
+
+bool upb_msg_getscalarhandlerdata(const upb_handlers *h,
+ upb_selector_t s,
+ upb_fieldtype_t *type,
+ size_t *offset,
+ int32_t *hasbit) {
+ const upb_msg_handlerdata *d;
+ upb_func *f = upb_handlers_gethandler(h, s);
+
+ if ((upb_int64_handlerfunc*)f == upb_msg_setint64) {
+ *type = UPB_TYPE_INT64;
+ } else if ((upb_int32_handlerfunc*)f == upb_msg_setint32) {
+ *type = UPB_TYPE_INT32;
+ } else if ((upb_uint64_handlerfunc*)f == upb_msg_setuint64) {
+ *type = UPB_TYPE_UINT64;
+ } else if ((upb_uint32_handlerfunc*)f == upb_msg_setuint32) {
+ *type = UPB_TYPE_UINT32;
+ } else if ((upb_double_handlerfunc*)f == upb_msg_setdouble) {
+ *type = UPB_TYPE_DOUBLE;
+ } else if ((upb_float_handlerfunc*)f == upb_msg_setfloat) {
+ *type = UPB_TYPE_FLOAT;
+ } else if ((upb_bool_handlerfunc*)f == upb_msg_setbool) {
+ *type = UPB_TYPE_BOOL;
+ } else {
+ return false;
+ }
+
+ d = upb_handlers_gethandlerdata(h, s);
+ *offset = d->offset;
+ *hasbit = d->hasbit;
+ return true;
+}
/*
** upb::RefCounted Implementation
**
@@ -3703,579 +5218,91 @@ bool upb_refcounted_freeze(upb_refcounted *const*roots, int n, upb_status *s,
}
-/* Fallback implementation if the shim is not specialized by the JIT. */
-#define SHIM_WRITER(type, ctype) \
- bool upb_shim_set ## type (void *c, const void *hd, ctype val) { \
- uint8_t *m = c; \
- const upb_shim_data *d = hd; \
- if (d->hasbit > 0) \
- *(uint8_t*)&m[d->hasbit / 8] |= 1 << (d->hasbit % 8); \
- *(ctype*)&m[d->offset] = val; \
- return true; \
- } \
-
-SHIM_WRITER(double, double)
-SHIM_WRITER(float, float)
-SHIM_WRITER(int32, int32_t)
-SHIM_WRITER(int64, int64_t)
-SHIM_WRITER(uint32, uint32_t)
-SHIM_WRITER(uint64, uint64_t)
-SHIM_WRITER(bool, bool)
-#undef SHIM_WRITER
-
-bool upb_shim_set(upb_handlers *h, const upb_fielddef *f, size_t offset,
- int32_t hasbit) {
- upb_handlerattr attr = UPB_HANDLERATTR_INITIALIZER;
- bool ok;
-
- upb_shim_data *d = upb_gmalloc(sizeof(*d));
- if (!d) return false;
- d->offset = offset;
- d->hasbit = hasbit;
-
- upb_handlerattr_sethandlerdata(&attr, d);
- upb_handlerattr_setalwaysok(&attr, true);
- upb_handlers_addcleanup(h, d, upb_gfree);
-
-#define TYPE(u, l) \
- case UPB_TYPE_##u: \
- ok = upb_handlers_set##l(h, f, upb_shim_set##l, &attr); break;
-
- ok = false;
-
- switch (upb_fielddef_type(f)) {
- TYPE(INT64, int64);
- TYPE(INT32, int32);
- TYPE(ENUM, int32);
- TYPE(UINT64, uint64);
- TYPE(UINT32, uint32);
- TYPE(DOUBLE, double);
- TYPE(FLOAT, float);
- TYPE(BOOL, bool);
- default: UPB_ASSERT(false); break;
- }
-#undef TYPE
-
- upb_handlerattr_uninit(&attr);
- return ok;
-}
-
-const upb_shim_data *upb_shim_getdata(const upb_handlers *h, upb_selector_t s,
- upb_fieldtype_t *type) {
- upb_func *f = upb_handlers_gethandler(h, s);
-
- if ((upb_int64_handlerfunc*)f == upb_shim_setint64) {
- *type = UPB_TYPE_INT64;
- } else if ((upb_int32_handlerfunc*)f == upb_shim_setint32) {
- *type = UPB_TYPE_INT32;
- } else if ((upb_uint64_handlerfunc*)f == upb_shim_setuint64) {
- *type = UPB_TYPE_UINT64;
- } else if ((upb_uint32_handlerfunc*)f == upb_shim_setuint32) {
- *type = UPB_TYPE_UINT32;
- } else if ((upb_double_handlerfunc*)f == upb_shim_setdouble) {
- *type = UPB_TYPE_DOUBLE;
- } else if ((upb_float_handlerfunc*)f == upb_shim_setfloat) {
- *type = UPB_TYPE_FLOAT;
- } else if ((upb_bool_handlerfunc*)f == upb_shim_setbool) {
- *type = UPB_TYPE_BOOL;
- } else {
- return NULL;
- }
-
- return (const upb_shim_data*)upb_handlers_gethandlerdata(h, s);
-}
-
-
-#include <string.h>
-
-static void upb_symtab_free(upb_refcounted *r) {
- upb_symtab *s = (upb_symtab*)r;
- upb_strtable_iter i;
- upb_strtable_begin(&i, &s->symtab);
- for (; !upb_strtable_done(&i); upb_strtable_next(&i)) {
- const upb_def *def = upb_value_getptr(upb_strtable_iter_value(&i));
- upb_def_unref(def, s);
- }
- upb_strtable_uninit(&s->symtab);
- upb_gfree(s);
-}
-
-upb_symtab *upb_symtab_new(const void *owner) {
- static const struct upb_refcounted_vtbl vtbl = {NULL, &upb_symtab_free};
-
- upb_symtab *s = upb_gmalloc(sizeof(*s));
- if (!s) {
- return NULL;
+bool upb_bufsrc_putbuf(const char *buf, size_t len, upb_bytessink *sink) {
+ void *subc;
+ bool ret;
+ upb_bufhandle handle;
+ upb_bufhandle_init(&handle);
+ upb_bufhandle_setbuf(&handle, buf, 0);
+ ret = upb_bytessink_start(sink, len, &subc);
+ if (ret && len != 0) {
+ ret = (upb_bytessink_putbuf(sink, subc, buf, len, &handle) >= len);
}
-
- upb_refcounted_init(upb_symtab_upcast_mutable(s), &vtbl, owner);
- upb_strtable_init(&s->symtab, UPB_CTYPE_PTR);
- return s;
-}
-
-void upb_symtab_freeze(upb_symtab *s) {
- upb_refcounted *r;
- bool ok;
-
- UPB_ASSERT(!upb_symtab_isfrozen(s));
- r = upb_symtab_upcast_mutable(s);
- /* The symtab does not take ref2's (see refcounted.h) on the defs, because
- * defs cannot refer back to the table and therefore cannot create cycles. So
- * 0 will suffice for maxdepth here. */
- ok = upb_refcounted_freeze(&r, 1, NULL, 0);
- UPB_ASSERT(ok);
-}
-
-const upb_def *upb_symtab_lookup(const upb_symtab *s, const char *sym) {
- upb_value v;
- upb_def *ret = upb_strtable_lookup(&s->symtab, sym, &v) ?
- upb_value_getptr(v) : NULL;
- return ret;
-}
-
-const upb_msgdef *upb_symtab_lookupmsg(const upb_symtab *s, const char *sym) {
- upb_value v;
- upb_def *def = upb_strtable_lookup(&s->symtab, sym, &v) ?
- upb_value_getptr(v) : NULL;
- return def ? upb_dyncast_msgdef(def) : NULL;
-}
-
-const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym) {
- upb_value v;
- upb_def *def = upb_strtable_lookup(&s->symtab, sym, &v) ?
- upb_value_getptr(v) : NULL;
- return def ? upb_dyncast_enumdef(def) : NULL;
-}
-
-/* Given a symbol and the base symbol inside which it is defined, find the
- * symbol's definition in t. */
-static upb_def *upb_resolvename(const upb_strtable *t,
- const char *base, const char *sym) {
- if(strlen(sym) == 0) return NULL;
- if(sym[0] == '.') {
- /* Symbols starting with '.' are absolute, so we do a single lookup.
- * Slice to omit the leading '.' */
- upb_value v;
- return upb_strtable_lookup(t, sym + 1, &v) ? upb_value_getptr(v) : NULL;
- } else {
- /* Remove components from base until we find an entry or run out.
- * TODO: This branch is totally broken, but currently not used. */
- (void)base;
- UPB_ASSERT(false);
- return NULL;
+ if (ret) {
+ ret = upb_bytessink_end(sink);
}
-}
-
-const upb_def *upb_symtab_resolve(const upb_symtab *s, const char *base,
- const char *sym) {
- upb_def *ret = upb_resolvename(&s->symtab, base, sym);
+ upb_bufhandle_uninit(&handle);
return ret;
}
-/* Starts a depth-first traversal at "def", recursing into any subdefs
- * (ie. submessage types). Adds duplicates of existing defs to addtab
- * wherever necessary, so that the resulting symtab will be consistent once
- * addtab is added.
- *
- * More specifically, if any def D is found in the DFS that:
- *
- * 1. can reach a def that is being replaced by something in addtab, AND
- *
- * 2. is not itself being replaced already (ie. this name doesn't already
- * exist in addtab)
- *
- * ...then a duplicate (new copy) of D will be added to addtab.
- *
- * Returns true if this happened for any def reachable from "def."
- *
- * It is slightly tricky to do this correctly in the presence of cycles. If we
- * detect that our DFS has hit a cycle, we might not yet know if any SCCs on
- * our stack can reach a def in addtab or not. Once we figure this out, that
- * answer needs to apply to *all* defs in these SCCs, even if we visited them
- * already. So a straight up one-pass cycle-detecting DFS won't work.
- *
- * To work around this problem, we traverse each SCC (which we already
- * computed, since these defs are frozen) as a single node. We first compute
- * whether the SCC as a whole can reach any def in addtab, then we dup (or not)
- * the entire SCC. This requires breaking the encapsulation of upb_refcounted,
- * since that is where we get the data about what SCC we are in. */
-static bool upb_resolve_dfs(const upb_def *def, upb_strtable *addtab,
- const void *new_owner, upb_inttable *seen,
- upb_status *s) {
- upb_value v;
- bool need_dup;
- const upb_def *base;
- const void* memoize_key;
-
- /* Memoize results of this function for efficiency (since we're traversing a
- * DAG this is not needed to limit the depth of the search).
- *
- * We memoize by SCC instead of by individual def. */
- memoize_key = def->base.group;
-
- if (upb_inttable_lookupptr(seen, memoize_key, &v))
- return upb_value_getbool(v);
-
- /* Visit submessages for all messages in the SCC. */
- need_dup = false;
- base = def;
- do {
- upb_value v;
- const upb_msgdef *m;
-
- UPB_ASSERT(upb_def_isfrozen(def));
- if (def->type == UPB_DEF_FIELD) continue;
- if (upb_strtable_lookup(addtab, upb_def_fullname(def), &v)) {
- need_dup = true;
- }
-
- /* For messages, continue the recursion by visiting all subdefs, but only
- * ones in different SCCs. */
- m = upb_dyncast_msgdef(def);
- if (m) {
- upb_msg_field_iter i;
- for(upb_msg_field_begin(&i, m);
- !upb_msg_field_done(&i);
- upb_msg_field_next(&i)) {
- upb_fielddef *f = upb_msg_iter_field(&i);
- const upb_def *subdef;
-
- if (!upb_fielddef_hassubdef(f)) continue;
- subdef = upb_fielddef_subdef(f);
-
- /* Skip subdefs in this SCC. */
- if (def->base.group == subdef->base.group) continue;
-
- /* |= to avoid short-circuit; we need its side-effects. */
- need_dup |= upb_resolve_dfs(subdef, addtab, new_owner, seen, s);
- if (!upb_ok(s)) return false;
- }
- }
- } while ((def = (upb_def*)def->base.next) != base);
-
- if (need_dup) {
- /* Dup all defs in this SCC that don't already have entries in addtab. */
- def = base;
- do {
- const char *name;
-
- if (def->type == UPB_DEF_FIELD) continue;
- name = upb_def_fullname(def);
- if (!upb_strtable_lookup(addtab, name, NULL)) {
- upb_def *newdef = upb_def_dup(def, new_owner);
- if (!newdef) goto oom;
- newdef->came_from_user = false;
- if (!upb_strtable_insert(addtab, name, upb_value_ptr(newdef)))
- goto oom;
- }
- } while ((def = (upb_def*)def->base.next) != base);
- }
-
- upb_inttable_insertptr(seen, memoize_key, upb_value_bool(need_dup));
- return need_dup;
-
-oom:
- upb_status_seterrmsg(s, "out of memory");
- return false;
-}
-
-/* TODO(haberman): we need a lot more testing of error conditions.
- * The came_from_user stuff in particular is not tested. */
-static bool symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
- void *ref_donor, upb_refcounted *freeze_also,
- upb_status *status) {
- size_t i;
- size_t add_n;
- size_t freeze_n;
- upb_strtable_iter iter;
- upb_refcounted **add_objs = NULL;
- upb_def **add_defs = NULL;
- size_t add_objs_size;
- upb_strtable addtab;
- upb_inttable seen;
-
- if (n == 0 && !freeze_also) {
- return true;
- }
-
- UPB_ASSERT(!upb_symtab_isfrozen(s));
- if (!upb_strtable_init(&addtab, UPB_CTYPE_PTR)) {
- upb_status_seterrmsg(status, "out of memory");
- return false;
- }
-
- /* Add new defs to our "add" set. */
- for (i = 0; i < n; i++) {
- upb_def *def = defs[i];
- const char *fullname;
- upb_fielddef *f;
-
- if (upb_def_isfrozen(def)) {
- upb_status_seterrmsg(status, "added defs must be mutable");
- goto err;
- }
- UPB_ASSERT(!upb_def_isfrozen(def));
- fullname = upb_def_fullname(def);
- if (!fullname) {
- upb_status_seterrmsg(
- status, "Anonymous defs cannot be added to a symtab");
- goto err;
- }
-
- f = upb_dyncast_fielddef_mutable(def);
-
- if (f) {
- if (!upb_fielddef_containingtypename(f)) {
- upb_status_seterrmsg(status,
- "Standalone fielddefs must have a containing type "
- "(extendee) name set");
- goto err;
- }
- } else {
- if (upb_strtable_lookup(&addtab, fullname, NULL)) {
- upb_status_seterrf(status, "Conflicting defs named '%s'", fullname);
- goto err;
- }
- /* We need this to back out properly, because if there is a failure we
- * need to donate the ref back to the caller. */
- def->came_from_user = true;
- upb_def_donateref(def, ref_donor, s);
- if (!upb_strtable_insert(&addtab, fullname, upb_value_ptr(def)))
- goto oom_err;
- }
- }
-
- /* Add standalone fielddefs (ie. extensions) to the appropriate messages.
- * If the appropriate message only exists in the existing symtab, duplicate
- * it so we have a mutable copy we can add the fields to. */
- for (i = 0; i < n; i++) {
- upb_def *def = defs[i];
- upb_fielddef *f = upb_dyncast_fielddef_mutable(def);
- const char *msgname;
- upb_value v;
- upb_msgdef *m;
-
- if (!f) continue;
- msgname = upb_fielddef_containingtypename(f);
- /* We validated this earlier in this function. */
- UPB_ASSERT(msgname);
-
- /* If the extendee name is absolutely qualified, move past the initial ".".
- * TODO(haberman): it is not obvious what it would mean if this was not
- * absolutely qualified. */
- if (msgname[0] == '.') {
- msgname++;
- }
-
- if (upb_strtable_lookup(&addtab, msgname, &v)) {
- /* Extendee is in the set of defs the user asked us to add. */
- m = upb_value_getptr(v);
- } else {
- /* Need to find and dup the extendee from the existing symtab. */
- const upb_msgdef *frozen_m = upb_symtab_lookupmsg(s, msgname);
- if (!frozen_m) {
- upb_status_seterrf(status,
- "Tried to extend message %s that does not exist "
- "in this SymbolTable.",
- msgname);
- goto err;
- }
- m = upb_msgdef_dup(frozen_m, s);
- if (!m) goto oom_err;
- if (!upb_strtable_insert(&addtab, msgname, upb_value_ptr(m))) {
- upb_msgdef_unref(m, s);
- goto oom_err;
- }
- }
-
- if (!upb_msgdef_addfield(m, f, ref_donor, status)) {
- goto err;
- }
- }
-
- /* Add dups of any existing def that can reach a def with the same name as
- * anything in our "add" set. */
- if (!upb_inttable_init(&seen, UPB_CTYPE_BOOL)) goto oom_err;
- upb_strtable_begin(&iter, &s->symtab);
- for (; !upb_strtable_done(&iter); upb_strtable_next(&iter)) {
- upb_def *def = upb_value_getptr(upb_strtable_iter_value(&iter));
- upb_resolve_dfs(def, &addtab, s, &seen, status);
- if (!upb_ok(status)) goto err;
- }
- upb_inttable_uninit(&seen);
-
- /* Now using the table, resolve symbolic references for subdefs. */
- upb_strtable_begin(&iter, &addtab);
- for (; !upb_strtable_done(&iter); upb_strtable_next(&iter)) {
- const char *base;
- upb_def *def = upb_value_getptr(upb_strtable_iter_value(&iter));
- upb_msgdef *m = upb_dyncast_msgdef_mutable(def);
- upb_msg_field_iter j;
-
- if (!m) continue;
- /* Type names are resolved relative to the message in which they appear. */
- base = upb_msgdef_fullname(m);
-
- for(upb_msg_field_begin(&j, m);
- !upb_msg_field_done(&j);
- upb_msg_field_next(&j)) {
- upb_fielddef *f = upb_msg_iter_field(&j);
- const char *name = upb_fielddef_subdefname(f);
- if (name && !upb_fielddef_subdef(f)) {
- /* Try the lookup in the current set of to-be-added defs first. If not
- * there, try existing defs. */
- upb_def *subdef = upb_resolvename(&addtab, base, name);
- if (subdef == NULL) {
- subdef = upb_resolvename(&s->symtab, base, name);
- }
- if (subdef == NULL) {
- upb_status_seterrf(
- status, "couldn't resolve name '%s' in message '%s'", name, base);
- goto err;
- } else if (!upb_fielddef_setsubdef(f, subdef, status)) {
- goto err;
- }
- }
- }
- }
-
- /* We need an array of the defs in addtab, for passing to
- * upb_refcounted_freeze(). */
- add_objs_size = upb_strtable_count(&addtab);
- if (freeze_also) {
- add_objs_size++;
- }
-
- add_defs = upb_gmalloc(sizeof(void*) * add_objs_size);
- if (add_defs == NULL) goto oom_err;
- upb_strtable_begin(&iter, &addtab);
- for (add_n = 0; !upb_strtable_done(&iter); upb_strtable_next(&iter)) {
- add_defs[add_n++] = upb_value_getptr(upb_strtable_iter_value(&iter));
- }
-
- /* Validate defs. */
- if (!_upb_def_validate(add_defs, add_n, status)) {
- goto err;
- }
-
- /* Cheat a little and give the array a new type.
- * This is probably undefined behavior, but this code will be deleted soon. */
- add_objs = (upb_refcounted**)add_defs;
-
- freeze_n = add_n;
- if (freeze_also) {
- add_objs[freeze_n++] = freeze_also;
- }
-
- if (!upb_refcounted_freeze(add_objs, freeze_n, status,
- UPB_MAX_MESSAGE_DEPTH * 2)) {
- goto err;
- }
-
- /* This must be delayed until all errors have been detected, since error
- * recovery code uses this table to cleanup defs. */
- upb_strtable_uninit(&addtab);
-
- /* TODO(haberman) we don't properly handle errors after this point (like
- * OOM in upb_strtable_insert() below). */
- for (i = 0; i < add_n; i++) {
- upb_def *def = (upb_def*)add_objs[i];
- const char *name = upb_def_fullname(def);
- upb_value v;
- bool success;
-
- if (upb_strtable_remove(&s->symtab, name, &v)) {
- const upb_def *def = upb_value_getptr(v);
- upb_def_unref(def, s);
- }
- success = upb_strtable_insert(&s->symtab, name, upb_value_ptr(def));
- UPB_ASSERT(success == true);
- }
- upb_gfree(add_defs);
- return true;
-
-oom_err:
- upb_status_seterrmsg(status, "out of memory");
-err: {
- /* For defs the user passed in, we need to donate the refs back. For defs
- * we dup'd, we need to just unref them. */
- upb_strtable_begin(&iter, &addtab);
- for (; !upb_strtable_done(&iter); upb_strtable_next(&iter)) {
- upb_def *def = upb_value_getptr(upb_strtable_iter_value(&iter));
- bool came_from_user = def->came_from_user;
- def->came_from_user = false;
- if (came_from_user) {
- upb_def_donateref(def, s, ref_donor);
- } else {
- upb_def_unref(def, s);
- }
- }
- }
- upb_strtable_uninit(&addtab);
- upb_gfree(add_defs);
- UPB_ASSERT(!upb_ok(status));
- return false;
-}
+struct upb_bufsink {
+ upb_byteshandler handler;
+ upb_bytessink sink;
+ upb_env *env;
+ char *ptr;
+ size_t len, size;
+};
-bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
- void *ref_donor, upb_status *status) {
- return symtab_add(s, defs, n, ref_donor, NULL, status);
+static void *upb_bufsink_start(void *_sink, const void *hd, size_t size_hint) {
+ upb_bufsink *sink = _sink;
+ UPB_UNUSED(hd);
+ UPB_UNUSED(size_hint);
+ sink->len = 0;
+ return sink;
}
-bool upb_symtab_addfile(upb_symtab *s, upb_filedef *file, upb_status *status) {
- size_t n;
- size_t i;
- upb_def **defs;
- bool ret;
+static size_t upb_bufsink_string(void *_sink, const void *hd, const char *ptr,
+ size_t len, const upb_bufhandle *handle) {
+ upb_bufsink *sink = _sink;
+ size_t new_size = sink->size;
- n = upb_filedef_defcount(file);
- defs = upb_gmalloc(sizeof(*defs) * n);
+ UPB_ASSERT(new_size > 0);
+ UPB_UNUSED(hd);
+ UPB_UNUSED(handle);
- if (defs == NULL) {
- upb_status_seterrmsg(status, "Out of memory");
- return false;
+ while (sink->len + len > new_size) {
+ new_size *= 2;
}
- for (i = 0; i < n; i++) {
- defs[i] = upb_filedef_mutabledef(file, i);
+ if (new_size != sink->size) {
+ sink->ptr = upb_env_realloc(sink->env, sink->ptr, sink->size, new_size);
+ sink->size = new_size;
}
- ret = symtab_add(s, defs, n, NULL, upb_filedef_upcast_mutable(file), status);
+ memcpy(sink->ptr + sink->len, ptr, len);
+ sink->len += len;
- upb_gfree(defs);
- return ret;
+ return len;
}
-/* Iteration. */
+upb_bufsink *upb_bufsink_new(upb_env *env) {
+ upb_bufsink *sink = upb_env_malloc(env, sizeof(upb_bufsink));
+ upb_byteshandler_init(&sink->handler);
+ upb_byteshandler_setstartstr(&sink->handler, upb_bufsink_start, NULL);
+ upb_byteshandler_setstring(&sink->handler, upb_bufsink_string, NULL);
-static void advance_to_matching(upb_symtab_iter *iter) {
- if (iter->type == UPB_DEF_ANY)
- return;
+ upb_bytessink_reset(&sink->sink, &sink->handler, sink);
- while (!upb_strtable_done(&iter->iter) &&
- iter->type != upb_symtab_iter_def(iter)->type) {
- upb_strtable_next(&iter->iter);
- }
-}
+ sink->env = env;
+ sink->size = 32;
+ sink->ptr = upb_env_malloc(env, sink->size);
+ sink->len = 0;
-void upb_symtab_begin(upb_symtab_iter *iter, const upb_symtab *s,
- upb_deftype_t type) {
- upb_strtable_begin(&iter->iter, &s->symtab);
- iter->type = type;
- advance_to_matching(iter);
+ return sink;
}
-void upb_symtab_next(upb_symtab_iter *iter) {
- upb_strtable_next(&iter->iter);
- advance_to_matching(iter);
+void upb_bufsink_free(upb_bufsink *sink) {
+ upb_env_free(sink->env, sink->ptr);
+ upb_env_free(sink->env, sink);
}
-bool upb_symtab_done(const upb_symtab_iter *iter) {
- return upb_strtable_done(&iter->iter);
+upb_bytessink *upb_bufsink_sink(upb_bufsink *sink) {
+ return &sink->sink;
}
-const upb_def *upb_symtab_iter_def(const upb_symtab_iter *iter) {
- return upb_value_getptr(upb_strtable_iter_value(&iter->iter));
+const char *upb_bufsink_getdata(const upb_bufsink *sink, size_t *len) {
+ *len = sink->len;
+ return sink->ptr;
}
/*
** upb_table Implementation
@@ -5285,7 +6312,7 @@ upb_alloc upb_alloc_global = {&upb_global_allocfunc};
/* Be conservative and choose 16 in case anyone is using SSE. */
static const size_t maxalign = 16;
-static size_t align_up(size_t size) {
+static size_t align_up_max(size_t size) {
return ((size + maxalign - 1) / maxalign) * maxalign;
}
@@ -5309,7 +6336,7 @@ static void upb_arena_addblock(upb_arena *a, void *ptr, size_t size,
block->next = a->block_head;
block->size = size;
- block->used = align_up(sizeof(mem_block));
+ block->used = align_up_max(sizeof(mem_block));
block->owned = owned;
a->block_head = block;
@@ -5342,7 +6369,7 @@ static void *upb_arena_doalloc(upb_alloc *alloc, void *ptr, size_t oldsize,
return NULL; /* We are an arena, don't need individual frees. */
}
- size = align_up(size);
+ size = align_up_max(size);
/* TODO(haberman): special-case if this is a realloc of the last alloc? */
@@ -5412,6 +6439,10 @@ void upb_arena_uninit(upb_arena *a) {
block = next;
}
+
+ /* Protect against multiple-uninit. */
+ a->cleanup_head = NULL;
+ a->block_head = NULL;
}
bool upb_arena_addcleanup(upb_arena *a, upb_cleanup_func *func, void *ud) {
@@ -6481,7 +7512,7 @@ struct upb_descreader {
upb_fielddef *f;
};
-static char *upb_strndup(const char *buf, size_t n) {
+static char *upb_gstrndup(const char *buf, size_t n) {
char *ret = upb_gmalloc(n + 1);
if (!ret) return NULL;
memcpy(ret, buf, n);
@@ -6631,7 +7662,7 @@ static size_t file_onname(void *closure, const void *hd, const char *buf,
UPB_UNUSED(hd);
UPB_UNUSED(handle);
- name = upb_strndup(buf, n);
+ name = upb_gstrndup(buf, n);
/* XXX: see comment at the top of the file. */
ok = upb_filedef_setname(r->file, name, NULL);
upb_gfree(name);
@@ -6647,7 +7678,7 @@ static size_t file_onpackage(void *closure, const void *hd, const char *buf,
UPB_UNUSED(hd);
UPB_UNUSED(handle);
- package = upb_strndup(buf, n);
+ package = upb_gstrndup(buf, n);
/* XXX: see comment at the top of the file. */
upb_descreader_setscopename(r, package);
ok = upb_filedef_setpackage(r->file, package, NULL);
@@ -6719,7 +7750,7 @@ static size_t enumval_onname(void *closure, const void *hd, const char *buf,
UPB_UNUSED(handle);
/* XXX: see comment at the top of the file. */
upb_gfree(r->name);
- r->name = upb_strndup(buf, n);
+ r->name = upb_gstrndup(buf, n);
r->saw_name = true;
return n;
}
@@ -6770,7 +7801,7 @@ static bool enum_endmsg(void *closure, const void *hd, upb_status *status) {
static size_t enum_onname(void *closure, const void *hd, const char *buf,
size_t n, const upb_bufhandle *handle) {
upb_descreader *r = closure;
- char *fullname = upb_strndup(buf, n);
+ char *fullname = upb_gstrndup(buf, n);
UPB_UNUSED(hd);
UPB_UNUSED(handle);
/* XXX: see comment at the top of the file. */
@@ -6938,7 +7969,7 @@ static bool field_onnumber(void *closure, const void *hd, int32_t val) {
static size_t field_onname(void *closure, const void *hd, const char *buf,
size_t n, const upb_bufhandle *handle) {
upb_descreader *r = closure;
- char *name = upb_strndup(buf, n);
+ char *name = upb_gstrndup(buf, n);
UPB_UNUSED(hd);
UPB_UNUSED(handle);
@@ -6951,7 +7982,7 @@ static size_t field_onname(void *closure, const void *hd, const char *buf,
static size_t field_ontypename(void *closure, const void *hd, const char *buf,
size_t n, const upb_bufhandle *handle) {
upb_descreader *r = closure;
- char *name = upb_strndup(buf, n);
+ char *name = upb_gstrndup(buf, n);
UPB_UNUSED(hd);
UPB_UNUSED(handle);
@@ -6964,7 +7995,7 @@ static size_t field_ontypename(void *closure, const void *hd, const char *buf,
static size_t field_onextendee(void *closure, const void *hd, const char *buf,
size_t n, const upb_bufhandle *handle) {
upb_descreader *r = closure;
- char *name = upb_strndup(buf, n);
+ char *name = upb_gstrndup(buf, n);
UPB_UNUSED(hd);
UPB_UNUSED(handle);
@@ -6984,7 +8015,7 @@ static size_t field_ondefaultval(void *closure, const void *hd, const char *buf,
* type yet, so we save it as a string until the end of the field.
* XXX: see comment at the top of the file. */
upb_gfree(r->default_string);
- r->default_string = upb_strndup(buf, n);
+ r->default_string = upb_gstrndup(buf, n);
return n;
}
@@ -7005,7 +8036,7 @@ static size_t oneof_name(void *closure, const void *hd, const char *buf,
upb_descreader *r = closure;
upb_descreader_frame *f = &r->stack[r->stack_len-1];
upb_oneofdef *o = upb_descreader_getoneof(r, f->oneof_index++);
- char *name_null_terminated = upb_strndup(buf, n);
+ char *name_null_terminated = upb_gstrndup(buf, n);
bool ok = upb_oneofdef_setname(o, name_null_terminated, NULL);
UPB_UNUSED(hd);
UPB_UNUSED(handle);
@@ -7042,7 +8073,7 @@ static size_t msg_name(void *closure, const void *hd, const char *buf,
upb_descreader *r = closure;
upb_msgdef *m = upb_descreader_top(r);
/* XXX: see comment at the top of the file. */
- char *name = upb_strndup(buf, n);
+ char *name = upb_gstrndup(buf, n);
UPB_UNUSED(hd);
UPB_UNUSED(handle);
diff --git a/php/ext/google/protobuf/upb.h b/php/ext/google/protobuf/upb.h
index c83b0e03..5f780458 100644
--- a/php/ext/google/protobuf/upb.h
+++ b/php/ext/google/protobuf/upb.h
@@ -123,20 +123,21 @@ template <int N> class InlinedEnvironment;
#define UPB_NORETURN
#endif
+#if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L
+/* C99/C++11 versions. */
+#include <stdio.h>
+#define _upb_snprintf snprintf
+#define _upb_vsnprintf vsnprintf
+#define _upb_va_copy(a, b) va_copy(a, b)
+#elif defined __GNUC__
/* A few hacky workarounds for functions not in C89.
* For internal use only!
* TODO(haberman): fix these by including our own implementations, or finding
* another workaround.
*/
-#ifdef __GNUC__
#define _upb_snprintf __builtin_snprintf
#define _upb_vsnprintf __builtin_vsnprintf
#define _upb_va_copy(a, b) __va_copy(a, b)
-#elif __STDC_VERSION__ >= 199901L
-/* C99 versions. */
-#define _upb_snprintf snprintf
-#define _upb_vsnprintf vsnprintf
-#define _upb_va_copy(a, b) va_copy(a, b)
#else
#error Need implementations of [v]snprintf and va_copy
#endif
@@ -280,6 +281,12 @@ template <int N> class InlinedEnvironment;
* exist in debug mode. This turns into regular assert. */
#define UPB_ASSERT_DEBUGVAR(expr) assert(expr)
+#ifdef __GNUC__
+#define UPB_UNREACHABLE() do { assert(0); __builtin_unreachable(); } while(0)
+#else
+#define UPB_UNREACHABLE() do { assert(0); } while(0)
+#endif
+
/* Generic function type. */
typedef void upb_func();
@@ -513,17 +520,18 @@ struct upb_alloc {
};
UPB_INLINE void *upb_malloc(upb_alloc *alloc, size_t size) {
- UPB_ASSERT(size > 0);
+ UPB_ASSERT(alloc);
return alloc->func(alloc, NULL, 0, size);
}
UPB_INLINE void *upb_realloc(upb_alloc *alloc, void *ptr, size_t oldsize,
size_t size) {
- UPB_ASSERT(size > 0);
+ UPB_ASSERT(alloc);
return alloc->func(alloc, ptr, oldsize, size);
}
UPB_INLINE void upb_free(upb_alloc *alloc, void *ptr) {
+ assert(alloc);
alloc->func(alloc, ptr, 0, 0);
}
@@ -572,11 +580,11 @@ UPB_BEGIN_EXTERN_C
void upb_arena_init(upb_arena *a);
void upb_arena_init2(upb_arena *a, void *mem, size_t n, upb_alloc *alloc);
void upb_arena_uninit(upb_arena *a);
-upb_alloc *upb_arena_alloc(upb_arena *a);
bool upb_arena_addcleanup(upb_arena *a, upb_cleanup_func *func, void *ud);
size_t upb_arena_bytesallocated(const upb_arena *a);
void upb_arena_setnextblocksize(upb_arena *a, size_t size);
void upb_arena_setmaxblocksize(upb_arena *a, size_t size);
+UPB_INLINE upb_alloc *upb_arena_alloc(upb_arena *a) { return (upb_alloc*)a; }
UPB_END_EXTERN_C
@@ -807,7 +815,9 @@ typedef enum {
UPB_CTYPE_CSTR = 6,
UPB_CTYPE_PTR = 7,
UPB_CTYPE_CONSTPTR = 8,
- UPB_CTYPE_FPTR = 9
+ UPB_CTYPE_FPTR = 9,
+ UPB_CTYPE_FLOAT = 10,
+ UPB_CTYPE_DOUBLE = 11
} upb_ctype_t;
typedef struct {
@@ -881,6 +891,29 @@ FUNCS(constptr, constptr, const void*, uintptr_t, UPB_CTYPE_CONSTPTR)
FUNCS(fptr, fptr, upb_func*, uintptr_t, UPB_CTYPE_FPTR)
#undef FUNCS
+
+UPB_INLINE void upb_value_setfloat(upb_value *val, float cval) {
+ memcpy(&val->val, &cval, sizeof(cval));
+ SET_TYPE(val->ctype, UPB_CTYPE_FLOAT);
+}
+
+UPB_INLINE void upb_value_setdouble(upb_value *val, double cval) {
+ memcpy(&val->val, &cval, sizeof(cval));
+ SET_TYPE(val->ctype, UPB_CTYPE_DOUBLE);
+}
+
+UPB_INLINE upb_value upb_value_float(float cval) {
+ upb_value ret;
+ upb_value_setfloat(&ret, cval);
+ return ret;
+}
+
+UPB_INLINE upb_value upb_value_double(double cval) {
+ upb_value ret;
+ upb_value_setdouble(&ret, cval);
+ return ret;
+}
+
#undef SET_TYPE
@@ -1123,6 +1156,13 @@ UPB_INLINE size_t upb_strtable_count(const upb_strtable *t) {
return t->t.count;
}
+void upb_inttable_packedsize(const upb_inttable *t, size_t *size);
+void upb_strtable_packedsize(const upb_strtable *t, size_t *size);
+upb_inttable *upb_inttable_pack(const upb_inttable *t, void *p, size_t *ofs,
+ size_t size);
+upb_strtable *upb_strtable_pack(const upb_strtable *t, void *p, size_t *ofs,
+ size_t size);
+
/* Inserts the given key into the hashtable with the given value. The key must
* not already exist in the hash table. For string tables, the key must be
* NULL-terminated, and the table will make an internal copy of the key.
@@ -1669,6 +1709,7 @@ class FieldDef;
class FileDef;
class MessageDef;
class OneofDef;
+class SymbolTable;
}
#endif
@@ -1677,6 +1718,8 @@ UPB_DECLARE_DERIVED_TYPE(upb::OneofDef, upb::RefCounted, upb_oneofdef,
upb_refcounted)
UPB_DECLARE_DERIVED_TYPE(upb::FileDef, upb::RefCounted, upb_filedef,
upb_refcounted)
+UPB_DECLARE_TYPE(upb::SymbolTable, upb_symtab)
+
/* The maximum message depth that the type graph can have. This is a resource
* limit for the C stack since we sometimes need to recursively traverse the
@@ -1710,8 +1753,6 @@ class upb::Def {
public:
typedef upb_deftype_t Type;
- Def* Dup(const void *owner) const;
-
/* upb::RefCounted methods like Ref()/Unref(). */
UPB_REFCOUNTED_CPPMETHODS
@@ -1757,9 +1798,6 @@ class upb::Def {
UPB_BEGIN_EXTERN_C
-/* Native C API. */
-upb_def *upb_def_dup(const upb_def *def, const void *owner);
-
/* Include upb_refcounted methods like upb_def_ref()/upb_def_unref(). */
UPB_REFCOUNTED_CMETHODS(upb_def, upb_def_upcast)
@@ -1856,15 +1894,19 @@ UPB_DECLARE_DEF_TYPE(upb::EnumDef, enumdef, ENUM)
* types defined in descriptor.proto, which gives INT32 and SINT32 separate
* types (we distinguish the two with the "integer encoding" enum below). */
typedef enum {
- UPB_TYPE_FLOAT = 1,
- UPB_TYPE_DOUBLE = 2,
- UPB_TYPE_BOOL = 3,
- UPB_TYPE_STRING = 4,
- UPB_TYPE_BYTES = 5,
- UPB_TYPE_MESSAGE = 6,
- UPB_TYPE_ENUM = 7, /* Enum values are int32. */
- UPB_TYPE_INT32 = 8,
- UPB_TYPE_UINT32 = 9,
+ /* Types stored in 1 byte. */
+ UPB_TYPE_BOOL = 1,
+ /* Types stored in 4 bytes. */
+ UPB_TYPE_FLOAT = 2,
+ UPB_TYPE_INT32 = 3,
+ UPB_TYPE_UINT32 = 4,
+ UPB_TYPE_ENUM = 5, /* Enum values are int32. */
+ /* Types stored as pointers (probably 4 or 8 bytes). */
+ UPB_TYPE_STRING = 6,
+ UPB_TYPE_BYTES = 7,
+ UPB_TYPE_MESSAGE = 8,
+ /* Types stored as 8 bytes. */
+ UPB_TYPE_DOUBLE = 9,
UPB_TYPE_INT64 = 10,
UPB_TYPE_UINT64 = 11
} upb_fieldtype_t;
@@ -1945,13 +1987,6 @@ class upb::FieldDef {
/* Returns NULL if memory allocation failed. */
static reffed_ptr<FieldDef> New();
- /* Duplicates the given field, returning NULL if memory allocation failed.
- * When a fielddef is duplicated, the subdef (if any) is made symbolic if it
- * wasn't already. If the subdef is set but has no name (which is possible
- * since msgdefs are not required to have a name) the new fielddef's subdef
- * will be unset. */
- FieldDef* Dup(const void* owner) const;
-
/* upb::RefCounted methods like Ref()/Unref(). */
UPB_REFCOUNTED_CPPMETHODS
@@ -2038,16 +2073,10 @@ class upb::FieldDef {
bool IsPrimitive() const;
bool IsMap() const;
- /* Whether this field must be able to explicitly represent presence:
- *
- * * This is always false for repeated fields (an empty repeated field is
- * equivalent to a repeated field with zero entries).
+ /* Returns whether this field explicitly represents presence.
*
- * * This is always true for submessages.
- *
- * * For other fields, it depends on the message (see
- * MessageDef::SetPrimitivesHavePresence())
- */
+ * For proto2 messages: Returns true for any scalar (non-repeated) field.
+ * For proto3 messages: Returns true for scalar submessage or oneof fields. */
bool HasPresence() const;
/* How integers are encoded. Only meaningful for integer types.
@@ -2206,7 +2235,6 @@ UPB_BEGIN_EXTERN_C
/* Native C API. */
upb_fielddef *upb_fielddef_new(const void *owner);
-upb_fielddef *upb_fielddef_dup(const upb_fielddef *f, const void *owner);
/* Include upb_refcounted methods like upb_fielddef_ref(). */
UPB_REFCOUNTED_CMETHODS(upb_fielddef, upb_fielddef_upcast2)
@@ -2416,16 +2444,6 @@ class upb::MessageDef {
return FindOneofByName(str.c_str(), str.size());
}
- /* Returns a new msgdef that is a copy of the given msgdef (and a copy of all
- * the fields) but with any references to submessages broken and replaced
- * with just the name of the submessage. Returns NULL if memory allocation
- * failed.
- *
- * TODO(haberman): which is more useful, keeping fields resolved or
- * unresolving them? If there's no obvious answer, Should this functionality
- * just be moved into symtab.c? */
- MessageDef* Dup(const void* owner) const;
-
/* Is this message a map entry? */
void setmapentry(bool map_entry);
bool mapentry() const;
@@ -2559,7 +2577,6 @@ UPB_REFCOUNTED_CMETHODS(upb_msgdef, upb_msgdef_upcast2)
bool upb_msgdef_freeze(upb_msgdef *m, upb_status *status);
-upb_msgdef *upb_msgdef_dup(const upb_msgdef *m, const void *owner);
const char *upb_msgdef_fullname(const upb_msgdef *m);
const char *upb_msgdef_name(const upb_msgdef *m);
int upb_msgdef_numoneofs(const upb_msgdef *m);
@@ -2709,10 +2726,6 @@ class upb::EnumDef {
* first one that was added. */
const char* FindValueByNumber(int32_t num) const;
- /* Returns a new EnumDef with all the same values. The new EnumDef will be
- * owned by the given owner. */
- EnumDef* Dup(const void* owner) const;
-
/* Iteration over name/value pairs. The order is undefined.
* Adding an enum val invalidates any iterators.
*
@@ -2740,7 +2753,6 @@ UPB_BEGIN_EXTERN_C
/* Native C API. */
upb_enumdef *upb_enumdef_new(const void *owner);
-upb_enumdef *upb_enumdef_dup(const upb_enumdef *e, const void *owner);
/* Include upb_refcounted methods like upb_enumdef_ref(). */
UPB_REFCOUNTED_CMETHODS(upb_enumdef, upb_enumdef_upcast2)
@@ -2785,6 +2797,7 @@ int32_t upb_enum_iter_number(upb_enum_iter *iter);
UPB_END_EXTERN_C
+
/* upb::OneofDef **************************************************************/
typedef upb_inttable_iter upb_oneof_iter;
@@ -2849,10 +2862,6 @@ class upb::OneofDef {
/* Looks up by tag number. */
const FieldDef* FindFieldByNumber(uint32_t num) const;
- /* Returns a new OneofDef with all the same fields. The OneofDef will be owned
- * by the given owner. */
- OneofDef* Dup(const void* owner) const;
-
/* Iteration over fields. The order is undefined. */
class iterator : public std::iterator<std::forward_iterator_tag, FieldDef*> {
public:
@@ -2898,16 +2907,16 @@ UPB_BEGIN_EXTERN_C
/* Native C API. */
upb_oneofdef *upb_oneofdef_new(const void *owner);
-upb_oneofdef *upb_oneofdef_dup(const upb_oneofdef *o, const void *owner);
/* Include upb_refcounted methods like upb_oneofdef_ref(). */
UPB_REFCOUNTED_CMETHODS(upb_oneofdef, upb_oneofdef_upcast)
const char *upb_oneofdef_name(const upb_oneofdef *o);
-bool upb_oneofdef_setname(upb_oneofdef *o, const char *name, upb_status *s);
-
const upb_msgdef *upb_oneofdef_containingtype(const upb_oneofdef *o);
int upb_oneofdef_numfields(const upb_oneofdef *o);
+uint32_t upb_oneofdef_index(const upb_oneofdef *o);
+
+bool upb_oneofdef_setname(upb_oneofdef *o, const char *name, upb_status *s);
bool upb_oneofdef_addfield(upb_oneofdef *o, upb_fielddef *f,
const void *ref_donor,
upb_status *s);
@@ -3051,6 +3060,153 @@ UPB_INLINE upb_def *upb_filedef_mutabledef(upb_filedef *f, int i) {
UPB_END_EXTERN_C
+typedef struct {
+ UPB_PRIVATE_FOR_CPP
+ upb_strtable_iter iter;
+ upb_deftype_t type;
+} upb_symtab_iter;
+
+#ifdef __cplusplus
+
+/* Non-const methods in upb::SymbolTable are NOT thread-safe. */
+class upb::SymbolTable {
+ public:
+ /* Returns a new symbol table with a single ref owned by "owner."
+ * Returns NULL if memory allocation failed. */
+ static SymbolTable* New();
+ static void Free(upb::SymbolTable* table);
+
+ /* For all lookup functions, the returned pointer is not owned by the
+ * caller; it may be invalidated by any non-const call or unref of the
+ * SymbolTable! To protect against this, take a ref if desired. */
+
+ /* Freezes the symbol table: prevents further modification of it.
+ * After the Freeze() operation is successful, the SymbolTable must only be
+ * accessed via a const pointer.
+ *
+ * Unlike with upb::MessageDef/upb::EnumDef/etc, freezing a SymbolTable is not
+ * a necessary step in using a SymbolTable. If you have no need for it to be
+ * immutable, there is no need to freeze it ever. However sometimes it is
+ * useful, and SymbolTables that are statically compiled into the binary are
+ * always frozen by nature. */
+ void Freeze();
+
+ /* Resolves the given symbol using the rules described in descriptor.proto,
+ * namely:
+ *
+ * If the name starts with a '.', it is fully-qualified. Otherwise,
+ * C++-like scoping rules are used to find the type (i.e. first the nested
+ * types within this message are searched, then within the parent, on up
+ * to the root namespace).
+ *
+ * If not found, returns NULL. */
+ const Def* Resolve(const char* base, const char* sym) const;
+
+ /* Finds an entry in the symbol table with this exact name. If not found,
+ * returns NULL. */
+ const Def* Lookup(const char *sym) const;
+ const MessageDef* LookupMessage(const char *sym) const;
+ const EnumDef* LookupEnum(const char *sym) const;
+
+ /* TODO: introduce a C++ iterator, but make it nice and templated so that if
+ * you ask for an iterator of MessageDef the iterated elements are strongly
+ * typed as MessageDef*. */
+
+ /* Adds the given mutable defs to the symtab, resolving all symbols (including
+ * enum default values) and finalizing the defs. Only one def per name may be
+ * in the list, and the defs may not duplicate any name already in the symtab.
+ * All defs must have a name -- anonymous defs are not allowed. Anonymous
+ * defs can still be frozen by calling upb_def_freeze() directly.
+ *
+ * The entire operation either succeeds or fails. If the operation fails,
+ * the symtab is unchanged, false is returned, and status indicates the
+ * error. The caller passes a ref on all defs to the symtab (even if the
+ * operation fails).
+ *
+ * TODO(haberman): currently failure will leave the symtab unchanged, but may
+ * leave the defs themselves partially resolved. Does this matter? If so we
+ * could do a prepass that ensures that all symbols are resolvable and bail
+ * if not, so we don't mutate anything until we know the operation will
+ * succeed. */
+ bool Add(Def*const* defs, size_t n, void* ref_donor, Status* status);
+
+ bool Add(const std::vector<Def*>& defs, void *owner, Status* status) {
+ return Add((Def*const*)&defs[0], defs.size(), owner, status);
+ }
+
+ /* Resolves all subdefs for messages in this file and attempts to freeze the
+ * file. If this succeeds, adds all the symbols to this SymbolTable
+ * (replacing any existing ones with the same names). */
+ bool AddFile(FileDef* file, Status* s);
+
+ private:
+ UPB_DISALLOW_POD_OPS(SymbolTable, upb::SymbolTable)
+};
+
+#endif /* __cplusplus */
+
+UPB_BEGIN_EXTERN_C
+
+/* Native C API. */
+
+upb_symtab *upb_symtab_new();
+void upb_symtab_free(upb_symtab* s);
+const upb_def *upb_symtab_resolve(const upb_symtab *s, const char *base,
+ const char *sym);
+const upb_def *upb_symtab_lookup(const upb_symtab *s, const char *sym);
+const upb_msgdef *upb_symtab_lookupmsg(const upb_symtab *s, const char *sym);
+const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym);
+bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
+ void *ref_donor, upb_status *status);
+bool upb_symtab_addfile(upb_symtab *s, upb_filedef *file, upb_status* status);
+
+/* upb_symtab_iter i;
+ * for(upb_symtab_begin(&i, s, type); !upb_symtab_done(&i);
+ * upb_symtab_next(&i)) {
+ * const upb_def *def = upb_symtab_iter_def(&i);
+ * // ...
+ * }
+ *
+ * For C we don't have separate iterators for const and non-const.
+ * It is the caller's responsibility to cast the upb_fielddef* to
+ * const if the upb_msgdef* is const. */
+void upb_symtab_begin(upb_symtab_iter *iter, const upb_symtab *s,
+ upb_deftype_t type);
+void upb_symtab_next(upb_symtab_iter *iter);
+bool upb_symtab_done(const upb_symtab_iter *iter);
+const upb_def *upb_symtab_iter_def(const upb_symtab_iter *iter);
+
+UPB_END_EXTERN_C
+
+#ifdef __cplusplus
+/* C++ inline wrappers. */
+namespace upb {
+inline SymbolTable* SymbolTable::New() {
+ return upb_symtab_new();
+}
+inline void SymbolTable::Free(SymbolTable* s) {
+ upb_symtab_free(s);
+}
+inline const Def *SymbolTable::Resolve(const char *base,
+ const char *sym) const {
+ return upb_symtab_resolve(this, base, sym);
+}
+inline const Def* SymbolTable::Lookup(const char *sym) const {
+ return upb_symtab_lookup(this, sym);
+}
+inline const MessageDef *SymbolTable::LookupMessage(const char *sym) const {
+ return upb_symtab_lookupmsg(this, sym);
+}
+inline bool SymbolTable::Add(
+ Def*const* defs, size_t n, void* ref_donor, Status* status) {
+ return upb_symtab_add(this, (upb_def*const*)defs, n, ref_donor, status);
+}
+inline bool SymbolTable::AddFile(FileDef* file, Status* s) {
+ return upb_symtab_addfile(this, file, s);
+}
+} /* namespace upb */
+#endif
+
#ifdef __cplusplus
UPB_INLINE const char* upb_safecstr(const std::string& str) {
@@ -3061,9 +3217,6 @@ UPB_INLINE const char* upb_safecstr(const std::string& str) {
/* Inline C++ wrappers. */
namespace upb {
-inline Def* Def::Dup(const void* owner) const {
- return upb_def_dup(this, owner);
-}
inline Def::Type Def::def_type() const { return upb_def_type(this); }
inline const char* Def::full_name() const { return upb_def_fullname(this); }
inline const char* Def::name() const { return upb_def_name(this); }
@@ -3113,9 +3266,6 @@ inline reffed_ptr<FieldDef> FieldDef::New() {
upb_fielddef *f = upb_fielddef_new(&f);
return reffed_ptr<FieldDef>(f, &f);
}
-inline FieldDef* FieldDef::Dup(const void* owner) const {
- return upb_fielddef_dup(this, owner);
-}
inline const char* FieldDef::full_name() const {
return upb_fielddef_fullname(this);
}
@@ -3355,9 +3505,6 @@ inline const OneofDef* MessageDef::FindOneofByName(const char* name,
size_t len) const {
return upb_msgdef_ntoo(this, name, len);
}
-inline MessageDef* MessageDef::Dup(const void *owner) const {
- return upb_msgdef_dup(this, owner);
-}
inline void MessageDef::setmapentry(bool map_entry) {
upb_msgdef_setmapentry(this, map_entry);
}
@@ -3527,9 +3674,6 @@ inline bool EnumDef::FindValueByName(const char* name, int32_t *num) const {
inline const char* EnumDef::FindValueByNumber(int32_t num) const {
return upb_enumdef_iton(this, num);
}
-inline EnumDef* EnumDef::Dup(const void* owner) const {
- return upb_enumdef_dup(this, owner);
-}
inline EnumDef::Iterator::Iterator(const EnumDef* e) {
upb_enum_begin(&iter_, e);
@@ -3836,6 +3980,7 @@ extern const struct upb_refcounted_vtbl upb_enumdef_vtbl;
struct upb_oneofdef {
upb_refcounted base;
+ uint32_t index; /* Index within oneofs. */
const char *name;
upb_strtable ntof;
upb_inttable itof;
@@ -3845,7 +3990,7 @@ struct upb_oneofdef {
extern const struct upb_refcounted_vtbl upb_oneofdef_vtbl;
#define UPB_ONEOFDEF_INIT(name, ntof, itof, refs, ref2s) \
- { UPB_REFCOUNT_INIT(&upb_oneofdef_vtbl, refs, ref2s), name, ntof, itof }
+ { UPB_REFCOUNT_INIT(&upb_oneofdef_vtbl, refs, ref2s), 0, name, ntof, itof }
/* upb_symtab *****************************************************************/
@@ -5832,12 +5977,14 @@ inline BytesHandler::~BytesHandler() {}
#ifdef __cplusplus
namespace upb {
+class BufferSink;
class BufferSource;
class BytesSink;
class Sink;
}
#endif
+UPB_DECLARE_TYPE(upb::BufferSink, upb_bufsink)
UPB_DECLARE_TYPE(upb::BufferSource, upb_bufsrc)
UPB_DECLARE_TYPE(upb::BytesSink, upb_bytessink)
UPB_DECLARE_TYPE(upb::Sink, upb_sink)
@@ -6024,6 +6171,13 @@ struct upb_bufsrc {
UPB_BEGIN_EXTERN_C
+/* A class for accumulating output string data in a flat buffer. */
+
+upb_bufsink *upb_bufsink_new(upb_env *env);
+void upb_bufsink_free(upb_bufsink *sink);
+upb_bytessink *upb_bufsink_sink(upb_bufsink *sink);
+const char *upb_bufsink_getdata(const upb_bufsink *sink, size_t *len);
+
/* Inline definitions. */
UPB_INLINE void upb_bytessink_reset(upb_bytessink *s, const upb_byteshandler *h,
@@ -6073,23 +6227,7 @@ UPB_INLINE bool upb_bytessink_end(upb_bytessink *s) {
&s->handler->table[UPB_ENDSTR_SELECTOR].attr));
}
-UPB_INLINE bool upb_bufsrc_putbuf(const char *buf, size_t len,
- upb_bytessink *sink) {
- void *subc;
- bool ret;
- upb_bufhandle handle;
- upb_bufhandle_init(&handle);
- upb_bufhandle_setbuf(&handle, buf, 0);
- ret = upb_bytessink_start(sink, len, &subc);
- if (ret && len != 0) {
- ret = (upb_bytessink_putbuf(sink, subc, buf, len, &handle) >= len);
- }
- if (ret) {
- ret = upb_bytessink_end(sink);
- }
- upb_bufhandle_uninit(&handle);
- return ret;
-}
+bool upb_bufsrc_putbuf(const char *buf, size_t len, upb_bytessink *sink);
#define PUTVAL(type, ctype) \
UPB_INLINE bool upb_sink_put##type(upb_sink *s, upb_selector_t sel, \
@@ -6337,267 +6475,407 @@ inline bool BufferSource::PutBuffer(const char *buf, size_t len,
#endif
/*
-** For handlers that do very tiny, very simple operations, the function call
-** overhead of calling a handler can be significant. This file allows the
-** user to define handlers that do something very simple like store the value
-** to memory and/or set a hasbit. JIT compilers can then special-case these
-** handlers and emit specialized code for them instead of actually calling the
-** handler.
+** upb::Message is a representation for protobuf messages.
**
-** The functionality is very simple/limited right now but may expand to be able
-** to call another function.
-*/
-
-#ifndef UPB_SHIM_H
-#define UPB_SHIM_H
+** However it differs from other common representations like
+** google::protobuf::Message in one key way: it does not prescribe any
+** ownership between messages and submessages, and it relies on the
+** client to delete each message/submessage/array/map at the appropriate
+** time.
+**
+** A client can access a upb::Message without knowing anything about
+** ownership semantics, but to create or mutate a message a user needs
+** to implement the memory management themselves.
+**
+** Currently all messages, arrays, and maps store a upb_alloc* internally.
+** Mutating operations use this when they require dynamically-allocated
+** memory. We could potentially eliminate this size overhead later by
+** letting the user flip a bit on the factory that prevents this from
+** being stored. The user would then need to use separate functions where
+** the upb_alloc* is passed explicitly. However for handlers to populate
+** such structures, they would need a place to store this upb_alloc* during
+** parsing; upb_handlers don't currently have a good way to accommodate this.
+**
+** TODO: UTF-8 checking?
+**/
+#ifndef UPB_MSG_H_
+#define UPB_MSG_H_
-typedef struct {
- size_t offset;
- int32_t hasbit;
-} upb_shim_data;
#ifdef __cplusplus
namespace upb {
+class Array;
+class Map;
+class MapIterator;
+class MessageFactory;
+class MessageLayout;
+class Visitor;
+class VisitorPlan;
+}
-struct Shim {
- typedef upb_shim_data Data;
+#endif
- /* Sets a handler for the given field that writes the value to the given
- * offset and, if hasbit >= 0, sets a bit at the given bit offset. Returns
- * true if the handler was set successfully. */
- static bool Set(Handlers *h, const FieldDef *f, size_t ofs, int32_t hasbit);
+UPB_DECLARE_TYPE(upb::MessageFactory, upb_msgfactory)
+UPB_DECLARE_TYPE(upb::MessageLayout, upb_msglayout)
+UPB_DECLARE_TYPE(upb::Array, upb_array)
+UPB_DECLARE_TYPE(upb::Map, upb_map)
+UPB_DECLARE_TYPE(upb::MapIterator, upb_mapiter)
+UPB_DECLARE_TYPE(upb::Visitor, upb_visitor)
+UPB_DECLARE_TYPE(upb::VisitorPlan, upb_visitorplan)
- /* If this handler is a shim, returns the corresponding upb::Shim::Data and
- * stores the type in "type". Otherwise returns NULL. */
- static const Data* GetData(const Handlers* h, Handlers::Selector s,
- FieldDef::Type* type);
-};
+/* TODO(haberman): C++ accessors */
-} /* namespace upb */
+UPB_BEGIN_EXTERN_C
-#endif
+typedef void upb_msg;
-UPB_BEGIN_EXTERN_C
-/* C API. */
-bool upb_shim_set(upb_handlers *h, const upb_fielddef *f, size_t offset,
- int32_t hasbit);
-const upb_shim_data *upb_shim_getdata(const upb_handlers *h, upb_selector_t s,
- upb_fieldtype_t *type);
+/** upb_msglayout *************************************************************/
-UPB_END_EXTERN_C
+/* upb_msglayout represents the memory layout of a given upb_msgdef. You get
+ * instances of this from a upb_msgfactory, and the factory always owns the
+ * msglayout. */
-#ifdef __cplusplus
-/* C++ Wrappers. */
-namespace upb {
-inline bool Shim::Set(Handlers* h, const FieldDef* f, size_t ofs,
- int32_t hasbit) {
- return upb_shim_set(h, f, ofs, hasbit);
-}
-inline const Shim::Data* Shim::GetData(const Handlers* h, Handlers::Selector s,
- FieldDef::Type* type) {
- return upb_shim_getdata(h, s, type);
-}
-} /* namespace upb */
-#endif
+/* Gets the factory for this layout */
+upb_msgfactory *upb_msglayout_factory(const upb_msglayout *l);
-#endif /* UPB_SHIM_H */
-/*
-** upb::SymbolTable (upb_symtab)
-**
-** A symtab (symbol table) stores a name->def map of upb_defs. Clients could
-** always create such tables themselves, but upb_symtab has logic for resolving
-** symbolic references, and in particular, for keeping a whole set of consistent
-** defs when replacing some subset of those defs. This logic is nontrivial.
-**
-** This is a mixed C/C++ interface that offers a full API to both languages.
-** See the top-level README for more information.
-*/
+/* Get the msglayout for a submessage. This requires that this field is a
+ * submessage, ie. upb_fielddef_issubmsg(upb_msglayout_msgdef(l)) == true.
+ *
+ * Since map entry messages don't have layouts, if upb_fielddef_ismap(f) == true
+ * then this function will return the layout for the map's value. It requires
+ * that the value type of the map field is a submessage. */
+const upb_msglayout *upb_msglayout_sublayout(const upb_msglayout *l,
+ const upb_fielddef *f);
-#ifndef UPB_SYMTAB_H_
-#define UPB_SYMTAB_H_
+/* Returns the msgdef for this msglayout. */
+const upb_msgdef *upb_msglayout_msgdef(const upb_msglayout *l);
-#ifdef __cplusplus
-#include <vector>
-namespace upb { class SymbolTable; }
-#endif
+/** upb_visitor ***************************************************************/
-UPB_DECLARE_DERIVED_TYPE(upb::SymbolTable, upb::RefCounted,
- upb_symtab, upb_refcounted)
+/* upb_visitor will visit all the fields of a message and its submessages. It
+ * uses a upb_visitorplan which you can obtain from a upb_msgfactory. */
-typedef struct {
- UPB_PRIVATE_FOR_CPP
- upb_strtable_iter iter;
- upb_deftype_t type;
-} upb_symtab_iter;
+upb_visitor *upb_visitor_create(upb_env *e, const upb_visitorplan *vp,
+ upb_sink *output);
+bool upb_visitor_visitmsg(upb_visitor *v, const upb_msg *msg);
-#ifdef __cplusplus
-/* Non-const methods in upb::SymbolTable are NOT thread-safe. */
-class upb::SymbolTable {
- public:
- /* Returns a new symbol table with a single ref owned by "owner."
- * Returns NULL if memory allocation failed. */
- static reffed_ptr<SymbolTable> New();
+/** upb_msgfactory ************************************************************/
- /* Include RefCounted base methods. */
- UPB_REFCOUNTED_CPPMETHODS
+/* A upb_msgfactory contains a cache of upb_msglayout, upb_handlers, and
+ * upb_visitorplan objects. These are the objects necessary to represent,
+ * populate, and and visit upb_msg objects.
+ *
+ * These caches are all populated by upb_msgdef, and lazily created on demand.
+ */
- /* For all lookup functions, the returned pointer is not owned by the
- * caller; it may be invalidated by any non-const call or unref of the
- * SymbolTable! To protect against this, take a ref if desired. */
+/* Creates and destroys a msgfactory, respectively. The messages for this
+ * msgfactory must come from |symtab| (which should outlive the msgfactory). */
+upb_msgfactory *upb_msgfactory_new(const upb_symtab *symtab);
+void upb_msgfactory_free(upb_msgfactory *f);
- /* Freezes the symbol table: prevents further modification of it.
- * After the Freeze() operation is successful, the SymbolTable must only be
- * accessed via a const pointer.
- *
- * Unlike with upb::MessageDef/upb::EnumDef/etc, freezing a SymbolTable is not
- * a necessary step in using a SymbolTable. If you have no need for it to be
- * immutable, there is no need to freeze it ever. However sometimes it is
- * useful, and SymbolTables that are statically compiled into the binary are
- * always frozen by nature. */
- void Freeze();
+const upb_symtab *upb_msgfactory_symtab(const upb_msgfactory *f);
- /* Resolves the given symbol using the rules described in descriptor.proto,
- * namely:
- *
- * If the name starts with a '.', it is fully-qualified. Otherwise,
- * C++-like scoping rules are used to find the type (i.e. first the nested
- * types within this message are searched, then within the parent, on up
- * to the root namespace).
- *
- * If not found, returns NULL. */
- const Def* Resolve(const char* base, const char* sym) const;
+/* The functions to get cached objects, lazily creating them on demand. These
+ * all require:
+ *
+ * - m is in upb_msgfactory_symtab(f)
+ * - upb_msgdef_mapentry(m) == false (since map messages can't have layouts).
+ *
+ * The returned objects will live for as long as the msgfactory does.
+ *
+ * TODO(haberman): consider making this thread-safe and take a const
+ * upb_msgfactory. */
+const upb_msglayout *upb_msgfactory_getlayout(upb_msgfactory *f,
+ const upb_msgdef *m);
+const upb_handlers *upb_msgfactory_getmergehandlers(upb_msgfactory *f,
+ const upb_msgdef *m);
+const upb_visitorplan *upb_msgfactory_getvisitorplan(upb_msgfactory *f,
+ const upb_handlers *h);
- /* Finds an entry in the symbol table with this exact name. If not found,
- * returns NULL. */
- const Def* Lookup(const char *sym) const;
- const MessageDef* LookupMessage(const char *sym) const;
- const EnumDef* LookupEnum(const char *sym) const;
- /* TODO: introduce a C++ iterator, but make it nice and templated so that if
- * you ask for an iterator of MessageDef the iterated elements are strongly
- * typed as MessageDef*. */
+/** upb_msgval ****************************************************************/
- /* Adds the given mutable defs to the symtab, resolving all symbols
- * (including enum default values) and finalizing the defs. Only one def per
- * name may be in the list, but defs can replace existing defs in the symtab.
- * All defs must have a name -- anonymous defs are not allowed. Anonymous
- * defs can still be frozen by calling upb_def_freeze() directly.
- *
- * Any existing defs that can reach defs that are being replaced will
- * themselves be replaced also, so that the resulting set of defs is fully
- * consistent.
- *
- * This logic implemented in this method is a convenience; ultimately it
- * calls some combination of upb_fielddef_setsubdef(), upb_def_dup(), and
- * upb_freeze(), any of which the client could call themself. However, since
- * the logic for doing so is nontrivial, we provide it here.
- *
- * The entire operation either succeeds or fails. If the operation fails,
- * the symtab is unchanged, false is returned, and status indicates the
- * error. The caller passes a ref on all defs to the symtab (even if the
- * operation fails).
- *
- * TODO(haberman): currently failure will leave the symtab unchanged, but may
- * leave the defs themselves partially resolved. Does this matter? If so we
- * could do a prepass that ensures that all symbols are resolvable and bail
- * if not, so we don't mutate anything until we know the operation will
- * succeed.
- *
- * TODO(haberman): since the defs must be mutable, refining a frozen def
- * requires making mutable copies of the entire tree. This is wasteful if
- * only a few messages are changing. We may want to add a way of adding a
- * tree of frozen defs to the symtab (perhaps an alternate constructor where
- * you pass the root of the tree?) */
- bool Add(Def*const* defs, size_t n, void* ref_donor, Status* status);
+/* A union representing all possible protobuf values. Used for generic get/set
+ * operations. */
- bool Add(const std::vector<Def*>& defs, void *owner, Status* status) {
- return Add((Def*const*)&defs[0], defs.size(), owner, status);
+typedef union {
+ bool b;
+ float flt;
+ double dbl;
+ int32_t i32;
+ int64_t i64;
+ uint32_t u32;
+ uint64_t u64;
+ const upb_map* map;
+ const upb_msg* msg;
+ const upb_array* arr;
+ const void* ptr;
+ struct {
+ const char *ptr;
+ size_t len;
+ } str;
+} upb_msgval;
+
+#define ACCESSORS(name, membername, ctype) \
+ UPB_INLINE ctype upb_msgval_get ## name(upb_msgval v) { \
+ return v.membername; \
+ } \
+ UPB_INLINE void upb_msgval_set ## name(upb_msgval *v, ctype cval) { \
+ v->membername = cval; \
+ } \
+ UPB_INLINE upb_msgval upb_msgval_ ## name(ctype v) { \
+ upb_msgval ret; \
+ ret.membername = v; \
+ return ret; \
}
- /* Resolves all subdefs for messages in this file and attempts to freeze the
- * file. If this succeeds, adds all the symbols to this SymbolTable
- * (replacing any existing ones with the same names). */
- bool AddFile(FileDef* file, Status* s);
+ACCESSORS(bool, b, bool)
+ACCESSORS(float, flt, float)
+ACCESSORS(double, dbl, double)
+ACCESSORS(int32, i32, int32_t)
+ACCESSORS(int64, i64, int64_t)
+ACCESSORS(uint32, u32, uint32_t)
+ACCESSORS(uint64, u64, uint64_t)
+ACCESSORS(map, map, const upb_map*)
+ACCESSORS(msg, msg, const upb_msg*)
+ACCESSORS(ptr, ptr, const void*)
+ACCESSORS(arr, arr, const upb_array*)
+
+#undef ACCESSORS
+
+UPB_INLINE upb_msgval upb_msgval_str(const char *ptr, size_t len) {
+ upb_msgval ret;
+ ret.str.ptr = ptr;
+ ret.str.len = len;
+ return ret;
+}
- private:
- UPB_DISALLOW_POD_OPS(SymbolTable, upb::SymbolTable)
-};
+UPB_INLINE const char* upb_msgval_getstr(upb_msgval val) {
+ return val.str.ptr;
+}
-#endif /* __cplusplus */
+UPB_INLINE size_t upb_msgval_getstrlen(upb_msgval val) {
+ return val.str.len;
+}
-UPB_BEGIN_EXTERN_C
-/* Native C API. */
+/** upb_msg *******************************************************************/
-/* Include refcounted methods like upb_symtab_ref(). */
-UPB_REFCOUNTED_CMETHODS(upb_symtab, upb_symtab_upcast)
+/* A upb_msg represents a protobuf message. It always corresponds to a specific
+ * upb_msglayout, which describes how it is laid out in memory.
+ *
+ * The message will have a fixed size, as returned by upb_msg_sizeof(), which
+ * will be used to store fixed-length fields. The upb_msg may also allocate
+ * dynamic memory internally to store data such as:
+ *
+ * - extensions
+ * - unknown fields
+ */
-upb_symtab *upb_symtab_new(const void *owner);
-void upb_symtab_freeze(upb_symtab *s);
-const upb_def *upb_symtab_resolve(const upb_symtab *s, const char *base,
- const char *sym);
-const upb_def *upb_symtab_lookup(const upb_symtab *s, const char *sym);
-const upb_msgdef *upb_symtab_lookupmsg(const upb_symtab *s, const char *sym);
-const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym);
-bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
- void *ref_donor, upb_status *status);
-bool upb_symtab_addfile(upb_symtab *s, upb_filedef *file, upb_status* status);
+/* Returns the size of a message given this layout. */
+size_t upb_msg_sizeof(const upb_msglayout *l);
-/* upb_symtab_iter i;
- * for(upb_symtab_begin(&i, s, type); !upb_symtab_done(&i);
- * upb_symtab_next(&i)) {
- * const upb_def *def = upb_symtab_iter_def(&i);
- * // ...
- * }
+/* upb_msg_init() / upb_msg_uninit() allow the user to use a pre-allocated
+ * block of memory as a message. The block's size should be upb_msg_sizeof().
+ * upb_msg_uninit() must be called to release internally-allocated memory
+ * unless the allocator is an arena that does not require freeing.
*
- * For C we don't have separate iterators for const and non-const.
- * It is the caller's responsibility to cast the upb_fielddef* to
- * const if the upb_msgdef* is const. */
-void upb_symtab_begin(upb_symtab_iter *iter, const upb_symtab *s,
- upb_deftype_t type);
-void upb_symtab_next(upb_symtab_iter *iter);
-bool upb_symtab_done(const upb_symtab_iter *iter);
-const upb_def *upb_symtab_iter_def(const upb_symtab_iter *iter);
+ * Please note that upb_msg_uninit() does *not* free any submessages, maps,
+ * or arrays referred to by this message's fields. You must free them manually
+ * yourself. */
+void upb_msg_init(upb_msg *msg, const upb_msglayout *l, upb_alloc *a);
+void upb_msg_uninit(upb_msg *msg, const upb_msglayout *l);
+
+/* Like upb_msg_init() / upb_msg_uninit(), except the message's memory is
+ * allocated / freed from the given upb_alloc. */
+upb_msg *upb_msg_new(const upb_msglayout *l, upb_alloc *a);
+void upb_msg_free(upb_msg *msg, const upb_msglayout *l);
+
+/* Returns the upb_alloc for the given message. */
+upb_alloc *upb_msg_alloc(const upb_msg *msg, const upb_msglayout *l);
+
+/* Packs the tree of messages rooted at "msg" into a single hunk of memory,
+ * allocated from the given allocator. */
+void *upb_msg_pack(const upb_msg *msg, const upb_msglayout *l,
+ void *p, size_t *ofs, size_t size);
+
+/* Read-only message API. Can be safely called by anyone. */
+
+/* Returns the value associated with this field:
+ * - for scalar fields (including strings), the value directly.
+ * - return upb_msg*, or upb_map* for msg/map.
+ * If the field is unset for these field types, returns NULL.
+ *
+ * TODO(haberman): should we let users store cached array/map/msg
+ * pointers here for fields that are unset? Could be useful for the
+ * strongly-owned submessage model (ie. generated C API that doesn't use
+ * arenas).
+ */
+upb_msgval upb_msg_get(const upb_msg *msg,
+ const upb_fielddef *f,
+ const upb_msglayout *l);
-UPB_END_EXTERN_C
+/* May only be called for fields where upb_fielddef_haspresence(f) == true. */
+bool upb_msg_has(const upb_msg *msg,
+ const upb_fielddef *f,
+ const upb_msglayout *l);
-#ifdef __cplusplus
-/* C++ inline wrappers. */
-namespace upb {
-inline reffed_ptr<SymbolTable> SymbolTable::New() {
- upb_symtab *s = upb_symtab_new(&s);
- return reffed_ptr<SymbolTable>(s, &s);
-}
+/* Returns NULL if no field in the oneof is set. */
+const upb_fielddef *upb_msg_getoneofcase(const upb_msg *msg,
+ const upb_oneofdef *o,
+ const upb_msglayout *l);
-inline void SymbolTable::Freeze() {
- return upb_symtab_freeze(this);
-}
-inline const Def *SymbolTable::Resolve(const char *base,
- const char *sym) const {
- return upb_symtab_resolve(this, base, sym);
-}
-inline const Def* SymbolTable::Lookup(const char *sym) const {
- return upb_symtab_lookup(this, sym);
-}
-inline const MessageDef *SymbolTable::LookupMessage(const char *sym) const {
- return upb_symtab_lookupmsg(this, sym);
-}
-inline bool SymbolTable::Add(
- Def*const* defs, size_t n, void* ref_donor, Status* status) {
- return upb_symtab_add(this, (upb_def*const*)defs, n, ref_donor, status);
-}
-inline bool SymbolTable::AddFile(FileDef* file, Status* s) {
- return upb_symtab_addfile(this, file, s);
-}
-} /* namespace upb */
-#endif
+/* Returns true if any field in the oneof is set. */
+bool upb_msg_hasoneof(const upb_msg *msg,
+ const upb_oneofdef *o,
+ const upb_msglayout *l);
+
+
+/* Mutable message API. May only be called by the owner of the message who
+ * knows its ownership scheme and how to keep it consistent. */
+
+/* Sets the given field to the given value. Does not perform any memory
+ * management: if you overwrite a pointer to a msg/array/map/string without
+ * cleaning it up (or using an arena) it will leak.
+ */
+bool upb_msg_set(upb_msg *msg,
+ const upb_fielddef *f,
+ upb_msgval val,
+ const upb_msglayout *l);
+
+/* For a primitive field, set it back to its default. For repeated, string, and
+ * submessage fields set it back to NULL. This could involve releasing some
+ * internal memory (for example, from an extension dictionary), but it is not
+ * recursive in any way and will not recover any memory that may be used by
+ * arrays/maps/strings/msgs that this field may have pointed to.
+ */
+bool upb_msg_clearfield(upb_msg *msg,
+ const upb_fielddef *f,
+ const upb_msglayout *l);
+
+/* Clears all fields in the oneof such that none of them are set. */
+bool upb_msg_clearoneof(upb_msg *msg,
+ const upb_oneofdef *o,
+ const upb_msglayout *l);
+
+/* TODO(haberman): copyfrom()/mergefrom()? */
+
+
+/** upb_array *****************************************************************/
+
+/* A upb_array stores data for a repeated field. The memory management
+ * semantics are the same as upb_msg. A upb_array allocates dynamic
+ * memory internally for the array elements. */
+
+size_t upb_array_sizeof(upb_fieldtype_t type);
+void upb_array_init(upb_array *arr, upb_fieldtype_t type, upb_alloc *a);
+void upb_array_uninit(upb_array *arr);
+upb_array *upb_array_new(upb_fieldtype_t type, upb_alloc *a);
+void upb_array_free(upb_array *arr);
+
+/* Read-only interface. Safe for anyone to call. */
+
+size_t upb_array_size(const upb_array *arr);
+upb_fieldtype_t upb_array_type(const upb_array *arr);
+upb_msgval upb_array_get(const upb_array *arr, size_t i);
+
+/* Write interface. May only be called by the message's owner who can enforce
+ * its memory management invariants. */
+
+bool upb_array_set(upb_array *arr, size_t i, upb_msgval val);
+
+
+/** upb_map *******************************************************************/
+
+/* A upb_map stores data for a map field. The memory management semantics are
+ * the same as upb_msg, with one notable exception. upb_map will internally
+ * store a copy of all string keys, but *not* any string values or submessages.
+ * So you must ensure that any string or message values outlive the map, and you
+ * must delete them manually when they are no longer required. */
+
+size_t upb_map_sizeof(upb_fieldtype_t ktype, upb_fieldtype_t vtype);
+bool upb_map_init(upb_map *map, upb_fieldtype_t ktype, upb_fieldtype_t vtype,
+ upb_alloc *a);
+void upb_map_uninit(upb_map *map);
+upb_map *upb_map_new(upb_fieldtype_t ktype, upb_fieldtype_t vtype, upb_alloc *a);
+void upb_map_free(upb_map *map);
+
+/* Read-only interface. Safe for anyone to call. */
+
+size_t upb_map_size(const upb_map *map);
+upb_fieldtype_t upb_map_keytype(const upb_map *map);
+upb_fieldtype_t upb_map_valuetype(const upb_map *map);
+bool upb_map_get(const upb_map *map, upb_msgval key, upb_msgval *val);
+
+/* Write interface. May only be called by the message's owner who can enforce
+ * its memory management invariants. */
+
+/* Sets or overwrites an entry in the map. Return value indicates whether
+ * the operation succeeded or failed with OOM, and also whether an existing
+ * key was replaced or not. */
+bool upb_map_set(upb_map *map,
+ upb_msgval key, upb_msgval val,
+ upb_msgval *valremoved);
+
+/* Deletes an entry in the map. Returns true if the key was present. */
+bool upb_map_del(upb_map *map, upb_msgval key);
+
+
+/** upb_mapiter ***************************************************************/
+
+/* For iterating over a map. Map iterators are invalidated by mutations to the
+ * map, but an invalidated iterator will never return junk or crash the process.
+ * An invalidated iterator may return entries that were already returned though,
+ * and if you keep invalidating the iterator during iteration, the program may
+ * enter an infinite loop. */
+
+size_t upb_mapiter_sizeof();
+
+void upb_mapiter_begin(upb_mapiter *i, const upb_map *t);
+upb_mapiter *upb_mapiter_new(const upb_map *t, upb_alloc *a);
+void upb_mapiter_free(upb_mapiter *i, upb_alloc *a);
+void upb_mapiter_next(upb_mapiter *i);
+bool upb_mapiter_done(const upb_mapiter *i);
+
+upb_msgval upb_mapiter_key(const upb_mapiter *i);
+upb_msgval upb_mapiter_value(const upb_mapiter *i);
+void upb_mapiter_setdone(upb_mapiter *i);
+bool upb_mapiter_isequal(const upb_mapiter *i1, const upb_mapiter *i2);
+
+
+/** Handlers ******************************************************************/
+
+/* These are the handlers used internally by upb_msgfactory_getmergehandlers().
+ * They write scalar data to a known offset from the message pointer.
+ *
+ * These would be trivial for anyone to implement themselves, but it's better
+ * to use these because some JITs will recognize and specialize these instead
+ * of actually calling the function. */
+
+/* Sets a handler for the given primitive field that will write the data at the
+ * given offset. If hasbit > 0, also sets a hasbit at the given bit offset
+ * (addressing each byte low to high). */
+bool upb_msg_setscalarhandler(upb_handlers *h,
+ const upb_fielddef *f,
+ size_t offset,
+ int32_t hasbit);
+
+/* If the given handler is a msghandlers_primitive field, returns true and sets
+ * *type, *offset and *hasbit. Otherwise returns false. */
+bool upb_msg_getscalarhandlerdata(const upb_handlers *h,
+ upb_selector_t s,
+ upb_fieldtype_t *type,
+ size_t *offset,
+ int32_t *hasbit);
+
+UPB_END_EXTERN_C
-#endif /* UPB_SYMTAB_H_ */
+#endif /* UPB_MSG_H_ */
/*
** upb::descriptor::Reader (upb_descreader)
**
diff --git a/php/phpunit.xml b/php/phpunit.xml
new file mode 100644
index 00000000..0191a601
--- /dev/null
+++ b/php/phpunit.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<phpunit bootstrap="./vendor/autoload.php"
+ colors="true">
+ <testsuites>
+ <testsuite name="protobuf-tests">
+ <file>tests/php_implementation_test.php</file>
+ <file>tests/array_test.php</file>
+ <file>tests/encode_decode_test.php</file>
+ <file>tests/generated_class_test.php</file>
+ <file>tests/map_field_test.php</file>
+ <file>tests/well_known_test.php</file>
+ </testsuite>
+ </testsuites>
+</phpunit>
diff --git a/php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php b/php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php
new file mode 100644
index 00000000..7c5c8df4
--- /dev/null
+++ b/php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php
@@ -0,0 +1,260 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace GPBMetadata\Google\Protobuf\Internal;
+
+class Descriptor
+{
+ public static $is_initialized = false;
+
+ public static function initOnce() {
+ $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool();
+
+ if (static::$is_initialized == true) {
+ return;
+ }
+ $pool->addMessage('google.protobuf.internal.FileDescriptorSet', \Google\Protobuf\Internal\FileDescriptorSet::class)
+ ->repeated('file', \Google\Protobuf\Internal\GPBType::MESSAGE, 1, 'google.protobuf.internal.FileDescriptorProto')
+ ->finalizeToPool();
+
+ $pool->addMessage('google.protobuf.internal.FileDescriptorProto', \Google\Protobuf\Internal\FileDescriptorProto::class)
+ ->optional('name', \Google\Protobuf\Internal\GPBType::STRING, 1)
+ ->optional('package', \Google\Protobuf\Internal\GPBType::STRING, 2)
+ ->repeated('dependency', \Google\Protobuf\Internal\GPBType::STRING, 3)
+ ->repeated('public_dependency', \Google\Protobuf\Internal\GPBType::INT32, 10)
+ ->repeated('weak_dependency', \Google\Protobuf\Internal\GPBType::INT32, 11)
+ ->repeated('message_type', \Google\Protobuf\Internal\GPBType::MESSAGE, 4, 'google.protobuf.internal.DescriptorProto')
+ ->repeated('enum_type', \Google\Protobuf\Internal\GPBType::MESSAGE, 5, 'google.protobuf.internal.EnumDescriptorProto')
+ ->repeated('service', \Google\Protobuf\Internal\GPBType::MESSAGE, 6, 'google.protobuf.internal.ServiceDescriptorProto')
+ ->repeated('extension', \Google\Protobuf\Internal\GPBType::MESSAGE, 7, 'google.protobuf.internal.FieldDescriptorProto')
+ ->optional('options', \Google\Protobuf\Internal\GPBType::MESSAGE, 8, 'google.protobuf.internal.FileOptions')
+ ->optional('source_code_info', \Google\Protobuf\Internal\GPBType::MESSAGE, 9, 'google.protobuf.internal.SourceCodeInfo')
+ ->optional('syntax', \Google\Protobuf\Internal\GPBType::STRING, 12)
+ ->finalizeToPool();
+
+ $pool->addMessage('google.protobuf.internal.DescriptorProto', \Google\Protobuf\Internal\DescriptorProto::class)
+ ->optional('name', \Google\Protobuf\Internal\GPBType::STRING, 1)
+ ->repeated('field', \Google\Protobuf\Internal\GPBType::MESSAGE, 2, 'google.protobuf.internal.FieldDescriptorProto')
+ ->repeated('extension', \Google\Protobuf\Internal\GPBType::MESSAGE, 6, 'google.protobuf.internal.FieldDescriptorProto')
+ ->repeated('nested_type', \Google\Protobuf\Internal\GPBType::MESSAGE, 3, 'google.protobuf.internal.DescriptorProto')
+ ->repeated('enum_type', \Google\Protobuf\Internal\GPBType::MESSAGE, 4, 'google.protobuf.internal.EnumDescriptorProto')
+ ->repeated('extension_range', \Google\Protobuf\Internal\GPBType::MESSAGE, 5, 'google.protobuf.internal.DescriptorProto.ExtensionRange')
+ ->repeated('oneof_decl', \Google\Protobuf\Internal\GPBType::MESSAGE, 8, 'google.protobuf.internal.OneofDescriptorProto')
+ ->optional('options', \Google\Protobuf\Internal\GPBType::MESSAGE, 7, 'google.protobuf.internal.MessageOptions')
+ ->repeated('reserved_range', \Google\Protobuf\Internal\GPBType::MESSAGE, 9, 'google.protobuf.internal.DescriptorProto.ReservedRange')
+ ->repeated('reserved_name', \Google\Protobuf\Internal\GPBType::STRING, 10)
+ ->finalizeToPool();
+
+ $pool->addMessage('google.protobuf.internal.DescriptorProto.ExtensionRange', \Google\Protobuf\Internal\DescriptorProto_ExtensionRange::class)
+ ->optional('start', \Google\Protobuf\Internal\GPBType::INT32, 1)
+ ->optional('end', \Google\Protobuf\Internal\GPBType::INT32, 2)
+ ->finalizeToPool();
+
+ $pool->addMessage('google.protobuf.internal.DescriptorProto.ReservedRange', \Google\Protobuf\Internal\DescriptorProto_ReservedRange::class)
+ ->optional('start', \Google\Protobuf\Internal\GPBType::INT32, 1)
+ ->optional('end', \Google\Protobuf\Internal\GPBType::INT32, 2)
+ ->finalizeToPool();
+
+ $pool->addMessage('google.protobuf.internal.FieldDescriptorProto', \Google\Protobuf\Internal\FieldDescriptorProto::class)
+ ->optional('name', \Google\Protobuf\Internal\GPBType::STRING, 1)
+ ->optional('number', \Google\Protobuf\Internal\GPBType::INT32, 3)
+ ->optional('label', \Google\Protobuf\Internal\GPBType::ENUM, 4, 'google.protobuf.internal.FieldDescriptorProto.Label')
+ ->optional('type', \Google\Protobuf\Internal\GPBType::ENUM, 5, 'google.protobuf.internal.FieldDescriptorProto.Type')
+ ->optional('type_name', \Google\Protobuf\Internal\GPBType::STRING, 6)
+ ->optional('extendee', \Google\Protobuf\Internal\GPBType::STRING, 2)
+ ->optional('default_value', \Google\Protobuf\Internal\GPBType::STRING, 7)
+ ->optional('oneof_index', \Google\Protobuf\Internal\GPBType::INT32, 9)
+ ->optional('json_name', \Google\Protobuf\Internal\GPBType::STRING, 10)
+ ->optional('options', \Google\Protobuf\Internal\GPBType::MESSAGE, 8, 'google.protobuf.internal.FieldOptions')
+ ->finalizeToPool();
+
+ $pool->addEnum('google.protobuf.internal.FieldDescriptorProto.Type', \Google\Protobuf\Internal\Type::class)
+ ->value("TYPE_DOUBLE", 1)
+ ->value("TYPE_FLOAT", 2)
+ ->value("TYPE_INT64", 3)
+ ->value("TYPE_UINT64", 4)
+ ->value("TYPE_INT32", 5)
+ ->value("TYPE_FIXED64", 6)
+ ->value("TYPE_FIXED32", 7)
+ ->value("TYPE_BOOL", 8)
+ ->value("TYPE_STRING", 9)
+ ->value("TYPE_GROUP", 10)
+ ->value("TYPE_MESSAGE", 11)
+ ->value("TYPE_BYTES", 12)
+ ->value("TYPE_UINT32", 13)
+ ->value("TYPE_ENUM", 14)
+ ->value("TYPE_SFIXED32", 15)
+ ->value("TYPE_SFIXED64", 16)
+ ->value("TYPE_SINT32", 17)
+ ->value("TYPE_SINT64", 18)
+ ->finalizeToPool();
+
+ $pool->addEnum('google.protobuf.internal.FieldDescriptorProto.Label', \Google\Protobuf\Internal\Label::class)
+ ->value("LABEL_OPTIONAL", 1)
+ ->value("LABEL_REQUIRED", 2)
+ ->value("LABEL_REPEATED", 3)
+ ->finalizeToPool();
+
+ $pool->addMessage('google.protobuf.internal.OneofDescriptorProto', \Google\Protobuf\Internal\OneofDescriptorProto::class)
+ ->optional('name', \Google\Protobuf\Internal\GPBType::STRING, 1)
+ ->optional('options', \Google\Protobuf\Internal\GPBType::MESSAGE, 2, 'google.protobuf.internal.OneofOptions')
+ ->finalizeToPool();
+
+ $pool->addMessage('google.protobuf.internal.EnumDescriptorProto', \Google\Protobuf\Internal\EnumDescriptorProto::class)
+ ->optional('name', \Google\Protobuf\Internal\GPBType::STRING, 1)
+ ->repeated('value', \Google\Protobuf\Internal\GPBType::MESSAGE, 2, 'google.protobuf.internal.EnumValueDescriptorProto')
+ ->optional('options', \Google\Protobuf\Internal\GPBType::MESSAGE, 3, 'google.protobuf.internal.EnumOptions')
+ ->finalizeToPool();
+
+ $pool->addMessage('google.protobuf.internal.EnumValueDescriptorProto', \Google\Protobuf\Internal\EnumValueDescriptorProto::class)
+ ->optional('name', \Google\Protobuf\Internal\GPBType::STRING, 1)
+ ->optional('number', \Google\Protobuf\Internal\GPBType::INT32, 2)
+ ->optional('options', \Google\Protobuf\Internal\GPBType::MESSAGE, 3, 'google.protobuf.internal.EnumValueOptions')
+ ->finalizeToPool();
+
+ $pool->addMessage('google.protobuf.internal.ServiceDescriptorProto', \Google\Protobuf\Internal\ServiceDescriptorProto::class)
+ ->optional('name', \Google\Protobuf\Internal\GPBType::STRING, 1)
+ ->repeated('method', \Google\Protobuf\Internal\GPBType::MESSAGE, 2, 'google.protobuf.internal.MethodDescriptorProto')
+ ->optional('options', \Google\Protobuf\Internal\GPBType::MESSAGE, 3, 'google.protobuf.internal.ServiceOptions')
+ ->finalizeToPool();
+
+ $pool->addMessage('google.protobuf.internal.MethodDescriptorProto', \Google\Protobuf\Internal\MethodDescriptorProto::class)
+ ->optional('name', \Google\Protobuf\Internal\GPBType::STRING, 1)
+ ->optional('input_type', \Google\Protobuf\Internal\GPBType::STRING, 2)
+ ->optional('output_type', \Google\Protobuf\Internal\GPBType::STRING, 3)
+ ->optional('options', \Google\Protobuf\Internal\GPBType::MESSAGE, 4, 'google.protobuf.internal.MethodOptions')
+ ->optional('client_streaming', \Google\Protobuf\Internal\GPBType::BOOL, 5)
+ ->optional('server_streaming', \Google\Protobuf\Internal\GPBType::BOOL, 6)
+ ->finalizeToPool();
+
+ $pool->addMessage('google.protobuf.internal.FileOptions', \Google\Protobuf\Internal\FileOptions::class)
+ ->optional('java_package', \Google\Protobuf\Internal\GPBType::STRING, 1)
+ ->optional('java_outer_classname', \Google\Protobuf\Internal\GPBType::STRING, 8)
+ ->optional('java_multiple_files', \Google\Protobuf\Internal\GPBType::BOOL, 10)
+ ->optional('java_generate_equals_and_hash', \Google\Protobuf\Internal\GPBType::BOOL, 20)
+ ->optional('java_string_check_utf8', \Google\Protobuf\Internal\GPBType::BOOL, 27)
+ ->optional('optimize_for', \Google\Protobuf\Internal\GPBType::ENUM, 9, 'google.protobuf.internal.FileOptions.OptimizeMode')
+ ->optional('go_package', \Google\Protobuf\Internal\GPBType::STRING, 11)
+ ->optional('cc_generic_services', \Google\Protobuf\Internal\GPBType::BOOL, 16)
+ ->optional('java_generic_services', \Google\Protobuf\Internal\GPBType::BOOL, 17)
+ ->optional('py_generic_services', \Google\Protobuf\Internal\GPBType::BOOL, 18)
+ ->optional('deprecated', \Google\Protobuf\Internal\GPBType::BOOL, 23)
+ ->optional('cc_enable_arenas', \Google\Protobuf\Internal\GPBType::BOOL, 31)
+ ->optional('objc_class_prefix', \Google\Protobuf\Internal\GPBType::STRING, 36)
+ ->optional('csharp_namespace', \Google\Protobuf\Internal\GPBType::STRING, 37)
+ ->optional('swift_prefix', \Google\Protobuf\Internal\GPBType::STRING, 39)
+ ->repeated('uninterpreted_option', \Google\Protobuf\Internal\GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption')
+ ->finalizeToPool();
+
+ $pool->addEnum('google.protobuf.internal.FileOptions.OptimizeMode', \Google\Protobuf\Internal\OptimizeMode::class)
+ ->value("SPEED", 1)
+ ->value("CODE_SIZE", 2)
+ ->value("LITE_RUNTIME", 3)
+ ->finalizeToPool();
+
+ $pool->addMessage('google.protobuf.internal.MessageOptions', \Google\Protobuf\Internal\MessageOptions::class)
+ ->optional('message_set_wire_format', \Google\Protobuf\Internal\GPBType::BOOL, 1)
+ ->optional('no_standard_descriptor_accessor', \Google\Protobuf\Internal\GPBType::BOOL, 2)
+ ->optional('deprecated', \Google\Protobuf\Internal\GPBType::BOOL, 3)
+ ->optional('map_entry', \Google\Protobuf\Internal\GPBType::BOOL, 7)
+ ->repeated('uninterpreted_option', \Google\Protobuf\Internal\GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption')
+ ->finalizeToPool();
+
+ $pool->addMessage('google.protobuf.internal.FieldOptions', \Google\Protobuf\Internal\FieldOptions::class)
+ ->optional('ctype', \Google\Protobuf\Internal\GPBType::ENUM, 1, 'google.protobuf.internal.FieldOptions.CType')
+ ->optional('packed', \Google\Protobuf\Internal\GPBType::BOOL, 2)
+ ->optional('jstype', \Google\Protobuf\Internal\GPBType::ENUM, 6, 'google.protobuf.internal.FieldOptions.JSType')
+ ->optional('lazy', \Google\Protobuf\Internal\GPBType::BOOL, 5)
+ ->optional('deprecated', \Google\Protobuf\Internal\GPBType::BOOL, 3)
+ ->optional('weak', \Google\Protobuf\Internal\GPBType::BOOL, 10)
+ ->repeated('uninterpreted_option', \Google\Protobuf\Internal\GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption')
+ ->finalizeToPool();
+
+ $pool->addEnum('google.protobuf.internal.FieldOptions.CType', \Google\Protobuf\Internal\CType::class)
+ ->value("STRING", 0)
+ ->value("CORD", 1)
+ ->value("STRING_PIECE", 2)
+ ->finalizeToPool();
+
+ $pool->addEnum('google.protobuf.internal.FieldOptions.JSType', \Google\Protobuf\Internal\JSType::class)
+ ->value("JS_NORMAL", 0)
+ ->value("JS_STRING", 1)
+ ->value("JS_NUMBER", 2)
+ ->finalizeToPool();
+
+ $pool->addMessage('google.protobuf.internal.OneofOptions', \Google\Protobuf\Internal\OneofOptions::class)
+ ->repeated('uninterpreted_option', \Google\Protobuf\Internal\GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption')
+ ->finalizeToPool();
+
+ $pool->addMessage('google.protobuf.internal.EnumOptions', \Google\Protobuf\Internal\EnumOptions::class)
+ ->optional('allow_alias', \Google\Protobuf\Internal\GPBType::BOOL, 2)
+ ->optional('deprecated', \Google\Protobuf\Internal\GPBType::BOOL, 3)
+ ->repeated('uninterpreted_option', \Google\Protobuf\Internal\GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption')
+ ->finalizeToPool();
+
+ $pool->addMessage('google.protobuf.internal.EnumValueOptions', \Google\Protobuf\Internal\EnumValueOptions::class)
+ ->optional('deprecated', \Google\Protobuf\Internal\GPBType::BOOL, 1)
+ ->repeated('uninterpreted_option', \Google\Protobuf\Internal\GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption')
+ ->finalizeToPool();
+
+ $pool->addMessage('google.protobuf.internal.ServiceOptions', \Google\Protobuf\Internal\ServiceOptions::class)
+ ->optional('deprecated', \Google\Protobuf\Internal\GPBType::BOOL, 33)
+ ->repeated('uninterpreted_option', \Google\Protobuf\Internal\GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption')
+ ->finalizeToPool();
+
+ $pool->addMessage('google.protobuf.internal.MethodOptions', \Google\Protobuf\Internal\MethodOptions::class)
+ ->optional('deprecated', \Google\Protobuf\Internal\GPBType::BOOL, 33)
+ ->optional('idempotency_level', \Google\Protobuf\Internal\GPBType::ENUM, 34, 'google.protobuf.internal.MethodOptions.IdempotencyLevel')
+ ->repeated('uninterpreted_option', \Google\Protobuf\Internal\GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption')
+ ->finalizeToPool();
+
+ $pool->addEnum('google.protobuf.internal.MethodOptions.IdempotencyLevel', \Google\Protobuf\Internal\IdempotencyLevel::class)
+ ->value("IDEMPOTENCY_UNKNOWN", 0)
+ ->value("NO_SIDE_EFFECTS", 1)
+ ->value("IDEMPOTENT", 2)
+ ->finalizeToPool();
+
+ $pool->addMessage('google.protobuf.internal.UninterpretedOption', \Google\Protobuf\Internal\UninterpretedOption::class)
+ ->repeated('name', \Google\Protobuf\Internal\GPBType::MESSAGE, 2, 'google.protobuf.internal.UninterpretedOption.NamePart')
+ ->optional('identifier_value', \Google\Protobuf\Internal\GPBType::STRING, 3)
+ ->optional('positive_int_value', \Google\Protobuf\Internal\GPBType::UINT64, 4)
+ ->optional('negative_int_value', \Google\Protobuf\Internal\GPBType::INT64, 5)
+ ->optional('double_value', \Google\Protobuf\Internal\GPBType::DOUBLE, 6)
+ ->optional('string_value', \Google\Protobuf\Internal\GPBType::BYTES, 7)
+ ->optional('aggregate_value', \Google\Protobuf\Internal\GPBType::STRING, 8)
+ ->finalizeToPool();
+
+ $pool->addMessage('google.protobuf.internal.UninterpretedOption.NamePart', \Google\Protobuf\Internal\UninterpretedOption_NamePart::class)
+ ->required('name_part', \Google\Protobuf\Internal\GPBType::STRING, 1)
+ ->required('is_extension', \Google\Protobuf\Internal\GPBType::BOOL, 2)
+ ->finalizeToPool();
+
+ $pool->addMessage('google.protobuf.internal.SourceCodeInfo', \Google\Protobuf\Internal\SourceCodeInfo::class)
+ ->repeated('location', \Google\Protobuf\Internal\GPBType::MESSAGE, 1, 'google.protobuf.internal.SourceCodeInfo.Location')
+ ->finalizeToPool();
+
+ $pool->addMessage('google.protobuf.internal.SourceCodeInfo.Location', \Google\Protobuf\Internal\SourceCodeInfo_Location::class)
+ ->repeated('path', \Google\Protobuf\Internal\GPBType::INT32, 1)
+ ->repeated('span', \Google\Protobuf\Internal\GPBType::INT32, 2)
+ ->optional('leading_comments', \Google\Protobuf\Internal\GPBType::STRING, 3)
+ ->optional('trailing_comments', \Google\Protobuf\Internal\GPBType::STRING, 4)
+ ->repeated('leading_detached_comments', \Google\Protobuf\Internal\GPBType::STRING, 6)
+ ->finalizeToPool();
+
+ $pool->addMessage('google.protobuf.internal.GeneratedCodeInfo', \Google\Protobuf\Internal\GeneratedCodeInfo::class)
+ ->repeated('annotation', \Google\Protobuf\Internal\GPBType::MESSAGE, 1, 'google.protobuf.internal.GeneratedCodeInfo.Annotation')
+ ->finalizeToPool();
+
+ $pool->addMessage('google.protobuf.internal.GeneratedCodeInfo.Annotation', \Google\Protobuf\Internal\GeneratedCodeInfo_Annotation::class)
+ ->repeated('path', \Google\Protobuf\Internal\GPBType::INT32, 1)
+ ->optional('source_file', \Google\Protobuf\Internal\GPBType::STRING, 2)
+ ->optional('begin', \Google\Protobuf\Internal\GPBType::INT32, 3)
+ ->optional('end', \Google\Protobuf\Internal\GPBType::INT32, 4)
+ ->finalizeToPool();
+
+ $pool->finish();
+ static::$is_initialized = true;
+ }
+}
+
diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto.php b/php/src/Google/Protobuf/Internal/DescriptorProto.php
new file mode 100644
index 00000000..f076f6be
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/DescriptorProto.php
@@ -0,0 +1,325 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\GPBWire;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\InputStream;
+
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * <pre>
+ * Describes a message type.
+ * </pre>
+ *
+ * Protobuf type <code>google.protobuf.DescriptorProto</code>
+ */
+class DescriptorProto extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * <code>optional string name = 1;</code>
+ */
+ private $name = '';
+ private $has_name = false;
+ /**
+ * <code>repeated .google.protobuf.FieldDescriptorProto field = 2;</code>
+ */
+ private $field;
+ private $has_field = false;
+ /**
+ * <code>repeated .google.protobuf.FieldDescriptorProto extension = 6;</code>
+ */
+ private $extension;
+ private $has_extension = false;
+ /**
+ * <code>repeated .google.protobuf.DescriptorProto nested_type = 3;</code>
+ */
+ private $nested_type;
+ private $has_nested_type = false;
+ /**
+ * <code>repeated .google.protobuf.EnumDescriptorProto enum_type = 4;</code>
+ */
+ private $enum_type;
+ private $has_enum_type = false;
+ /**
+ * <code>repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;</code>
+ */
+ private $extension_range;
+ private $has_extension_range = false;
+ /**
+ * <code>repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;</code>
+ */
+ private $oneof_decl;
+ private $has_oneof_decl = false;
+ /**
+ * <code>optional .google.protobuf.MessageOptions options = 7;</code>
+ */
+ private $options = null;
+ private $has_options = false;
+ /**
+ * <code>repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;</code>
+ */
+ private $reserved_range;
+ private $has_reserved_range = false;
+ /**
+ * <pre>
+ * Reserved field names, which may not be used by fields in the same message.
+ * A given name may only be reserved once.
+ * </pre>
+ *
+ * <code>repeated string reserved_name = 10;</code>
+ */
+ private $reserved_name;
+ private $has_reserved_name = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * <code>optional string name = 1;</code>
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * <code>optional string name = 1;</code>
+ */
+ public function setName($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->name = $var;
+ $this->has_name = true;
+ }
+
+ public function hasName()
+ {
+ return $this->has_name;
+ }
+
+ /**
+ * <code>repeated .google.protobuf.FieldDescriptorProto field = 2;</code>
+ */
+ public function getField()
+ {
+ return $this->field;
+ }
+
+ /**
+ * <code>repeated .google.protobuf.FieldDescriptorProto field = 2;</code>
+ */
+ public function setField(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class);
+ $this->field = $var;
+ $this->has_field = true;
+ }
+
+ public function hasField()
+ {
+ return $this->has_field;
+ }
+
+ /**
+ * <code>repeated .google.protobuf.FieldDescriptorProto extension = 6;</code>
+ */
+ public function getExtension()
+ {
+ return $this->extension;
+ }
+
+ /**
+ * <code>repeated .google.protobuf.FieldDescriptorProto extension = 6;</code>
+ */
+ public function setExtension(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class);
+ $this->extension = $var;
+ $this->has_extension = true;
+ }
+
+ public function hasExtension()
+ {
+ return $this->has_extension;
+ }
+
+ /**
+ * <code>repeated .google.protobuf.DescriptorProto nested_type = 3;</code>
+ */
+ public function getNestedType()
+ {
+ return $this->nested_type;
+ }
+
+ /**
+ * <code>repeated .google.protobuf.DescriptorProto nested_type = 3;</code>
+ */
+ public function setNestedType(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto::class);
+ $this->nested_type = $var;
+ $this->has_nested_type = true;
+ }
+
+ public function hasNestedType()
+ {
+ return $this->has_nested_type;
+ }
+
+ /**
+ * <code>repeated .google.protobuf.EnumDescriptorProto enum_type = 4;</code>
+ */
+ public function getEnumType()
+ {
+ return $this->enum_type;
+ }
+
+ /**
+ * <code>repeated .google.protobuf.EnumDescriptorProto enum_type = 4;</code>
+ */
+ public function setEnumType(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumDescriptorProto::class);
+ $this->enum_type = $var;
+ $this->has_enum_type = true;
+ }
+
+ public function hasEnumType()
+ {
+ return $this->has_enum_type;
+ }
+
+ /**
+ * <code>repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;</code>
+ */
+ public function getExtensionRange()
+ {
+ return $this->extension_range;
+ }
+
+ /**
+ * <code>repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;</code>
+ */
+ public function setExtensionRange(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto_ExtensionRange::class);
+ $this->extension_range = $var;
+ $this->has_extension_range = true;
+ }
+
+ public function hasExtensionRange()
+ {
+ return $this->has_extension_range;
+ }
+
+ /**
+ * <code>repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;</code>
+ */
+ public function getOneofDecl()
+ {
+ return $this->oneof_decl;
+ }
+
+ /**
+ * <code>repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;</code>
+ */
+ public function setOneofDecl(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\OneofDescriptorProto::class);
+ $this->oneof_decl = $var;
+ $this->has_oneof_decl = true;
+ }
+
+ public function hasOneofDecl()
+ {
+ return $this->has_oneof_decl;
+ }
+
+ /**
+ * <code>optional .google.protobuf.MessageOptions options = 7;</code>
+ */
+ public function getOptions()
+ {
+ return $this->options;
+ }
+
+ /**
+ * <code>optional .google.protobuf.MessageOptions options = 7;</code>
+ */
+ public function setOptions(&$var)
+ {
+ GPBUtil::checkMessage($var, \Google\Protobuf\Internal\MessageOptions::class);
+ $this->options = $var;
+ $this->has_options = true;
+ }
+
+ public function hasOptions()
+ {
+ return $this->has_options;
+ }
+
+ /**
+ * <code>repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;</code>
+ */
+ public function getReservedRange()
+ {
+ return $this->reserved_range;
+ }
+
+ /**
+ * <code>repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;</code>
+ */
+ public function setReservedRange(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto_ReservedRange::class);
+ $this->reserved_range = $var;
+ $this->has_reserved_range = true;
+ }
+
+ public function hasReservedRange()
+ {
+ return $this->has_reserved_range;
+ }
+
+ /**
+ * <pre>
+ * Reserved field names, which may not be used by fields in the same message.
+ * A given name may only be reserved once.
+ * </pre>
+ *
+ * <code>repeated string reserved_name = 10;</code>
+ */
+ public function getReservedName()
+ {
+ return $this->reserved_name;
+ }
+
+ /**
+ * <pre>
+ * Reserved field names, which may not be used by fields in the same message.
+ * A given name may only be reserved once.
+ * </pre>
+ *
+ * <code>repeated string reserved_name = 10;</code>
+ */
+ public function setReservedName(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
+ $this->reserved_name = $var;
+ $this->has_reserved_name = true;
+ }
+
+ public function hasReservedName()
+ {
+ return $this->has_reserved_name;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php b/php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php
new file mode 100644
index 00000000..738a1738
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php
@@ -0,0 +1,82 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\GPBWire;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\InputStream;
+
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Protobuf type <code>google.protobuf.DescriptorProto.ExtensionRange</code>
+ */
+class DescriptorProto_ExtensionRange extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * <code>optional int32 start = 1;</code>
+ */
+ private $start = 0;
+ private $has_start = false;
+ /**
+ * <code>optional int32 end = 2;</code>
+ */
+ private $end = 0;
+ private $has_end = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * <code>optional int32 start = 1;</code>
+ */
+ public function getStart()
+ {
+ return $this->start;
+ }
+
+ /**
+ * <code>optional int32 start = 1;</code>
+ */
+ public function setStart($var)
+ {
+ GPBUtil::checkInt32($var);
+ $this->start = $var;
+ $this->has_start = true;
+ }
+
+ public function hasStart()
+ {
+ return $this->has_start;
+ }
+
+ /**
+ * <code>optional int32 end = 2;</code>
+ */
+ public function getEnd()
+ {
+ return $this->end;
+ }
+
+ /**
+ * <code>optional int32 end = 2;</code>
+ */
+ public function setEnd($var)
+ {
+ GPBUtil::checkInt32($var);
+ $this->end = $var;
+ $this->has_end = true;
+ }
+
+ public function hasEnd()
+ {
+ return $this->has_end;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php b/php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php
new file mode 100644
index 00000000..be36b8aa
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php
@@ -0,0 +1,112 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\GPBWire;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\InputStream;
+
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * <pre>
+ * Range of reserved tag numbers. Reserved tag numbers may not be used by
+ * fields or extension ranges in the same message. Reserved ranges may
+ * not overlap.
+ * </pre>
+ *
+ * Protobuf type <code>google.protobuf.DescriptorProto.ReservedRange</code>
+ */
+class DescriptorProto_ReservedRange extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * <pre>
+ * Inclusive.
+ * </pre>
+ *
+ * <code>optional int32 start = 1;</code>
+ */
+ private $start = 0;
+ private $has_start = false;
+ /**
+ * <pre>
+ * Exclusive.
+ * </pre>
+ *
+ * <code>optional int32 end = 2;</code>
+ */
+ private $end = 0;
+ private $has_end = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * <pre>
+ * Inclusive.
+ * </pre>
+ *
+ * <code>optional int32 start = 1;</code>
+ */
+ public function getStart()
+ {
+ return $this->start;
+ }
+
+ /**
+ * <pre>
+ * Inclusive.
+ * </pre>
+ *
+ * <code>optional int32 start = 1;</code>
+ */
+ public function setStart($var)
+ {
+ GPBUtil::checkInt32($var);
+ $this->start = $var;
+ $this->has_start = true;
+ }
+
+ public function hasStart()
+ {
+ return $this->has_start;
+ }
+
+ /**
+ * <pre>
+ * Exclusive.
+ * </pre>
+ *
+ * <code>optional int32 end = 2;</code>
+ */
+ public function getEnd()
+ {
+ return $this->end;
+ }
+
+ /**
+ * <pre>
+ * Exclusive.
+ * </pre>
+ *
+ * <code>optional int32 end = 2;</code>
+ */
+ public function setEnd($var)
+ {
+ GPBUtil::checkInt32($var);
+ $this->end = $var;
+ $this->has_end = true;
+ }
+
+ public function hasEnd()
+ {
+ return $this->has_end;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php
new file mode 100644
index 00000000..9c5f245b
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php
@@ -0,0 +1,114 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\GPBWire;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\InputStream;
+
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * <pre>
+ * Describes an enum type.
+ * </pre>
+ *
+ * Protobuf type <code>google.protobuf.EnumDescriptorProto</code>
+ */
+class EnumDescriptorProto extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * <code>optional string name = 1;</code>
+ */
+ private $name = '';
+ private $has_name = false;
+ /**
+ * <code>repeated .google.protobuf.EnumValueDescriptorProto value = 2;</code>
+ */
+ private $value;
+ private $has_value = false;
+ /**
+ * <code>optional .google.protobuf.EnumOptions options = 3;</code>
+ */
+ private $options = null;
+ private $has_options = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * <code>optional string name = 1;</code>
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * <code>optional string name = 1;</code>
+ */
+ public function setName($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->name = $var;
+ $this->has_name = true;
+ }
+
+ public function hasName()
+ {
+ return $this->has_name;
+ }
+
+ /**
+ * <code>repeated .google.protobuf.EnumValueDescriptorProto value = 2;</code>
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+
+ /**
+ * <code>repeated .google.protobuf.EnumValueDescriptorProto value = 2;</code>
+ */
+ public function setValue(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumValueDescriptorProto::class);
+ $this->value = $var;
+ $this->has_value = true;
+ }
+
+ public function hasValue()
+ {
+ return $this->has_value;
+ }
+
+ /**
+ * <code>optional .google.protobuf.EnumOptions options = 3;</code>
+ */
+ public function getOptions()
+ {
+ return $this->options;
+ }
+
+ /**
+ * <code>optional .google.protobuf.EnumOptions options = 3;</code>
+ */
+ public function setOptions(&$var)
+ {
+ GPBUtil::checkMessage($var, \Google\Protobuf\Internal\EnumOptions::class);
+ $this->options = $var;
+ $this->has_options = true;
+ }
+
+ public function hasOptions()
+ {
+ return $this->has_options;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Internal/EnumOptions.php b/php/src/Google/Protobuf/Internal/EnumOptions.php
new file mode 100644
index 00000000..a9c4e0d7
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/EnumOptions.php
@@ -0,0 +1,158 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\GPBWire;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\InputStream;
+
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Protobuf type <code>google.protobuf.EnumOptions</code>
+ */
+class EnumOptions extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * <pre>
+ * Set this option to true to allow mapping different tag names to the same
+ * value.
+ * </pre>
+ *
+ * <code>optional bool allow_alias = 2;</code>
+ */
+ private $allow_alias = false;
+ private $has_allow_alias = false;
+ /**
+ * <pre>
+ * Is this enum deprecated?
+ * Depending on the target platform, this can emit Deprecated annotations
+ * for the enum, or it will be completely ignored; in the very least, this
+ * is a formalization for deprecating enums.
+ * </pre>
+ *
+ * <code>optional bool deprecated = 3 [default = false];</code>
+ */
+ private $deprecated = false;
+ private $has_deprecated = false;
+ /**
+ * <pre>
+ * The parser stores options it doesn't recognize here. See above.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
+ */
+ private $uninterpreted_option;
+ private $has_uninterpreted_option = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * <pre>
+ * Set this option to true to allow mapping different tag names to the same
+ * value.
+ * </pre>
+ *
+ * <code>optional bool allow_alias = 2;</code>
+ */
+ public function getAllowAlias()
+ {
+ return $this->allow_alias;
+ }
+
+ /**
+ * <pre>
+ * Set this option to true to allow mapping different tag names to the same
+ * value.
+ * </pre>
+ *
+ * <code>optional bool allow_alias = 2;</code>
+ */
+ public function setAllowAlias($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->allow_alias = $var;
+ $this->has_allow_alias = true;
+ }
+
+ public function hasAllowAlias()
+ {
+ return $this->has_allow_alias;
+ }
+
+ /**
+ * <pre>
+ * Is this enum deprecated?
+ * Depending on the target platform, this can emit Deprecated annotations
+ * for the enum, or it will be completely ignored; in the very least, this
+ * is a formalization for deprecating enums.
+ * </pre>
+ *
+ * <code>optional bool deprecated = 3 [default = false];</code>
+ */
+ public function getDeprecated()
+ {
+ return $this->deprecated;
+ }
+
+ /**
+ * <pre>
+ * Is this enum deprecated?
+ * Depending on the target platform, this can emit Deprecated annotations
+ * for the enum, or it will be completely ignored; in the very least, this
+ * is a formalization for deprecating enums.
+ * </pre>
+ *
+ * <code>optional bool deprecated = 3 [default = false];</code>
+ */
+ public function setDeprecated($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->deprecated = $var;
+ $this->has_deprecated = true;
+ }
+
+ public function hasDeprecated()
+ {
+ return $this->has_deprecated;
+ }
+
+ /**
+ * <pre>
+ * The parser stores options it doesn't recognize here. See above.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
+ */
+ public function getUninterpretedOption()
+ {
+ return $this->uninterpreted_option;
+ }
+
+ /**
+ * <pre>
+ * The parser stores options it doesn't recognize here. See above.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
+ */
+ public function setUninterpretedOption(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
+ $this->uninterpreted_option = $var;
+ $this->has_uninterpreted_option = true;
+ }
+
+ public function hasUninterpretedOption()
+ {
+ return $this->has_uninterpreted_option;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php
new file mode 100644
index 00000000..94dc36ec
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php
@@ -0,0 +1,114 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\GPBWire;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\InputStream;
+
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * <pre>
+ * Describes a value within an enum.
+ * </pre>
+ *
+ * Protobuf type <code>google.protobuf.EnumValueDescriptorProto</code>
+ */
+class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * <code>optional string name = 1;</code>
+ */
+ private $name = '';
+ private $has_name = false;
+ /**
+ * <code>optional int32 number = 2;</code>
+ */
+ private $number = 0;
+ private $has_number = false;
+ /**
+ * <code>optional .google.protobuf.EnumValueOptions options = 3;</code>
+ */
+ private $options = null;
+ private $has_options = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * <code>optional string name = 1;</code>
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * <code>optional string name = 1;</code>
+ */
+ public function setName($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->name = $var;
+ $this->has_name = true;
+ }
+
+ public function hasName()
+ {
+ return $this->has_name;
+ }
+
+ /**
+ * <code>optional int32 number = 2;</code>
+ */
+ public function getNumber()
+ {
+ return $this->number;
+ }
+
+ /**
+ * <code>optional int32 number = 2;</code>
+ */
+ public function setNumber($var)
+ {
+ GPBUtil::checkInt32($var);
+ $this->number = $var;
+ $this->has_number = true;
+ }
+
+ public function hasNumber()
+ {
+ return $this->has_number;
+ }
+
+ /**
+ * <code>optional .google.protobuf.EnumValueOptions options = 3;</code>
+ */
+ public function getOptions()
+ {
+ return $this->options;
+ }
+
+ /**
+ * <code>optional .google.protobuf.EnumValueOptions options = 3;</code>
+ */
+ public function setOptions(&$var)
+ {
+ GPBUtil::checkMessage($var, \Google\Protobuf\Internal\EnumValueOptions::class);
+ $this->options = $var;
+ $this->has_options = true;
+ }
+
+ public function hasOptions()
+ {
+ return $this->has_options;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Internal/EnumValueOptions.php b/php/src/Google/Protobuf/Internal/EnumValueOptions.php
new file mode 100644
index 00000000..6446ecd4
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/EnumValueOptions.php
@@ -0,0 +1,115 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\GPBWire;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\InputStream;
+
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Protobuf type <code>google.protobuf.EnumValueOptions</code>
+ */
+class EnumValueOptions extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * <pre>
+ * Is this enum value deprecated?
+ * Depending on the target platform, this can emit Deprecated annotations
+ * for the enum value, or it will be completely ignored; in the very least,
+ * this is a formalization for deprecating enum values.
+ * </pre>
+ *
+ * <code>optional bool deprecated = 1 [default = false];</code>
+ */
+ private $deprecated = false;
+ private $has_deprecated = false;
+ /**
+ * <pre>
+ * The parser stores options it doesn't recognize here. See above.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
+ */
+ private $uninterpreted_option;
+ private $has_uninterpreted_option = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * <pre>
+ * Is this enum value deprecated?
+ * Depending on the target platform, this can emit Deprecated annotations
+ * for the enum value, or it will be completely ignored; in the very least,
+ * this is a formalization for deprecating enum values.
+ * </pre>
+ *
+ * <code>optional bool deprecated = 1 [default = false];</code>
+ */
+ public function getDeprecated()
+ {
+ return $this->deprecated;
+ }
+
+ /**
+ * <pre>
+ * Is this enum value deprecated?
+ * Depending on the target platform, this can emit Deprecated annotations
+ * for the enum value, or it will be completely ignored; in the very least,
+ * this is a formalization for deprecating enum values.
+ * </pre>
+ *
+ * <code>optional bool deprecated = 1 [default = false];</code>
+ */
+ public function setDeprecated($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->deprecated = $var;
+ $this->has_deprecated = true;
+ }
+
+ public function hasDeprecated()
+ {
+ return $this->has_deprecated;
+ }
+
+ /**
+ * <pre>
+ * The parser stores options it doesn't recognize here. See above.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
+ */
+ public function getUninterpretedOption()
+ {
+ return $this->uninterpreted_option;
+ }
+
+ /**
+ * <pre>
+ * The parser stores options it doesn't recognize here. See above.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
+ */
+ public function setUninterpretedOption(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
+ $this->uninterpreted_option = $var;
+ $this->has_uninterpreted_option = true;
+ }
+
+ public function hasUninterpretedOption()
+ {
+ return $this->has_uninterpreted_option;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php
new file mode 100644
index 00000000..6ae2cd41
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php
@@ -0,0 +1,424 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\GPBWire;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\InputStream;
+
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * <pre>
+ * Describes a field within a message.
+ * </pre>
+ *
+ * Protobuf type <code>google.protobuf.FieldDescriptorProto</code>
+ */
+class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * <code>optional string name = 1;</code>
+ */
+ private $name = '';
+ private $has_name = false;
+ /**
+ * <code>optional int32 number = 3;</code>
+ */
+ private $number = 0;
+ private $has_number = false;
+ /**
+ * <code>optional .google.protobuf.FieldDescriptorProto.Label label = 4;</code>
+ */
+ private $label = 0;
+ private $has_label = false;
+ /**
+ * <pre>
+ * If type_name is set, this need not be set. If both this and type_name
+ * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
+ * </pre>
+ *
+ * <code>optional .google.protobuf.FieldDescriptorProto.Type type = 5;</code>
+ */
+ private $type = 0;
+ private $has_type = false;
+ /**
+ * <pre>
+ * For message and enum types, this is the name of the type. If the name
+ * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping
+ * rules are used to find the type (i.e. first the nested types within this
+ * message are searched, then within the parent, on up to the root
+ * namespace).
+ * </pre>
+ *
+ * <code>optional string type_name = 6;</code>
+ */
+ private $type_name = '';
+ private $has_type_name = false;
+ /**
+ * <pre>
+ * For extensions, this is the name of the type being extended. It is
+ * resolved in the same manner as type_name.
+ * </pre>
+ *
+ * <code>optional string extendee = 2;</code>
+ */
+ private $extendee = '';
+ private $has_extendee = false;
+ /**
+ * <pre>
+ * For numeric types, contains the original text representation of the value.
+ * For booleans, "true" or "false".
+ * For strings, contains the default text contents (not escaped in any way).
+ * For bytes, contains the C escaped value. All bytes &gt;= 128 are escaped.
+ * TODO(kenton): Base-64 encode?
+ * </pre>
+ *
+ * <code>optional string default_value = 7;</code>
+ */
+ private $default_value = '';
+ private $has_default_value = false;
+ /**
+ * <pre>
+ * If set, gives the index of a oneof in the containing type's oneof_decl
+ * list. This field is a member of that oneof.
+ * </pre>
+ *
+ * <code>optional int32 oneof_index = 9;</code>
+ */
+ private $oneof_index = 0;
+ private $has_oneof_index = false;
+ /**
+ * <pre>
+ * JSON name of this field. The value is set by protocol compiler. If the
+ * user has set a "json_name" option on this field, that option's value
+ * will be used. Otherwise, it's deduced from the field's name by converting
+ * it to camelCase.
+ * </pre>
+ *
+ * <code>optional string json_name = 10;</code>
+ */
+ private $json_name = '';
+ private $has_json_name = false;
+ /**
+ * <code>optional .google.protobuf.FieldOptions options = 8;</code>
+ */
+ private $options = null;
+ private $has_options = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * <code>optional string name = 1;</code>
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * <code>optional string name = 1;</code>
+ */
+ public function setName($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->name = $var;
+ $this->has_name = true;
+ }
+
+ public function hasName()
+ {
+ return $this->has_name;
+ }
+
+ /**
+ * <code>optional int32 number = 3;</code>
+ */
+ public function getNumber()
+ {
+ return $this->number;
+ }
+
+ /**
+ * <code>optional int32 number = 3;</code>
+ */
+ public function setNumber($var)
+ {
+ GPBUtil::checkInt32($var);
+ $this->number = $var;
+ $this->has_number = true;
+ }
+
+ public function hasNumber()
+ {
+ return $this->has_number;
+ }
+
+ /**
+ * <code>optional .google.protobuf.FieldDescriptorProto.Label label = 4;</code>
+ */
+ public function getLabel()
+ {
+ return $this->label;
+ }
+
+ /**
+ * <code>optional .google.protobuf.FieldDescriptorProto.Label label = 4;</code>
+ */
+ public function setLabel($var)
+ {
+ GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldDescriptorProto_Label::class);
+ $this->label = $var;
+ $this->has_label = true;
+ }
+
+ public function hasLabel()
+ {
+ return $this->has_label;
+ }
+
+ /**
+ * <pre>
+ * If type_name is set, this need not be set. If both this and type_name
+ * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
+ * </pre>
+ *
+ * <code>optional .google.protobuf.FieldDescriptorProto.Type type = 5;</code>
+ */
+ public function getType()
+ {
+ return $this->type;
+ }
+
+ /**
+ * <pre>
+ * If type_name is set, this need not be set. If both this and type_name
+ * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
+ * </pre>
+ *
+ * <code>optional .google.protobuf.FieldDescriptorProto.Type type = 5;</code>
+ */
+ public function setType($var)
+ {
+ GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldDescriptorProto_Type::class);
+ $this->type = $var;
+ $this->has_type = true;
+ }
+
+ public function hasType()
+ {
+ return $this->has_type;
+ }
+
+ /**
+ * <pre>
+ * For message and enum types, this is the name of the type. If the name
+ * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping
+ * rules are used to find the type (i.e. first the nested types within this
+ * message are searched, then within the parent, on up to the root
+ * namespace).
+ * </pre>
+ *
+ * <code>optional string type_name = 6;</code>
+ */
+ public function getTypeName()
+ {
+ return $this->type_name;
+ }
+
+ /**
+ * <pre>
+ * For message and enum types, this is the name of the type. If the name
+ * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping
+ * rules are used to find the type (i.e. first the nested types within this
+ * message are searched, then within the parent, on up to the root
+ * namespace).
+ * </pre>
+ *
+ * <code>optional string type_name = 6;</code>
+ */
+ public function setTypeName($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->type_name = $var;
+ $this->has_type_name = true;
+ }
+
+ public function hasTypeName()
+ {
+ return $this->has_type_name;
+ }
+
+ /**
+ * <pre>
+ * For extensions, this is the name of the type being extended. It is
+ * resolved in the same manner as type_name.
+ * </pre>
+ *
+ * <code>optional string extendee = 2;</code>
+ */
+ public function getExtendee()
+ {
+ return $this->extendee;
+ }
+
+ /**
+ * <pre>
+ * For extensions, this is the name of the type being extended. It is
+ * resolved in the same manner as type_name.
+ * </pre>
+ *
+ * <code>optional string extendee = 2;</code>
+ */
+ public function setExtendee($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->extendee = $var;
+ $this->has_extendee = true;
+ }
+
+ public function hasExtendee()
+ {
+ return $this->has_extendee;
+ }
+
+ /**
+ * <pre>
+ * For numeric types, contains the original text representation of the value.
+ * For booleans, "true" or "false".
+ * For strings, contains the default text contents (not escaped in any way).
+ * For bytes, contains the C escaped value. All bytes &gt;= 128 are escaped.
+ * TODO(kenton): Base-64 encode?
+ * </pre>
+ *
+ * <code>optional string default_value = 7;</code>
+ */
+ public function getDefaultValue()
+ {
+ return $this->default_value;
+ }
+
+ /**
+ * <pre>
+ * For numeric types, contains the original text representation of the value.
+ * For booleans, "true" or "false".
+ * For strings, contains the default text contents (not escaped in any way).
+ * For bytes, contains the C escaped value. All bytes &gt;= 128 are escaped.
+ * TODO(kenton): Base-64 encode?
+ * </pre>
+ *
+ * <code>optional string default_value = 7;</code>
+ */
+ public function setDefaultValue($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->default_value = $var;
+ $this->has_default_value = true;
+ }
+
+ public function hasDefaultValue()
+ {
+ return $this->has_default_value;
+ }
+
+ /**
+ * <pre>
+ * If set, gives the index of a oneof in the containing type's oneof_decl
+ * list. This field is a member of that oneof.
+ * </pre>
+ *
+ * <code>optional int32 oneof_index = 9;</code>
+ */
+ public function getOneofIndex()
+ {
+ return $this->oneof_index;
+ }
+
+ /**
+ * <pre>
+ * If set, gives the index of a oneof in the containing type's oneof_decl
+ * list. This field is a member of that oneof.
+ * </pre>
+ *
+ * <code>optional int32 oneof_index = 9;</code>
+ */
+ public function setOneofIndex($var)
+ {
+ GPBUtil::checkInt32($var);
+ $this->oneof_index = $var;
+ $this->has_oneof_index = true;
+ }
+
+ public function hasOneofIndex()
+ {
+ return $this->has_oneof_index;
+ }
+
+ /**
+ * <pre>
+ * JSON name of this field. The value is set by protocol compiler. If the
+ * user has set a "json_name" option on this field, that option's value
+ * will be used. Otherwise, it's deduced from the field's name by converting
+ * it to camelCase.
+ * </pre>
+ *
+ * <code>optional string json_name = 10;</code>
+ */
+ public function getJsonName()
+ {
+ return $this->json_name;
+ }
+
+ /**
+ * <pre>
+ * JSON name of this field. The value is set by protocol compiler. If the
+ * user has set a "json_name" option on this field, that option's value
+ * will be used. Otherwise, it's deduced from the field's name by converting
+ * it to camelCase.
+ * </pre>
+ *
+ * <code>optional string json_name = 10;</code>
+ */
+ public function setJsonName($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->json_name = $var;
+ $this->has_json_name = true;
+ }
+
+ public function hasJsonName()
+ {
+ return $this->has_json_name;
+ }
+
+ /**
+ * <code>optional .google.protobuf.FieldOptions options = 8;</code>
+ */
+ public function getOptions()
+ {
+ return $this->options;
+ }
+
+ /**
+ * <code>optional .google.protobuf.FieldOptions options = 8;</code>
+ */
+ public function setOptions(&$var)
+ {
+ GPBUtil::checkMessage($var, \Google\Protobuf\Internal\FieldOptions::class);
+ $this->options = $var;
+ $this->has_options = true;
+ }
+
+ public function hasOptions()
+ {
+ return $this->has_options;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php b/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php
new file mode 100644
index 00000000..06f26015
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php
@@ -0,0 +1,29 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+/**
+ * Protobuf enum <code>google.protobuf.FieldDescriptorProto.Label</code>
+ */
+namespace Google\Protobuf\Internal;
+
+class FieldDescriptorProto_Label
+{
+ /**
+ * <pre>
+ * 0 is reserved for errors
+ * </pre>
+ *
+ * <code>LABEL_OPTIONAL = 1;</code>
+ */
+ const LABEL_OPTIONAL = 1;
+ /**
+ * <code>LABEL_REQUIRED = 2;</code>
+ */
+ const LABEL_REQUIRED = 2;
+ /**
+ * <code>LABEL_REPEATED = 3;</code>
+ */
+ const LABEL_REPEATED = 3;
+}
+
diff --git a/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Type.php b/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Type.php
new file mode 100644
index 00000000..9bda76c2
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Type.php
@@ -0,0 +1,120 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+/**
+ * Protobuf enum <code>google.protobuf.FieldDescriptorProto.Type</code>
+ */
+namespace Google\Protobuf\Internal;
+
+class FieldDescriptorProto_Type
+{
+ /**
+ * <pre>
+ * 0 is reserved for errors.
+ * Order is weird for historical reasons.
+ * </pre>
+ *
+ * <code>TYPE_DOUBLE = 1;</code>
+ */
+ const TYPE_DOUBLE = 1;
+ /**
+ * <code>TYPE_FLOAT = 2;</code>
+ */
+ const TYPE_FLOAT = 2;
+ /**
+ * <pre>
+ * Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if
+ * negative values are likely.
+ * </pre>
+ *
+ * <code>TYPE_INT64 = 3;</code>
+ */
+ const TYPE_INT64 = 3;
+ /**
+ * <code>TYPE_UINT64 = 4;</code>
+ */
+ const TYPE_UINT64 = 4;
+ /**
+ * <pre>
+ * Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if
+ * negative values are likely.
+ * </pre>
+ *
+ * <code>TYPE_INT32 = 5;</code>
+ */
+ const TYPE_INT32 = 5;
+ /**
+ * <code>TYPE_FIXED64 = 6;</code>
+ */
+ const TYPE_FIXED64 = 6;
+ /**
+ * <code>TYPE_FIXED32 = 7;</code>
+ */
+ const TYPE_FIXED32 = 7;
+ /**
+ * <code>TYPE_BOOL = 8;</code>
+ */
+ const TYPE_BOOL = 8;
+ /**
+ * <code>TYPE_STRING = 9;</code>
+ */
+ const TYPE_STRING = 9;
+ /**
+ * <pre>
+ * Tag-delimited aggregate.
+ * </pre>
+ *
+ * <code>TYPE_GROUP = 10;</code>
+ */
+ const TYPE_GROUP = 10;
+ /**
+ * <pre>
+ * Length-delimited aggregate.
+ * </pre>
+ *
+ * <code>TYPE_MESSAGE = 11;</code>
+ */
+ const TYPE_MESSAGE = 11;
+ /**
+ * <pre>
+ * New in version 2.
+ * </pre>
+ *
+ * <code>TYPE_BYTES = 12;</code>
+ */
+ const TYPE_BYTES = 12;
+ /**
+ * <code>TYPE_UINT32 = 13;</code>
+ */
+ const TYPE_UINT32 = 13;
+ /**
+ * <code>TYPE_ENUM = 14;</code>
+ */
+ const TYPE_ENUM = 14;
+ /**
+ * <code>TYPE_SFIXED32 = 15;</code>
+ */
+ const TYPE_SFIXED32 = 15;
+ /**
+ * <code>TYPE_SFIXED64 = 16;</code>
+ */
+ const TYPE_SFIXED64 = 16;
+ /**
+ * <pre>
+ * Uses ZigZag encoding.
+ * </pre>
+ *
+ * <code>TYPE_SINT32 = 17;</code>
+ */
+ const TYPE_SINT32 = 17;
+ /**
+ * <pre>
+ * Uses ZigZag encoding.
+ * </pre>
+ *
+ * <code>TYPE_SINT64 = 18;</code>
+ */
+ const TYPE_SINT64 = 18;
+}
+
diff --git a/php/src/Google/Protobuf/Internal/FieldOptions.php b/php/src/Google/Protobuf/Internal/FieldOptions.php
new file mode 100644
index 00000000..af1393a5
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/FieldOptions.php
@@ -0,0 +1,429 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\GPBWire;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\InputStream;
+
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Protobuf type <code>google.protobuf.FieldOptions</code>
+ */
+class FieldOptions extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * <pre>
+ * The ctype option instructs the C++ code generator to use a different
+ * representation of the field than it normally would. See the specific
+ * options below. This option is not yet implemented in the open source
+ * release -- sorry, we'll try to include it in a future version!
+ * </pre>
+ *
+ * <code>optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];</code>
+ */
+ private $ctype = 0;
+ private $has_ctype = false;
+ /**
+ * <pre>
+ * The packed option can be enabled for repeated primitive fields to enable
+ * a more efficient representation on the wire. Rather than repeatedly
+ * writing the tag and type for each element, the entire array is encoded as
+ * a single length-delimited blob. In proto3, only explicit setting it to
+ * false will avoid using packed encoding.
+ * </pre>
+ *
+ * <code>optional bool packed = 2;</code>
+ */
+ private $packed = false;
+ private $has_packed = false;
+ /**
+ * <pre>
+ * The jstype option determines the JavaScript type used for values of the
+ * field. The option is permitted only for 64 bit integral and fixed types
+ * (int64, uint64, sint64, fixed64, sfixed64). By default these types are
+ * represented as JavaScript strings. This avoids loss of precision that can
+ * happen when a large value is converted to a floating point JavaScript
+ * numbers. Specifying JS_NUMBER for the jstype causes the generated
+ * JavaScript code to use the JavaScript "number" type instead of strings.
+ * This option is an enum to permit additional types to be added,
+ * e.g. goog.math.Integer.
+ * </pre>
+ *
+ * <code>optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];</code>
+ */
+ private $jstype = 0;
+ private $has_jstype = false;
+ /**
+ * <pre>
+ * Should this field be parsed lazily? Lazy applies only to message-type
+ * fields. It means that when the outer message is initially parsed, the
+ * inner message's contents will not be parsed but instead stored in encoded
+ * form. The inner message will actually be parsed when it is first accessed.
+ * This is only a hint. Implementations are free to choose whether to use
+ * eager or lazy parsing regardless of the value of this option. However,
+ * setting this option true suggests that the protocol author believes that
+ * using lazy parsing on this field is worth the additional bookkeeping
+ * overhead typically needed to implement it.
+ * This option does not affect the public interface of any generated code;
+ * all method signatures remain the same. Furthermore, thread-safety of the
+ * interface is not affected by this option; const methods remain safe to
+ * call from multiple threads concurrently, while non-const methods continue
+ * to require exclusive access.
+ * Note that implementations may choose not to check required fields within
+ * a lazy sub-message. That is, calling IsInitialized() on the outer message
+ * may return true even if the inner message has missing required fields.
+ * This is necessary because otherwise the inner message would have to be
+ * parsed in order to perform the check, defeating the purpose of lazy
+ * parsing. An implementation which chooses not to check required fields
+ * must be consistent about it. That is, for any particular sub-message, the
+ * implementation must either *always* check its required fields, or *never*
+ * check its required fields, regardless of whether or not the message has
+ * been parsed.
+ * </pre>
+ *
+ * <code>optional bool lazy = 5 [default = false];</code>
+ */
+ private $lazy = false;
+ private $has_lazy = false;
+ /**
+ * <pre>
+ * Is this field deprecated?
+ * Depending on the target platform, this can emit Deprecated annotations
+ * for accessors, or it will be completely ignored; in the very least, this
+ * is a formalization for deprecating fields.
+ * </pre>
+ *
+ * <code>optional bool deprecated = 3 [default = false];</code>
+ */
+ private $deprecated = false;
+ private $has_deprecated = false;
+ /**
+ * <pre>
+ * For Google-internal migration only. Do not use.
+ * </pre>
+ *
+ * <code>optional bool weak = 10 [default = false];</code>
+ */
+ private $weak = false;
+ private $has_weak = false;
+ /**
+ * <pre>
+ * The parser stores options it doesn't recognize here. See above.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
+ */
+ private $uninterpreted_option;
+ private $has_uninterpreted_option = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * <pre>
+ * The ctype option instructs the C++ code generator to use a different
+ * representation of the field than it normally would. See the specific
+ * options below. This option is not yet implemented in the open source
+ * release -- sorry, we'll try to include it in a future version!
+ * </pre>
+ *
+ * <code>optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];</code>
+ */
+ public function getCtype()
+ {
+ return $this->ctype;
+ }
+
+ /**
+ * <pre>
+ * The ctype option instructs the C++ code generator to use a different
+ * representation of the field than it normally would. See the specific
+ * options below. This option is not yet implemented in the open source
+ * release -- sorry, we'll try to include it in a future version!
+ * </pre>
+ *
+ * <code>optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];</code>
+ */
+ public function setCtype($var)
+ {
+ GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldOptions_CType::class);
+ $this->ctype = $var;
+ $this->has_ctype = true;
+ }
+
+ public function hasCtype()
+ {
+ return $this->has_ctype;
+ }
+
+ /**
+ * <pre>
+ * The packed option can be enabled for repeated primitive fields to enable
+ * a more efficient representation on the wire. Rather than repeatedly
+ * writing the tag and type for each element, the entire array is encoded as
+ * a single length-delimited blob. In proto3, only explicit setting it to
+ * false will avoid using packed encoding.
+ * </pre>
+ *
+ * <code>optional bool packed = 2;</code>
+ */
+ public function getPacked()
+ {
+ return $this->packed;
+ }
+
+ /**
+ * <pre>
+ * The packed option can be enabled for repeated primitive fields to enable
+ * a more efficient representation on the wire. Rather than repeatedly
+ * writing the tag and type for each element, the entire array is encoded as
+ * a single length-delimited blob. In proto3, only explicit setting it to
+ * false will avoid using packed encoding.
+ * </pre>
+ *
+ * <code>optional bool packed = 2;</code>
+ */
+ public function setPacked($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->packed = $var;
+ $this->has_packed = true;
+ }
+
+ public function hasPacked()
+ {
+ return $this->has_packed;
+ }
+
+ /**
+ * <pre>
+ * The jstype option determines the JavaScript type used for values of the
+ * field. The option is permitted only for 64 bit integral and fixed types
+ * (int64, uint64, sint64, fixed64, sfixed64). By default these types are
+ * represented as JavaScript strings. This avoids loss of precision that can
+ * happen when a large value is converted to a floating point JavaScript
+ * numbers. Specifying JS_NUMBER for the jstype causes the generated
+ * JavaScript code to use the JavaScript "number" type instead of strings.
+ * This option is an enum to permit additional types to be added,
+ * e.g. goog.math.Integer.
+ * </pre>
+ *
+ * <code>optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];</code>
+ */
+ public function getJstype()
+ {
+ return $this->jstype;
+ }
+
+ /**
+ * <pre>
+ * The jstype option determines the JavaScript type used for values of the
+ * field. The option is permitted only for 64 bit integral and fixed types
+ * (int64, uint64, sint64, fixed64, sfixed64). By default these types are
+ * represented as JavaScript strings. This avoids loss of precision that can
+ * happen when a large value is converted to a floating point JavaScript
+ * numbers. Specifying JS_NUMBER for the jstype causes the generated
+ * JavaScript code to use the JavaScript "number" type instead of strings.
+ * This option is an enum to permit additional types to be added,
+ * e.g. goog.math.Integer.
+ * </pre>
+ *
+ * <code>optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];</code>
+ */
+ public function setJstype($var)
+ {
+ GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldOptions_JSType::class);
+ $this->jstype = $var;
+ $this->has_jstype = true;
+ }
+
+ public function hasJstype()
+ {
+ return $this->has_jstype;
+ }
+
+ /**
+ * <pre>
+ * Should this field be parsed lazily? Lazy applies only to message-type
+ * fields. It means that when the outer message is initially parsed, the
+ * inner message's contents will not be parsed but instead stored in encoded
+ * form. The inner message will actually be parsed when it is first accessed.
+ * This is only a hint. Implementations are free to choose whether to use
+ * eager or lazy parsing regardless of the value of this option. However,
+ * setting this option true suggests that the protocol author believes that
+ * using lazy parsing on this field is worth the additional bookkeeping
+ * overhead typically needed to implement it.
+ * This option does not affect the public interface of any generated code;
+ * all method signatures remain the same. Furthermore, thread-safety of the
+ * interface is not affected by this option; const methods remain safe to
+ * call from multiple threads concurrently, while non-const methods continue
+ * to require exclusive access.
+ * Note that implementations may choose not to check required fields within
+ * a lazy sub-message. That is, calling IsInitialized() on the outer message
+ * may return true even if the inner message has missing required fields.
+ * This is necessary because otherwise the inner message would have to be
+ * parsed in order to perform the check, defeating the purpose of lazy
+ * parsing. An implementation which chooses not to check required fields
+ * must be consistent about it. That is, for any particular sub-message, the
+ * implementation must either *always* check its required fields, or *never*
+ * check its required fields, regardless of whether or not the message has
+ * been parsed.
+ * </pre>
+ *
+ * <code>optional bool lazy = 5 [default = false];</code>
+ */
+ public function getLazy()
+ {
+ return $this->lazy;
+ }
+
+ /**
+ * <pre>
+ * Should this field be parsed lazily? Lazy applies only to message-type
+ * fields. It means that when the outer message is initially parsed, the
+ * inner message's contents will not be parsed but instead stored in encoded
+ * form. The inner message will actually be parsed when it is first accessed.
+ * This is only a hint. Implementations are free to choose whether to use
+ * eager or lazy parsing regardless of the value of this option. However,
+ * setting this option true suggests that the protocol author believes that
+ * using lazy parsing on this field is worth the additional bookkeeping
+ * overhead typically needed to implement it.
+ * This option does not affect the public interface of any generated code;
+ * all method signatures remain the same. Furthermore, thread-safety of the
+ * interface is not affected by this option; const methods remain safe to
+ * call from multiple threads concurrently, while non-const methods continue
+ * to require exclusive access.
+ * Note that implementations may choose not to check required fields within
+ * a lazy sub-message. That is, calling IsInitialized() on the outer message
+ * may return true even if the inner message has missing required fields.
+ * This is necessary because otherwise the inner message would have to be
+ * parsed in order to perform the check, defeating the purpose of lazy
+ * parsing. An implementation which chooses not to check required fields
+ * must be consistent about it. That is, for any particular sub-message, the
+ * implementation must either *always* check its required fields, or *never*
+ * check its required fields, regardless of whether or not the message has
+ * been parsed.
+ * </pre>
+ *
+ * <code>optional bool lazy = 5 [default = false];</code>
+ */
+ public function setLazy($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->lazy = $var;
+ $this->has_lazy = true;
+ }
+
+ public function hasLazy()
+ {
+ return $this->has_lazy;
+ }
+
+ /**
+ * <pre>
+ * Is this field deprecated?
+ * Depending on the target platform, this can emit Deprecated annotations
+ * for accessors, or it will be completely ignored; in the very least, this
+ * is a formalization for deprecating fields.
+ * </pre>
+ *
+ * <code>optional bool deprecated = 3 [default = false];</code>
+ */
+ public function getDeprecated()
+ {
+ return $this->deprecated;
+ }
+
+ /**
+ * <pre>
+ * Is this field deprecated?
+ * Depending on the target platform, this can emit Deprecated annotations
+ * for accessors, or it will be completely ignored; in the very least, this
+ * is a formalization for deprecating fields.
+ * </pre>
+ *
+ * <code>optional bool deprecated = 3 [default = false];</code>
+ */
+ public function setDeprecated($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->deprecated = $var;
+ $this->has_deprecated = true;
+ }
+
+ public function hasDeprecated()
+ {
+ return $this->has_deprecated;
+ }
+
+ /**
+ * <pre>
+ * For Google-internal migration only. Do not use.
+ * </pre>
+ *
+ * <code>optional bool weak = 10 [default = false];</code>
+ */
+ public function getWeak()
+ {
+ return $this->weak;
+ }
+
+ /**
+ * <pre>
+ * For Google-internal migration only. Do not use.
+ * </pre>
+ *
+ * <code>optional bool weak = 10 [default = false];</code>
+ */
+ public function setWeak($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->weak = $var;
+ $this->has_weak = true;
+ }
+
+ public function hasWeak()
+ {
+ return $this->has_weak;
+ }
+
+ /**
+ * <pre>
+ * The parser stores options it doesn't recognize here. See above.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
+ */
+ public function getUninterpretedOption()
+ {
+ return $this->uninterpreted_option;
+ }
+
+ /**
+ * <pre>
+ * The parser stores options it doesn't recognize here. See above.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
+ */
+ public function setUninterpretedOption(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
+ $this->uninterpreted_option = $var;
+ $this->has_uninterpreted_option = true;
+ }
+
+ public function hasUninterpretedOption()
+ {
+ return $this->has_uninterpreted_option;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Internal/FieldOptions_CType.php b/php/src/Google/Protobuf/Internal/FieldOptions_CType.php
new file mode 100644
index 00000000..2ff2a478
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/FieldOptions_CType.php
@@ -0,0 +1,29 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+/**
+ * Protobuf enum <code>google.protobuf.FieldOptions.CType</code>
+ */
+namespace Google\Protobuf\Internal;
+
+class FieldOptions_CType
+{
+ /**
+ * <pre>
+ * Default mode.
+ * </pre>
+ *
+ * <code>STRING = 0;</code>
+ */
+ const STRING = 0;
+ /**
+ * <code>CORD = 1;</code>
+ */
+ const CORD = 1;
+ /**
+ * <code>STRING_PIECE = 2;</code>
+ */
+ const STRING_PIECE = 2;
+}
+
diff --git a/php/src/Google/Protobuf/Internal/FieldOptions_JSType.php b/php/src/Google/Protobuf/Internal/FieldOptions_JSType.php
new file mode 100644
index 00000000..541c8ae5
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/FieldOptions_JSType.php
@@ -0,0 +1,37 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+/**
+ * Protobuf enum <code>google.protobuf.FieldOptions.JSType</code>
+ */
+namespace Google\Protobuf\Internal;
+
+class FieldOptions_JSType
+{
+ /**
+ * <pre>
+ * Use the default type.
+ * </pre>
+ *
+ * <code>JS_NORMAL = 0;</code>
+ */
+ const JS_NORMAL = 0;
+ /**
+ * <pre>
+ * Use JavaScript strings.
+ * </pre>
+ *
+ * <code>JS_STRING = 1;</code>
+ */
+ const JS_STRING = 1;
+ /**
+ * <pre>
+ * Use JavaScript numbers.
+ * </pre>
+ *
+ * <code>JS_NUMBER = 2;</code>
+ */
+ const JS_NUMBER = 2;
+}
+
diff --git a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php
new file mode 100644
index 00000000..39f67768
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php
@@ -0,0 +1,477 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\GPBWire;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\InputStream;
+
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * <pre>
+ * Describes a complete .proto file.
+ * </pre>
+ *
+ * Protobuf type <code>google.protobuf.FileDescriptorProto</code>
+ */
+class FileDescriptorProto extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * <pre>
+ * file name, relative to root of source tree
+ * </pre>
+ *
+ * <code>optional string name = 1;</code>
+ */
+ private $name = '';
+ private $has_name = false;
+ /**
+ * <pre>
+ * e.g. "foo", "foo.bar", etc.
+ * </pre>
+ *
+ * <code>optional string package = 2;</code>
+ */
+ private $package = '';
+ private $has_package = false;
+ /**
+ * <pre>
+ * Names of files imported by this file.
+ * </pre>
+ *
+ * <code>repeated string dependency = 3;</code>
+ */
+ private $dependency;
+ private $has_dependency = false;
+ /**
+ * <pre>
+ * Indexes of the public imported files in the dependency list above.
+ * </pre>
+ *
+ * <code>repeated int32 public_dependency = 10;</code>
+ */
+ private $public_dependency;
+ private $has_public_dependency = false;
+ /**
+ * <pre>
+ * Indexes of the weak imported files in the dependency list.
+ * For Google-internal migration only. Do not use.
+ * </pre>
+ *
+ * <code>repeated int32 weak_dependency = 11;</code>
+ */
+ private $weak_dependency;
+ private $has_weak_dependency = false;
+ /**
+ * <pre>
+ * All top-level definitions in this file.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.DescriptorProto message_type = 4;</code>
+ */
+ private $message_type;
+ private $has_message_type = false;
+ /**
+ * <code>repeated .google.protobuf.EnumDescriptorProto enum_type = 5;</code>
+ */
+ private $enum_type;
+ private $has_enum_type = false;
+ /**
+ * <code>repeated .google.protobuf.ServiceDescriptorProto service = 6;</code>
+ */
+ private $service;
+ private $has_service = false;
+ /**
+ * <code>repeated .google.protobuf.FieldDescriptorProto extension = 7;</code>
+ */
+ private $extension;
+ private $has_extension = false;
+ /**
+ * <code>optional .google.protobuf.FileOptions options = 8;</code>
+ */
+ private $options = null;
+ private $has_options = false;
+ /**
+ * <pre>
+ * This field contains optional information about the original source code.
+ * You may safely remove this entire field without harming runtime
+ * functionality of the descriptors -- the information is needed only by
+ * development tools.
+ * </pre>
+ *
+ * <code>optional .google.protobuf.SourceCodeInfo source_code_info = 9;</code>
+ */
+ private $source_code_info = null;
+ private $has_source_code_info = false;
+ /**
+ * <pre>
+ * The syntax of the proto file.
+ * The supported values are "proto2" and "proto3".
+ * </pre>
+ *
+ * <code>optional string syntax = 12;</code>
+ */
+ private $syntax = '';
+ private $has_syntax = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * <pre>
+ * file name, relative to root of source tree
+ * </pre>
+ *
+ * <code>optional string name = 1;</code>
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * <pre>
+ * file name, relative to root of source tree
+ * </pre>
+ *
+ * <code>optional string name = 1;</code>
+ */
+ public function setName($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->name = $var;
+ $this->has_name = true;
+ }
+
+ public function hasName()
+ {
+ return $this->has_name;
+ }
+
+ /**
+ * <pre>
+ * e.g. "foo", "foo.bar", etc.
+ * </pre>
+ *
+ * <code>optional string package = 2;</code>
+ */
+ public function getPackage()
+ {
+ return $this->package;
+ }
+
+ /**
+ * <pre>
+ * e.g. "foo", "foo.bar", etc.
+ * </pre>
+ *
+ * <code>optional string package = 2;</code>
+ */
+ public function setPackage($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->package = $var;
+ $this->has_package = true;
+ }
+
+ public function hasPackage()
+ {
+ return $this->has_package;
+ }
+
+ /**
+ * <pre>
+ * Names of files imported by this file.
+ * </pre>
+ *
+ * <code>repeated string dependency = 3;</code>
+ */
+ public function getDependency()
+ {
+ return $this->dependency;
+ }
+
+ /**
+ * <pre>
+ * Names of files imported by this file.
+ * </pre>
+ *
+ * <code>repeated string dependency = 3;</code>
+ */
+ public function setDependency(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
+ $this->dependency = $var;
+ $this->has_dependency = true;
+ }
+
+ public function hasDependency()
+ {
+ return $this->has_dependency;
+ }
+
+ /**
+ * <pre>
+ * Indexes of the public imported files in the dependency list above.
+ * </pre>
+ *
+ * <code>repeated int32 public_dependency = 10;</code>
+ */
+ public function getPublicDependency()
+ {
+ return $this->public_dependency;
+ }
+
+ /**
+ * <pre>
+ * Indexes of the public imported files in the dependency list above.
+ * </pre>
+ *
+ * <code>repeated int32 public_dependency = 10;</code>
+ */
+ public function setPublicDependency(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
+ $this->public_dependency = $var;
+ $this->has_public_dependency = true;
+ }
+
+ public function hasPublicDependency()
+ {
+ return $this->has_public_dependency;
+ }
+
+ /**
+ * <pre>
+ * Indexes of the weak imported files in the dependency list.
+ * For Google-internal migration only. Do not use.
+ * </pre>
+ *
+ * <code>repeated int32 weak_dependency = 11;</code>
+ */
+ public function getWeakDependency()
+ {
+ return $this->weak_dependency;
+ }
+
+ /**
+ * <pre>
+ * Indexes of the weak imported files in the dependency list.
+ * For Google-internal migration only. Do not use.
+ * </pre>
+ *
+ * <code>repeated int32 weak_dependency = 11;</code>
+ */
+ public function setWeakDependency(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
+ $this->weak_dependency = $var;
+ $this->has_weak_dependency = true;
+ }
+
+ public function hasWeakDependency()
+ {
+ return $this->has_weak_dependency;
+ }
+
+ /**
+ * <pre>
+ * All top-level definitions in this file.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.DescriptorProto message_type = 4;</code>
+ */
+ public function getMessageType()
+ {
+ return $this->message_type;
+ }
+
+ /**
+ * <pre>
+ * All top-level definitions in this file.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.DescriptorProto message_type = 4;</code>
+ */
+ public function setMessageType(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto::class);
+ $this->message_type = $var;
+ $this->has_message_type = true;
+ }
+
+ public function hasMessageType()
+ {
+ return $this->has_message_type;
+ }
+
+ /**
+ * <code>repeated .google.protobuf.EnumDescriptorProto enum_type = 5;</code>
+ */
+ public function getEnumType()
+ {
+ return $this->enum_type;
+ }
+
+ /**
+ * <code>repeated .google.protobuf.EnumDescriptorProto enum_type = 5;</code>
+ */
+ public function setEnumType(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumDescriptorProto::class);
+ $this->enum_type = $var;
+ $this->has_enum_type = true;
+ }
+
+ public function hasEnumType()
+ {
+ return $this->has_enum_type;
+ }
+
+ /**
+ * <code>repeated .google.protobuf.ServiceDescriptorProto service = 6;</code>
+ */
+ public function getService()
+ {
+ return $this->service;
+ }
+
+ /**
+ * <code>repeated .google.protobuf.ServiceDescriptorProto service = 6;</code>
+ */
+ public function setService(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\ServiceDescriptorProto::class);
+ $this->service = $var;
+ $this->has_service = true;
+ }
+
+ public function hasService()
+ {
+ return $this->has_service;
+ }
+
+ /**
+ * <code>repeated .google.protobuf.FieldDescriptorProto extension = 7;</code>
+ */
+ public function getExtension()
+ {
+ return $this->extension;
+ }
+
+ /**
+ * <code>repeated .google.protobuf.FieldDescriptorProto extension = 7;</code>
+ */
+ public function setExtension(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class);
+ $this->extension = $var;
+ $this->has_extension = true;
+ }
+
+ public function hasExtension()
+ {
+ return $this->has_extension;
+ }
+
+ /**
+ * <code>optional .google.protobuf.FileOptions options = 8;</code>
+ */
+ public function getOptions()
+ {
+ return $this->options;
+ }
+
+ /**
+ * <code>optional .google.protobuf.FileOptions options = 8;</code>
+ */
+ public function setOptions(&$var)
+ {
+ GPBUtil::checkMessage($var, \Google\Protobuf\Internal\FileOptions::class);
+ $this->options = $var;
+ $this->has_options = true;
+ }
+
+ public function hasOptions()
+ {
+ return $this->has_options;
+ }
+
+ /**
+ * <pre>
+ * This field contains optional information about the original source code.
+ * You may safely remove this entire field without harming runtime
+ * functionality of the descriptors -- the information is needed only by
+ * development tools.
+ * </pre>
+ *
+ * <code>optional .google.protobuf.SourceCodeInfo source_code_info = 9;</code>
+ */
+ public function getSourceCodeInfo()
+ {
+ return $this->source_code_info;
+ }
+
+ /**
+ * <pre>
+ * This field contains optional information about the original source code.
+ * You may safely remove this entire field without harming runtime
+ * functionality of the descriptors -- the information is needed only by
+ * development tools.
+ * </pre>
+ *
+ * <code>optional .google.protobuf.SourceCodeInfo source_code_info = 9;</code>
+ */
+ public function setSourceCodeInfo(&$var)
+ {
+ GPBUtil::checkMessage($var, \Google\Protobuf\Internal\SourceCodeInfo::class);
+ $this->source_code_info = $var;
+ $this->has_source_code_info = true;
+ }
+
+ public function hasSourceCodeInfo()
+ {
+ return $this->has_source_code_info;
+ }
+
+ /**
+ * <pre>
+ * The syntax of the proto file.
+ * The supported values are "proto2" and "proto3".
+ * </pre>
+ *
+ * <code>optional string syntax = 12;</code>
+ */
+ public function getSyntax()
+ {
+ return $this->syntax;
+ }
+
+ /**
+ * <pre>
+ * The syntax of the proto file.
+ * The supported values are "proto2" and "proto3".
+ * </pre>
+ *
+ * <code>optional string syntax = 12;</code>
+ */
+ public function setSyntax($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->syntax = $var;
+ $this->has_syntax = true;
+ }
+
+ public function hasSyntax()
+ {
+ return $this->has_syntax;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Internal/FileDescriptorSet.php b/php/src/Google/Protobuf/Internal/FileDescriptorSet.php
new file mode 100644
index 00000000..20a165c4
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/FileDescriptorSet.php
@@ -0,0 +1,59 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\GPBWire;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\InputStream;
+
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * <pre>
+ * The protocol compiler can output a FileDescriptorSet containing the .proto
+ * files it parses.
+ * </pre>
+ *
+ * Protobuf type <code>google.protobuf.FileDescriptorSet</code>
+ */
+class FileDescriptorSet extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * <code>repeated .google.protobuf.FileDescriptorProto file = 1;</code>
+ */
+ private $file;
+ private $has_file = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * <code>repeated .google.protobuf.FileDescriptorProto file = 1;</code>
+ */
+ public function getFile()
+ {
+ return $this->file;
+ }
+
+ /**
+ * <code>repeated .google.protobuf.FileDescriptorProto file = 1;</code>
+ */
+ public function setFile(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FileDescriptorProto::class);
+ $this->file = $var;
+ $this->has_file = true;
+ }
+
+ public function hasFile()
+ {
+ return $this->has_file;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Internal/FileOptions.php b/php/src/Google/Protobuf/Internal/FileOptions.php
new file mode 100644
index 00000000..2422f3ee
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/FileOptions.php
@@ -0,0 +1,741 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\GPBWire;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\InputStream;
+
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Protobuf type <code>google.protobuf.FileOptions</code>
+ */
+class FileOptions extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * <pre>
+ * Sets the Java package where classes generated from this .proto will be
+ * placed. By default, the proto package is used, but this is often
+ * inappropriate because proto packages do not normally start with backwards
+ * domain names.
+ * </pre>
+ *
+ * <code>optional string java_package = 1;</code>
+ */
+ private $java_package = '';
+ private $has_java_package = false;
+ /**
+ * <pre>
+ * If set, all the classes from the .proto file are wrapped in a single
+ * outer class with the given name. This applies to both Proto1
+ * (equivalent to the old "--one_java_file" option) and Proto2 (where
+ * a .proto always translates to a single class, but you may want to
+ * explicitly choose the class name).
+ * </pre>
+ *
+ * <code>optional string java_outer_classname = 8;</code>
+ */
+ private $java_outer_classname = '';
+ private $has_java_outer_classname = false;
+ /**
+ * <pre>
+ * If set true, then the Java code generator will generate a separate .java
+ * file for each top-level message, enum, and service defined in the .proto
+ * file. Thus, these types will *not* be nested inside the outer class
+ * named by java_outer_classname. However, the outer class will still be
+ * generated to contain the file's getDescriptor() method as well as any
+ * top-level extensions defined in the file.
+ * </pre>
+ *
+ * <code>optional bool java_multiple_files = 10 [default = false];</code>
+ */
+ private $java_multiple_files = false;
+ private $has_java_multiple_files = false;
+ /**
+ * <pre>
+ * This option does nothing.
+ * </pre>
+ *
+ * <code>optional bool java_generate_equals_and_hash = 20 [deprecated = true];</code>
+ */
+ private $java_generate_equals_and_hash = false;
+ private $has_java_generate_equals_and_hash = false;
+ /**
+ * <pre>
+ * If set true, then the Java2 code generator will generate code that
+ * throws an exception whenever an attempt is made to assign a non-UTF-8
+ * byte sequence to a string field.
+ * Message reflection will do the same.
+ * However, an extension field still accepts non-UTF-8 byte sequences.
+ * This option has no effect on when used with the lite runtime.
+ * </pre>
+ *
+ * <code>optional bool java_string_check_utf8 = 27 [default = false];</code>
+ */
+ private $java_string_check_utf8 = false;
+ private $has_java_string_check_utf8 = false;
+ /**
+ * <code>optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];</code>
+ */
+ private $optimize_for = 0;
+ private $has_optimize_for = false;
+ /**
+ * <pre>
+ * Sets the Go package where structs generated from this .proto will be
+ * placed. If omitted, the Go package will be derived from the following:
+ * - The basename of the package import path, if provided.
+ * - Otherwise, the package statement in the .proto file, if present.
+ * - Otherwise, the basename of the .proto file, without extension.
+ * </pre>
+ *
+ * <code>optional string go_package = 11;</code>
+ */
+ private $go_package = '';
+ private $has_go_package = false;
+ /**
+ * <pre>
+ * Should generic services be generated in each language? "Generic" services
+ * are not specific to any particular RPC system. They are generated by the
+ * main code generators in each language (without additional plugins).
+ * Generic services were the only kind of service generation supported by
+ * early versions of google.protobuf.
+ * Generic services are now considered deprecated in favor of using plugins
+ * that generate code specific to your particular RPC system. Therefore,
+ * these default to false. Old code which depends on generic services should
+ * explicitly set them to true.
+ * </pre>
+ *
+ * <code>optional bool cc_generic_services = 16 [default = false];</code>
+ */
+ private $cc_generic_services = false;
+ private $has_cc_generic_services = false;
+ /**
+ * <code>optional bool java_generic_services = 17 [default = false];</code>
+ */
+ private $java_generic_services = false;
+ private $has_java_generic_services = false;
+ /**
+ * <code>optional bool py_generic_services = 18 [default = false];</code>
+ */
+ private $py_generic_services = false;
+ private $has_py_generic_services = false;
+ /**
+ * <pre>
+ * Is this file deprecated?
+ * Depending on the target platform, this can emit Deprecated annotations
+ * for everything in the file, or it will be completely ignored; in the very
+ * least, this is a formalization for deprecating files.
+ * </pre>
+ *
+ * <code>optional bool deprecated = 23 [default = false];</code>
+ */
+ private $deprecated = false;
+ private $has_deprecated = false;
+ /**
+ * <pre>
+ * Enables the use of arenas for the proto messages in this file. This applies
+ * only to generated classes for C++.
+ * </pre>
+ *
+ * <code>optional bool cc_enable_arenas = 31 [default = false];</code>
+ */
+ private $cc_enable_arenas = false;
+ private $has_cc_enable_arenas = false;
+ /**
+ * <pre>
+ * Sets the objective c class prefix which is prepended to all objective c
+ * generated classes from this .proto. There is no default.
+ * </pre>
+ *
+ * <code>optional string objc_class_prefix = 36;</code>
+ */
+ private $objc_class_prefix = '';
+ private $has_objc_class_prefix = false;
+ /**
+ * <pre>
+ * Namespace for generated classes; defaults to the package.
+ * </pre>
+ *
+ * <code>optional string csharp_namespace = 37;</code>
+ */
+ private $csharp_namespace = '';
+ private $has_csharp_namespace = false;
+ /**
+ * <pre>
+ * By default Swift generators will take the proto package and CamelCase it
+ * replacing '.' with underscore and use that to prefix the types/symbols
+ * defined. When this options is provided, they will use this value instead
+ * to prefix the types/symbols defined.
+ * </pre>
+ *
+ * <code>optional string swift_prefix = 39;</code>
+ */
+ private $swift_prefix = '';
+ private $has_swift_prefix = false;
+ /**
+ * <pre>
+ * The parser stores options it doesn't recognize here. See above.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
+ */
+ private $uninterpreted_option;
+ private $has_uninterpreted_option = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * <pre>
+ * Sets the Java package where classes generated from this .proto will be
+ * placed. By default, the proto package is used, but this is often
+ * inappropriate because proto packages do not normally start with backwards
+ * domain names.
+ * </pre>
+ *
+ * <code>optional string java_package = 1;</code>
+ */
+ public function getJavaPackage()
+ {
+ return $this->java_package;
+ }
+
+ /**
+ * <pre>
+ * Sets the Java package where classes generated from this .proto will be
+ * placed. By default, the proto package is used, but this is often
+ * inappropriate because proto packages do not normally start with backwards
+ * domain names.
+ * </pre>
+ *
+ * <code>optional string java_package = 1;</code>
+ */
+ public function setJavaPackage($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->java_package = $var;
+ $this->has_java_package = true;
+ }
+
+ public function hasJavaPackage()
+ {
+ return $this->has_java_package;
+ }
+
+ /**
+ * <pre>
+ * If set, all the classes from the .proto file are wrapped in a single
+ * outer class with the given name. This applies to both Proto1
+ * (equivalent to the old "--one_java_file" option) and Proto2 (where
+ * a .proto always translates to a single class, but you may want to
+ * explicitly choose the class name).
+ * </pre>
+ *
+ * <code>optional string java_outer_classname = 8;</code>
+ */
+ public function getJavaOuterClassname()
+ {
+ return $this->java_outer_classname;
+ }
+
+ /**
+ * <pre>
+ * If set, all the classes from the .proto file are wrapped in a single
+ * outer class with the given name. This applies to both Proto1
+ * (equivalent to the old "--one_java_file" option) and Proto2 (where
+ * a .proto always translates to a single class, but you may want to
+ * explicitly choose the class name).
+ * </pre>
+ *
+ * <code>optional string java_outer_classname = 8;</code>
+ */
+ public function setJavaOuterClassname($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->java_outer_classname = $var;
+ $this->has_java_outer_classname = true;
+ }
+
+ public function hasJavaOuterClassname()
+ {
+ return $this->has_java_outer_classname;
+ }
+
+ /**
+ * <pre>
+ * If set true, then the Java code generator will generate a separate .java
+ * file for each top-level message, enum, and service defined in the .proto
+ * file. Thus, these types will *not* be nested inside the outer class
+ * named by java_outer_classname. However, the outer class will still be
+ * generated to contain the file's getDescriptor() method as well as any
+ * top-level extensions defined in the file.
+ * </pre>
+ *
+ * <code>optional bool java_multiple_files = 10 [default = false];</code>
+ */
+ public function getJavaMultipleFiles()
+ {
+ return $this->java_multiple_files;
+ }
+
+ /**
+ * <pre>
+ * If set true, then the Java code generator will generate a separate .java
+ * file for each top-level message, enum, and service defined in the .proto
+ * file. Thus, these types will *not* be nested inside the outer class
+ * named by java_outer_classname. However, the outer class will still be
+ * generated to contain the file's getDescriptor() method as well as any
+ * top-level extensions defined in the file.
+ * </pre>
+ *
+ * <code>optional bool java_multiple_files = 10 [default = false];</code>
+ */
+ public function setJavaMultipleFiles($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->java_multiple_files = $var;
+ $this->has_java_multiple_files = true;
+ }
+
+ public function hasJavaMultipleFiles()
+ {
+ return $this->has_java_multiple_files;
+ }
+
+ /**
+ * <pre>
+ * This option does nothing.
+ * </pre>
+ *
+ * <code>optional bool java_generate_equals_and_hash = 20 [deprecated = true];</code>
+ */
+ public function getJavaGenerateEqualsAndHash()
+ {
+ return $this->java_generate_equals_and_hash;
+ }
+
+ /**
+ * <pre>
+ * This option does nothing.
+ * </pre>
+ *
+ * <code>optional bool java_generate_equals_and_hash = 20 [deprecated = true];</code>
+ */
+ public function setJavaGenerateEqualsAndHash($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->java_generate_equals_and_hash = $var;
+ $this->has_java_generate_equals_and_hash = true;
+ }
+
+ public function hasJavaGenerateEqualsAndHash()
+ {
+ return $this->has_java_generate_equals_and_hash;
+ }
+
+ /**
+ * <pre>
+ * If set true, then the Java2 code generator will generate code that
+ * throws an exception whenever an attempt is made to assign a non-UTF-8
+ * byte sequence to a string field.
+ * Message reflection will do the same.
+ * However, an extension field still accepts non-UTF-8 byte sequences.
+ * This option has no effect on when used with the lite runtime.
+ * </pre>
+ *
+ * <code>optional bool java_string_check_utf8 = 27 [default = false];</code>
+ */
+ public function getJavaStringCheckUtf8()
+ {
+ return $this->java_string_check_utf8;
+ }
+
+ /**
+ * <pre>
+ * If set true, then the Java2 code generator will generate code that
+ * throws an exception whenever an attempt is made to assign a non-UTF-8
+ * byte sequence to a string field.
+ * Message reflection will do the same.
+ * However, an extension field still accepts non-UTF-8 byte sequences.
+ * This option has no effect on when used with the lite runtime.
+ * </pre>
+ *
+ * <code>optional bool java_string_check_utf8 = 27 [default = false];</code>
+ */
+ public function setJavaStringCheckUtf8($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->java_string_check_utf8 = $var;
+ $this->has_java_string_check_utf8 = true;
+ }
+
+ public function hasJavaStringCheckUtf8()
+ {
+ return $this->has_java_string_check_utf8;
+ }
+
+ /**
+ * <code>optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];</code>
+ */
+ public function getOptimizeFor()
+ {
+ return $this->optimize_for;
+ }
+
+ /**
+ * <code>optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];</code>
+ */
+ public function setOptimizeFor($var)
+ {
+ GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FileOptions_OptimizeMode::class);
+ $this->optimize_for = $var;
+ $this->has_optimize_for = true;
+ }
+
+ public function hasOptimizeFor()
+ {
+ return $this->has_optimize_for;
+ }
+
+ /**
+ * <pre>
+ * Sets the Go package where structs generated from this .proto will be
+ * placed. If omitted, the Go package will be derived from the following:
+ * - The basename of the package import path, if provided.
+ * - Otherwise, the package statement in the .proto file, if present.
+ * - Otherwise, the basename of the .proto file, without extension.
+ * </pre>
+ *
+ * <code>optional string go_package = 11;</code>
+ */
+ public function getGoPackage()
+ {
+ return $this->go_package;
+ }
+
+ /**
+ * <pre>
+ * Sets the Go package where structs generated from this .proto will be
+ * placed. If omitted, the Go package will be derived from the following:
+ * - The basename of the package import path, if provided.
+ * - Otherwise, the package statement in the .proto file, if present.
+ * - Otherwise, the basename of the .proto file, without extension.
+ * </pre>
+ *
+ * <code>optional string go_package = 11;</code>
+ */
+ public function setGoPackage($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->go_package = $var;
+ $this->has_go_package = true;
+ }
+
+ public function hasGoPackage()
+ {
+ return $this->has_go_package;
+ }
+
+ /**
+ * <pre>
+ * Should generic services be generated in each language? "Generic" services
+ * are not specific to any particular RPC system. They are generated by the
+ * main code generators in each language (without additional plugins).
+ * Generic services were the only kind of service generation supported by
+ * early versions of google.protobuf.
+ * Generic services are now considered deprecated in favor of using plugins
+ * that generate code specific to your particular RPC system. Therefore,
+ * these default to false. Old code which depends on generic services should
+ * explicitly set them to true.
+ * </pre>
+ *
+ * <code>optional bool cc_generic_services = 16 [default = false];</code>
+ */
+ public function getCcGenericServices()
+ {
+ return $this->cc_generic_services;
+ }
+
+ /**
+ * <pre>
+ * Should generic services be generated in each language? "Generic" services
+ * are not specific to any particular RPC system. They are generated by the
+ * main code generators in each language (without additional plugins).
+ * Generic services were the only kind of service generation supported by
+ * early versions of google.protobuf.
+ * Generic services are now considered deprecated in favor of using plugins
+ * that generate code specific to your particular RPC system. Therefore,
+ * these default to false. Old code which depends on generic services should
+ * explicitly set them to true.
+ * </pre>
+ *
+ * <code>optional bool cc_generic_services = 16 [default = false];</code>
+ */
+ public function setCcGenericServices($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->cc_generic_services = $var;
+ $this->has_cc_generic_services = true;
+ }
+
+ public function hasCcGenericServices()
+ {
+ return $this->has_cc_generic_services;
+ }
+
+ /**
+ * <code>optional bool java_generic_services = 17 [default = false];</code>
+ */
+ public function getJavaGenericServices()
+ {
+ return $this->java_generic_services;
+ }
+
+ /**
+ * <code>optional bool java_generic_services = 17 [default = false];</code>
+ */
+ public function setJavaGenericServices($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->java_generic_services = $var;
+ $this->has_java_generic_services = true;
+ }
+
+ public function hasJavaGenericServices()
+ {
+ return $this->has_java_generic_services;
+ }
+
+ /**
+ * <code>optional bool py_generic_services = 18 [default = false];</code>
+ */
+ public function getPyGenericServices()
+ {
+ return $this->py_generic_services;
+ }
+
+ /**
+ * <code>optional bool py_generic_services = 18 [default = false];</code>
+ */
+ public function setPyGenericServices($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->py_generic_services = $var;
+ $this->has_py_generic_services = true;
+ }
+
+ public function hasPyGenericServices()
+ {
+ return $this->has_py_generic_services;
+ }
+
+ /**
+ * <pre>
+ * Is this file deprecated?
+ * Depending on the target platform, this can emit Deprecated annotations
+ * for everything in the file, or it will be completely ignored; in the very
+ * least, this is a formalization for deprecating files.
+ * </pre>
+ *
+ * <code>optional bool deprecated = 23 [default = false];</code>
+ */
+ public function getDeprecated()
+ {
+ return $this->deprecated;
+ }
+
+ /**
+ * <pre>
+ * Is this file deprecated?
+ * Depending on the target platform, this can emit Deprecated annotations
+ * for everything in the file, or it will be completely ignored; in the very
+ * least, this is a formalization for deprecating files.
+ * </pre>
+ *
+ * <code>optional bool deprecated = 23 [default = false];</code>
+ */
+ public function setDeprecated($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->deprecated = $var;
+ $this->has_deprecated = true;
+ }
+
+ public function hasDeprecated()
+ {
+ return $this->has_deprecated;
+ }
+
+ /**
+ * <pre>
+ * Enables the use of arenas for the proto messages in this file. This applies
+ * only to generated classes for C++.
+ * </pre>
+ *
+ * <code>optional bool cc_enable_arenas = 31 [default = false];</code>
+ */
+ public function getCcEnableArenas()
+ {
+ return $this->cc_enable_arenas;
+ }
+
+ /**
+ * <pre>
+ * Enables the use of arenas for the proto messages in this file. This applies
+ * only to generated classes for C++.
+ * </pre>
+ *
+ * <code>optional bool cc_enable_arenas = 31 [default = false];</code>
+ */
+ public function setCcEnableArenas($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->cc_enable_arenas = $var;
+ $this->has_cc_enable_arenas = true;
+ }
+
+ public function hasCcEnableArenas()
+ {
+ return $this->has_cc_enable_arenas;
+ }
+
+ /**
+ * <pre>
+ * Sets the objective c class prefix which is prepended to all objective c
+ * generated classes from this .proto. There is no default.
+ * </pre>
+ *
+ * <code>optional string objc_class_prefix = 36;</code>
+ */
+ public function getObjcClassPrefix()
+ {
+ return $this->objc_class_prefix;
+ }
+
+ /**
+ * <pre>
+ * Sets the objective c class prefix which is prepended to all objective c
+ * generated classes from this .proto. There is no default.
+ * </pre>
+ *
+ * <code>optional string objc_class_prefix = 36;</code>
+ */
+ public function setObjcClassPrefix($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->objc_class_prefix = $var;
+ $this->has_objc_class_prefix = true;
+ }
+
+ public function hasObjcClassPrefix()
+ {
+ return $this->has_objc_class_prefix;
+ }
+
+ /**
+ * <pre>
+ * Namespace for generated classes; defaults to the package.
+ * </pre>
+ *
+ * <code>optional string csharp_namespace = 37;</code>
+ */
+ public function getCsharpNamespace()
+ {
+ return $this->csharp_namespace;
+ }
+
+ /**
+ * <pre>
+ * Namespace for generated classes; defaults to the package.
+ * </pre>
+ *
+ * <code>optional string csharp_namespace = 37;</code>
+ */
+ public function setCsharpNamespace($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->csharp_namespace = $var;
+ $this->has_csharp_namespace = true;
+ }
+
+ public function hasCsharpNamespace()
+ {
+ return $this->has_csharp_namespace;
+ }
+
+ /**
+ * <pre>
+ * By default Swift generators will take the proto package and CamelCase it
+ * replacing '.' with underscore and use that to prefix the types/symbols
+ * defined. When this options is provided, they will use this value instead
+ * to prefix the types/symbols defined.
+ * </pre>
+ *
+ * <code>optional string swift_prefix = 39;</code>
+ */
+ public function getSwiftPrefix()
+ {
+ return $this->swift_prefix;
+ }
+
+ /**
+ * <pre>
+ * By default Swift generators will take the proto package and CamelCase it
+ * replacing '.' with underscore and use that to prefix the types/symbols
+ * defined. When this options is provided, they will use this value instead
+ * to prefix the types/symbols defined.
+ * </pre>
+ *
+ * <code>optional string swift_prefix = 39;</code>
+ */
+ public function setSwiftPrefix($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->swift_prefix = $var;
+ $this->has_swift_prefix = true;
+ }
+
+ public function hasSwiftPrefix()
+ {
+ return $this->has_swift_prefix;
+ }
+
+ /**
+ * <pre>
+ * The parser stores options it doesn't recognize here. See above.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
+ */
+ public function getUninterpretedOption()
+ {
+ return $this->uninterpreted_option;
+ }
+
+ /**
+ * <pre>
+ * The parser stores options it doesn't recognize here. See above.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
+ */
+ public function setUninterpretedOption(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
+ $this->uninterpreted_option = $var;
+ $this->has_uninterpreted_option = true;
+ }
+
+ public function hasUninterpretedOption()
+ {
+ return $this->has_uninterpreted_option;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php b/php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php
new file mode 100644
index 00000000..7fd488eb
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php
@@ -0,0 +1,41 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+/**
+ * <pre>
+ * Generated classes can be optimized for speed or code size.
+ * </pre>
+ *
+ * Protobuf enum <code>google.protobuf.FileOptions.OptimizeMode</code>
+ */
+namespace Google\Protobuf\Internal;
+
+class FileOptions_OptimizeMode
+{
+ /**
+ * <pre>
+ * Generate complete code for parsing, serialization,
+ * </pre>
+ *
+ * <code>SPEED = 1;</code>
+ */
+ const SPEED = 1;
+ /**
+ * <pre>
+ * etc.
+ * </pre>
+ *
+ * <code>CODE_SIZE = 2;</code>
+ */
+ const CODE_SIZE = 2;
+ /**
+ * <pre>
+ * Generate code using MessageLite and the lite runtime.
+ * </pre>
+ *
+ * <code>LITE_RUNTIME = 3;</code>
+ */
+ const LITE_RUNTIME = 3;
+}
+
diff --git a/php/src/Google/Protobuf/Internal/GPBUtil.php b/php/src/Google/Protobuf/Internal/GPBUtil.php
index 30d7350f..ba1d2eb3 100644
--- a/php/src/Google/Protobuf/Internal/GPBUtil.php
+++ b/php/src/Google/Protobuf/Internal/GPBUtil.php
@@ -43,8 +43,15 @@ class GPBUtil
if ($isNeg) {
$value = bcsub(0, $value);
}
+
$high = (int) bcdiv(bcadd($value, 1), 4294967296);
- $low = (int) bcmod($value, 4294967296);
+ $low = bcmod($value, 4294967296);
+ if (bccomp($low, 2147483647) > 0) {
+ $low = (int) bcsub($low, 4294967296);
+ } else {
+ $low = (int) $low;
+ }
+
if ($isNeg) {
$high = ~$high;
$low = ~$low;
diff --git a/php/src/Google/Protobuf/Internal/GPBWire.php b/php/src/Google/Protobuf/Internal/GPBWire.php
index 7e2c124f..f75e0861 100644
--- a/php/src/Google/Protobuf/Internal/GPBWire.php
+++ b/php/src/Google/Protobuf/Internal/GPBWire.php
@@ -437,34 +437,65 @@ class GPBWire
public static function varint64Size($value)
{
- if ($value < 0) {
- return 10;
- }
- if ($value < (1 << 7)) {
- return 1;
- }
- if ($value < (1 << 14)) {
- return 2;
- }
- if ($value < (1 << 21)) {
- return 3;
- }
- if ($value < (1 << 28)) {
- return 4;
- }
- if ($value < (1 << 35)) {
- return 5;
- }
- if ($value < (1 << 42)) {
- return 6;
- }
- if ($value < (1 << 49)) {
- return 7;
- }
- if ($value < (1 << 56)) {
- return 8;
+ if (PHP_INT_SIZE == 4) {
+ if (bccomp($value, 0) < 0) {
+ return 10;
+ }
+ if (bccomp($value, 1 << 7) < 0) {
+ return 1;
+ }
+ if (bccomp($value, 1 << 14) < 0) {
+ return 2;
+ }
+ if (bccomp($value, 1 << 21) < 0) {
+ return 3;
+ }
+ if (bccomp($value, 1 << 28) < 0) {
+ return 4;
+ }
+ if (bccomp($value, '34359738368') < 0) {
+ return 5;
+ }
+ if (bccomp($value, '4398046511104') < 0) {
+ return 6;
+ }
+ if (bccomp($value, '562949953421312') < 0) {
+ return 7;
+ }
+ if (bccomp($value, '72057594037927936') < 0) {
+ return 8;
+ }
+ return 9;
+ } else {
+ if ($value < 0) {
+ return 10;
+ }
+ if ($value < (1 << 7)) {
+ return 1;
+ }
+ if ($value < (1 << 14)) {
+ return 2;
+ }
+ if ($value < (1 << 21)) {
+ return 3;
+ }
+ if ($value < (1 << 28)) {
+ return 4;
+ }
+ if ($value < (1 << 35)) {
+ return 5;
+ }
+ if ($value < (1 << 42)) {
+ return 6;
+ }
+ if ($value < (1 << 49)) {
+ return 7;
+ }
+ if ($value < (1 << 56)) {
+ return 8;
+ }
+ return 9;
}
- return 9;
}
public static function serializeFieldToStream(
diff --git a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php
new file mode 100644
index 00000000..8e493c2f
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php
@@ -0,0 +1,75 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\GPBWire;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\InputStream;
+
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * <pre>
+ * Describes the relationship between generated code and its original source
+ * file. A GeneratedCodeInfo message is associated with only one generated
+ * source file, but may contain references to different source .proto files.
+ * </pre>
+ *
+ * Protobuf type <code>google.protobuf.GeneratedCodeInfo</code>
+ */
+class GeneratedCodeInfo extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * <pre>
+ * An Annotation connects some span of text in generated code to an element
+ * of its generating .proto file.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;</code>
+ */
+ private $annotation;
+ private $has_annotation = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * <pre>
+ * An Annotation connects some span of text in generated code to an element
+ * of its generating .proto file.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;</code>
+ */
+ public function getAnnotation()
+ {
+ return $this->annotation;
+ }
+
+ /**
+ * <pre>
+ * An Annotation connects some span of text in generated code to an element
+ * of its generating .proto file.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;</code>
+ */
+ public function setAnnotation(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\GeneratedCodeInfo_Annotation::class);
+ $this->annotation = $var;
+ $this->has_annotation = true;
+ }
+
+ public function hasAnnotation()
+ {
+ return $this->has_annotation;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php
new file mode 100644
index 00000000..dcc7edfe
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php
@@ -0,0 +1,198 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\GPBWire;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\InputStream;
+
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Protobuf type <code>google.protobuf.GeneratedCodeInfo.Annotation</code>
+ */
+class GeneratedCodeInfo_Annotation extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * <pre>
+ * Identifies the element in the original source .proto file. This field
+ * is formatted the same as SourceCodeInfo.Location.path.
+ * </pre>
+ *
+ * <code>repeated int32 path = 1 [packed = true];</code>
+ */
+ private $path;
+ private $has_path = false;
+ /**
+ * <pre>
+ * Identifies the filesystem path to the original source .proto.
+ * </pre>
+ *
+ * <code>optional string source_file = 2;</code>
+ */
+ private $source_file = '';
+ private $has_source_file = false;
+ /**
+ * <pre>
+ * Identifies the starting offset in bytes in the generated code
+ * that relates to the identified object.
+ * </pre>
+ *
+ * <code>optional int32 begin = 3;</code>
+ */
+ private $begin = 0;
+ private $has_begin = false;
+ /**
+ * <pre>
+ * Identifies the ending offset in bytes in the generated code that
+ * relates to the identified offset. The end offset should be one past
+ * the last relevant byte (so the length of the text = end - begin).
+ * </pre>
+ *
+ * <code>optional int32 end = 4;</code>
+ */
+ private $end = 0;
+ private $has_end = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * <pre>
+ * Identifies the element in the original source .proto file. This field
+ * is formatted the same as SourceCodeInfo.Location.path.
+ * </pre>
+ *
+ * <code>repeated int32 path = 1 [packed = true];</code>
+ */
+ public function getPath()
+ {
+ return $this->path;
+ }
+
+ /**
+ * <pre>
+ * Identifies the element in the original source .proto file. This field
+ * is formatted the same as SourceCodeInfo.Location.path.
+ * </pre>
+ *
+ * <code>repeated int32 path = 1 [packed = true];</code>
+ */
+ public function setPath(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
+ $this->path = $var;
+ $this->has_path = true;
+ }
+
+ public function hasPath()
+ {
+ return $this->has_path;
+ }
+
+ /**
+ * <pre>
+ * Identifies the filesystem path to the original source .proto.
+ * </pre>
+ *
+ * <code>optional string source_file = 2;</code>
+ */
+ public function getSourceFile()
+ {
+ return $this->source_file;
+ }
+
+ /**
+ * <pre>
+ * Identifies the filesystem path to the original source .proto.
+ * </pre>
+ *
+ * <code>optional string source_file = 2;</code>
+ */
+ public function setSourceFile($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->source_file = $var;
+ $this->has_source_file = true;
+ }
+
+ public function hasSourceFile()
+ {
+ return $this->has_source_file;
+ }
+
+ /**
+ * <pre>
+ * Identifies the starting offset in bytes in the generated code
+ * that relates to the identified object.
+ * </pre>
+ *
+ * <code>optional int32 begin = 3;</code>
+ */
+ public function getBegin()
+ {
+ return $this->begin;
+ }
+
+ /**
+ * <pre>
+ * Identifies the starting offset in bytes in the generated code
+ * that relates to the identified object.
+ * </pre>
+ *
+ * <code>optional int32 begin = 3;</code>
+ */
+ public function setBegin($var)
+ {
+ GPBUtil::checkInt32($var);
+ $this->begin = $var;
+ $this->has_begin = true;
+ }
+
+ public function hasBegin()
+ {
+ return $this->has_begin;
+ }
+
+ /**
+ * <pre>
+ * Identifies the ending offset in bytes in the generated code that
+ * relates to the identified offset. The end offset should be one past
+ * the last relevant byte (so the length of the text = end - begin).
+ * </pre>
+ *
+ * <code>optional int32 end = 4;</code>
+ */
+ public function getEnd()
+ {
+ return $this->end;
+ }
+
+ /**
+ * <pre>
+ * Identifies the ending offset in bytes in the generated code that
+ * relates to the identified offset. The end offset should be one past
+ * the last relevant byte (so the length of the text = end - begin).
+ * </pre>
+ *
+ * <code>optional int32 end = 4;</code>
+ */
+ public function setEnd($var)
+ {
+ GPBUtil::checkInt32($var);
+ $this->end = $var;
+ $this->has_end = true;
+ }
+
+ public function hasEnd()
+ {
+ return $this->has_end;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Internal/InputStream.php b/php/src/Google/Protobuf/Internal/InputStream.php
index 6d6c74e9..bf052c2f 100644
--- a/php/src/Google/Protobuf/Internal/InputStream.php
+++ b/php/src/Google/Protobuf/Internal/InputStream.php
@@ -46,6 +46,9 @@ function combineInt32ToInt64($high, $low)
}
}
$result = bcadd(bcmul($high, 4294967296), $low);
+ if ($low < 0) {
+ $result = bcadd($result, 4294967296);
+ }
if ($isNeg) {
$result = bcsub(0, $result);
}
@@ -160,40 +163,59 @@ class InputStream
*/
public function readVarint64(&$var)
{
- $high = 0;
- $low = 0;
$count = 0;
- $b = 0;
-
- do {
- if ($this->current === $this->buffer_end) {
- return false;
- }
- if ($count === self::MAX_VARINT_BYTES) {
- return false;
- }
- $b = ord($this->buffer[$this->current]);
- $bits = 7 * $count;
- if ($bits >= 32) {
- $high |= (($b & 0x7F) << ($bits - 32));
- } else if ($bits > 25){
- $high_bits = $bits - 25;
- $low = ($low | (($b & 0x7F) << $bits)) & (int) 0xFFFFFFFF;
- $high = $b & ((0x1 << $high_bits) -1);
- } else {
- $low |= (($b & 0x7F) << $bits);
- }
-
- $this->advance(1);
- $count += 1;
- } while ($b & 0x80);
if (PHP_INT_SIZE == 4) {
+ $high = 0;
+ $low = 0;
+ $b = 0;
+
+ do {
+ if ($this->current === $this->buffer_end) {
+ return false;
+ }
+ if ($count === self::MAX_VARINT_BYTES) {
+ return false;
+ }
+ $b = ord($this->buffer[$this->current]);
+ $bits = 7 * $count;
+ if ($bits >= 32) {
+ $high |= (($b & 0x7F) << ($bits - 32));
+ } else if ($bits > 25){
+ // $bits is 28 in this case.
+ $low |= (($b & 0x7F) << 28);
+ $high = ($b & 0x7F) >> 4;
+ } else {
+ $low |= (($b & 0x7F) << $bits);
+ }
+
+ $this->advance(1);
+ $count += 1;
+ } while ($b & 0x80);
+
$var = combineInt32ToInt64($high, $low);
} else {
- $var = ($high & 0xFFFFFFFF) << 32 |
- ($low & 0xFFFFFFFF);
+ $result = 0;
+ $shift = 0;
+
+ do {
+ if ($this->current === $this->buffer_end) {
+ return false;
+ }
+ if ($count === self::MAX_VARINT_BYTES) {
+ return false;
+ }
+
+ $byte = ord($this->buffer[$this->current]);
+ $result |= ($byte & 0x7f) << $shift;
+ $shift += 7;
+ $this->advance(1);
+ $count += 1;
+ } while ($byte > 0x7f);
+
+ $var = $result;
}
+
return true;
}
diff --git a/php/src/Google/Protobuf/Internal/Message.php b/php/src/Google/Protobuf/Internal/Message.php
index 3d1f1598..9e162a22 100644
--- a/php/src/Google/Protobuf/Internal/Message.php
+++ b/php/src/Google/Protobuf/Internal/Message.php
@@ -125,7 +125,7 @@ class Message
$oneof = $this->desc->getOneofDecl()[$field->getOneofIndex()];
$oneof_name = $oneof->getName();
$this->$oneof_name = new OneofField($oneof);
- } else if ($field->getLabel() === GPBLabel::OPTIONAL &&
+ } else if ($field->getLabel() === GPBLabel::OPTIONAL &&
PHP_INT_SIZE == 4) {
switch ($field->getType()) {
case GPBType::INT64:
@@ -163,6 +163,17 @@ class Message
$oneof_field->setNumber($number);
}
+ protected function whichOneof($oneof_name)
+ {
+ $oneof_field = $this->$oneof_name;
+ $number = $oneof_field->getNumber();
+ if ($number == 0) {
+ return "";
+ }
+ $field = $this->desc->getFieldByNumber($number);
+ return $field->getName();
+ }
+
/**
* @ignore
*/
@@ -175,17 +186,22 @@ class Message
case GPBType::FLOAT:
return 0.0;
case GPBType::UINT32:
- case GPBType::UINT64:
case GPBType::INT32:
- case GPBType::INT64:
case GPBType::FIXED32:
- case GPBType::FIXED64:
case GPBType::SFIXED32:
- case GPBType::SFIXED64:
case GPBType::SINT32:
- case GPBType::SINT64:
case GPBType::ENUM:
return 0;
+ case GPBType::INT64:
+ case GPBType::UINT64:
+ case GPBType::FIXED64:
+ case GPBType::SFIXED64:
+ case GPBType::SINT64:
+ if (PHP_INT_SIZE === 4) {
+ return '0';
+ } else {
+ return 0;
+ }
case GPBType::BOOL:
return false;
case GPBType::STRING:
@@ -366,6 +382,115 @@ class Message
}
/**
+ * Clear all containing fields.
+ * @return null.
+ */
+ public function clear()
+ {
+ foreach ($this->desc->getField() as $field) {
+ $setter = $field->getSetter();
+ if ($field->isMap()) {
+ $message_type = $field->getMessageType();
+ $key_field = $message_type->getFieldByNumber(1);
+ $value_field = $message_type->getFieldByNumber(2);
+ switch ($value_field->getType()) {
+ case GPBType::MESSAGE:
+ case GPBType::GROUP:
+ $map_field = new MapField(
+ $key_field->getType(),
+ $value_field->getType(),
+ $value_field->getMessageType()->getClass());
+ $this->$setter($map_field);
+ break;
+ case GPBType::ENUM:
+ $map_field = new MapField(
+ $key_field->getType(),
+ $value_field->getType(),
+ $value_field->getEnumType()->getClass());
+ $this->$setter($map_field);
+ break;
+ default:
+ $map_field = new MapField(
+ $key_field->getType(),
+ $value_field->getType());
+ $this->$setter($map_field);
+ break;
+ }
+ } else if ($field->getLabel() === GPBLabel::REPEATED) {
+ switch ($field->getType()) {
+ case GPBType::MESSAGE:
+ case GPBType::GROUP:
+ $repeated_field = new RepeatedField(
+ $field->getType(),
+ $field->getMessageType()->getClass());
+ $this->$setter($repeated_field);
+ break;
+ case GPBType::ENUM:
+ $repeated_field = new RepeatedField(
+ $field->getType(),
+ $field->getEnumType()->getClass());
+ $this->$setter($repeated_field);
+ break;
+ default:
+ $repeated_field = new RepeatedField($field->getType());
+ $this->$setter($repeated_field);
+ break;
+ }
+ } else if ($field->getOneofIndex() !== -1) {
+ $oneof = $this->desc->getOneofDecl()[$field->getOneofIndex()];
+ $oneof_name = $oneof->getName();
+ $this->$oneof_name = new OneofField($oneof);
+ } else if ($field->getLabel() === GPBLabel::OPTIONAL) {
+ switch ($field->getType()) {
+ case GPBType::DOUBLE :
+ case GPBType::FLOAT :
+ $this->$setter(0.0);
+ break;
+ case GPBType::INT32 :
+ case GPBType::FIXED32 :
+ case GPBType::UINT32 :
+ case GPBType::SFIXED32 :
+ case GPBType::SINT32 :
+ case GPBType::ENUM :
+ $this->$setter(0);
+ break;
+ case GPBType::BOOL :
+ $this->$setter(false);
+ break;
+ case GPBType::STRING :
+ case GPBType::BYTES :
+ $this->$setter("");
+ break;
+ case GPBType::GROUP :
+ case GPBType::MESSAGE :
+ $null = null;
+ $this->$setter($null);
+ break;
+ }
+ if (PHP_INT_SIZE == 4) {
+ switch ($field->getType()) {
+ case GPBType::INT64:
+ case GPBType::UINT64:
+ case GPBType::FIXED64:
+ case GPBType::SFIXED64:
+ case GPBType::SINT64:
+ $this->$setter("0");
+ }
+ } else {
+ switch ($field->getType()) {
+ case GPBType::INT64:
+ case GPBType::UINT64:
+ case GPBType::FIXED64:
+ case GPBType::SFIXED64:
+ case GPBType::SINT64:
+ $this->$setter(0);
+ }
+ }
+ }
+ }
+ }
+
+ /**
* Parses a protocol buffer contained in a string.
*
* This function takes a string in the (non-human-readable) binary wire
@@ -395,6 +520,11 @@ class Message
$number = GPBWire::getTagFieldNumber($tag);
$field = $this->desc->getFieldByNumber($number);
+ // Check whether we retrieved a known field
+ if ($field === NULL) {
+ continue;
+ }
+
if (!$this->parseFieldFromStream($tag, $input, $field)) {
return false;
}
diff --git a/php/src/Google/Protobuf/Internal/MessageOptions.php b/php/src/Google/Protobuf/Internal/MessageOptions.php
new file mode 100644
index 00000000..e4a214cb
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/MessageOptions.php
@@ -0,0 +1,334 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\GPBWire;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\InputStream;
+
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Protobuf type <code>google.protobuf.MessageOptions</code>
+ */
+class MessageOptions extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * <pre>
+ * Set true to use the old proto1 MessageSet wire format for extensions.
+ * This is provided for backwards-compatibility with the MessageSet wire
+ * format. You should not use this for any other reason: It's less
+ * efficient, has fewer features, and is more complicated.
+ * The message must be defined exactly as follows:
+ * message Foo {
+ * option message_set_wire_format = true;
+ * extensions 4 to max;
+ * }
+ * Note that the message cannot have any defined fields; MessageSets only
+ * have extensions.
+ * All extensions of your type must be singular messages; e.g. they cannot
+ * be int32s, enums, or repeated messages.
+ * Because this is an option, the above two restrictions are not enforced by
+ * the protocol compiler.
+ * </pre>
+ *
+ * <code>optional bool message_set_wire_format = 1 [default = false];</code>
+ */
+ private $message_set_wire_format = false;
+ private $has_message_set_wire_format = false;
+ /**
+ * <pre>
+ * Disables the generation of the standard "descriptor()" accessor, which can
+ * conflict with a field of the same name. This is meant to make migration
+ * from proto1 easier; new code should avoid fields named "descriptor".
+ * </pre>
+ *
+ * <code>optional bool no_standard_descriptor_accessor = 2 [default = false];</code>
+ */
+ private $no_standard_descriptor_accessor = false;
+ private $has_no_standard_descriptor_accessor = false;
+ /**
+ * <pre>
+ * Is this message deprecated?
+ * Depending on the target platform, this can emit Deprecated annotations
+ * for the message, or it will be completely ignored; in the very least,
+ * this is a formalization for deprecating messages.
+ * </pre>
+ *
+ * <code>optional bool deprecated = 3 [default = false];</code>
+ */
+ private $deprecated = false;
+ private $has_deprecated = false;
+ /**
+ * <pre>
+ * Whether the message is an automatically generated map entry type for the
+ * maps field.
+ * For maps fields:
+ * map&lt;KeyType, ValueType&gt; map_field = 1;
+ * The parsed descriptor looks like:
+ * message MapFieldEntry {
+ * option map_entry = true;
+ * optional KeyType key = 1;
+ * optional ValueType value = 2;
+ * }
+ * repeated MapFieldEntry map_field = 1;
+ * Implementations may choose not to generate the map_entry=true message, but
+ * use a native map in the target language to hold the keys and values.
+ * The reflection APIs in such implementions still need to work as
+ * if the field is a repeated message field.
+ * NOTE: Do not set the option in .proto files. Always use the maps syntax
+ * instead. The option should only be implicitly set by the proto compiler
+ * parser.
+ * </pre>
+ *
+ * <code>optional bool map_entry = 7;</code>
+ */
+ private $map_entry = false;
+ private $has_map_entry = false;
+ /**
+ * <pre>
+ * The parser stores options it doesn't recognize here. See above.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
+ */
+ private $uninterpreted_option;
+ private $has_uninterpreted_option = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * <pre>
+ * Set true to use the old proto1 MessageSet wire format for extensions.
+ * This is provided for backwards-compatibility with the MessageSet wire
+ * format. You should not use this for any other reason: It's less
+ * efficient, has fewer features, and is more complicated.
+ * The message must be defined exactly as follows:
+ * message Foo {
+ * option message_set_wire_format = true;
+ * extensions 4 to max;
+ * }
+ * Note that the message cannot have any defined fields; MessageSets only
+ * have extensions.
+ * All extensions of your type must be singular messages; e.g. they cannot
+ * be int32s, enums, or repeated messages.
+ * Because this is an option, the above two restrictions are not enforced by
+ * the protocol compiler.
+ * </pre>
+ *
+ * <code>optional bool message_set_wire_format = 1 [default = false];</code>
+ */
+ public function getMessageSetWireFormat()
+ {
+ return $this->message_set_wire_format;
+ }
+
+ /**
+ * <pre>
+ * Set true to use the old proto1 MessageSet wire format for extensions.
+ * This is provided for backwards-compatibility with the MessageSet wire
+ * format. You should not use this for any other reason: It's less
+ * efficient, has fewer features, and is more complicated.
+ * The message must be defined exactly as follows:
+ * message Foo {
+ * option message_set_wire_format = true;
+ * extensions 4 to max;
+ * }
+ * Note that the message cannot have any defined fields; MessageSets only
+ * have extensions.
+ * All extensions of your type must be singular messages; e.g. they cannot
+ * be int32s, enums, or repeated messages.
+ * Because this is an option, the above two restrictions are not enforced by
+ * the protocol compiler.
+ * </pre>
+ *
+ * <code>optional bool message_set_wire_format = 1 [default = false];</code>
+ */
+ public function setMessageSetWireFormat($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->message_set_wire_format = $var;
+ $this->has_message_set_wire_format = true;
+ }
+
+ public function hasMessageSetWireFormat()
+ {
+ return $this->has_message_set_wire_format;
+ }
+
+ /**
+ * <pre>
+ * Disables the generation of the standard "descriptor()" accessor, which can
+ * conflict with a field of the same name. This is meant to make migration
+ * from proto1 easier; new code should avoid fields named "descriptor".
+ * </pre>
+ *
+ * <code>optional bool no_standard_descriptor_accessor = 2 [default = false];</code>
+ */
+ public function getNoStandardDescriptorAccessor()
+ {
+ return $this->no_standard_descriptor_accessor;
+ }
+
+ /**
+ * <pre>
+ * Disables the generation of the standard "descriptor()" accessor, which can
+ * conflict with a field of the same name. This is meant to make migration
+ * from proto1 easier; new code should avoid fields named "descriptor".
+ * </pre>
+ *
+ * <code>optional bool no_standard_descriptor_accessor = 2 [default = false];</code>
+ */
+ public function setNoStandardDescriptorAccessor($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->no_standard_descriptor_accessor = $var;
+ $this->has_no_standard_descriptor_accessor = true;
+ }
+
+ public function hasNoStandardDescriptorAccessor()
+ {
+ return $this->has_no_standard_descriptor_accessor;
+ }
+
+ /**
+ * <pre>
+ * Is this message deprecated?
+ * Depending on the target platform, this can emit Deprecated annotations
+ * for the message, or it will be completely ignored; in the very least,
+ * this is a formalization for deprecating messages.
+ * </pre>
+ *
+ * <code>optional bool deprecated = 3 [default = false];</code>
+ */
+ public function getDeprecated()
+ {
+ return $this->deprecated;
+ }
+
+ /**
+ * <pre>
+ * Is this message deprecated?
+ * Depending on the target platform, this can emit Deprecated annotations
+ * for the message, or it will be completely ignored; in the very least,
+ * this is a formalization for deprecating messages.
+ * </pre>
+ *
+ * <code>optional bool deprecated = 3 [default = false];</code>
+ */
+ public function setDeprecated($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->deprecated = $var;
+ $this->has_deprecated = true;
+ }
+
+ public function hasDeprecated()
+ {
+ return $this->has_deprecated;
+ }
+
+ /**
+ * <pre>
+ * Whether the message is an automatically generated map entry type for the
+ * maps field.
+ * For maps fields:
+ * map&lt;KeyType, ValueType&gt; map_field = 1;
+ * The parsed descriptor looks like:
+ * message MapFieldEntry {
+ * option map_entry = true;
+ * optional KeyType key = 1;
+ * optional ValueType value = 2;
+ * }
+ * repeated MapFieldEntry map_field = 1;
+ * Implementations may choose not to generate the map_entry=true message, but
+ * use a native map in the target language to hold the keys and values.
+ * The reflection APIs in such implementions still need to work as
+ * if the field is a repeated message field.
+ * NOTE: Do not set the option in .proto files. Always use the maps syntax
+ * instead. The option should only be implicitly set by the proto compiler
+ * parser.
+ * </pre>
+ *
+ * <code>optional bool map_entry = 7;</code>
+ */
+ public function getMapEntry()
+ {
+ return $this->map_entry;
+ }
+
+ /**
+ * <pre>
+ * Whether the message is an automatically generated map entry type for the
+ * maps field.
+ * For maps fields:
+ * map&lt;KeyType, ValueType&gt; map_field = 1;
+ * The parsed descriptor looks like:
+ * message MapFieldEntry {
+ * option map_entry = true;
+ * optional KeyType key = 1;
+ * optional ValueType value = 2;
+ * }
+ * repeated MapFieldEntry map_field = 1;
+ * Implementations may choose not to generate the map_entry=true message, but
+ * use a native map in the target language to hold the keys and values.
+ * The reflection APIs in such implementions still need to work as
+ * if the field is a repeated message field.
+ * NOTE: Do not set the option in .proto files. Always use the maps syntax
+ * instead. The option should only be implicitly set by the proto compiler
+ * parser.
+ * </pre>
+ *
+ * <code>optional bool map_entry = 7;</code>
+ */
+ public function setMapEntry($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->map_entry = $var;
+ $this->has_map_entry = true;
+ }
+
+ public function hasMapEntry()
+ {
+ return $this->has_map_entry;
+ }
+
+ /**
+ * <pre>
+ * The parser stores options it doesn't recognize here. See above.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
+ */
+ public function getUninterpretedOption()
+ {
+ return $this->uninterpreted_option;
+ }
+
+ /**
+ * <pre>
+ * The parser stores options it doesn't recognize here. See above.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
+ */
+ public function setUninterpretedOption(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
+ $this->uninterpreted_option = $var;
+ $this->has_uninterpreted_option = true;
+ }
+
+ public function hasUninterpretedOption()
+ {
+ return $this->has_uninterpreted_option;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php
new file mode 100644
index 00000000..3d8df7af
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php
@@ -0,0 +1,237 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\GPBWire;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\InputStream;
+
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * <pre>
+ * Describes a method of a service.
+ * </pre>
+ *
+ * Protobuf type <code>google.protobuf.MethodDescriptorProto</code>
+ */
+class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * <code>optional string name = 1;</code>
+ */
+ private $name = '';
+ private $has_name = false;
+ /**
+ * <pre>
+ * Input and output type names. These are resolved in the same way as
+ * FieldDescriptorProto.type_name, but must refer to a message type.
+ * </pre>
+ *
+ * <code>optional string input_type = 2;</code>
+ */
+ private $input_type = '';
+ private $has_input_type = false;
+ /**
+ * <code>optional string output_type = 3;</code>
+ */
+ private $output_type = '';
+ private $has_output_type = false;
+ /**
+ * <code>optional .google.protobuf.MethodOptions options = 4;</code>
+ */
+ private $options = null;
+ private $has_options = false;
+ /**
+ * <pre>
+ * Identifies if client streams multiple client messages
+ * </pre>
+ *
+ * <code>optional bool client_streaming = 5 [default = false];</code>
+ */
+ private $client_streaming = false;
+ private $has_client_streaming = false;
+ /**
+ * <pre>
+ * Identifies if server streams multiple server messages
+ * </pre>
+ *
+ * <code>optional bool server_streaming = 6 [default = false];</code>
+ */
+ private $server_streaming = false;
+ private $has_server_streaming = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * <code>optional string name = 1;</code>
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * <code>optional string name = 1;</code>
+ */
+ public function setName($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->name = $var;
+ $this->has_name = true;
+ }
+
+ public function hasName()
+ {
+ return $this->has_name;
+ }
+
+ /**
+ * <pre>
+ * Input and output type names. These are resolved in the same way as
+ * FieldDescriptorProto.type_name, but must refer to a message type.
+ * </pre>
+ *
+ * <code>optional string input_type = 2;</code>
+ */
+ public function getInputType()
+ {
+ return $this->input_type;
+ }
+
+ /**
+ * <pre>
+ * Input and output type names. These are resolved in the same way as
+ * FieldDescriptorProto.type_name, but must refer to a message type.
+ * </pre>
+ *
+ * <code>optional string input_type = 2;</code>
+ */
+ public function setInputType($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->input_type = $var;
+ $this->has_input_type = true;
+ }
+
+ public function hasInputType()
+ {
+ return $this->has_input_type;
+ }
+
+ /**
+ * <code>optional string output_type = 3;</code>
+ */
+ public function getOutputType()
+ {
+ return $this->output_type;
+ }
+
+ /**
+ * <code>optional string output_type = 3;</code>
+ */
+ public function setOutputType($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->output_type = $var;
+ $this->has_output_type = true;
+ }
+
+ public function hasOutputType()
+ {
+ return $this->has_output_type;
+ }
+
+ /**
+ * <code>optional .google.protobuf.MethodOptions options = 4;</code>
+ */
+ public function getOptions()
+ {
+ return $this->options;
+ }
+
+ /**
+ * <code>optional .google.protobuf.MethodOptions options = 4;</code>
+ */
+ public function setOptions(&$var)
+ {
+ GPBUtil::checkMessage($var, \Google\Protobuf\Internal\MethodOptions::class);
+ $this->options = $var;
+ $this->has_options = true;
+ }
+
+ public function hasOptions()
+ {
+ return $this->has_options;
+ }
+
+ /**
+ * <pre>
+ * Identifies if client streams multiple client messages
+ * </pre>
+ *
+ * <code>optional bool client_streaming = 5 [default = false];</code>
+ */
+ public function getClientStreaming()
+ {
+ return $this->client_streaming;
+ }
+
+ /**
+ * <pre>
+ * Identifies if client streams multiple client messages
+ * </pre>
+ *
+ * <code>optional bool client_streaming = 5 [default = false];</code>
+ */
+ public function setClientStreaming($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->client_streaming = $var;
+ $this->has_client_streaming = true;
+ }
+
+ public function hasClientStreaming()
+ {
+ return $this->has_client_streaming;
+ }
+
+ /**
+ * <pre>
+ * Identifies if server streams multiple server messages
+ * </pre>
+ *
+ * <code>optional bool server_streaming = 6 [default = false];</code>
+ */
+ public function getServerStreaming()
+ {
+ return $this->server_streaming;
+ }
+
+ /**
+ * <pre>
+ * Identifies if server streams multiple server messages
+ * </pre>
+ *
+ * <code>optional bool server_streaming = 6 [default = false];</code>
+ */
+ public function setServerStreaming($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->server_streaming = $var;
+ $this->has_server_streaming = true;
+ }
+
+ public function hasServerStreaming()
+ {
+ return $this->has_server_streaming;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Internal/MethodOptions.php b/php/src/Google/Protobuf/Internal/MethodOptions.php
new file mode 100644
index 00000000..3325e52b
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/MethodOptions.php
@@ -0,0 +1,143 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\GPBWire;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\InputStream;
+
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Protobuf type <code>google.protobuf.MethodOptions</code>
+ */
+class MethodOptions extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * <pre>
+ * Is this method deprecated?
+ * Depending on the target platform, this can emit Deprecated annotations
+ * for the method, or it will be completely ignored; in the very least,
+ * this is a formalization for deprecating methods.
+ * </pre>
+ *
+ * <code>optional bool deprecated = 33 [default = false];</code>
+ */
+ private $deprecated = false;
+ private $has_deprecated = false;
+ /**
+ * <code>optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];</code>
+ */
+ private $idempotency_level = 0;
+ private $has_idempotency_level = false;
+ /**
+ * <pre>
+ * The parser stores options it doesn't recognize here. See above.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
+ */
+ private $uninterpreted_option;
+ private $has_uninterpreted_option = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * <pre>
+ * Is this method deprecated?
+ * Depending on the target platform, this can emit Deprecated annotations
+ * for the method, or it will be completely ignored; in the very least,
+ * this is a formalization for deprecating methods.
+ * </pre>
+ *
+ * <code>optional bool deprecated = 33 [default = false];</code>
+ */
+ public function getDeprecated()
+ {
+ return $this->deprecated;
+ }
+
+ /**
+ * <pre>
+ * Is this method deprecated?
+ * Depending on the target platform, this can emit Deprecated annotations
+ * for the method, or it will be completely ignored; in the very least,
+ * this is a formalization for deprecating methods.
+ * </pre>
+ *
+ * <code>optional bool deprecated = 33 [default = false];</code>
+ */
+ public function setDeprecated($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->deprecated = $var;
+ $this->has_deprecated = true;
+ }
+
+ public function hasDeprecated()
+ {
+ return $this->has_deprecated;
+ }
+
+ /**
+ * <code>optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];</code>
+ */
+ public function getIdempotencyLevel()
+ {
+ return $this->idempotency_level;
+ }
+
+ /**
+ * <code>optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];</code>
+ */
+ public function setIdempotencyLevel($var)
+ {
+ GPBUtil::checkEnum($var, \Google\Protobuf\Internal\MethodOptions_IdempotencyLevel::class);
+ $this->idempotency_level = $var;
+ $this->has_idempotency_level = true;
+ }
+
+ public function hasIdempotencyLevel()
+ {
+ return $this->has_idempotency_level;
+ }
+
+ /**
+ * <pre>
+ * The parser stores options it doesn't recognize here. See above.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
+ */
+ public function getUninterpretedOption()
+ {
+ return $this->uninterpreted_option;
+ }
+
+ /**
+ * <pre>
+ * The parser stores options it doesn't recognize here. See above.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
+ */
+ public function setUninterpretedOption(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
+ $this->uninterpreted_option = $var;
+ $this->has_uninterpreted_option = true;
+ }
+
+ public function hasUninterpretedOption()
+ {
+ return $this->has_uninterpreted_option;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php b/php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php
new file mode 100644
index 00000000..62768b5c
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php
@@ -0,0 +1,39 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+/**
+ * <pre>
+ * Is this method side-effect-free (or safe in HTTP parlance), or idempotent,
+ * or neither? HTTP based RPC implementation may choose GET verb for safe
+ * methods, and PUT verb for idempotent methods instead of the default POST.
+ * </pre>
+ *
+ * Protobuf enum <code>google.protobuf.MethodOptions.IdempotencyLevel</code>
+ */
+namespace Google\Protobuf\Internal;
+
+class MethodOptions_IdempotencyLevel
+{
+ /**
+ * <code>IDEMPOTENCY_UNKNOWN = 0;</code>
+ */
+ const IDEMPOTENCY_UNKNOWN = 0;
+ /**
+ * <pre>
+ * implies idempotent
+ * </pre>
+ *
+ * <code>NO_SIDE_EFFECTS = 1;</code>
+ */
+ const NO_SIDE_EFFECTS = 1;
+ /**
+ * <pre>
+ * idempotent, but may have side effects
+ * </pre>
+ *
+ * <code>IDEMPOTENT = 2;</code>
+ */
+ const IDEMPOTENT = 2;
+}
+
diff --git a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php
new file mode 100644
index 00000000..e5fbe370
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php
@@ -0,0 +1,86 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\GPBWire;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\InputStream;
+
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * <pre>
+ * Describes a oneof.
+ * </pre>
+ *
+ * Protobuf type <code>google.protobuf.OneofDescriptorProto</code>
+ */
+class OneofDescriptorProto extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * <code>optional string name = 1;</code>
+ */
+ private $name = '';
+ private $has_name = false;
+ /**
+ * <code>optional .google.protobuf.OneofOptions options = 2;</code>
+ */
+ private $options = null;
+ private $has_options = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * <code>optional string name = 1;</code>
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * <code>optional string name = 1;</code>
+ */
+ public function setName($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->name = $var;
+ $this->has_name = true;
+ }
+
+ public function hasName()
+ {
+ return $this->has_name;
+ }
+
+ /**
+ * <code>optional .google.protobuf.OneofOptions options = 2;</code>
+ */
+ public function getOptions()
+ {
+ return $this->options;
+ }
+
+ /**
+ * <code>optional .google.protobuf.OneofOptions options = 2;</code>
+ */
+ public function setOptions(&$var)
+ {
+ GPBUtil::checkMessage($var, \Google\Protobuf\Internal\OneofOptions::class);
+ $this->options = $var;
+ $this->has_options = true;
+ }
+
+ public function hasOptions()
+ {
+ return $this->has_options;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Internal/OneofOptions.php b/php/src/Google/Protobuf/Internal/OneofOptions.php
new file mode 100644
index 00000000..083d9929
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/OneofOptions.php
@@ -0,0 +1,66 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\GPBWire;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\InputStream;
+
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Protobuf type <code>google.protobuf.OneofOptions</code>
+ */
+class OneofOptions extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * <pre>
+ * The parser stores options it doesn't recognize here. See above.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
+ */
+ private $uninterpreted_option;
+ private $has_uninterpreted_option = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * <pre>
+ * The parser stores options it doesn't recognize here. See above.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
+ */
+ public function getUninterpretedOption()
+ {
+ return $this->uninterpreted_option;
+ }
+
+ /**
+ * <pre>
+ * The parser stores options it doesn't recognize here. See above.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
+ */
+ public function setUninterpretedOption(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
+ $this->uninterpreted_option = $var;
+ $this->has_uninterpreted_option = true;
+ }
+
+ public function hasUninterpretedOption()
+ {
+ return $this->has_uninterpreted_option;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php
new file mode 100644
index 00000000..624bde84
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php
@@ -0,0 +1,114 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\GPBWire;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\InputStream;
+
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * <pre>
+ * Describes a service.
+ * </pre>
+ *
+ * Protobuf type <code>google.protobuf.ServiceDescriptorProto</code>
+ */
+class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * <code>optional string name = 1;</code>
+ */
+ private $name = '';
+ private $has_name = false;
+ /**
+ * <code>repeated .google.protobuf.MethodDescriptorProto method = 2;</code>
+ */
+ private $method;
+ private $has_method = false;
+ /**
+ * <code>optional .google.protobuf.ServiceOptions options = 3;</code>
+ */
+ private $options = null;
+ private $has_options = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * <code>optional string name = 1;</code>
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * <code>optional string name = 1;</code>
+ */
+ public function setName($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->name = $var;
+ $this->has_name = true;
+ }
+
+ public function hasName()
+ {
+ return $this->has_name;
+ }
+
+ /**
+ * <code>repeated .google.protobuf.MethodDescriptorProto method = 2;</code>
+ */
+ public function getMethod()
+ {
+ return $this->method;
+ }
+
+ /**
+ * <code>repeated .google.protobuf.MethodDescriptorProto method = 2;</code>
+ */
+ public function setMethod(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\MethodDescriptorProto::class);
+ $this->method = $var;
+ $this->has_method = true;
+ }
+
+ public function hasMethod()
+ {
+ return $this->has_method;
+ }
+
+ /**
+ * <code>optional .google.protobuf.ServiceOptions options = 3;</code>
+ */
+ public function getOptions()
+ {
+ return $this->options;
+ }
+
+ /**
+ * <code>optional .google.protobuf.ServiceOptions options = 3;</code>
+ */
+ public function setOptions(&$var)
+ {
+ GPBUtil::checkMessage($var, \Google\Protobuf\Internal\ServiceOptions::class);
+ $this->options = $var;
+ $this->has_options = true;
+ }
+
+ public function hasOptions()
+ {
+ return $this->has_options;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Internal/ServiceOptions.php b/php/src/Google/Protobuf/Internal/ServiceOptions.php
new file mode 100644
index 00000000..5f3564e4
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/ServiceOptions.php
@@ -0,0 +1,115 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\GPBWire;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\InputStream;
+
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Protobuf type <code>google.protobuf.ServiceOptions</code>
+ */
+class ServiceOptions extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * <pre>
+ * Is this service deprecated?
+ * Depending on the target platform, this can emit Deprecated annotations
+ * for the service, or it will be completely ignored; in the very least,
+ * this is a formalization for deprecating services.
+ * </pre>
+ *
+ * <code>optional bool deprecated = 33 [default = false];</code>
+ */
+ private $deprecated = false;
+ private $has_deprecated = false;
+ /**
+ * <pre>
+ * The parser stores options it doesn't recognize here. See above.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
+ */
+ private $uninterpreted_option;
+ private $has_uninterpreted_option = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * <pre>
+ * Is this service deprecated?
+ * Depending on the target platform, this can emit Deprecated annotations
+ * for the service, or it will be completely ignored; in the very least,
+ * this is a formalization for deprecating services.
+ * </pre>
+ *
+ * <code>optional bool deprecated = 33 [default = false];</code>
+ */
+ public function getDeprecated()
+ {
+ return $this->deprecated;
+ }
+
+ /**
+ * <pre>
+ * Is this service deprecated?
+ * Depending on the target platform, this can emit Deprecated annotations
+ * for the service, or it will be completely ignored; in the very least,
+ * this is a formalization for deprecating services.
+ * </pre>
+ *
+ * <code>optional bool deprecated = 33 [default = false];</code>
+ */
+ public function setDeprecated($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->deprecated = $var;
+ $this->has_deprecated = true;
+ }
+
+ public function hasDeprecated()
+ {
+ return $this->has_deprecated;
+ }
+
+ /**
+ * <pre>
+ * The parser stores options it doesn't recognize here. See above.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
+ */
+ public function getUninterpretedOption()
+ {
+ return $this->uninterpreted_option;
+ }
+
+ /**
+ * <pre>
+ * The parser stores options it doesn't recognize here. See above.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code>
+ */
+ public function setUninterpretedOption(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
+ $this->uninterpreted_option = $var;
+ $this->has_uninterpreted_option = true;
+ }
+
+ public function hasUninterpretedOption()
+ {
+ return $this->has_uninterpreted_option;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Internal/SourceCodeInfo.php b/php/src/Google/Protobuf/Internal/SourceCodeInfo.php
new file mode 100644
index 00000000..d2352ddd
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/SourceCodeInfo.php
@@ -0,0 +1,191 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\GPBWire;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\InputStream;
+
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * <pre>
+ * Encapsulates information about the original source file from which a
+ * FileDescriptorProto was generated.
+ * </pre>
+ *
+ * Protobuf type <code>google.protobuf.SourceCodeInfo</code>
+ */
+class SourceCodeInfo extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * <pre>
+ * A Location identifies a piece of source code in a .proto file which
+ * corresponds to a particular definition. This information is intended
+ * to be useful to IDEs, code indexers, documentation generators, and similar
+ * tools.
+ * For example, say we have a file like:
+ * message Foo {
+ * optional string foo = 1;
+ * }
+ * Let's look at just the field definition:
+ * optional string foo = 1;
+ * ^ ^^ ^^ ^ ^^^
+ * a bc de f ghi
+ * We have the following locations:
+ * span path represents
+ * [a,i) [ 4, 0, 2, 0 ] The whole field definition.
+ * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional).
+ * [c,d) [ 4, 0, 2, 0, 5 ] The type (string).
+ * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo).
+ * [g,h) [ 4, 0, 2, 0, 3 ] The number (1).
+ * Notes:
+ * - A location may refer to a repeated field itself (i.e. not to any
+ * particular index within it). This is used whenever a set of elements are
+ * logically enclosed in a single code segment. For example, an entire
+ * extend block (possibly containing multiple extension definitions) will
+ * have an outer location whose path refers to the "extensions" repeated
+ * field without an index.
+ * - Multiple locations may have the same path. This happens when a single
+ * logical declaration is spread out across multiple places. The most
+ * obvious example is the "extend" block again -- there may be multiple
+ * extend blocks in the same scope, each of which will have the same path.
+ * - A location's span is not always a subset of its parent's span. For
+ * example, the "extendee" of an extension declaration appears at the
+ * beginning of the "extend" block and is shared by all extensions within
+ * the block.
+ * - Just because a location's span is a subset of some other location's span
+ * does not mean that it is a descendent. For example, a "group" defines
+ * both a type and a field in a single declaration. Thus, the locations
+ * corresponding to the type and field and their components will overlap.
+ * - Code which tries to interpret locations should probably be designed to
+ * ignore those that it doesn't understand, as more types of locations could
+ * be recorded in the future.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.SourceCodeInfo.Location location = 1;</code>
+ */
+ private $location;
+ private $has_location = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * <pre>
+ * A Location identifies a piece of source code in a .proto file which
+ * corresponds to a particular definition. This information is intended
+ * to be useful to IDEs, code indexers, documentation generators, and similar
+ * tools.
+ * For example, say we have a file like:
+ * message Foo {
+ * optional string foo = 1;
+ * }
+ * Let's look at just the field definition:
+ * optional string foo = 1;
+ * ^ ^^ ^^ ^ ^^^
+ * a bc de f ghi
+ * We have the following locations:
+ * span path represents
+ * [a,i) [ 4, 0, 2, 0 ] The whole field definition.
+ * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional).
+ * [c,d) [ 4, 0, 2, 0, 5 ] The type (string).
+ * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo).
+ * [g,h) [ 4, 0, 2, 0, 3 ] The number (1).
+ * Notes:
+ * - A location may refer to a repeated field itself (i.e. not to any
+ * particular index within it). This is used whenever a set of elements are
+ * logically enclosed in a single code segment. For example, an entire
+ * extend block (possibly containing multiple extension definitions) will
+ * have an outer location whose path refers to the "extensions" repeated
+ * field without an index.
+ * - Multiple locations may have the same path. This happens when a single
+ * logical declaration is spread out across multiple places. The most
+ * obvious example is the "extend" block again -- there may be multiple
+ * extend blocks in the same scope, each of which will have the same path.
+ * - A location's span is not always a subset of its parent's span. For
+ * example, the "extendee" of an extension declaration appears at the
+ * beginning of the "extend" block and is shared by all extensions within
+ * the block.
+ * - Just because a location's span is a subset of some other location's span
+ * does not mean that it is a descendent. For example, a "group" defines
+ * both a type and a field in a single declaration. Thus, the locations
+ * corresponding to the type and field and their components will overlap.
+ * - Code which tries to interpret locations should probably be designed to
+ * ignore those that it doesn't understand, as more types of locations could
+ * be recorded in the future.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.SourceCodeInfo.Location location = 1;</code>
+ */
+ public function getLocation()
+ {
+ return $this->location;
+ }
+
+ /**
+ * <pre>
+ * A Location identifies a piece of source code in a .proto file which
+ * corresponds to a particular definition. This information is intended
+ * to be useful to IDEs, code indexers, documentation generators, and similar
+ * tools.
+ * For example, say we have a file like:
+ * message Foo {
+ * optional string foo = 1;
+ * }
+ * Let's look at just the field definition:
+ * optional string foo = 1;
+ * ^ ^^ ^^ ^ ^^^
+ * a bc de f ghi
+ * We have the following locations:
+ * span path represents
+ * [a,i) [ 4, 0, 2, 0 ] The whole field definition.
+ * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional).
+ * [c,d) [ 4, 0, 2, 0, 5 ] The type (string).
+ * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo).
+ * [g,h) [ 4, 0, 2, 0, 3 ] The number (1).
+ * Notes:
+ * - A location may refer to a repeated field itself (i.e. not to any
+ * particular index within it). This is used whenever a set of elements are
+ * logically enclosed in a single code segment. For example, an entire
+ * extend block (possibly containing multiple extension definitions) will
+ * have an outer location whose path refers to the "extensions" repeated
+ * field without an index.
+ * - Multiple locations may have the same path. This happens when a single
+ * logical declaration is spread out across multiple places. The most
+ * obvious example is the "extend" block again -- there may be multiple
+ * extend blocks in the same scope, each of which will have the same path.
+ * - A location's span is not always a subset of its parent's span. For
+ * example, the "extendee" of an extension declaration appears at the
+ * beginning of the "extend" block and is shared by all extensions within
+ * the block.
+ * - Just because a location's span is a subset of some other location's span
+ * does not mean that it is a descendent. For example, a "group" defines
+ * both a type and a field in a single declaration. Thus, the locations
+ * corresponding to the type and field and their components will overlap.
+ * - Code which tries to interpret locations should probably be designed to
+ * ignore those that it doesn't understand, as more types of locations could
+ * be recorded in the future.
+ * </pre>
+ *
+ * <code>repeated .google.protobuf.SourceCodeInfo.Location location = 1;</code>
+ */
+ public function setLocation(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\SourceCodeInfo_Location::class);
+ $this->location = $var;
+ $this->has_location = true;
+ }
+
+ public function hasLocation()
+ {
+ return $this->has_location;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php b/php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php
new file mode 100644
index 00000000..d1bdb166
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php
@@ -0,0 +1,379 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\GPBWire;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\InputStream;
+
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Protobuf type <code>google.protobuf.SourceCodeInfo.Location</code>
+ */
+class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * <pre>
+ * Identifies which part of the FileDescriptorProto was defined at this
+ * location.
+ * Each element is a field number or an index. They form a path from
+ * the root FileDescriptorProto to the place where the definition. For
+ * example, this path:
+ * [ 4, 3, 2, 7, 1 ]
+ * refers to:
+ * file.message_type(3) // 4, 3
+ * .field(7) // 2, 7
+ * .name() // 1
+ * This is because FileDescriptorProto.message_type has field number 4:
+ * repeated DescriptorProto message_type = 4;
+ * and DescriptorProto.field has field number 2:
+ * repeated FieldDescriptorProto field = 2;
+ * and FieldDescriptorProto.name has field number 1:
+ * optional string name = 1;
+ * Thus, the above path gives the location of a field name. If we removed
+ * the last element:
+ * [ 4, 3, 2, 7 ]
+ * this path refers to the whole field declaration (from the beginning
+ * of the label to the terminating semicolon).
+ * </pre>
+ *
+ * <code>repeated int32 path = 1 [packed = true];</code>
+ */
+ private $path;
+ private $has_path = false;
+ /**
+ * <pre>
+ * Always has exactly three or four elements: start line, start column,
+ * end line (optional, otherwise assumed same as start line), end column.
+ * These are packed into a single field for efficiency. Note that line
+ * and column numbers are zero-based -- typically you will want to add
+ * 1 to each before displaying to a user.
+ * </pre>
+ *
+ * <code>repeated int32 span = 2 [packed = true];</code>
+ */
+ private $span;
+ private $has_span = false;
+ /**
+ * <pre>
+ * If this SourceCodeInfo represents a complete declaration, these are any
+ * comments appearing before and after the declaration which appear to be
+ * attached to the declaration.
+ * A series of line comments appearing on consecutive lines, with no other
+ * tokens appearing on those lines, will be treated as a single comment.
+ * leading_detached_comments will keep paragraphs of comments that appear
+ * before (but not connected to) the current element. Each paragraph,
+ * separated by empty lines, will be one comment element in the repeated
+ * field.
+ * Only the comment content is provided; comment markers (e.g. //) are
+ * stripped out. For block comments, leading whitespace and an asterisk
+ * will be stripped from the beginning of each line other than the first.
+ * Newlines are included in the output.
+ * Examples:
+ * optional int32 foo = 1; // Comment attached to foo.
+ * // Comment attached to bar.
+ * optional int32 bar = 2;
+ * optional string baz = 3;
+ * // Comment attached to baz.
+ * // Another line attached to baz.
+ * // Comment attached to qux.
+ * //
+ * // Another line attached to qux.
+ * optional double qux = 4;
+ * // Detached comment for corge. This is not leading or trailing comments
+ * // to qux or corge because there are blank lines separating it from
+ * // both.
+ * // Detached comment for corge paragraph 2.
+ * optional string corge = 5;
+ * /&#42; Block comment attached
+ * * to corge. Leading asterisks
+ * * will be removed. *&#47;
+ * /&#42; Block comment attached to
+ * * grault. *&#47;
+ * optional int32 grault = 6;
+ * // ignored detached comments.
+ * </pre>
+ *
+ * <code>optional string leading_comments = 3;</code>
+ */
+ private $leading_comments = '';
+ private $has_leading_comments = false;
+ /**
+ * <code>optional string trailing_comments = 4;</code>
+ */
+ private $trailing_comments = '';
+ private $has_trailing_comments = false;
+ /**
+ * <code>repeated string leading_detached_comments = 6;</code>
+ */
+ private $leading_detached_comments;
+ private $has_leading_detached_comments = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * <pre>
+ * Identifies which part of the FileDescriptorProto was defined at this
+ * location.
+ * Each element is a field number or an index. They form a path from
+ * the root FileDescriptorProto to the place where the definition. For
+ * example, this path:
+ * [ 4, 3, 2, 7, 1 ]
+ * refers to:
+ * file.message_type(3) // 4, 3
+ * .field(7) // 2, 7
+ * .name() // 1
+ * This is because FileDescriptorProto.message_type has field number 4:
+ * repeated DescriptorProto message_type = 4;
+ * and DescriptorProto.field has field number 2:
+ * repeated FieldDescriptorProto field = 2;
+ * and FieldDescriptorProto.name has field number 1:
+ * optional string name = 1;
+ * Thus, the above path gives the location of a field name. If we removed
+ * the last element:
+ * [ 4, 3, 2, 7 ]
+ * this path refers to the whole field declaration (from the beginning
+ * of the label to the terminating semicolon).
+ * </pre>
+ *
+ * <code>repeated int32 path = 1 [packed = true];</code>
+ */
+ public function getPath()
+ {
+ return $this->path;
+ }
+
+ /**
+ * <pre>
+ * Identifies which part of the FileDescriptorProto was defined at this
+ * location.
+ * Each element is a field number or an index. They form a path from
+ * the root FileDescriptorProto to the place where the definition. For
+ * example, this path:
+ * [ 4, 3, 2, 7, 1 ]
+ * refers to:
+ * file.message_type(3) // 4, 3
+ * .field(7) // 2, 7
+ * .name() // 1
+ * This is because FileDescriptorProto.message_type has field number 4:
+ * repeated DescriptorProto message_type = 4;
+ * and DescriptorProto.field has field number 2:
+ * repeated FieldDescriptorProto field = 2;
+ * and FieldDescriptorProto.name has field number 1:
+ * optional string name = 1;
+ * Thus, the above path gives the location of a field name. If we removed
+ * the last element:
+ * [ 4, 3, 2, 7 ]
+ * this path refers to the whole field declaration (from the beginning
+ * of the label to the terminating semicolon).
+ * </pre>
+ *
+ * <code>repeated int32 path = 1 [packed = true];</code>
+ */
+ public function setPath(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
+ $this->path = $var;
+ $this->has_path = true;
+ }
+
+ public function hasPath()
+ {
+ return $this->has_path;
+ }
+
+ /**
+ * <pre>
+ * Always has exactly three or four elements: start line, start column,
+ * end line (optional, otherwise assumed same as start line), end column.
+ * These are packed into a single field for efficiency. Note that line
+ * and column numbers are zero-based -- typically you will want to add
+ * 1 to each before displaying to a user.
+ * </pre>
+ *
+ * <code>repeated int32 span = 2 [packed = true];</code>
+ */
+ public function getSpan()
+ {
+ return $this->span;
+ }
+
+ /**
+ * <pre>
+ * Always has exactly three or four elements: start line, start column,
+ * end line (optional, otherwise assumed same as start line), end column.
+ * These are packed into a single field for efficiency. Note that line
+ * and column numbers are zero-based -- typically you will want to add
+ * 1 to each before displaying to a user.
+ * </pre>
+ *
+ * <code>repeated int32 span = 2 [packed = true];</code>
+ */
+ public function setSpan(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
+ $this->span = $var;
+ $this->has_span = true;
+ }
+
+ public function hasSpan()
+ {
+ return $this->has_span;
+ }
+
+ /**
+ * <pre>
+ * If this SourceCodeInfo represents a complete declaration, these are any
+ * comments appearing before and after the declaration which appear to be
+ * attached to the declaration.
+ * A series of line comments appearing on consecutive lines, with no other
+ * tokens appearing on those lines, will be treated as a single comment.
+ * leading_detached_comments will keep paragraphs of comments that appear
+ * before (but not connected to) the current element. Each paragraph,
+ * separated by empty lines, will be one comment element in the repeated
+ * field.
+ * Only the comment content is provided; comment markers (e.g. //) are
+ * stripped out. For block comments, leading whitespace and an asterisk
+ * will be stripped from the beginning of each line other than the first.
+ * Newlines are included in the output.
+ * Examples:
+ * optional int32 foo = 1; // Comment attached to foo.
+ * // Comment attached to bar.
+ * optional int32 bar = 2;
+ * optional string baz = 3;
+ * // Comment attached to baz.
+ * // Another line attached to baz.
+ * // Comment attached to qux.
+ * //
+ * // Another line attached to qux.
+ * optional double qux = 4;
+ * // Detached comment for corge. This is not leading or trailing comments
+ * // to qux or corge because there are blank lines separating it from
+ * // both.
+ * // Detached comment for corge paragraph 2.
+ * optional string corge = 5;
+ * /&#42; Block comment attached
+ * * to corge. Leading asterisks
+ * * will be removed. *&#47;
+ * /&#42; Block comment attached to
+ * * grault. *&#47;
+ * optional int32 grault = 6;
+ * // ignored detached comments.
+ * </pre>
+ *
+ * <code>optional string leading_comments = 3;</code>
+ */
+ public function getLeadingComments()
+ {
+ return $this->leading_comments;
+ }
+
+ /**
+ * <pre>
+ * If this SourceCodeInfo represents a complete declaration, these are any
+ * comments appearing before and after the declaration which appear to be
+ * attached to the declaration.
+ * A series of line comments appearing on consecutive lines, with no other
+ * tokens appearing on those lines, will be treated as a single comment.
+ * leading_detached_comments will keep paragraphs of comments that appear
+ * before (but not connected to) the current element. Each paragraph,
+ * separated by empty lines, will be one comment element in the repeated
+ * field.
+ * Only the comment content is provided; comment markers (e.g. //) are
+ * stripped out. For block comments, leading whitespace and an asterisk
+ * will be stripped from the beginning of each line other than the first.
+ * Newlines are included in the output.
+ * Examples:
+ * optional int32 foo = 1; // Comment attached to foo.
+ * // Comment attached to bar.
+ * optional int32 bar = 2;
+ * optional string baz = 3;
+ * // Comment attached to baz.
+ * // Another line attached to baz.
+ * // Comment attached to qux.
+ * //
+ * // Another line attached to qux.
+ * optional double qux = 4;
+ * // Detached comment for corge. This is not leading or trailing comments
+ * // to qux or corge because there are blank lines separating it from
+ * // both.
+ * // Detached comment for corge paragraph 2.
+ * optional string corge = 5;
+ * /&#42; Block comment attached
+ * * to corge. Leading asterisks
+ * * will be removed. *&#47;
+ * /&#42; Block comment attached to
+ * * grault. *&#47;
+ * optional int32 grault = 6;
+ * // ignored detached comments.
+ * </pre>
+ *
+ * <code>optional string leading_comments = 3;</code>
+ */
+ public function setLeadingComments($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->leading_comments = $var;
+ $this->has_leading_comments = true;
+ }
+
+ public function hasLeadingComments()
+ {
+ return $this->has_leading_comments;
+ }
+
+ /**
+ * <code>optional string trailing_comments = 4;</code>
+ */
+ public function getTrailingComments()
+ {
+ return $this->trailing_comments;
+ }
+
+ /**
+ * <code>optional string trailing_comments = 4;</code>
+ */
+ public function setTrailingComments($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->trailing_comments = $var;
+ $this->has_trailing_comments = true;
+ }
+
+ public function hasTrailingComments()
+ {
+ return $this->has_trailing_comments;
+ }
+
+ /**
+ * <code>repeated string leading_detached_comments = 6;</code>
+ */
+ public function getLeadingDetachedComments()
+ {
+ return $this->leading_detached_comments;
+ }
+
+ /**
+ * <code>repeated string leading_detached_comments = 6;</code>
+ */
+ public function setLeadingDetachedComments(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
+ $this->leading_detached_comments = $var;
+ $this->has_leading_detached_comments = true;
+ }
+
+ public function hasLeadingDetachedComments()
+ {
+ return $this->has_leading_detached_comments;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Internal/UninterpretedOption.php b/php/src/Google/Protobuf/Internal/UninterpretedOption.php
new file mode 100644
index 00000000..c0f48310
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/UninterpretedOption.php
@@ -0,0 +1,246 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\GPBWire;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\InputStream;
+
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * <pre>
+ * A message representing a option the parser does not recognize. This only
+ * appears in options protos created by the compiler::Parser class.
+ * DescriptorPool resolves these when building Descriptor objects. Therefore,
+ * options protos in descriptor objects (e.g. returned by Descriptor::options(),
+ * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions
+ * in them.
+ * </pre>
+ *
+ * Protobuf type <code>google.protobuf.UninterpretedOption</code>
+ */
+class UninterpretedOption extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * <code>repeated .google.protobuf.UninterpretedOption.NamePart name = 2;</code>
+ */
+ private $name;
+ private $has_name = false;
+ /**
+ * <pre>
+ * The value of the uninterpreted option, in whatever type the tokenizer
+ * identified it as during parsing. Exactly one of these should be set.
+ * </pre>
+ *
+ * <code>optional string identifier_value = 3;</code>
+ */
+ private $identifier_value = '';
+ private $has_identifier_value = false;
+ /**
+ * <code>optional uint64 positive_int_value = 4;</code>
+ */
+ private $positive_int_value = 0;
+ private $has_positive_int_value = false;
+ /**
+ * <code>optional int64 negative_int_value = 5;</code>
+ */
+ private $negative_int_value = 0;
+ private $has_negative_int_value = false;
+ /**
+ * <code>optional double double_value = 6;</code>
+ */
+ private $double_value = 0.0;
+ private $has_double_value = false;
+ /**
+ * <code>optional bytes string_value = 7;</code>
+ */
+ private $string_value = '';
+ private $has_string_value = false;
+ /**
+ * <code>optional string aggregate_value = 8;</code>
+ */
+ private $aggregate_value = '';
+ private $has_aggregate_value = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * <code>repeated .google.protobuf.UninterpretedOption.NamePart name = 2;</code>
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * <code>repeated .google.protobuf.UninterpretedOption.NamePart name = 2;</code>
+ */
+ public function setName(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption_NamePart::class);
+ $this->name = $var;
+ $this->has_name = true;
+ }
+
+ public function hasName()
+ {
+ return $this->has_name;
+ }
+
+ /**
+ * <pre>
+ * The value of the uninterpreted option, in whatever type the tokenizer
+ * identified it as during parsing. Exactly one of these should be set.
+ * </pre>
+ *
+ * <code>optional string identifier_value = 3;</code>
+ */
+ public function getIdentifierValue()
+ {
+ return $this->identifier_value;
+ }
+
+ /**
+ * <pre>
+ * The value of the uninterpreted option, in whatever type the tokenizer
+ * identified it as during parsing. Exactly one of these should be set.
+ * </pre>
+ *
+ * <code>optional string identifier_value = 3;</code>
+ */
+ public function setIdentifierValue($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->identifier_value = $var;
+ $this->has_identifier_value = true;
+ }
+
+ public function hasIdentifierValue()
+ {
+ return $this->has_identifier_value;
+ }
+
+ /**
+ * <code>optional uint64 positive_int_value = 4;</code>
+ */
+ public function getPositiveIntValue()
+ {
+ return $this->positive_int_value;
+ }
+
+ /**
+ * <code>optional uint64 positive_int_value = 4;</code>
+ */
+ public function setPositiveIntValue($var)
+ {
+ GPBUtil::checkUint64($var);
+ $this->positive_int_value = $var;
+ $this->has_positive_int_value = true;
+ }
+
+ public function hasPositiveIntValue()
+ {
+ return $this->has_positive_int_value;
+ }
+
+ /**
+ * <code>optional int64 negative_int_value = 5;</code>
+ */
+ public function getNegativeIntValue()
+ {
+ return $this->negative_int_value;
+ }
+
+ /**
+ * <code>optional int64 negative_int_value = 5;</code>
+ */
+ public function setNegativeIntValue($var)
+ {
+ GPBUtil::checkInt64($var);
+ $this->negative_int_value = $var;
+ $this->has_negative_int_value = true;
+ }
+
+ public function hasNegativeIntValue()
+ {
+ return $this->has_negative_int_value;
+ }
+
+ /**
+ * <code>optional double double_value = 6;</code>
+ */
+ public function getDoubleValue()
+ {
+ return $this->double_value;
+ }
+
+ /**
+ * <code>optional double double_value = 6;</code>
+ */
+ public function setDoubleValue($var)
+ {
+ GPBUtil::checkDouble($var);
+ $this->double_value = $var;
+ $this->has_double_value = true;
+ }
+
+ public function hasDoubleValue()
+ {
+ return $this->has_double_value;
+ }
+
+ /**
+ * <code>optional bytes string_value = 7;</code>
+ */
+ public function getStringValue()
+ {
+ return $this->string_value;
+ }
+
+ /**
+ * <code>optional bytes string_value = 7;</code>
+ */
+ public function setStringValue($var)
+ {
+ GPBUtil::checkString($var, False);
+ $this->string_value = $var;
+ $this->has_string_value = true;
+ }
+
+ public function hasStringValue()
+ {
+ return $this->has_string_value;
+ }
+
+ /**
+ * <code>optional string aggregate_value = 8;</code>
+ */
+ public function getAggregateValue()
+ {
+ return $this->aggregate_value;
+ }
+
+ /**
+ * <code>optional string aggregate_value = 8;</code>
+ */
+ public function setAggregateValue($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->aggregate_value = $var;
+ $this->has_aggregate_value = true;
+ }
+
+ public function hasAggregateValue()
+ {
+ return $this->has_aggregate_value;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php b/php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php
new file mode 100644
index 00000000..86484d23
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php
@@ -0,0 +1,90 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\GPBWire;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\InputStream;
+
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * <pre>
+ * The name of the uninterpreted option. Each string represents a segment in
+ * a dot-separated name. is_extension is true iff a segment represents an
+ * extension (denoted with parentheses in options specs in .proto files).
+ * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents
+ * "foo.(bar.baz).qux".
+ * </pre>
+ *
+ * Protobuf type <code>google.protobuf.UninterpretedOption.NamePart</code>
+ */
+class UninterpretedOption_NamePart extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * <code>required string name_part = 1;</code>
+ */
+ private $name_part = '';
+ private $has_name_part = false;
+ /**
+ * <code>required bool is_extension = 2;</code>
+ */
+ private $is_extension = false;
+ private $has_is_extension = false;
+
+ public function __construct() {
+ \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce();
+ parent::__construct();
+ }
+
+ /**
+ * <code>required string name_part = 1;</code>
+ */
+ public function getNamePart()
+ {
+ return $this->name_part;
+ }
+
+ /**
+ * <code>required string name_part = 1;</code>
+ */
+ public function setNamePart($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->name_part = $var;
+ $this->has_name_part = true;
+ }
+
+ public function hasNamePart()
+ {
+ return $this->has_name_part;
+ }
+
+ /**
+ * <code>required bool is_extension = 2;</code>
+ */
+ public function getIsExtension()
+ {
+ return $this->is_extension;
+ }
+
+ /**
+ * <code>required bool is_extension = 2;</code>
+ */
+ public function setIsExtension($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->is_extension = $var;
+ $this->has_is_extension = true;
+ }
+
+ public function hasIsExtension()
+ {
+ return $this->has_is_extension;
+ }
+
+}
+
diff --git a/php/src/Google/Protobuf/descriptor.php b/php/src/Google/Protobuf/descriptor.php
index e5cff0ba..9e56ef27 100644
--- a/php/src/Google/Protobuf/descriptor.php
+++ b/php/src/Google/Protobuf/descriptor.php
@@ -155,7 +155,11 @@ class Descriptor
public function getFieldByNumber($number)
{
+ if (!isset($this->field[$number])) {
+ return NULL;
+ } else {
return $this->field[$number];
+ }
}
public function setClass($klass)
@@ -215,6 +219,18 @@ class Descriptor
return $desc;
}
}
+
+function addPrefixIfSpecial(
+ $name,
+ $package)
+{
+ if ($name === "Empty" && $package === "google.protobuf") {
+ return "GPBEmpty";
+ } else {
+ return $name;
+ }
+}
+
function getFullClassName(
$proto,
$containing,
@@ -224,7 +240,8 @@ function getFullClassName(
&$fullname)
{
// Full name needs to start with '.'.
- $message_name_without_package = $proto->getName();
+ $message_name_without_package =
+ addPrefixIfSpecial($proto->getName(), $package);
if ($containing !== "") {
$message_name_without_package =
$containing . "." . $message_name_without_package;
diff --git a/php/src/Google/Protobuf/descriptor_internal.pb.php b/php/src/Google/Protobuf/descriptor_internal.pb.php
deleted file mode 100644
index 161a9f52..00000000
--- a/php/src/Google/Protobuf/descriptor_internal.pb.php
+++ /dev/null
@@ -1,2532 +0,0 @@
-<?php
-# Generated by the protocol buffer compiler. DO NOT EDIT!
-# source: google/protobuf/descriptor.proto
-
-namespace Google\Protobuf\Internal;
-
-use Google\Protobuf\Internal\DescriptorPool;
-use Google\Protobuf\Internal\GPBType;
-use Google\Protobuf\Internal\GPBWire;
-use Google\Protobuf\Internal\RepeatedField;
-use Google\Protobuf\Internal\InputStream;
-
-use Google\Protobuf\Internal\GPBUtil;
-
-class FileDescriptorSet extends \Google\Protobuf\Internal\Message
-{
- private $file;
- private $has_file = false;
-
- public function getFile()
- {
- return $this->file;
- }
-
- public function setFile(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\FileDescriptorProto::class);
- $this->file = $var;
- $this->has_file = true;
- }
-
- public function hasFile()
- {
- return $this->has_file;
- }
-
-}
-
-class FileDescriptorProto extends \Google\Protobuf\Internal\Message
-{
- private $name = '';
- private $has_name = false;
- private $package = '';
- private $has_package = false;
- private $dependency;
- private $has_dependency = false;
- private $public_dependency;
- private $has_public_dependency = false;
- private $weak_dependency;
- private $has_weak_dependency = false;
- private $message_type;
- private $has_message_type = false;
- private $enum_type;
- private $has_enum_type = false;
- private $service;
- private $has_service = false;
- private $extension;
- private $has_extension = false;
- private $options = null;
- private $has_options = false;
- private $source_code_info = null;
- private $has_source_code_info = false;
- private $syntax = '';
- private $has_syntax = false;
-
- public function getName()
- {
- return $this->name;
- }
-
- public function setName($var)
- {
- GPBUtil::checkString($var, True);
- $this->name = $var;
- $this->has_name = true;
- }
-
- public function hasName()
- {
- return $this->has_name;
- }
-
- public function getPackage()
- {
- return $this->package;
- }
-
- public function setPackage($var)
- {
- GPBUtil::checkString($var, True);
- $this->package = $var;
- $this->has_package = true;
- }
-
- public function hasPackage()
- {
- return $this->has_package;
- }
-
- public function getDependency()
- {
- return $this->dependency;
- }
-
- public function setDependency(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::STRING);
- $this->dependency = $var;
- $this->has_dependency = true;
- }
-
- public function hasDependency()
- {
- return $this->has_dependency;
- }
-
- public function getPublicDependency()
- {
- return $this->public_dependency;
- }
-
- public function setPublicDependency(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::INT32);
- $this->public_dependency = $var;
- $this->has_public_dependency = true;
- }
-
- public function hasPublicDependency()
- {
- return $this->has_public_dependency;
- }
-
- public function getWeakDependency()
- {
- return $this->weak_dependency;
- }
-
- public function setWeakDependency(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::INT32);
- $this->weak_dependency = $var;
- $this->has_weak_dependency = true;
- }
-
- public function hasWeakDependency()
- {
- return $this->has_weak_dependency;
- }
-
- public function getMessageType()
- {
- return $this->message_type;
- }
-
- public function setMessageType(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto::class);
- $this->message_type = $var;
- $this->has_message_type = true;
- }
-
- public function hasMessageType()
- {
- return $this->has_message_type;
- }
-
- public function getEnumType()
- {
- return $this->enum_type;
- }
-
- public function setEnumType(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\EnumDescriptorProto::class);
- $this->enum_type = $var;
- $this->has_enum_type = true;
- }
-
- public function hasEnumType()
- {
- return $this->has_enum_type;
- }
-
- public function getService()
- {
- return $this->service;
- }
-
- public function setService(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\ServiceDescriptorProto::class);
- $this->service = $var;
- $this->has_service = true;
- }
-
- public function hasService()
- {
- return $this->has_service;
- }
-
- public function getExtension()
- {
- return $this->extension;
- }
-
- public function setExtension(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class);
- $this->extension = $var;
- $this->has_extension = true;
- }
-
- public function hasExtension()
- {
- return $this->has_extension;
- }
-
- public function getOptions()
- {
- return $this->options;
- }
-
- public function setOptions(&$var)
- {
- GPBUtil::checkMessage($var, \Google\Protobuf\Internal\FileOptions::class);
- $this->options = $var;
- $this->has_options = true;
- }
-
- public function hasOptions()
- {
- return $this->has_options;
- }
-
- public function getSourceCodeInfo()
- {
- return $this->source_code_info;
- }
-
- public function setSourceCodeInfo(&$var)
- {
- GPBUtil::checkMessage($var, \Google\Protobuf\Internal\SourceCodeInfo::class);
- $this->source_code_info = $var;
- $this->has_source_code_info = true;
- }
-
- public function hasSourceCodeInfo()
- {
- return $this->has_source_code_info;
- }
-
- public function getSyntax()
- {
- return $this->syntax;
- }
-
- public function setSyntax($var)
- {
- GPBUtil::checkString($var, True);
- $this->syntax = $var;
- $this->has_syntax = true;
- }
-
- public function hasSyntax()
- {
- return $this->has_syntax;
- }
-
-}
-
-class DescriptorProto extends \Google\Protobuf\Internal\Message
-{
- private $name = '';
- private $has_name = false;
- private $field;
- private $has_field = false;
- private $extension;
- private $has_extension = false;
- private $nested_type;
- private $has_nested_type = false;
- private $enum_type;
- private $has_enum_type = false;
- private $extension_range;
- private $has_extension_range = false;
- private $oneof_decl;
- private $has_oneof_decl = false;
- private $options = null;
- private $has_options = false;
- private $reserved_range;
- private $has_reserved_range = false;
- private $reserved_name;
- private $has_reserved_name = false;
-
- public function getName()
- {
- return $this->name;
- }
-
- public function setName($var)
- {
- GPBUtil::checkString($var, True);
- $this->name = $var;
- $this->has_name = true;
- }
-
- public function hasName()
- {
- return $this->has_name;
- }
-
- public function getField()
- {
- return $this->field;
- }
-
- public function setField(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class);
- $this->field = $var;
- $this->has_field = true;
- }
-
- public function hasField()
- {
- return $this->has_field;
- }
-
- public function getExtension()
- {
- return $this->extension;
- }
-
- public function setExtension(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class);
- $this->extension = $var;
- $this->has_extension = true;
- }
-
- public function hasExtension()
- {
- return $this->has_extension;
- }
-
- public function getNestedType()
- {
- return $this->nested_type;
- }
-
- public function setNestedType(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto::class);
- $this->nested_type = $var;
- $this->has_nested_type = true;
- }
-
- public function hasNestedType()
- {
- return $this->has_nested_type;
- }
-
- public function getEnumType()
- {
- return $this->enum_type;
- }
-
- public function setEnumType(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\EnumDescriptorProto::class);
- $this->enum_type = $var;
- $this->has_enum_type = true;
- }
-
- public function hasEnumType()
- {
- return $this->has_enum_type;
- }
-
- public function getExtensionRange()
- {
- return $this->extension_range;
- }
-
- public function setExtensionRange(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto_ExtensionRange::class);
- $this->extension_range = $var;
- $this->has_extension_range = true;
- }
-
- public function hasExtensionRange()
- {
- return $this->has_extension_range;
- }
-
- public function getOneofDecl()
- {
- return $this->oneof_decl;
- }
-
- public function setOneofDecl(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\OneofDescriptorProto::class);
- $this->oneof_decl = $var;
- $this->has_oneof_decl = true;
- }
-
- public function hasOneofDecl()
- {
- return $this->has_oneof_decl;
- }
-
- public function getOptions()
- {
- return $this->options;
- }
-
- public function setOptions(&$var)
- {
- GPBUtil::checkMessage($var, \Google\Protobuf\Internal\MessageOptions::class);
- $this->options = $var;
- $this->has_options = true;
- }
-
- public function hasOptions()
- {
- return $this->has_options;
- }
-
- public function getReservedRange()
- {
- return $this->reserved_range;
- }
-
- public function setReservedRange(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto_ReservedRange::class);
- $this->reserved_range = $var;
- $this->has_reserved_range = true;
- }
-
- public function hasReservedRange()
- {
- return $this->has_reserved_range;
- }
-
- public function getReservedName()
- {
- return $this->reserved_name;
- }
-
- public function setReservedName(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::STRING);
- $this->reserved_name = $var;
- $this->has_reserved_name = true;
- }
-
- public function hasReservedName()
- {
- return $this->has_reserved_name;
- }
-
-}
-
-class DescriptorProto_ExtensionRange extends \Google\Protobuf\Internal\Message
-{
- private $start = 0;
- private $has_start = false;
- private $end = 0;
- private $has_end = false;
-
- public function getStart()
- {
- return $this->start;
- }
-
- public function setStart($var)
- {
- GPBUtil::checkInt32($var);
- $this->start = $var;
- $this->has_start = true;
- }
-
- public function hasStart()
- {
- return $this->has_start;
- }
-
- public function getEnd()
- {
- return $this->end;
- }
-
- public function setEnd($var)
- {
- GPBUtil::checkInt32($var);
- $this->end = $var;
- $this->has_end = true;
- }
-
- public function hasEnd()
- {
- return $this->has_end;
- }
-
-}
-
-class DescriptorProto_ReservedRange extends \Google\Protobuf\Internal\Message
-{
- private $start = 0;
- private $has_start = false;
- private $end = 0;
- private $has_end = false;
-
- public function getStart()
- {
- return $this->start;
- }
-
- public function setStart($var)
- {
- GPBUtil::checkInt32($var);
- $this->start = $var;
- $this->has_start = true;
- }
-
- public function hasStart()
- {
- return $this->has_start;
- }
-
- public function getEnd()
- {
- return $this->end;
- }
-
- public function setEnd($var)
- {
- GPBUtil::checkInt32($var);
- $this->end = $var;
- $this->has_end = true;
- }
-
- public function hasEnd()
- {
- return $this->has_end;
- }
-
-}
-
-class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
-{
- private $name = '';
- private $has_name = false;
- private $number = 0;
- private $has_number = false;
- private $label = 0;
- private $has_label = false;
- private $type = 0;
- private $has_type = false;
- private $type_name = '';
- private $has_type_name = false;
- private $extendee = '';
- private $has_extendee = false;
- private $default_value = '';
- private $has_default_value = false;
- private $oneof_index = 0;
- private $has_oneof_index = false;
- private $json_name = '';
- private $has_json_name = false;
- private $options = null;
- private $has_options = false;
-
- public function getName()
- {
- return $this->name;
- }
-
- public function setName($var)
- {
- GPBUtil::checkString($var, True);
- $this->name = $var;
- $this->has_name = true;
- }
-
- public function hasName()
- {
- return $this->has_name;
- }
-
- public function getNumber()
- {
- return $this->number;
- }
-
- public function setNumber($var)
- {
- GPBUtil::checkInt32($var);
- $this->number = $var;
- $this->has_number = true;
- }
-
- public function hasNumber()
- {
- return $this->has_number;
- }
-
- public function getLabel()
- {
- return $this->label;
- }
-
- public function setLabel($var)
- {
- GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldDescriptorProto_Label::class);
- $this->label = $var;
- $this->has_label = true;
- }
-
- public function hasLabel()
- {
- return $this->has_label;
- }
-
- public function getType()
- {
- return $this->type;
- }
-
- public function setType($var)
- {
- GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldDescriptorProto_Type::class);
- $this->type = $var;
- $this->has_type = true;
- }
-
- public function hasType()
- {
- return $this->has_type;
- }
-
- public function getTypeName()
- {
- return $this->type_name;
- }
-
- public function setTypeName($var)
- {
- GPBUtil::checkString($var, True);
- $this->type_name = $var;
- $this->has_type_name = true;
- }
-
- public function hasTypeName()
- {
- return $this->has_type_name;
- }
-
- public function getExtendee()
- {
- return $this->extendee;
- }
-
- public function setExtendee($var)
- {
- GPBUtil::checkString($var, True);
- $this->extendee = $var;
- $this->has_extendee = true;
- }
-
- public function hasExtendee()
- {
- return $this->has_extendee;
- }
-
- public function getDefaultValue()
- {
- return $this->default_value;
- }
-
- public function setDefaultValue($var)
- {
- GPBUtil::checkString($var, True);
- $this->default_value = $var;
- $this->has_default_value = true;
- }
-
- public function hasDefaultValue()
- {
- return $this->has_default_value;
- }
-
- public function getOneofIndex()
- {
- return $this->oneof_index;
- }
-
- public function setOneofIndex($var)
- {
- GPBUtil::checkInt32($var);
- $this->oneof_index = $var;
- $this->has_oneof_index = true;
- }
-
- public function hasOneofIndex()
- {
- return $this->has_oneof_index;
- }
-
- public function getJsonName()
- {
- return $this->json_name;
- }
-
- public function setJsonName($var)
- {
- GPBUtil::checkString($var, True);
- $this->json_name = $var;
- $this->has_json_name = true;
- }
-
- public function hasJsonName()
- {
- return $this->has_json_name;
- }
-
- public function getOptions()
- {
- return $this->options;
- }
-
- public function setOptions(&$var)
- {
- GPBUtil::checkMessage($var, \Google\Protobuf\Internal\FieldOptions::class);
- $this->options = $var;
- $this->has_options = true;
- }
-
- public function hasOptions()
- {
- return $this->has_options;
- }
-
-}
-
-class FieldDescriptorProto_Type
-{
- const TYPE_DOUBLE = 1;
- const TYPE_FLOAT = 2;
- const TYPE_INT64 = 3;
- const TYPE_UINT64 = 4;
- const TYPE_INT32 = 5;
- const TYPE_FIXED64 = 6;
- const TYPE_FIXED32 = 7;
- const TYPE_BOOL = 8;
- const TYPE_STRING = 9;
- const TYPE_GROUP = 10;
- const TYPE_MESSAGE = 11;
- const TYPE_BYTES = 12;
- const TYPE_UINT32 = 13;
- const TYPE_ENUM = 14;
- const TYPE_SFIXED32 = 15;
- const TYPE_SFIXED64 = 16;
- const TYPE_SINT32 = 17;
- const TYPE_SINT64 = 18;
-}
-
-class FieldDescriptorProto_Label
-{
- const LABEL_OPTIONAL = 1;
- const LABEL_REQUIRED = 2;
- const LABEL_REPEATED = 3;
-}
-
-class OneofDescriptorProto extends \Google\Protobuf\Internal\Message
-{
- private $name = '';
- private $has_name = false;
- private $options = null;
- private $has_options = false;
-
- public function getName()
- {
- return $this->name;
- }
-
- public function setName($var)
- {
- GPBUtil::checkString($var, True);
- $this->name = $var;
- $this->has_name = true;
- }
-
- public function hasName()
- {
- return $this->has_name;
- }
-
- public function getOptions()
- {
- return $this->options;
- }
-
- public function setOptions(&$var)
- {
- GPBUtil::checkMessage($var, \Google\Protobuf\Internal\OneofOptions::class);
- $this->options = $var;
- $this->has_options = true;
- }
-
- public function hasOptions()
- {
- return $this->has_options;
- }
-
-}
-
-class EnumDescriptorProto extends \Google\Protobuf\Internal\Message
-{
- private $name = '';
- private $has_name = false;
- private $value;
- private $has_value = false;
- private $options = null;
- private $has_options = false;
-
- public function getName()
- {
- return $this->name;
- }
-
- public function setName($var)
- {
- GPBUtil::checkString($var, True);
- $this->name = $var;
- $this->has_name = true;
- }
-
- public function hasName()
- {
- return $this->has_name;
- }
-
- public function getValue()
- {
- return $this->value;
- }
-
- public function setValue(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\EnumValueDescriptorProto::class);
- $this->value = $var;
- $this->has_value = true;
- }
-
- public function hasValue()
- {
- return $this->has_value;
- }
-
- public function getOptions()
- {
- return $this->options;
- }
-
- public function setOptions(&$var)
- {
- GPBUtil::checkMessage($var, \Google\Protobuf\Internal\EnumOptions::class);
- $this->options = $var;
- $this->has_options = true;
- }
-
- public function hasOptions()
- {
- return $this->has_options;
- }
-
-}
-
-class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message
-{
- private $name = '';
- private $has_name = false;
- private $number = 0;
- private $has_number = false;
- private $options = null;
- private $has_options = false;
-
- public function getName()
- {
- return $this->name;
- }
-
- public function setName($var)
- {
- GPBUtil::checkString($var, True);
- $this->name = $var;
- $this->has_name = true;
- }
-
- public function hasName()
- {
- return $this->has_name;
- }
-
- public function getNumber()
- {
- return $this->number;
- }
-
- public function setNumber($var)
- {
- GPBUtil::checkInt32($var);
- $this->number = $var;
- $this->has_number = true;
- }
-
- public function hasNumber()
- {
- return $this->has_number;
- }
-
- public function getOptions()
- {
- return $this->options;
- }
-
- public function setOptions(&$var)
- {
- GPBUtil::checkMessage($var, \Google\Protobuf\Internal\EnumValueOptions::class);
- $this->options = $var;
- $this->has_options = true;
- }
-
- public function hasOptions()
- {
- return $this->has_options;
- }
-
-}
-
-class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message
-{
- private $name = '';
- private $has_name = false;
- private $method;
- private $has_method = false;
- private $options = null;
- private $has_options = false;
-
- public function getName()
- {
- return $this->name;
- }
-
- public function setName($var)
- {
- GPBUtil::checkString($var, True);
- $this->name = $var;
- $this->has_name = true;
- }
-
- public function hasName()
- {
- return $this->has_name;
- }
-
- public function getMethod()
- {
- return $this->method;
- }
-
- public function setMethod(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\MethodDescriptorProto::class);
- $this->method = $var;
- $this->has_method = true;
- }
-
- public function hasMethod()
- {
- return $this->has_method;
- }
-
- public function getOptions()
- {
- return $this->options;
- }
-
- public function setOptions(&$var)
- {
- GPBUtil::checkMessage($var, \Google\Protobuf\Internal\ServiceOptions::class);
- $this->options = $var;
- $this->has_options = true;
- }
-
- public function hasOptions()
- {
- return $this->has_options;
- }
-
-}
-
-class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
-{
- private $name = '';
- private $has_name = false;
- private $input_type = '';
- private $has_input_type = false;
- private $output_type = '';
- private $has_output_type = false;
- private $options = null;
- private $has_options = false;
- private $client_streaming = false;
- private $has_client_streaming = false;
- private $server_streaming = false;
- private $has_server_streaming = false;
-
- public function getName()
- {
- return $this->name;
- }
-
- public function setName($var)
- {
- GPBUtil::checkString($var, True);
- $this->name = $var;
- $this->has_name = true;
- }
-
- public function hasName()
- {
- return $this->has_name;
- }
-
- public function getInputType()
- {
- return $this->input_type;
- }
-
- public function setInputType($var)
- {
- GPBUtil::checkString($var, True);
- $this->input_type = $var;
- $this->has_input_type = true;
- }
-
- public function hasInputType()
- {
- return $this->has_input_type;
- }
-
- public function getOutputType()
- {
- return $this->output_type;
- }
-
- public function setOutputType($var)
- {
- GPBUtil::checkString($var, True);
- $this->output_type = $var;
- $this->has_output_type = true;
- }
-
- public function hasOutputType()
- {
- return $this->has_output_type;
- }
-
- public function getOptions()
- {
- return $this->options;
- }
-
- public function setOptions(&$var)
- {
- GPBUtil::checkMessage($var, \Google\Protobuf\Internal\MethodOptions::class);
- $this->options = $var;
- $this->has_options = true;
- }
-
- public function hasOptions()
- {
- return $this->has_options;
- }
-
- public function getClientStreaming()
- {
- return $this->client_streaming;
- }
-
- public function setClientStreaming($var)
- {
- GPBUtil::checkBool($var);
- $this->client_streaming = $var;
- $this->has_client_streaming = true;
- }
-
- public function hasClientStreaming()
- {
- return $this->has_client_streaming;
- }
-
- public function getServerStreaming()
- {
- return $this->server_streaming;
- }
-
- public function setServerStreaming($var)
- {
- GPBUtil::checkBool($var);
- $this->server_streaming = $var;
- $this->has_server_streaming = true;
- }
-
- public function hasServerStreaming()
- {
- return $this->has_server_streaming;
- }
-
-}
-
-class FileOptions extends \Google\Protobuf\Internal\Message
-{
- private $java_package = '';
- private $has_java_package = false;
- private $java_outer_classname = '';
- private $has_java_outer_classname = false;
- private $java_multiple_files = false;
- private $has_java_multiple_files = false;
- private $java_generate_equals_and_hash = false;
- private $has_java_generate_equals_and_hash = false;
- private $java_string_check_utf8 = false;
- private $has_java_string_check_utf8 = false;
- private $optimize_for = 0;
- private $has_optimize_for = false;
- private $go_package = '';
- private $has_go_package = false;
- private $cc_generic_services = false;
- private $has_cc_generic_services = false;
- private $java_generic_services = false;
- private $has_java_generic_services = false;
- private $py_generic_services = false;
- private $has_py_generic_services = false;
- private $deprecated = false;
- private $has_deprecated = false;
- private $cc_enable_arenas = false;
- private $has_cc_enable_arenas = false;
- private $objc_class_prefix = '';
- private $has_objc_class_prefix = false;
- private $csharp_namespace = '';
- private $has_csharp_namespace = false;
- private $uninterpreted_option;
- private $has_uninterpreted_option = false;
-
- public function getJavaPackage()
- {
- return $this->java_package;
- }
-
- public function setJavaPackage($var)
- {
- GPBUtil::checkString($var, True);
- $this->java_package = $var;
- $this->has_java_package = true;
- }
-
- public function hasJavaPackage()
- {
- return $this->has_java_package;
- }
-
- public function getJavaOuterClassname()
- {
- return $this->java_outer_classname;
- }
-
- public function setJavaOuterClassname($var)
- {
- GPBUtil::checkString($var, True);
- $this->java_outer_classname = $var;
- $this->has_java_outer_classname = true;
- }
-
- public function hasJavaOuterClassname()
- {
- return $this->has_java_outer_classname;
- }
-
- public function getJavaMultipleFiles()
- {
- return $this->java_multiple_files;
- }
-
- public function setJavaMultipleFiles($var)
- {
- GPBUtil::checkBool($var);
- $this->java_multiple_files = $var;
- $this->has_java_multiple_files = true;
- }
-
- public function hasJavaMultipleFiles()
- {
- return $this->has_java_multiple_files;
- }
-
- public function getJavaGenerateEqualsAndHash()
- {
- return $this->java_generate_equals_and_hash;
- }
-
- public function setJavaGenerateEqualsAndHash($var)
- {
- GPBUtil::checkBool($var);
- $this->java_generate_equals_and_hash = $var;
- $this->has_java_generate_equals_and_hash = true;
- }
-
- public function hasJavaGenerateEqualsAndHash()
- {
- return $this->has_java_generate_equals_and_hash;
- }
-
- public function getJavaStringCheckUtf8()
- {
- return $this->java_string_check_utf8;
- }
-
- public function setJavaStringCheckUtf8($var)
- {
- GPBUtil::checkBool($var);
- $this->java_string_check_utf8 = $var;
- $this->has_java_string_check_utf8 = true;
- }
-
- public function hasJavaStringCheckUtf8()
- {
- return $this->has_java_string_check_utf8;
- }
-
- public function getOptimizeFor()
- {
- return $this->optimize_for;
- }
-
- public function setOptimizeFor($var)
- {
- GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FileOptions_OptimizeMode::class);
- $this->optimize_for = $var;
- $this->has_optimize_for = true;
- }
-
- public function hasOptimizeFor()
- {
- return $this->has_optimize_for;
- }
-
- public function getGoPackage()
- {
- return $this->go_package;
- }
-
- public function setGoPackage($var)
- {
- GPBUtil::checkString($var, True);
- $this->go_package = $var;
- $this->has_go_package = true;
- }
-
- public function hasGoPackage()
- {
- return $this->has_go_package;
- }
-
- public function getCcGenericServices()
- {
- return $this->cc_generic_services;
- }
-
- public function setCcGenericServices($var)
- {
- GPBUtil::checkBool($var);
- $this->cc_generic_services = $var;
- $this->has_cc_generic_services = true;
- }
-
- public function hasCcGenericServices()
- {
- return $this->has_cc_generic_services;
- }
-
- public function getJavaGenericServices()
- {
- return $this->java_generic_services;
- }
-
- public function setJavaGenericServices($var)
- {
- GPBUtil::checkBool($var);
- $this->java_generic_services = $var;
- $this->has_java_generic_services = true;
- }
-
- public function hasJavaGenericServices()
- {
- return $this->has_java_generic_services;
- }
-
- public function getPyGenericServices()
- {
- return $this->py_generic_services;
- }
-
- public function setPyGenericServices($var)
- {
- GPBUtil::checkBool($var);
- $this->py_generic_services = $var;
- $this->has_py_generic_services = true;
- }
-
- public function hasPyGenericServices()
- {
- return $this->has_py_generic_services;
- }
-
- public function getDeprecated()
- {
- return $this->deprecated;
- }
-
- public function setDeprecated($var)
- {
- GPBUtil::checkBool($var);
- $this->deprecated = $var;
- $this->has_deprecated = true;
- }
-
- public function hasDeprecated()
- {
- return $this->has_deprecated;
- }
-
- public function getCcEnableArenas()
- {
- return $this->cc_enable_arenas;
- }
-
- public function setCcEnableArenas($var)
- {
- GPBUtil::checkBool($var);
- $this->cc_enable_arenas = $var;
- $this->has_cc_enable_arenas = true;
- }
-
- public function hasCcEnableArenas()
- {
- return $this->has_cc_enable_arenas;
- }
-
- public function getObjcClassPrefix()
- {
- return $this->objc_class_prefix;
- }
-
- public function setObjcClassPrefix($var)
- {
- GPBUtil::checkString($var, True);
- $this->objc_class_prefix = $var;
- $this->has_objc_class_prefix = true;
- }
-
- public function hasObjcClassPrefix()
- {
- return $this->has_objc_class_prefix;
- }
-
- public function getCsharpNamespace()
- {
- return $this->csharp_namespace;
- }
-
- public function setCsharpNamespace($var)
- {
- GPBUtil::checkString($var, True);
- $this->csharp_namespace = $var;
- $this->has_csharp_namespace = true;
- }
-
- public function hasCsharpNamespace()
- {
- return $this->has_csharp_namespace;
- }
-
- public function getUninterpretedOption()
- {
- return $this->uninterpreted_option;
- }
-
- public function setUninterpretedOption(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
- $this->uninterpreted_option = $var;
- $this->has_uninterpreted_option = true;
- }
-
- public function hasUninterpretedOption()
- {
- return $this->has_uninterpreted_option;
- }
-
-}
-
-class FileOptions_OptimizeMode
-{
- const SPEED = 1;
- const CODE_SIZE = 2;
- const LITE_RUNTIME = 3;
-}
-
-class MessageOptions extends \Google\Protobuf\Internal\Message
-{
- private $message_set_wire_format = false;
- private $has_message_set_wire_format = false;
- private $no_standard_descriptor_accessor = false;
- private $has_no_standard_descriptor_accessor = false;
- private $deprecated = false;
- private $has_deprecated = false;
- private $map_entry = false;
- private $has_map_entry = false;
- private $uninterpreted_option;
- private $has_uninterpreted_option = false;
-
- public function getMessageSetWireFormat()
- {
- return $this->message_set_wire_format;
- }
-
- public function setMessageSetWireFormat($var)
- {
- GPBUtil::checkBool($var);
- $this->message_set_wire_format = $var;
- $this->has_message_set_wire_format = true;
- }
-
- public function hasMessageSetWireFormat()
- {
- return $this->has_message_set_wire_format;
- }
-
- public function getNoStandardDescriptorAccessor()
- {
- return $this->no_standard_descriptor_accessor;
- }
-
- public function setNoStandardDescriptorAccessor($var)
- {
- GPBUtil::checkBool($var);
- $this->no_standard_descriptor_accessor = $var;
- $this->has_no_standard_descriptor_accessor = true;
- }
-
- public function hasNoStandardDescriptorAccessor()
- {
- return $this->has_no_standard_descriptor_accessor;
- }
-
- public function getDeprecated()
- {
- return $this->deprecated;
- }
-
- public function setDeprecated($var)
- {
- GPBUtil::checkBool($var);
- $this->deprecated = $var;
- $this->has_deprecated = true;
- }
-
- public function hasDeprecated()
- {
- return $this->has_deprecated;
- }
-
- public function getMapEntry()
- {
- return $this->map_entry;
- }
-
- public function setMapEntry($var)
- {
- GPBUtil::checkBool($var);
- $this->map_entry = $var;
- $this->has_map_entry = true;
- }
-
- public function hasMapEntry()
- {
- return $this->has_map_entry;
- }
-
- public function getUninterpretedOption()
- {
- return $this->uninterpreted_option;
- }
-
- public function setUninterpretedOption(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
- $this->uninterpreted_option = $var;
- $this->has_uninterpreted_option = true;
- }
-
- public function hasUninterpretedOption()
- {
- return $this->has_uninterpreted_option;
- }
-
-}
-
-class FieldOptions extends \Google\Protobuf\Internal\Message
-{
- private $ctype = 0;
- private $has_ctype = false;
- private $packed = false;
- private $has_packed = false;
- private $jstype = 0;
- private $has_jstype = false;
- private $lazy = false;
- private $has_lazy = false;
- private $deprecated = false;
- private $has_deprecated = false;
- private $weak = false;
- private $has_weak = false;
- private $uninterpreted_option;
- private $has_uninterpreted_option = false;
-
- public function getCtype()
- {
- return $this->ctype;
- }
-
- public function setCtype($var)
- {
- GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldOptions_CType::class);
- $this->ctype = $var;
- $this->has_ctype = true;
- }
-
- public function hasCtype()
- {
- return $this->has_ctype;
- }
-
- public function getPacked()
- {
- return $this->packed;
- }
-
- public function setPacked($var)
- {
- GPBUtil::checkBool($var);
- $this->packed = $var;
- $this->has_packed = true;
- }
-
- public function hasPacked()
- {
- return $this->has_packed;
- }
-
- public function getJstype()
- {
- return $this->jstype;
- }
-
- public function setJstype($var)
- {
- GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldOptions_JSType::class);
- $this->jstype = $var;
- $this->has_jstype = true;
- }
-
- public function hasJstype()
- {
- return $this->has_jstype;
- }
-
- public function getLazy()
- {
- return $this->lazy;
- }
-
- public function setLazy($var)
- {
- GPBUtil::checkBool($var);
- $this->lazy = $var;
- $this->has_lazy = true;
- }
-
- public function hasLazy()
- {
- return $this->has_lazy;
- }
-
- public function getDeprecated()
- {
- return $this->deprecated;
- }
-
- public function setDeprecated($var)
- {
- GPBUtil::checkBool($var);
- $this->deprecated = $var;
- $this->has_deprecated = true;
- }
-
- public function hasDeprecated()
- {
- return $this->has_deprecated;
- }
-
- public function getWeak()
- {
- return $this->weak;
- }
-
- public function setWeak($var)
- {
- GPBUtil::checkBool($var);
- $this->weak = $var;
- $this->has_weak = true;
- }
-
- public function hasWeak()
- {
- return $this->has_weak;
- }
-
- public function getUninterpretedOption()
- {
- return $this->uninterpreted_option;
- }
-
- public function setUninterpretedOption(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
- $this->uninterpreted_option = $var;
- $this->has_uninterpreted_option = true;
- }
-
- public function hasUninterpretedOption()
- {
- return $this->has_uninterpreted_option;
- }
-
-}
-
-class FieldOptions_CType
-{
- const STRING = 0;
- const CORD = 1;
- const STRING_PIECE = 2;
-}
-
-class FieldOptions_JSType
-{
- const JS_NORMAL = 0;
- const JS_STRING = 1;
- const JS_NUMBER = 2;
-}
-
-class OneofOptions extends \Google\Protobuf\Internal\Message
-{
- private $uninterpreted_option;
- private $has_uninterpreted_option = false;
-
- public function getUninterpretedOption()
- {
- return $this->uninterpreted_option;
- }
-
- public function setUninterpretedOption(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
- $this->uninterpreted_option = $var;
- $this->has_uninterpreted_option = true;
- }
-
- public function hasUninterpretedOption()
- {
- return $this->has_uninterpreted_option;
- }
-
-}
-
-class EnumOptions extends \Google\Protobuf\Internal\Message
-{
- private $allow_alias = false;
- private $has_allow_alias = false;
- private $deprecated = false;
- private $has_deprecated = false;
- private $uninterpreted_option;
- private $has_uninterpreted_option = false;
-
- public function getAllowAlias()
- {
- return $this->allow_alias;
- }
-
- public function setAllowAlias($var)
- {
- GPBUtil::checkBool($var);
- $this->allow_alias = $var;
- $this->has_allow_alias = true;
- }
-
- public function hasAllowAlias()
- {
- return $this->has_allow_alias;
- }
-
- public function getDeprecated()
- {
- return $this->deprecated;
- }
-
- public function setDeprecated($var)
- {
- GPBUtil::checkBool($var);
- $this->deprecated = $var;
- $this->has_deprecated = true;
- }
-
- public function hasDeprecated()
- {
- return $this->has_deprecated;
- }
-
- public function getUninterpretedOption()
- {
- return $this->uninterpreted_option;
- }
-
- public function setUninterpretedOption(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
- $this->uninterpreted_option = $var;
- $this->has_uninterpreted_option = true;
- }
-
- public function hasUninterpretedOption()
- {
- return $this->has_uninterpreted_option;
- }
-
-}
-
-class EnumValueOptions extends \Google\Protobuf\Internal\Message
-{
- private $deprecated = false;
- private $has_deprecated = false;
- private $uninterpreted_option;
- private $has_uninterpreted_option = false;
-
- public function getDeprecated()
- {
- return $this->deprecated;
- }
-
- public function setDeprecated($var)
- {
- GPBUtil::checkBool($var);
- $this->deprecated = $var;
- $this->has_deprecated = true;
- }
-
- public function hasDeprecated()
- {
- return $this->has_deprecated;
- }
-
- public function getUninterpretedOption()
- {
- return $this->uninterpreted_option;
- }
-
- public function setUninterpretedOption(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
- $this->uninterpreted_option = $var;
- $this->has_uninterpreted_option = true;
- }
-
- public function hasUninterpretedOption()
- {
- return $this->has_uninterpreted_option;
- }
-
-}
-
-class ServiceOptions extends \Google\Protobuf\Internal\Message
-{
- private $deprecated = false;
- private $has_deprecated = false;
- private $uninterpreted_option;
- private $has_uninterpreted_option = false;
-
- public function getDeprecated()
- {
- return $this->deprecated;
- }
-
- public function setDeprecated($var)
- {
- GPBUtil::checkBool($var);
- $this->deprecated = $var;
- $this->has_deprecated = true;
- }
-
- public function hasDeprecated()
- {
- return $this->has_deprecated;
- }
-
- public function getUninterpretedOption()
- {
- return $this->uninterpreted_option;
- }
-
- public function setUninterpretedOption(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
- $this->uninterpreted_option = $var;
- $this->has_uninterpreted_option = true;
- }
-
- public function hasUninterpretedOption()
- {
- return $this->has_uninterpreted_option;
- }
-
-}
-
-class MethodOptions extends \Google\Protobuf\Internal\Message
-{
- private $deprecated = false;
- private $has_deprecated = false;
- private $uninterpreted_option;
- private $has_uninterpreted_option = false;
-
- public function getDeprecated()
- {
- return $this->deprecated;
- }
-
- public function setDeprecated($var)
- {
- GPBUtil::checkBool($var);
- $this->deprecated = $var;
- $this->has_deprecated = true;
- }
-
- public function hasDeprecated()
- {
- return $this->has_deprecated;
- }
-
- public function getUninterpretedOption()
- {
- return $this->uninterpreted_option;
- }
-
- public function setUninterpretedOption(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
- $this->uninterpreted_option = $var;
- $this->has_uninterpreted_option = true;
- }
-
- public function hasUninterpretedOption()
- {
- return $this->has_uninterpreted_option;
- }
-
-}
-
-class UninterpretedOption extends \Google\Protobuf\Internal\Message
-{
- private $name;
- private $has_name = false;
- private $identifier_value = '';
- private $has_identifier_value = false;
- private $positive_int_value = 0;
- private $has_positive_int_value = false;
- private $negative_int_value = 0;
- private $has_negative_int_value = false;
- private $double_value = 0.0;
- private $has_double_value = false;
- private $string_value = '';
- private $has_string_value = false;
- private $aggregate_value = '';
- private $has_aggregate_value = false;
-
- public function getName()
- {
- return $this->name;
- }
-
- public function setName(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption_NamePart::class);
- $this->name = $var;
- $this->has_name = true;
- }
-
- public function hasName()
- {
- return $this->has_name;
- }
-
- public function getIdentifierValue()
- {
- return $this->identifier_value;
- }
-
- public function setIdentifierValue($var)
- {
- GPBUtil::checkString($var, True);
- $this->identifier_value = $var;
- $this->has_identifier_value = true;
- }
-
- public function hasIdentifierValue()
- {
- return $this->has_identifier_value;
- }
-
- public function getPositiveIntValue()
- {
- return $this->positive_int_value;
- }
-
- public function setPositiveIntValue($var)
- {
- GPBUtil::checkUint64($var);
- $this->positive_int_value = $var;
- $this->has_positive_int_value = true;
- }
-
- public function hasPositiveIntValue()
- {
- return $this->has_positive_int_value;
- }
-
- public function getNegativeIntValue()
- {
- return $this->negative_int_value;
- }
-
- public function setNegativeIntValue($var)
- {
- GPBUtil::checkInt64($var);
- $this->negative_int_value = $var;
- $this->has_negative_int_value = true;
- }
-
- public function hasNegativeIntValue()
- {
- return $this->has_negative_int_value;
- }
-
- public function getDoubleValue()
- {
- return $this->double_value;
- }
-
- public function setDoubleValue($var)
- {
- GPBUtil::checkDouble($var);
- $this->double_value = $var;
- $this->has_double_value = true;
- }
-
- public function hasDoubleValue()
- {
- return $this->has_double_value;
- }
-
- public function getStringValue()
- {
- return $this->string_value;
- }
-
- public function setStringValue($var)
- {
- GPBUtil::checkString($var, False);
- $this->string_value = $var;
- $this->has_string_value = true;
- }
-
- public function hasStringValue()
- {
- return $this->has_string_value;
- }
-
- public function getAggregateValue()
- {
- return $this->aggregate_value;
- }
-
- public function setAggregateValue($var)
- {
- GPBUtil::checkString($var, True);
- $this->aggregate_value = $var;
- $this->has_aggregate_value = true;
- }
-
- public function hasAggregateValue()
- {
- return $this->has_aggregate_value;
- }
-
-}
-
-class UninterpretedOption_NamePart extends \Google\Protobuf\Internal\Message
-{
- private $name_part = '';
- private $has_name_part = false;
- private $is_extension = false;
- private $has_is_extension = false;
-
- public function getNamePart()
- {
- return $this->name_part;
- }
-
- public function setNamePart($var)
- {
- GPBUtil::checkString($var, True);
- $this->name_part = $var;
- $this->has_name_part = true;
- }
-
- public function hasNamePart()
- {
- return $this->has_name_part;
- }
-
- public function getIsExtension()
- {
- return $this->is_extension;
- }
-
- public function setIsExtension($var)
- {
- GPBUtil::checkBool($var);
- $this->is_extension = $var;
- $this->has_is_extension = true;
- }
-
- public function hasIsExtension()
- {
- return $this->has_is_extension;
- }
-
-}
-
-class SourceCodeInfo extends \Google\Protobuf\Internal\Message
-{
- private $location;
- private $has_location = false;
-
- public function getLocation()
- {
- return $this->location;
- }
-
- public function setLocation(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\SourceCodeInfo_Location::class);
- $this->location = $var;
- $this->has_location = true;
- }
-
- public function hasLocation()
- {
- return $this->has_location;
- }
-
-}
-
-class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message
-{
- private $path;
- private $has_path = false;
- private $span;
- private $has_span = false;
- private $leading_comments = '';
- private $has_leading_comments = false;
- private $trailing_comments = '';
- private $has_trailing_comments = false;
- private $leading_detached_comments;
- private $has_leading_detached_comments = false;
-
- public function getPath()
- {
- return $this->path;
- }
-
- public function setPath(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::INT32);
- $this->path = $var;
- $this->has_path = true;
- }
-
- public function hasPath()
- {
- return $this->has_path;
- }
-
- public function getSpan()
- {
- return $this->span;
- }
-
- public function setSpan(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::INT32);
- $this->span = $var;
- $this->has_span = true;
- }
-
- public function hasSpan()
- {
- return $this->has_span;
- }
-
- public function getLeadingComments()
- {
- return $this->leading_comments;
- }
-
- public function setLeadingComments($var)
- {
- GPBUtil::checkString($var, True);
- $this->leading_comments = $var;
- $this->has_leading_comments = true;
- }
-
- public function hasLeadingComments()
- {
- return $this->has_leading_comments;
- }
-
- public function getTrailingComments()
- {
- return $this->trailing_comments;
- }
-
- public function setTrailingComments($var)
- {
- GPBUtil::checkString($var, True);
- $this->trailing_comments = $var;
- $this->has_trailing_comments = true;
- }
-
- public function hasTrailingComments()
- {
- return $this->has_trailing_comments;
- }
-
- public function getLeadingDetachedComments()
- {
- return $this->leading_detached_comments;
- }
-
- public function setLeadingDetachedComments(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::STRING);
- $this->leading_detached_comments = $var;
- $this->has_leading_detached_comments = true;
- }
-
- public function hasLeadingDetachedComments()
- {
- return $this->has_leading_detached_comments;
- }
-
-}
-
-class GeneratedCodeInfo extends \Google\Protobuf\Internal\Message
-{
- private $annotation;
- private $has_annotation = false;
-
- public function getAnnotation()
- {
- return $this->annotation;
- }
-
- public function setAnnotation(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\GeneratedCodeInfo_Annotation::class);
- $this->annotation = $var;
- $this->has_annotation = true;
- }
-
- public function hasAnnotation()
- {
- return $this->has_annotation;
- }
-
-}
-
-class GeneratedCodeInfo_Annotation extends \Google\Protobuf\Internal\Message
-{
- private $path;
- private $has_path = false;
- private $source_file = '';
- private $has_source_file = false;
- private $begin = 0;
- private $has_begin = false;
- private $end = 0;
- private $has_end = false;
-
- public function getPath()
- {
- return $this->path;
- }
-
- public function setPath(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::INT32);
- $this->path = $var;
- $this->has_path = true;
- }
-
- public function hasPath()
- {
- return $this->has_path;
- }
-
- public function getSourceFile()
- {
- return $this->source_file;
- }
-
- public function setSourceFile($var)
- {
- GPBUtil::checkString($var, True);
- $this->source_file = $var;
- $this->has_source_file = true;
- }
-
- public function hasSourceFile()
- {
- return $this->has_source_file;
- }
-
- public function getBegin()
- {
- return $this->begin;
- }
-
- public function setBegin($var)
- {
- GPBUtil::checkInt32($var);
- $this->begin = $var;
- $this->has_begin = true;
- }
-
- public function hasBegin()
- {
- return $this->has_begin;
- }
-
- public function getEnd()
- {
- return $this->end;
- }
-
- public function setEnd($var)
- {
- GPBUtil::checkInt32($var);
- $this->end = $var;
- $this->has_end = true;
- }
-
- public function hasEnd()
- {
- return $this->has_end;
- }
-
-}
-
-$pool = DescriptorPool::getGeneratedPool();
-
-$pool->addMessage('google.protobuf.internal.FileDescriptorSet', FileDescriptorSet::class)
- ->repeated('file', GPBType::MESSAGE, 1, 'google.protobuf.internal.FileDescriptorProto')
- ->finalizeToPool();
-
-$pool->addMessage('google.protobuf.internal.FileDescriptorProto', FileDescriptorProto::class)
- ->optional('name', GPBType::STRING, 1)
- ->optional('package', GPBType::STRING, 2)
- ->repeated('dependency', GPBType::STRING, 3)
- ->repeated('public_dependency', GPBType::INT32, 10)
- ->repeated('weak_dependency', GPBType::INT32, 11)
- ->repeated('message_type', GPBType::MESSAGE, 4, 'google.protobuf.internal.DescriptorProto')
- ->repeated('enum_type', GPBType::MESSAGE, 5, 'google.protobuf.internal.EnumDescriptorProto')
- ->repeated('service', GPBType::MESSAGE, 6, 'google.protobuf.internal.ServiceDescriptorProto')
- ->repeated('extension', GPBType::MESSAGE, 7, 'google.protobuf.internal.FieldDescriptorProto')
- ->optional('options', GPBType::MESSAGE, 8, 'google.protobuf.internal.FileOptions')
- ->optional('source_code_info', GPBType::MESSAGE, 9, 'google.protobuf.internal.SourceCodeInfo')
- ->optional('syntax', GPBType::STRING, 12)
- ->finalizeToPool();
-
-$pool->addMessage('google.protobuf.internal.DescriptorProto', DescriptorProto::class)
- ->optional('name', GPBType::STRING, 1)
- ->repeated('field', GPBType::MESSAGE, 2, 'google.protobuf.internal.FieldDescriptorProto')
- ->repeated('extension', GPBType::MESSAGE, 6, 'google.protobuf.internal.FieldDescriptorProto')
- ->repeated('nested_type', GPBType::MESSAGE, 3, 'google.protobuf.internal.DescriptorProto')
- ->repeated('enum_type', GPBType::MESSAGE, 4, 'google.protobuf.internal.EnumDescriptorProto')
- ->repeated('extension_range', GPBType::MESSAGE, 5, 'google.protobuf.internal.DescriptorProto.ExtensionRange')
- ->repeated('oneof_decl', GPBType::MESSAGE, 8, 'google.protobuf.internal.OneofDescriptorProto')
- ->optional('options', GPBType::MESSAGE, 7, 'google.protobuf.internal.MessageOptions')
- ->repeated('reserved_range', GPBType::MESSAGE, 9, 'google.protobuf.internal.DescriptorProto.ReservedRange')
- ->repeated('reserved_name', GPBType::STRING, 10)
- ->finalizeToPool();
-
-$pool->addMessage('google.protobuf.internal.DescriptorProto.ExtensionRange', DescriptorProto_ExtensionRange::class)
- ->optional('start', GPBType::INT32, 1)
- ->optional('end', GPBType::INT32, 2)
- ->finalizeToPool();
-
-$pool->addMessage('google.protobuf.internal.DescriptorProto.ReservedRange', DescriptorProto_ReservedRange::class)
- ->optional('start', GPBType::INT32, 1)
- ->optional('end', GPBType::INT32, 2)
- ->finalizeToPool();
-
-$pool->addMessage('google.protobuf.internal.FieldDescriptorProto', FieldDescriptorProto::class)
- ->optional('name', GPBType::STRING, 1)
- ->optional('number', GPBType::INT32, 3)
- ->optional('label', GPBType::ENUM, 4, 'google.protobuf.internal.FieldDescriptorProto.Label')
- ->optional('type', GPBType::ENUM, 5, 'google.protobuf.internal.FieldDescriptorProto.Type')
- ->optional('type_name', GPBType::STRING, 6)
- ->optional('extendee', GPBType::STRING, 2)
- ->optional('default_value', GPBType::STRING, 7)
- ->optional('oneof_index', GPBType::INT32, 9)
- ->optional('json_name', GPBType::STRING, 10)
- ->optional('options', GPBType::MESSAGE, 8, 'google.protobuf.internal.FieldOptions')
- ->finalizeToPool();
-
-$pool->addEnum('google.protobuf.internal.FieldDescriptorProto.Type', Type::class)
- ->value("TYPE_DOUBLE", 1)
- ->value("TYPE_FLOAT", 2)
- ->value("TYPE_INT64", 3)
- ->value("TYPE_UINT64", 4)
- ->value("TYPE_INT32", 5)
- ->value("TYPE_FIXED64", 6)
- ->value("TYPE_FIXED32", 7)
- ->value("TYPE_BOOL", 8)
- ->value("TYPE_STRING", 9)
- ->value("TYPE_GROUP", 10)
- ->value("TYPE_MESSAGE", 11)
- ->value("TYPE_BYTES", 12)
- ->value("TYPE_UINT32", 13)
- ->value("TYPE_ENUM", 14)
- ->value("TYPE_SFIXED32", 15)
- ->value("TYPE_SFIXED64", 16)
- ->value("TYPE_SINT32", 17)
- ->value("TYPE_SINT64", 18)
- ->finalizeToPool();
-
-$pool->addEnum('google.protobuf.internal.FieldDescriptorProto.Label', Label::class)
- ->value("LABEL_OPTIONAL", 1)
- ->value("LABEL_REQUIRED", 2)
- ->value("LABEL_REPEATED", 3)
- ->finalizeToPool();
-
-$pool->addMessage('google.protobuf.internal.OneofDescriptorProto', OneofDescriptorProto::class)
- ->optional('name', GPBType::STRING, 1)
- ->optional('options', GPBType::MESSAGE, 2, 'google.protobuf.internal.OneofOptions')
- ->finalizeToPool();
-
-$pool->addMessage('google.protobuf.internal.EnumDescriptorProto', EnumDescriptorProto::class)
- ->optional('name', GPBType::STRING, 1)
- ->repeated('value', GPBType::MESSAGE, 2, 'google.protobuf.internal.EnumValueDescriptorProto')
- ->optional('options', GPBType::MESSAGE, 3, 'google.protobuf.internal.EnumOptions')
- ->finalizeToPool();
-
-$pool->addMessage('google.protobuf.internal.EnumValueDescriptorProto', EnumValueDescriptorProto::class)
- ->optional('name', GPBType::STRING, 1)
- ->optional('number', GPBType::INT32, 2)
- ->optional('options', GPBType::MESSAGE, 3, 'google.protobuf.internal.EnumValueOptions')
- ->finalizeToPool();
-
-$pool->addMessage('google.protobuf.internal.ServiceDescriptorProto', ServiceDescriptorProto::class)
- ->optional('name', GPBType::STRING, 1)
- ->repeated('method', GPBType::MESSAGE, 2, 'google.protobuf.internal.MethodDescriptorProto')
- ->optional('options', GPBType::MESSAGE, 3, 'google.protobuf.internal.ServiceOptions')
- ->finalizeToPool();
-
-$pool->addMessage('google.protobuf.internal.MethodDescriptorProto', MethodDescriptorProto::class)
- ->optional('name', GPBType::STRING, 1)
- ->optional('input_type', GPBType::STRING, 2)
- ->optional('output_type', GPBType::STRING, 3)
- ->optional('options', GPBType::MESSAGE, 4, 'google.protobuf.internal.MethodOptions')
- ->optional('client_streaming', GPBType::BOOL, 5)
- ->optional('server_streaming', GPBType::BOOL, 6)
- ->finalizeToPool();
-
-$pool->addMessage('google.protobuf.internal.FileOptions', FileOptions::class)
- ->optional('java_package', GPBType::STRING, 1)
- ->optional('java_outer_classname', GPBType::STRING, 8)
- ->optional('java_multiple_files', GPBType::BOOL, 10)
- ->optional('java_generate_equals_and_hash', GPBType::BOOL, 20)
- ->optional('java_string_check_utf8', GPBType::BOOL, 27)
- ->optional('optimize_for', GPBType::ENUM, 9, 'google.protobuf.internal.FileOptions.OptimizeMode')
- ->optional('go_package', GPBType::STRING, 11)
- ->optional('cc_generic_services', GPBType::BOOL, 16)
- ->optional('java_generic_services', GPBType::BOOL, 17)
- ->optional('py_generic_services', GPBType::BOOL, 18)
- ->optional('deprecated', GPBType::BOOL, 23)
- ->optional('cc_enable_arenas', GPBType::BOOL, 31)
- ->optional('objc_class_prefix', GPBType::STRING, 36)
- ->optional('csharp_namespace', GPBType::STRING, 37)
- ->repeated('uninterpreted_option', GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption')
- ->finalizeToPool();
-
-$pool->addEnum('google.protobuf.internal.FileOptions.OptimizeMode', OptimizeMode::class)
- ->value("SPEED", 1)
- ->value("CODE_SIZE", 2)
- ->value("LITE_RUNTIME", 3)
- ->finalizeToPool();
-
-$pool->addMessage('google.protobuf.internal.MessageOptions', MessageOptions::class)
- ->optional('message_set_wire_format', GPBType::BOOL, 1)
- ->optional('no_standard_descriptor_accessor', GPBType::BOOL, 2)
- ->optional('deprecated', GPBType::BOOL, 3)
- ->optional('map_entry', GPBType::BOOL, 7)
- ->repeated('uninterpreted_option', GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption')
- ->finalizeToPool();
-
-$pool->addMessage('google.protobuf.internal.FieldOptions', FieldOptions::class)
- ->optional('ctype', GPBType::ENUM, 1, 'google.protobuf.internal.FieldOptions.CType')
- ->optional('packed', GPBType::BOOL, 2)
- ->optional('jstype', GPBType::ENUM, 6, 'google.protobuf.internal.FieldOptions.JSType')
- ->optional('lazy', GPBType::BOOL, 5)
- ->optional('deprecated', GPBType::BOOL, 3)
- ->optional('weak', GPBType::BOOL, 10)
- ->repeated('uninterpreted_option', GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption')
- ->finalizeToPool();
-
-$pool->addEnum('google.protobuf.internal.FieldOptions.CType', CType::class)
- ->value("STRING", 0)
- ->value("CORD", 1)
- ->value("STRING_PIECE", 2)
- ->finalizeToPool();
-
-$pool->addEnum('google.protobuf.internal.FieldOptions.JSType', JSType::class)
- ->value("JS_NORMAL", 0)
- ->value("JS_STRING", 1)
- ->value("JS_NUMBER", 2)
- ->finalizeToPool();
-
-$pool->addMessage('google.protobuf.internal.OneofOptions', OneofOptions::class)
- ->repeated('uninterpreted_option', GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption')
- ->finalizeToPool();
-
-$pool->addMessage('google.protobuf.internal.EnumOptions', EnumOptions::class)
- ->optional('allow_alias', GPBType::BOOL, 2)
- ->optional('deprecated', GPBType::BOOL, 3)
- ->repeated('uninterpreted_option', GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption')
- ->finalizeToPool();
-
-$pool->addMessage('google.protobuf.internal.EnumValueOptions', EnumValueOptions::class)
- ->optional('deprecated', GPBType::BOOL, 1)
- ->repeated('uninterpreted_option', GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption')
- ->finalizeToPool();
-
-$pool->addMessage('google.protobuf.internal.ServiceOptions', ServiceOptions::class)
- ->optional('deprecated', GPBType::BOOL, 33)
- ->repeated('uninterpreted_option', GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption')
- ->finalizeToPool();
-
-$pool->addMessage('google.protobuf.internal.MethodOptions', MethodOptions::class)
- ->optional('deprecated', GPBType::BOOL, 33)
- ->repeated('uninterpreted_option', GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption')
- ->finalizeToPool();
-
-$pool->addMessage('google.protobuf.internal.UninterpretedOption', UninterpretedOption::class)
- ->repeated('name', GPBType::MESSAGE, 2, 'google.protobuf.internal.UninterpretedOption.NamePart')
- ->optional('identifier_value', GPBType::STRING, 3)
- ->optional('positive_int_value', GPBType::UINT64, 4)
- ->optional('negative_int_value', GPBType::INT64, 5)
- ->optional('double_value', GPBType::DOUBLE, 6)
- ->optional('string_value', GPBType::BYTES, 7)
- ->optional('aggregate_value', GPBType::STRING, 8)
- ->finalizeToPool();
-
-$pool->addMessage('google.protobuf.internal.UninterpretedOption.NamePart', UninterpretedOption_NamePart::class)
- ->required('name_part', GPBType::STRING, 1)
- ->required('is_extension', GPBType::BOOL, 2)
- ->finalizeToPool();
-
-$pool->addMessage('google.protobuf.internal.SourceCodeInfo', SourceCodeInfo::class)
- ->repeated('location', GPBType::MESSAGE, 1, 'google.protobuf.internal.SourceCodeInfo.Location')
- ->finalizeToPool();
-
-$pool->addMessage('google.protobuf.internal.SourceCodeInfo.Location', SourceCodeInfo_Location::class)
- ->repeated('path', GPBType::INT32, 1)
- ->repeated('span', GPBType::INT32, 2)
- ->optional('leading_comments', GPBType::STRING, 3)
- ->optional('trailing_comments', GPBType::STRING, 4)
- ->repeated('leading_detached_comments', GPBType::STRING, 6)
- ->finalizeToPool();
-
-$pool->addMessage('google.protobuf.internal.GeneratedCodeInfo', GeneratedCodeInfo::class)
- ->repeated('annotation', GPBType::MESSAGE, 1, 'google.protobuf.internal.GeneratedCodeInfo.Annotation')
- ->finalizeToPool();
-
-$pool->addMessage('google.protobuf.internal.GeneratedCodeInfo.Annotation', GeneratedCodeInfo_Annotation::class)
- ->repeated('path', GPBType::INT32, 1)
- ->optional('source_file', GPBType::STRING, 2)
- ->optional('begin', GPBType::INT32, 3)
- ->optional('end', GPBType::INT32, 4)
- ->finalizeToPool();
-
-$pool->finish();
diff --git a/php/tests/array_test.php b/php/tests/array_test.php
index a79a08bc..a4cad719 100644
--- a/php/tests/array_test.php
+++ b/php/tests/array_test.php
@@ -1,6 +1,5 @@
<?php
-require_once('test.pb.php');
require_once('test_util.php');
use Google\Protobuf\Internal\RepeatedField;
diff --git a/php/tests/autoload.php b/php/tests/autoload.php
new file mode 100755
index 00000000..0a917fc5
--- /dev/null
+++ b/php/tests/autoload.php
@@ -0,0 +1,25 @@
+<?php
+
+function getGeneratedFiles($dir, &$results = array())
+{
+ $files = scandir($dir);
+
+ foreach ($files as $key => $value) {
+ $path = realpath($dir.DIRECTORY_SEPARATOR.$value);
+ if (!is_dir($path)) {
+ $results[] = $path;
+ } else if ($value != "." && $value != "..") {
+ getGeneratedFiles($path, $results);
+ }
+ }
+ return $results;
+}
+
+foreach (getGeneratedFiles("generated") as $filename)
+{
+ if (!is_dir($filename)) {
+ include_once $filename;
+ }
+
+}
+
diff --git a/php/tests/encode_decode_test.php b/php/tests/encode_decode_test.php
index d07907c0..3218aa63 100644
--- a/php/tests/encode_decode_test.php
+++ b/php/tests/encode_decode_test.php
@@ -1,6 +1,5 @@
<?php
-require_once('test.pb.php');
require_once('test_base.php');
require_once('test_util.php');
@@ -23,7 +22,8 @@ class EncodeDecodeTest extends TestBase
$this->expectFields($from);
$data = $from->encode();
- $this->assertSame(TestUtil::getGoldenTestMessage(), $data);
+ $this->assertSame(bin2hex(TestUtil::getGoldenTestMessage()),
+ bin2hex($data));
}
public function testDecode()
@@ -133,4 +133,58 @@ class EncodeDecodeTest extends TestBase
$to->decode(TestUtil::getGoldenTestUnpackedMessage());
TestUtil::assertTestPackedMessage($to);
}
+
+ public function testDecodeInt64()
+ {
+ // Read 64 testing
+ $testVals = array(
+ '10' => '100a',
+ '100' => '1064',
+ '800' => '10a006',
+ '6400' => '108032',
+ '70400' => '1080a604',
+ '774400' => '1080a22f',
+ '9292800' => '108098b704',
+ '74342400' => '1080c0b923',
+ '743424000' => '108080bfe202',
+ '8177664000' => '108080b5bb1e',
+ '65421312000' => '108080a8dbf301',
+ '785055744000' => '108080e0c7ec16',
+ '9420668928000' => '10808080dd969202',
+ '103627358208000' => '10808080fff9c717',
+ '1139900940288000' => '10808080f5bd978302',
+ '13678811283456000' => '10808080fce699a618',
+ '109430490267648000' => '10808080e0b7ceb1c201',
+ '984874412408832000' => '10808080e0f5c1bed50d',
+ );
+
+ $msg = new TestMessage();
+ foreach ($testVals as $original => $encoded) {
+ $msg->setOptionalInt64($original);
+ $data = $msg->encode();
+ $this->assertSame($encoded, bin2hex($data));
+ $msg->setOptionalInt64(0);
+ $msg->decode($data);
+ $this->assertEquals($original, $msg->getOptionalInt64());
+ }
+ }
+
+ public function testDecodeFieldNonExist()
+ {
+ $data = hex2bin('c80501');
+ $m = new TestMessage();
+ $m->decode($data);
+ }
+
+ # TODO(teboring): Add test back when php implementation is ready for json
+ # encode/decode.
+ # public function testJsonEncode()
+ # {
+ # $from = new TestMessage();
+ # $this->setFields($from);
+ # $data = $from->jsonEncode();
+ # $to = new TestMessage();
+ # $to->jsonDecode($data);
+ # $this->expectFields($to);
+ # }
}
diff --git a/php/tests/gdb_test.sh b/php/tests/gdb_test.sh
new file mode 100755
index 00000000..3c0d97a2
--- /dev/null
+++ b/php/tests/gdb_test.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+# gdb --args php -dextension=../ext/google/protobuf/modules/protobuf.so `which
+# phpunit` --bootstrap autoload.php tmp_test.php
+#
+gdb --args php -dextension=../ext/google/protobuf/modules/protobuf.so `which phpunit` --bootstrap autoload.php encode_decode_test.php
+#
+# # gdb --args php -dextension=../ext/google/protobuf/modules/protobuf.so
+# memory_leak_test.php
+#
+# # USE_ZEND_ALLOC=0 valgrind --leak-check=yes php
+# -dextension=../ext/google/protobuf/modules/protobuf.so memory_leak_test.php
diff --git a/php/tests/generated_class_test.php b/php/tests/generated_class_test.php
index b3ecd3a1..83ce1139 100644
--- a/php/tests/generated_class_test.php
+++ b/php/tests/generated_class_test.php
@@ -1,7 +1,8 @@
<?php
-require_once('test.pb.php');
-require_once('test_no_namespace.pb.php');
+require_once('generated/NoNameSpaceEnum.php');
+require_once('generated/NoNameSpaceMessage.php');
+require_once('test_base.php');
require_once('test_util.php');
use Google\Protobuf\Internal\RepeatedField;
@@ -10,7 +11,7 @@ use Foo\TestEnum;
use Foo\TestMessage;
use Foo\TestMessage_Sub;
-class GeneratedClassTest extends PHPUnit_Framework_TestCase
+class GeneratedClassTest extends TestBase
{
#########################################################
@@ -574,23 +575,28 @@ class GeneratedClassTest extends PHPUnit_Framework_TestCase
public function testOneofField() {
$m = new TestMessage();
+ $this->assertSame("", $m->getMyOneof());
+
$m->setOneofInt32(1);
$this->assertSame(1, $m->getOneofInt32());
$this->assertSame(0.0, $m->getOneofFloat());
$this->assertSame('', $m->getOneofString());
$this->assertSame(NULL, $m->getOneofMessage());
+ $this->assertSame("oneof_int32", $m->getMyOneof());
$m->setOneofFloat(2.0);
$this->assertSame(0, $m->getOneofInt32());
$this->assertSame(2.0, $m->getOneofFloat());
$this->assertSame('', $m->getOneofString());
$this->assertSame(NULL, $m->getOneofMessage());
+ $this->assertSame("oneof_float", $m->getMyOneof());
$m->setOneofString('abc');
$this->assertSame(0, $m->getOneofInt32());
$this->assertSame(0.0, $m->getOneofFloat());
$this->assertSame('abc', $m->getOneofString());
$this->assertSame(NULL, $m->getOneofMessage());
+ $this->assertSame("oneof_string", $m->getMyOneof());
$sub_m = new TestMessage_Sub();
$sub_m->setA(1);
@@ -599,13 +605,33 @@ class GeneratedClassTest extends PHPUnit_Framework_TestCase
$this->assertSame(0.0, $m->getOneofFloat());
$this->assertSame('', $m->getOneofString());
$this->assertSame(1, $m->getOneofMessage()->getA());
+ $this->assertSame("oneof_message", $m->getMyOneof());
}
#########################################################
- # Test oneof field.
+ # Test clear method.
#########################################################
- public function testMessageWithoutNamespace() {
- $m = new NoNameSpace();
+ public function testMessageClear()
+ {
+ $m = new TestMessage();
+ $this->setFields($m);
+ $this->expectFields($m);
+ $m->clear();
+ $this->expectEmptyFields($m);
+ }
+
+ #########################################################
+ # Test message/enum without namespace.
+ #########################################################
+
+ public function testMessageWithoutNamespace()
+ {
+ $m = new NoNameSpaceMessage();
+ }
+
+ public function testEnumWithoutNamespace()
+ {
+ $m = new NoNameSpaceEnum();
}
}
diff --git a/php/tests/map_field_test.php b/php/tests/map_field_test.php
index 4e42361d..d4ec44fc 100644
--- a/php/tests/map_field_test.php
+++ b/php/tests/map_field_test.php
@@ -1,6 +1,5 @@
<?php
-require_once('test.pb.php');
require_once('test_util.php');
use Google\Protobuf\Internal\GPBType;
diff --git a/php/tests/memory_leak_test.php b/php/tests/memory_leak_test.php
index ec54597b..af327273 100644
--- a/php/tests/memory_leak_test.php
+++ b/php/tests/memory_leak_test.php
@@ -2,7 +2,15 @@
# phpunit has memory leak by itself. Thus, it cannot be used to test memory leak.
-require_once('test.pb.php');
+require_once('generated/Bar/TestInclude.php');
+require_once('generated/Foo/TestEnum.php');
+require_once('generated/Foo/TestMessage.php');
+require_once('generated/Foo/TestMessage_Sub.php');
+require_once('generated/Foo/TestPackedMessage.php');
+require_once('generated/Foo/TestPhpDoc.php');
+require_once('generated/Foo/TestUnpackedMessage.php');
+require_once('generated/GPBMetadata/Proto/Test.php');
+require_once('generated/GPBMetadata/Proto/TestInclude.php');
require_once('test_util.php');
use Google\Protobuf\Internal\RepeatedField;
diff --git a/php/tests/php_implementation_test.php b/php/tests/php_implementation_test.php
index 485956cc..00125db4 100644
--- a/php/tests/php_implementation_test.php
+++ b/php/tests/php_implementation_test.php
@@ -1,6 +1,5 @@
<?php
-require_once('test.pb.php');
require_once('test_base.php');
require_once('test_util.php');
@@ -367,6 +366,34 @@ class ImplementationTest extends TestBase
$this->assertSame(32768, $var);
}
$this->assertFalse($input->readVarint64($var));
+
+ // Read 64 testing
+ $testVals = array(
+ '10' => '0a000000000000000000',
+ '100' => '64000000000000000000',
+ '800' => 'a0060000000000000000',
+ '6400' => '80320000000000000000',
+ '70400' => '80a60400000000000000',
+ '774400' => '80a22f00000000000000',
+ '9292800' => '8098b704000000000000',
+ '74342400' => '80c0b923000000000000',
+ '743424000' => '8080bfe2020000000000',
+ '8177664000' => '8080b5bb1e0000000000',
+ '65421312000' => '8080a8dbf30100000000',
+ '785055744000' => '8080e0c7ec1600000000',
+ '9420668928000' => '808080dd969202000000',
+ '103627358208000' => '808080fff9c717000000',
+ '1139900940288000' => '808080f5bd9783020000',
+ '13678811283456000' => '808080fce699a6180000',
+ '109430490267648000' => '808080e0b7ceb1c20100',
+ '984874412408832000' => '808080e0f5c1bed50d00',
+ );
+
+ foreach ($testVals as $original => $encoded) {
+ $input = new InputStream(hex2bin($encoded));
+ $this->assertTrue($input->readVarint64($var));
+ $this->assertEquals($original, $var);
+ }
}
public function testReadVarint32()
@@ -469,7 +496,7 @@ class ImplementationTest extends TestBase
{
$m = new TestMessage();
TestUtil::setTestMessage($m);
- $this->assertSame(447, $m->byteSize());
+ $this->assertSame(481, $m->byteSize());
}
public function testPackedByteSize()
diff --git a/php/tests/test.proto b/php/tests/proto/test.proto
index 15709c83..594aee4d 100644
--- a/php/tests/test.proto
+++ b/php/tests/proto/test.proto
@@ -1,6 +1,6 @@
syntax = "proto3";
-import 'test_include.proto';
+import 'proto/test_include.proto';
package foo;
@@ -92,7 +92,8 @@ message TestMessage {
int32 a = 1;
}
- // NestedMessage nested_message = 90;
+ // Reserved for non-existing field test.
+ // int32 non_exist = 89;
}
enum TestEnum {
@@ -134,3 +135,8 @@ message TestUnpackedMessage {
repeated bool repeated_bool = 102 [packed = false];
repeated TestEnum repeated_enum = 103 [packed = false];
}
+
+// /**/@<>&\{
+message TestPhpDoc {
+ int32 a = 1;
+}
diff --git a/php/tests/test_include.proto b/php/tests/proto/test_include.proto
index 9844617f..9844617f 100644
--- a/php/tests/test_include.proto
+++ b/php/tests/proto/test_include.proto
diff --git a/php/tests/proto/test_no_namespace.proto b/php/tests/proto/test_no_namespace.proto
new file mode 100644
index 00000000..b8c4fdf2
--- /dev/null
+++ b/php/tests/proto/test_no_namespace.proto
@@ -0,0 +1,10 @@
+syntax = "proto3";
+
+message NoNameSpaceMessage {
+ int32 a = 1;
+}
+
+enum NoNameSpaceEnum {
+ VALUE_A = 0;
+ VALUE_B = 1;
+}
diff --git a/php/tests/test.pb.php b/php/tests/test.pb.php
deleted file mode 100644
index ed316b6e..00000000
--- a/php/tests/test.pb.php
+++ /dev/null
@@ -1,1385 +0,0 @@
-<?php
-# Generated by the protocol buffer compiler. DO NOT EDIT!
-# source: test.proto
-
-namespace Foo;
-
-require_once('test_include.pb.php');
-use Google\Protobuf\Internal\DescriptorPool;
-use Google\Protobuf\Internal\GPBType;
-use Google\Protobuf\Internal\RepeatedField;
-use Google\Protobuf\Internal\GPBUtil;
-
-class TestMessage extends \Google\Protobuf\Internal\Message
-{
- private $optional_int32 = 0;
- private $optional_int64 = 0;
- private $optional_uint32 = 0;
- private $optional_uint64 = 0;
- private $optional_sint32 = 0;
- private $optional_sint64 = 0;
- private $optional_fixed32 = 0;
- private $optional_fixed64 = 0;
- private $optional_sfixed32 = 0;
- private $optional_sfixed64 = 0;
- private $optional_float = 0.0;
- private $optional_double = 0.0;
- private $optional_bool = false;
- private $optional_string = '';
- private $optional_bytes = '';
- private $optional_enum = 0;
- private $optional_message = null;
- private $optional_included_message = null;
- private $recursive = null;
- private $repeated_int32;
- private $repeated_int64;
- private $repeated_uint32;
- private $repeated_uint64;
- private $repeated_sint32;
- private $repeated_sint64;
- private $repeated_fixed32;
- private $repeated_fixed64;
- private $repeated_sfixed32;
- private $repeated_sfixed64;
- private $repeated_float;
- private $repeated_double;
- private $repeated_bool;
- private $repeated_string;
- private $repeated_bytes;
- private $repeated_enum;
- private $repeated_message;
- private $repeated_recursive;
- private $map_int32_int32;
- private $map_int64_int64;
- private $map_uint32_uint32;
- private $map_uint64_uint64;
- private $map_sint32_sint32;
- private $map_sint64_sint64;
- private $map_fixed32_fixed32;
- private $map_fixed64_fixed64;
- private $map_sfixed32_sfixed32;
- private $map_sfixed64_sfixed64;
- private $map_int32_float;
- private $map_int32_double;
- private $map_bool_bool;
- private $map_string_string;
- private $map_int32_bytes;
- private $map_int32_enum;
- private $map_int32_message;
- private $map_recursive;
- protected $my_oneof;
-
- public function getOptionalInt32()
- {
- return $this->optional_int32;
- }
-
- public function setOptionalInt32($var)
- {
- GPBUtil::checkInt32($var);
- $this->optional_int32 = $var;
- }
-
- public function getOptionalInt64()
- {
- return $this->optional_int64;
- }
-
- public function setOptionalInt64($var)
- {
- GPBUtil::checkInt64($var);
- $this->optional_int64 = $var;
- }
-
- public function getOptionalUint32()
- {
- return $this->optional_uint32;
- }
-
- public function setOptionalUint32($var)
- {
- GPBUtil::checkUint32($var);
- $this->optional_uint32 = $var;
- }
-
- public function getOptionalUint64()
- {
- return $this->optional_uint64;
- }
-
- public function setOptionalUint64($var)
- {
- GPBUtil::checkUint64($var);
- $this->optional_uint64 = $var;
- }
-
- public function getOptionalSint32()
- {
- return $this->optional_sint32;
- }
-
- public function setOptionalSint32($var)
- {
- GPBUtil::checkInt32($var);
- $this->optional_sint32 = $var;
- }
-
- public function getOptionalSint64()
- {
- return $this->optional_sint64;
- }
-
- public function setOptionalSint64($var)
- {
- GPBUtil::checkInt64($var);
- $this->optional_sint64 = $var;
- }
-
- public function getOptionalFixed32()
- {
- return $this->optional_fixed32;
- }
-
- public function setOptionalFixed32($var)
- {
- GPBUtil::checkUint32($var);
- $this->optional_fixed32 = $var;
- }
-
- public function getOptionalFixed64()
- {
- return $this->optional_fixed64;
- }
-
- public function setOptionalFixed64($var)
- {
- GPBUtil::checkUint64($var);
- $this->optional_fixed64 = $var;
- }
-
- public function getOptionalSfixed32()
- {
- return $this->optional_sfixed32;
- }
-
- public function setOptionalSfixed32($var)
- {
- GPBUtil::checkInt32($var);
- $this->optional_sfixed32 = $var;
- }
-
- public function getOptionalSfixed64()
- {
- return $this->optional_sfixed64;
- }
-
- public function setOptionalSfixed64($var)
- {
- GPBUtil::checkInt64($var);
- $this->optional_sfixed64 = $var;
- }
-
- public function getOptionalFloat()
- {
- return $this->optional_float;
- }
-
- public function setOptionalFloat($var)
- {
- GPBUtil::checkFloat($var);
- $this->optional_float = $var;
- }
-
- public function getOptionalDouble()
- {
- return $this->optional_double;
- }
-
- public function setOptionalDouble($var)
- {
- GPBUtil::checkDouble($var);
- $this->optional_double = $var;
- }
-
- public function getOptionalBool()
- {
- return $this->optional_bool;
- }
-
- public function setOptionalBool($var)
- {
- GPBUtil::checkBool($var);
- $this->optional_bool = $var;
- }
-
- public function getOptionalString()
- {
- return $this->optional_string;
- }
-
- public function setOptionalString($var)
- {
- GPBUtil::checkString($var, True);
- $this->optional_string = $var;
- }
-
- public function getOptionalBytes()
- {
- return $this->optional_bytes;
- }
-
- public function setOptionalBytes($var)
- {
- GPBUtil::checkString($var, False);
- $this->optional_bytes = $var;
- }
-
- public function getOptionalEnum()
- {
- return $this->optional_enum;
- }
-
- public function setOptionalEnum($var)
- {
- GPBUtil::checkEnum($var, \Foo\TestEnum::class);
- $this->optional_enum = $var;
- }
-
- public function getOptionalMessage()
- {
- return $this->optional_message;
- }
-
- public function setOptionalMessage(&$var)
- {
- GPBUtil::checkMessage($var, \Foo\TestMessage_Sub::class);
- $this->optional_message = $var;
- }
-
- public function getOptionalIncludedMessage()
- {
- return $this->optional_included_message;
- }
-
- public function setOptionalIncludedMessage(&$var)
- {
- GPBUtil::checkMessage($var, \Bar\TestInclude::class);
- $this->optional_included_message = $var;
- }
-
- public function getRecursive()
- {
- return $this->recursive;
- }
-
- public function setRecursive(&$var)
- {
- GPBUtil::checkMessage($var, \Foo\TestMessage::class);
- $this->recursive = $var;
- }
-
- public function getRepeatedInt32()
- {
- return $this->repeated_int32;
- }
-
- public function setRepeatedInt32(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::INT32);
- $this->repeated_int32 = $var;
- }
-
- public function getRepeatedInt64()
- {
- return $this->repeated_int64;
- }
-
- public function setRepeatedInt64(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::INT64);
- $this->repeated_int64 = $var;
- }
-
- public function getRepeatedUint32()
- {
- return $this->repeated_uint32;
- }
-
- public function setRepeatedUint32(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::UINT32);
- $this->repeated_uint32 = $var;
- }
-
- public function getRepeatedUint64()
- {
- return $this->repeated_uint64;
- }
-
- public function setRepeatedUint64(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::UINT64);
- $this->repeated_uint64 = $var;
- }
-
- public function getRepeatedSint32()
- {
- return $this->repeated_sint32;
- }
-
- public function setRepeatedSint32(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::SINT32);
- $this->repeated_sint32 = $var;
- }
-
- public function getRepeatedSint64()
- {
- return $this->repeated_sint64;
- }
-
- public function setRepeatedSint64(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::SINT64);
- $this->repeated_sint64 = $var;
- }
-
- public function getRepeatedFixed32()
- {
- return $this->repeated_fixed32;
- }
-
- public function setRepeatedFixed32(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::FIXED32);
- $this->repeated_fixed32 = $var;
- }
-
- public function getRepeatedFixed64()
- {
- return $this->repeated_fixed64;
- }
-
- public function setRepeatedFixed64(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::FIXED64);
- $this->repeated_fixed64 = $var;
- }
-
- public function getRepeatedSfixed32()
- {
- return $this->repeated_sfixed32;
- }
-
- public function setRepeatedSfixed32(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::SFIXED32);
- $this->repeated_sfixed32 = $var;
- }
-
- public function getRepeatedSfixed64()
- {
- return $this->repeated_sfixed64;
- }
-
- public function setRepeatedSfixed64(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::SFIXED64);
- $this->repeated_sfixed64 = $var;
- }
-
- public function getRepeatedFloat()
- {
- return $this->repeated_float;
- }
-
- public function setRepeatedFloat(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::FLOAT);
- $this->repeated_float = $var;
- }
-
- public function getRepeatedDouble()
- {
- return $this->repeated_double;
- }
-
- public function setRepeatedDouble(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::DOUBLE);
- $this->repeated_double = $var;
- }
-
- public function getRepeatedBool()
- {
- return $this->repeated_bool;
- }
-
- public function setRepeatedBool(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::BOOL);
- $this->repeated_bool = $var;
- }
-
- public function getRepeatedString()
- {
- return $this->repeated_string;
- }
-
- public function setRepeatedString(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::STRING);
- $this->repeated_string = $var;
- }
-
- public function getRepeatedBytes()
- {
- return $this->repeated_bytes;
- }
-
- public function setRepeatedBytes(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::BYTES);
- $this->repeated_bytes = $var;
- }
-
- public function getRepeatedEnum()
- {
- return $this->repeated_enum;
- }
-
- public function setRepeatedEnum(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::ENUM, Foo\TestEnum::class);
- $this->repeated_enum = $var;
- }
-
- public function getRepeatedMessage()
- {
- return $this->repeated_message;
- }
-
- public function setRepeatedMessage(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Foo\TestMessage_Sub::class);
- $this->repeated_message = $var;
- }
-
- public function getRepeatedRecursive()
- {
- return $this->repeated_recursive;
- }
-
- public function setRepeatedRecursive(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Foo\TestMessage::class);
- $this->repeated_recursive = $var;
- }
-
- public function getOneofInt32()
- {
- return $this->readOneof(51);
- }
-
- public function setOneofInt32($var)
- {
- GPBUtil::checkInt32($var);
- $this->writeOneof(51, $var);
- }
-
- public function getOneofInt64()
- {
- return $this->readOneof(52);
- }
-
- public function setOneofInt64($var)
- {
- GPBUtil::checkInt64($var);
- $this->writeOneof(52, $var);
- }
-
- public function getOneofUint32()
- {
- return $this->readOneof(53);
- }
-
- public function setOneofUint32($var)
- {
- GPBUtil::checkUint32($var);
- $this->writeOneof(53, $var);
- }
-
- public function getOneofUint64()
- {
- return $this->readOneof(54);
- }
-
- public function setOneofUint64($var)
- {
- GPBUtil::checkUint64($var);
- $this->writeOneof(54, $var);
- }
-
- public function getOneofSint32()
- {
- return $this->readOneof(55);
- }
-
- public function setOneofSint32($var)
- {
- GPBUtil::checkUint32($var);
- $this->writeOneof(55, $var);
- }
-
- public function getOneofSint64()
- {
- return $this->readOneof(56);
- }
-
- public function setOneofSint64($var)
- {
- GPBUtil::checkUint64($var);
- $this->writeOneof(56, $var);
- }
-
- public function getOneofFixed32()
- {
- return $this->readOneof(57);
- }
-
- public function setOneofFixed32($var)
- {
- GPBUtil::checkUint32($var);
- $this->writeOneof(57, $var);
- }
-
- public function getOneofFixed64()
- {
- return $this->readOneof(58);
- }
-
- public function setOneofFixed64($var)
- {
- GPBUtil::checkUint64($var);
- $this->writeOneof(58, $var);
- }
-
- public function getOneofSfixed32()
- {
- return $this->readOneof(59);
- }
-
- public function setOneofSfixed32($var)
- {
- GPBUtil::checkUint32($var);
- $this->writeOneof(59, $var);
- }
-
- public function getOneofSfixed64()
- {
- return $this->readOneof(60);
- }
-
- public function setOneofSfixed64($var)
- {
- GPBUtil::checkUint64($var);
- $this->writeOneof(60, $var);
- }
-
- public function getOneofDouble()
- {
- return $this->readOneof(61);
- }
-
- public function setOneofDouble($var)
- {
- GPBUtil::checkDouble($var);
- $this->writeOneof(61, $var);
- }
-
- public function getOneofFloat()
- {
- return $this->readOneof(62);
- }
-
- public function setOneofFloat($var)
- {
- GPBUtil::checkFloat($var);
- $this->writeOneof(62, $var);
- }
-
- public function getOneofBool()
- {
- return $this->readOneof(63);
- }
-
- public function setOneofBool($var)
- {
- GPBUtil::checkBool($var);
- $this->writeOneof(63, $var);
- }
-
- public function getOneofString()
- {
- return $this->readOneof(64);
- }
-
- public function setOneofString($var)
- {
- GPBUtil::checkString($var, True);
- $this->writeOneof(64, $var);
- }
-
- public function getOneofBytes()
- {
- return $this->readOneof(65);
- }
-
- public function setOneofBytes($var)
- {
- GPBUtil::checkString($var, False);
- $this->writeOneof(65, $var);
- }
-
- public function getOneofEnum()
- {
- return $this->readOneof(66);
- }
-
- public function setOneofEnum($var)
- {
- GPBUtil::checkEnum($var, \Foo\TestEnum::class);
- $this->writeOneof(66, $var);
- }
-
- public function getOneofMessage()
- {
- return $this->readOneof(67);
- }
-
- public function setOneofMessage(&$var)
- {
- GPBUtil::checkMessage($var, \Foo\TestMessage_Sub::class);
- $this->writeOneof(67, $var);
- }
-
- public function getMapInt32Int32()
- {
- return $this->map_int32_int32;
- }
-
- public function setMapInt32Int32(&$var)
- {
- $this->map_int32_int32 = $var;
- }
-
- public function getMapInt64Int64()
- {
- return $this->map_int64_int64;
- }
-
- public function setMapInt64Int64(&$var)
- {
- $this->map_int64_int64 = $var;
- }
-
- public function getMapUint32Uint32()
- {
- return $this->map_uint32_uint32;
- }
-
- public function setMapUint32Uint32(&$var)
- {
- $this->map_uint32_uint32 = $var;
- }
-
- public function getMapUint64Uint64()
- {
- return $this->map_uint64_uint64;
- }
-
- public function setMapUint64Uint64(&$var)
- {
- $this->map_uint64_uint64 = $var;
- }
-
- public function getMapSint32Sint32()
- {
- return $this->map_sint32_sint32;
- }
-
- public function setMapSint32Sint32(&$var)
- {
- $this->map_sint32_sint32 = $var;
- }
-
- public function getMapSint64Sint64()
- {
- return $this->map_sint64_sint64;
- }
-
- public function setMapSint64Sint64(&$var)
- {
- $this->map_sint64_sint64 = $var;
- }
-
- public function getMapFixed32Fixed32()
- {
- return $this->map_fixed32_fixed32;
- }
-
- public function setMapFixed32Fixed32(&$var)
- {
- $this->map_fixed32_fixed32 = $var;
- }
-
- public function getMapFixed64Fixed64()
- {
- return $this->map_fixed64_fixed64;
- }
-
- public function setMapFixed64Fixed64(&$var)
- {
- $this->map_fixed64_fixed64 = $var;
- }
-
- public function getMapSfixed32Sfixed32()
- {
- return $this->map_sfixed32_sfixed32;
- }
-
- public function setMapSfixed32Sfixed32(&$var)
- {
- $this->map_sfixed32_sfixed32 = $var;
- }
-
- public function getMapSfixed64Sfixed64()
- {
- return $this->map_sfixed64_sfixed64;
- }
-
- public function setMapSfixed64Sfixed64(&$var)
- {
- $this->map_sfixed64_sfixed64 = $var;
- }
-
- public function getMapInt32Float()
- {
- return $this->map_int32_float;
- }
-
- public function setMapInt32Float(&$var)
- {
- $this->map_int32_float = $var;
- }
-
- public function getMapInt32Double()
- {
- return $this->map_int32_double;
- }
-
- public function setMapInt32Double(&$var)
- {
- $this->map_int32_double = $var;
- }
-
- public function getMapBoolBool()
- {
- return $this->map_bool_bool;
- }
-
- public function setMapBoolBool(&$var)
- {
- $this->map_bool_bool = $var;
- }
-
- public function getMapStringString()
- {
- return $this->map_string_string;
- }
-
- public function setMapStringString(&$var)
- {
- $this->map_string_string = $var;
- }
-
- public function getMapInt32Bytes()
- {
- return $this->map_int32_bytes;
- }
-
- public function setMapInt32Bytes(&$var)
- {
- $this->map_int32_bytes = $var;
- }
-
- public function getMapInt32Enum()
- {
- return $this->map_int32_enum;
- }
-
- public function setMapInt32Enum(&$var)
- {
- $this->map_int32_enum = $var;
- }
-
- public function getMapInt32Message()
- {
- return $this->map_int32_message;
- }
-
- public function setMapInt32Message(&$var)
- {
- $this->map_int32_message = $var;
- }
-
- public function getMapRecursive()
- {
- return $this->map_recursive;
- }
-
- public function setMapRecursive(&$var)
- {
- $this->map_recursive = $var;
- }
-
- public function getMyOneof()
- {
- return $this->my_oneof;
- }
-
-}
-
-class TestMessage_Sub extends \Google\Protobuf\Internal\Message
-{
- private $a = 0;
-
- public function getA()
- {
- return $this->a;
- }
-
- public function setA($var)
- {
- GPBUtil::checkInt32($var);
- $this->a = $var;
- }
-
-}
-
-class TestPackedMessage extends \Google\Protobuf\Internal\Message
-{
- private $repeated_int32;
- private $repeated_int64;
- private $repeated_uint32;
- private $repeated_uint64;
- private $repeated_sint32;
- private $repeated_sint64;
- private $repeated_fixed32;
- private $repeated_fixed64;
- private $repeated_sfixed32;
- private $repeated_sfixed64;
- private $repeated_float;
- private $repeated_double;
- private $repeated_bool;
- private $repeated_enum;
-
- public function getRepeatedInt32()
- {
- return $this->repeated_int32;
- }
-
- public function setRepeatedInt32(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::INT32);
- $this->repeated_int32 = $var;
- }
-
- public function getRepeatedInt64()
- {
- return $this->repeated_int64;
- }
-
- public function setRepeatedInt64(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::INT64);
- $this->repeated_int64 = $var;
- }
-
- public function getRepeatedUint32()
- {
- return $this->repeated_uint32;
- }
-
- public function setRepeatedUint32(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::UINT32);
- $this->repeated_uint32 = $var;
- }
-
- public function getRepeatedUint64()
- {
- return $this->repeated_uint64;
- }
-
- public function setRepeatedUint64(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::UINT64);
- $this->repeated_uint64 = $var;
- }
-
- public function getRepeatedSint32()
- {
- return $this->repeated_sint32;
- }
-
- public function setRepeatedSint32(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::SINT32);
- $this->repeated_sint32 = $var;
- }
-
- public function getRepeatedSint64()
- {
- return $this->repeated_sint64;
- }
-
- public function setRepeatedSint64(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::SINT64);
- $this->repeated_sint64 = $var;
- }
-
- public function getRepeatedFixed32()
- {
- return $this->repeated_fixed32;
- }
-
- public function setRepeatedFixed32(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::FIXED32);
- $this->repeated_fixed32 = $var;
- }
-
- public function getRepeatedFixed64()
- {
- return $this->repeated_fixed64;
- }
-
- public function setRepeatedFixed64(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::FIXED64);
- $this->repeated_fixed64 = $var;
- }
-
- public function getRepeatedSfixed32()
- {
- return $this->repeated_sfixed32;
- }
-
- public function setRepeatedSfixed32(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::SFIXED32);
- $this->repeated_sfixed32 = $var;
- }
-
- public function getRepeatedSfixed64()
- {
- return $this->repeated_sfixed64;
- }
-
- public function setRepeatedSfixed64(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::SFIXED64);
- $this->repeated_sfixed64 = $var;
- }
-
- public function getRepeatedFloat()
- {
- return $this->repeated_float;
- }
-
- public function setRepeatedFloat(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::FLOAT);
- $this->repeated_float = $var;
- }
-
- public function getRepeatedDouble()
- {
- return $this->repeated_double;
- }
-
- public function setRepeatedDouble(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::DOUBLE);
- $this->repeated_double = $var;
- }
-
- public function getRepeatedBool()
- {
- return $this->repeated_bool;
- }
-
- public function setRepeatedBool(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::BOOL);
- $this->repeated_bool = $var;
- }
-
- public function getRepeatedEnum()
- {
- return $this->repeated_enum;
- }
-
- public function setRepeatedEnum(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::ENUM, Foo\TestEnum::class);
- $this->repeated_enum = $var;
- }
-
-}
-
-class TestUnpackedMessage extends \Google\Protobuf\Internal\Message
-{
- private $repeated_int32;
- private $repeated_int64;
- private $repeated_uint32;
- private $repeated_uint64;
- private $repeated_sint32;
- private $repeated_sint64;
- private $repeated_fixed32;
- private $repeated_fixed64;
- private $repeated_sfixed32;
- private $repeated_sfixed64;
- private $repeated_float;
- private $repeated_double;
- private $repeated_bool;
- private $repeated_enum;
-
- public function getRepeatedInt32()
- {
- return $this->repeated_int32;
- }
-
- public function setRepeatedInt32(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::INT32);
- $this->repeated_int32 = $var;
- }
-
- public function getRepeatedInt64()
- {
- return $this->repeated_int64;
- }
-
- public function setRepeatedInt64(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::INT64);
- $this->repeated_int64 = $var;
- }
-
- public function getRepeatedUint32()
- {
- return $this->repeated_uint32;
- }
-
- public function setRepeatedUint32(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::UINT32);
- $this->repeated_uint32 = $var;
- }
-
- public function getRepeatedUint64()
- {
- return $this->repeated_uint64;
- }
-
- public function setRepeatedUint64(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::UINT64);
- $this->repeated_uint64 = $var;
- }
-
- public function getRepeatedSint32()
- {
- return $this->repeated_sint32;
- }
-
- public function setRepeatedSint32(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::SINT32);
- $this->repeated_sint32 = $var;
- }
-
- public function getRepeatedSint64()
- {
- return $this->repeated_sint64;
- }
-
- public function setRepeatedSint64(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::SINT64);
- $this->repeated_sint64 = $var;
- }
-
- public function getRepeatedFixed32()
- {
- return $this->repeated_fixed32;
- }
-
- public function setRepeatedFixed32(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::FIXED32);
- $this->repeated_fixed32 = $var;
- }
-
- public function getRepeatedFixed64()
- {
- return $this->repeated_fixed64;
- }
-
- public function setRepeatedFixed64(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::FIXED64);
- $this->repeated_fixed64 = $var;
- }
-
- public function getRepeatedSfixed32()
- {
- return $this->repeated_sfixed32;
- }
-
- public function setRepeatedSfixed32(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::SFIXED32);
- $this->repeated_sfixed32 = $var;
- }
-
- public function getRepeatedSfixed64()
- {
- return $this->repeated_sfixed64;
- }
-
- public function setRepeatedSfixed64(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::SFIXED64);
- $this->repeated_sfixed64 = $var;
- }
-
- public function getRepeatedFloat()
- {
- return $this->repeated_float;
- }
-
- public function setRepeatedFloat(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::FLOAT);
- $this->repeated_float = $var;
- }
-
- public function getRepeatedDouble()
- {
- return $this->repeated_double;
- }
-
- public function setRepeatedDouble(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::DOUBLE);
- $this->repeated_double = $var;
- }
-
- public function getRepeatedBool()
- {
- return $this->repeated_bool;
- }
-
- public function setRepeatedBool(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::BOOL);
- $this->repeated_bool = $var;
- }
-
- public function getRepeatedEnum()
- {
- return $this->repeated_enum;
- }
-
- public function setRepeatedEnum(&$var)
- {
- GPBUtil::checkRepeatedField($var, GPBType::ENUM, Foo\TestEnum::class);
- $this->repeated_enum = $var;
- }
-
-}
-
-class TestEnum
-{
- const ZERO = 0;
- const ONE = 1;
-}
-
-$pool = DescriptorPool::getGeneratedPool();
-
-$pool->internalAddGeneratedFile(hex2bin(
- "0a83250a0a746573742e70726f746f1203666f6f1a12746573745f696e63" .
- "6c7564652e70726f746f22be1d0a0b546573744d65737361676512160a0e" .
- "6f7074696f6e616c5f696e74333218012001280512160a0e6f7074696f6e" .
- "616c5f696e74363418022001280312170a0f6f7074696f6e616c5f75696e" .
- "74333218032001280d12170a0f6f7074696f6e616c5f75696e7436341804" .
- "2001280412170a0f6f7074696f6e616c5f73696e74333218052001281112" .
- "170a0f6f7074696f6e616c5f73696e74363418062001281212180a106f70" .
- "74696f6e616c5f6669786564333218072001280712180a106f7074696f6e" .
- "616c5f6669786564363418082001280612190a116f7074696f6e616c5f73" .
- "6669786564333218092001280f12190a116f7074696f6e616c5f73666978" .
- "65643634180a2001281012160a0e6f7074696f6e616c5f666c6f6174180b" .
- "2001280212170a0f6f7074696f6e616c5f646f75626c65180c2001280112" .
- "150a0d6f7074696f6e616c5f626f6f6c180d2001280812170a0f6f707469" .
- "6f6e616c5f737472696e67180e2001280912160a0e6f7074696f6e616c5f" .
- "6279746573180f2001280c12240a0d6f7074696f6e616c5f656e756d1810" .
- "2001280e320d2e666f6f2e54657374456e756d122e0a106f7074696f6e61" .
- "6c5f6d65737361676518112001280b32142e666f6f2e546573744d657373" .
- "6167652e53756212330a196f7074696f6e616c5f696e636c756465645f6d" .
- "65737361676518122001280b32102e6261722e54657374496e636c756465" .
- "12230a0972656375727369766518132001280b32102e666f6f2e54657374" .
- "4d65737361676512160a0e72657065617465645f696e743332181f200328" .
- "0512160a0e72657065617465645f696e74363418202003280312170a0f72" .
- "657065617465645f75696e74333218212003280d12170a0f726570656174" .
- "65645f75696e74363418222003280412170a0f72657065617465645f7369" .
- "6e74333218232003281112170a0f72657065617465645f73696e74363418" .
- "242003281212180a1072657065617465645f666978656433321825200328" .
- "0712180a1072657065617465645f6669786564363418262003280612190a" .
- "1172657065617465645f736669786564333218272003280f12190a117265" .
- "7065617465645f736669786564363418282003281012160a0e7265706561" .
- "7465645f666c6f617418292003280212170a0f72657065617465645f646f" .
- "75626c65182a2003280112150a0d72657065617465645f626f6f6c182b20" .
- "03280812170a0f72657065617465645f737472696e67182c200328091216" .
- "0a0e72657065617465645f6279746573182d2003280c12240a0d72657065" .
- "617465645f656e756d182e2003280e320d2e666f6f2e54657374456e756d" .
- "122e0a1072657065617465645f6d657373616765182f2003280b32142e66" .
- "6f6f2e546573744d6573736167652e537562122c0a127265706561746564" .
- "5f72656375727369766518302003280b32102e666f6f2e546573744d6573" .
- "7361676512150a0b6f6e656f665f696e743332183320012805480012150a" .
- "0b6f6e656f665f696e743634183420012803480012160a0c6f6e656f665f" .
- "75696e74333218352001280d480012160a0c6f6e656f665f75696e743634" .
- "183620012804480012160a0c6f6e656f665f73696e74333218372001280d" .
- "480012160a0c6f6e656f665f73696e743634183820012804480012170a0d" .
- "6f6e656f665f6669786564333218392001280d480012170a0d6f6e656f66" .
- "5f66697865643634183a20012804480012180a0e6f6e656f665f73666978" .
- "65643332183b2001280d480012180a0e6f6e656f665f7366697865643634" .
- "183c20012804480012160a0c6f6e656f665f646f75626c65183d20012801" .
- "480012150a0b6f6e656f665f666c6f6174183e20012802480012140a0a6f" .
- "6e656f665f626f6f6c183f20012808480012160a0c6f6e656f665f737472" .
- "696e67184020012809480012150a0b6f6e656f665f627974657318412001" .
- "280c480012230a0a6f6e656f665f656e756d18422001280e320d2e666f6f" .
- "2e54657374456e756d4800122d0a0d6f6e656f665f6d6573736167651843" .
- "2001280b32142e666f6f2e546573744d6573736167652e5375624800123c" .
- "0a0f6d61705f696e7433325f696e74333218472003280b32232e666f6f2e" .
- "546573744d6573736167652e4d6170496e743332496e743332456e747279" .
- "123c0a0f6d61705f696e7436345f696e74363418482003280b32232e666f" .
- "6f2e546573744d6573736167652e4d6170496e743634496e743634456e74" .
- "727912400a116d61705f75696e7433325f75696e74333218492003280b32" .
- "252e666f6f2e546573744d6573736167652e4d617055696e74333255696e" .
- "743332456e74727912400a116d61705f75696e7436345f75696e74363418" .
- "4a2003280b32252e666f6f2e546573744d6573736167652e4d617055696e" .
- "74363455696e743634456e74727912400a116d61705f73696e7433325f73" .
- "696e743332184b2003280b32252e666f6f2e546573744d6573736167652e" .
- "4d617053696e74333253696e743332456e74727912400a116d61705f7369" .
- "6e7436345f73696e743634184c2003280b32252e666f6f2e546573744d65" .
- "73736167652e4d617053696e74363453696e743634456e74727912440a13" .
- "6d61705f666978656433325f66697865643332184d2003280b32272e666f" .
- "6f2e546573744d6573736167652e4d617046697865643332466978656433" .
- "32456e74727912440a136d61705f666978656436345f6669786564363418" .
- "4e2003280b32272e666f6f2e546573744d6573736167652e4d6170466978" .
- "6564363446697865643634456e74727912480a156d61705f736669786564" .
- "33325f7366697865643332184f2003280b32292e666f6f2e546573744d65" .
- "73736167652e4d617053666978656433325366697865643332456e747279" .
- "12480a156d61705f73666978656436345f73666978656436341850200328" .
- "0b32292e666f6f2e546573744d6573736167652e4d617053666978656436" .
- "345366697865643634456e747279123c0a0f6d61705f696e7433325f666c" .
- "6f617418512003280b32232e666f6f2e546573744d6573736167652e4d61" .
- "70496e743332466c6f6174456e747279123e0a106d61705f696e7433325f" .
- "646f75626c6518522003280b32242e666f6f2e546573744d657373616765" .
- "2e4d6170496e743332446f75626c65456e74727912380a0d6d61705f626f" .
- "6f6c5f626f6f6c18532003280b32212e666f6f2e546573744d6573736167" .
- "652e4d6170426f6f6c426f6f6c456e74727912400a116d61705f73747269" .
- "6e675f737472696e6718542003280b32252e666f6f2e546573744d657373" .
- "6167652e4d6170537472696e67537472696e67456e747279123c0a0f6d61" .
- "705f696e7433325f627974657318552003280b32232e666f6f2e54657374" .
- "4d6573736167652e4d6170496e7433324279746573456e747279123a0a0e" .
- "6d61705f696e7433325f656e756d18562003280b32222e666f6f2e546573" .
- "744d6573736167652e4d6170496e743332456e756d456e74727912400a11" .
- "6d61705f696e7433325f6d65737361676518572003280b32252e666f6f2e" .
- "546573744d6573736167652e4d6170496e7433324d657373616765456e74" .
- "727912390a0d6d61705f72656375727369766518582003280b32222e666f" .
- "6f2e546573744d6573736167652e4d6170526563757273697665456e7472" .
- "791a340a124d6170496e743332496e743332456e747279120b0a036b6579" .
- "180120012805120d0a0576616c75651802200128053a0238011a340a124d" .
- "6170496e743634496e743634456e747279120b0a036b6579180120012803" .
- "120d0a0576616c75651802200128033a0238011a360a144d617055696e74" .
- "333255696e743332456e747279120b0a036b657918012001280d120d0a05" .
- "76616c756518022001280d3a0238011a360a144d617055696e7436345569" .
- "6e743634456e747279120b0a036b6579180120012804120d0a0576616c75" .
- "651802200128043a0238011a360a144d617053696e74333253696e743332" .
- "456e747279120b0a036b6579180120012811120d0a0576616c7565180220" .
- "0128113a0238011a360a144d617053696e74363453696e743634456e7472" .
- "79120b0a036b6579180120012812120d0a0576616c75651802200128123a" .
- "0238011a380a164d61704669786564333246697865643332456e74727912" .
- "0b0a036b6579180120012807120d0a0576616c75651802200128073a0238" .
- "011a380a164d61704669786564363446697865643634456e747279120b0a" .
- "036b6579180120012806120d0a0576616c75651802200128063a0238011a" .
- "3a0a184d617053666978656433325366697865643332456e747279120b0a" .
- "036b657918012001280f120d0a0576616c756518022001280f3a0238011a" .
- "3a0a184d617053666978656436345366697865643634456e747279120b0a" .
- "036b6579180120012810120d0a0576616c75651802200128103a0238011a" .
- "340a124d6170496e743332466c6f6174456e747279120b0a036b65791801" .
- "20012805120d0a0576616c75651802200128023a0238011a350a134d6170" .
- "496e743332446f75626c65456e747279120b0a036b657918012001280512" .
- "0d0a0576616c75651802200128013a0238011a320a104d6170426f6f6c42" .
- "6f6f6c456e747279120b0a036b6579180120012808120d0a0576616c7565" .
- "1802200128083a0238011a360a144d6170537472696e67537472696e6745" .
- "6e747279120b0a036b6579180120012809120d0a0576616c756518022001" .
- "28093a0238011a340a124d6170496e7433324279746573456e747279120b" .
- "0a036b6579180120012805120d0a0576616c756518022001280c3a023801" .
- "1a420a114d6170496e743332456e756d456e747279120b0a036b65791801" .
- "20012805121c0a0576616c756518022001280e320d2e666f6f2e54657374" .
- "456e756d3a0238011a4c0a144d6170496e7433324d657373616765456e74" .
- "7279120b0a036b657918012001280512230a0576616c756518022001280b" .
- "32142e666f6f2e546573744d6573736167652e5375623a0238011a450a11" .
- "4d6170526563757273697665456e747279120b0a036b6579180120012805" .
- "121f0a0576616c756518022001280b32102e666f6f2e546573744d657373" .
- "6167653a0238011a100a0353756212090a0161180120012805420a0a086d" .
- "795f6f6e656f6622b7030a11546573745061636b65644d65737361676512" .
- "1a0a0e72657065617465645f696e743332185a2003280542021001121a0a" .
- "0e72657065617465645f696e743634185b2003280342021001121b0a0f72" .
- "657065617465645f75696e743332185c2003280d42021001121b0a0f7265" .
- "7065617465645f75696e743634185d2003280442021001121b0a0f726570" .
- "65617465645f73696e743332185e2003281142021001121b0a0f72657065" .
- "617465645f73696e743634185f2003281242021001121c0a107265706561" .
- "7465645f6669786564333218602003280742021001121c0a107265706561" .
- "7465645f6669786564363418612003280642021001121d0a117265706561" .
- "7465645f736669786564333218622003280f42021001121d0a1172657065" .
- "617465645f736669786564363418632003281042021001121a0a0e726570" .
- "65617465645f666c6f617418642003280242021001121b0a0f7265706561" .
- "7465645f646f75626c651865200328014202100112190a0d726570656174" .
- "65645f626f6f6c1866200328084202100112280a0d72657065617465645f" .
- "656e756d18672003280e320d2e666f6f2e54657374456e756d4202100122" .
- "b9030a1354657374556e7061636b65644d657373616765121a0a0e726570" .
- "65617465645f696e743332185a2003280542021000121a0a0e7265706561" .
- "7465645f696e743634185b2003280342021000121b0a0f72657065617465" .
- "645f75696e743332185c2003280d42021000121b0a0f7265706561746564" .
- "5f75696e743634185d2003280442021000121b0a0f72657065617465645f" .
- "73696e743332185e2003281142021000121b0a0f72657065617465645f73" .
- "696e743634185f2003281242021000121c0a1072657065617465645f6669" .
- "786564333218602003280742021000121c0a1072657065617465645f6669" .
- "786564363418612003280642021000121d0a1172657065617465645f7366" .
- "69786564333218622003280f42021000121d0a1172657065617465645f73" .
- "6669786564363418632003281042021000121a0a0e72657065617465645f" .
- "666c6f617418642003280242021000121b0a0f72657065617465645f646f" .
- "75626c651865200328014202100012190a0d72657065617465645f626f6f" .
- "6c1866200328084202100012280a0d72657065617465645f656e756d1867" .
- "2003280e320d2e666f6f2e54657374456e756d420210002a1d0a08546573" .
- "74456e756d12080a045a45524f100012070a034f4e451001620670726f74" .
- "6f33"
-));
-
diff --git a/php/tests/test.sh b/php/tests/test.sh
index fe3dc7f6..3635d86c 100755
--- a/php/tests/test.sh
+++ b/php/tests/test.sh
@@ -1,24 +1,21 @@
#!/bin/bash
-# Generate test file
-../../src/protoc --php_out=. test.proto test_include.proto
-
# Compile c extension
pushd ../ext/google/protobuf/
make clean
set -e
# Add following in configure for debug: --enable-debug CFLAGS='-g -O0'
-phpize && ./configure && make
+phpize && ./configure --enable-debug CFLAGS='-g -O0' && make
popd
-tests=( array_test.php encode_decode_test.php generated_class_test.php map_field_test.php )
+tests=( array_test.php encode_decode_test.php generated_class_test.php map_field_test.php well_known_test.php )
for t in "${tests[@]}"
do
echo "****************************"
echo "* $t"
echo "****************************"
- php -dextension=../ext/google/protobuf/modules/protobuf.so `which phpunit` $t
+ php -dextension=../ext/google/protobuf/modules/protobuf.so `which phpunit` --bootstrap autoload.php $t
echo ""
done
diff --git a/php/tests/test_base.php b/php/tests/test_base.php
index d461f0f7..729fea3b 100644
--- a/php/tests/test_base.php
+++ b/php/tests/test_base.php
@@ -1,6 +1,7 @@
<?php
use Foo\TestMessage;
+use Foo\TestEnum;
use Foo\TestMessage_Sub;
class TestBase extends PHPUnit_Framework_TestCase
@@ -69,6 +70,32 @@ class TestBase extends PHPUnit_Framework_TestCase
$this->assertEquals('c', $m->getRepeatedString()[1]);
$this->assertEquals('d', $m->getRepeatedBytes()[1]);
$this->assertEquals(35, $m->getRepeatedMessage()[1]->GetA());
+
+ if (PHP_INT_SIZE == 4) {
+ $this->assertEquals('-63', $m->getMapInt64Int64()['-63']);
+ $this->assertEquals('63', $m->getMapUint64Uint64()['63']);
+ $this->assertEquals('-65', $m->getMapSint64Sint64()['-65']);
+ $this->assertEquals('67', $m->getMapFixed64Fixed64()['67']);
+ $this->assertEquals('-69', $m->getMapSfixed64Sfixed64()['-69']);
+ } else {
+ $this->assertEquals(-63, $m->getMapInt64Int64()[-63]);
+ $this->assertEquals(63, $m->getMapUint64Uint64()[63]);
+ $this->assertEquals(-65, $m->getMapSint64Sint64()[-65]);
+ $this->assertEquals(67, $m->getMapFixed64Fixed64()[67]);
+ $this->assertEquals(-69, $m->getMapSfixed64Sfixed64()[-69]);
+ }
+ $this->assertEquals(-62, $m->getMapInt32Int32()[-62]);
+ $this->assertEquals(62, $m->getMapUint32Uint32()[62]);
+ $this->assertEquals(-64, $m->getMapSint32Sint32()[-64]);
+ $this->assertEquals(66, $m->getMapFixed32Fixed32()[66]);
+ $this->assertEquals(-68, $m->getMapSfixed32Sfixed32()[-68]);
+ $this->assertEquals(3.5, $m->getMapInt32Float()[1]);
+ $this->assertEquals(3.6, $m->getMapInt32Double()[1]);
+ $this->assertEquals(true , $m->getMapBoolBool()[true]);
+ $this->assertEquals('e', $m->getMapStringString()['e']);
+ $this->assertEquals('f', $m->getMapInt32Bytes()[1]);
+ $this->assertEquals(TestEnum::ONE, $m->getMapInt32Enum()[1]);
+ $this->assertEquals(36, $m->getMapInt32Message()[1]->GetA());
}
public function expectEmptyFields(TestMessage $m)
@@ -83,7 +110,10 @@ class TestBase extends PHPUnit_Framework_TestCase
$this->assertSame(false, $m->getOptionalBool());
$this->assertSame('', $m->getOptionalString());
$this->assertSame('', $m->getOptionalBytes());
+ $this->assertSame(0, $m->getOptionalEnum());
$this->assertNull($m->getOptionalMessage());
+ $this->assertNull($m->getOptionalIncludedMessage());
+ $this->assertNull($m->getRecursive());
if (PHP_INT_SIZE == 4) {
$this->assertSame("0", $m->getOptionalInt64());
$this->assertSame("0", $m->getOptionalUint64());
@@ -97,6 +127,71 @@ class TestBase extends PHPUnit_Framework_TestCase
$this->assertSame(0, $m->getOptionalFixed64());
$this->assertSame(0, $m->getOptionalSfixed64());
}
+
+ $this->assertEquals(0, count($m->getRepeatedInt32()));
+ $this->assertEquals(0, count($m->getRepeatedUint32()));
+ $this->assertEquals(0, count($m->getRepeatedInt64()));
+ $this->assertEquals(0, count($m->getRepeatedUint64()));
+ $this->assertEquals(0, count($m->getRepeatedSint32()));
+ $this->assertEquals(0, count($m->getRepeatedSint64()));
+ $this->assertEquals(0, count($m->getRepeatedFixed32()));
+ $this->assertEquals(0, count($m->getRepeatedFixed64()));
+ $this->assertEquals(0, count($m->getRepeatedSfixed32()));
+ $this->assertEquals(0, count($m->getRepeatedSfixed64()));
+ $this->assertEquals(0, count($m->getRepeatedFloat()));
+ $this->assertEquals(0, count($m->getRepeatedDouble()));
+ $this->assertEquals(0, count($m->getRepeatedBool()));
+ $this->assertEquals(0, count($m->getRepeatedString()));
+ $this->assertEquals(0, count($m->getRepeatedBytes()));
+ $this->assertEquals(0, count($m->getRepeatedEnum()));
+ $this->assertEquals(0, count($m->getRepeatedMessage()));
+ $this->assertEquals(0, count($m->getRepeatedRecursive()));
+
+ $this->assertSame("", $m->getMyOneof());
+ $this->assertSame(0, $m->getOneofInt32());
+ $this->assertSame(0, $m->getOneofUint32());
+ $this->assertSame(0, $m->getOneofSint32());
+ $this->assertSame(0, $m->getOneofFixed32());
+ $this->assertSame(0, $m->getOneofSfixed32());
+ $this->assertSame(0.0, $m->getOneofFloat());
+ $this->assertSame(0.0, $m->getOneofDouble());
+ $this->assertSame(false, $m->getOneofBool());
+ $this->assertSame('', $m->getOneofString());
+ $this->assertSame('', $m->getOneofBytes());
+ $this->assertSame(0, $m->getOneofEnum());
+ $this->assertNull($m->getOptionalMessage());
+ if (PHP_INT_SIZE == 4) {
+ $this->assertSame("0", $m->getOneofInt64());
+ $this->assertSame("0", $m->getOneofUint64());
+ $this->assertSame("0", $m->getOneofSint64());
+ $this->assertSame("0", $m->getOneofFixed64());
+ $this->assertSame("0", $m->getOneofSfixed64());
+ } else {
+ $this->assertSame(0, $m->getOneofInt64());
+ $this->assertSame(0, $m->getOneofUint64());
+ $this->assertSame(0, $m->getOneofSint64());
+ $this->assertSame(0, $m->getOneofFixed64());
+ $this->assertSame(0, $m->getOneofSfixed64());
+ }
+
+ $this->assertEquals(0, count($m->getMapInt64Int64()));
+ $this->assertEquals(0, count($m->getMapUint64Uint64()));
+ $this->assertEquals(0, count($m->getMapSint64Sint64()));
+ $this->assertEquals(0, count($m->getMapFixed64Fixed64()));
+ $this->assertEquals(0, count($m->getMapInt32Int32()));
+ $this->assertEquals(0, count($m->getMapUint32Uint32()));
+ $this->assertEquals(0, count($m->getMapSint32Sint32()));
+ $this->assertEquals(0, count($m->getMapFixed32Fixed32()));
+ $this->assertEquals(0, count($m->getMapSfixed32Sfixed32()));
+ $this->assertEquals(0, count($m->getMapSfixed64Sfixed64()));
+ $this->assertEquals(0, count($m->getMapInt32Float()));
+ $this->assertEquals(0, count($m->getMapInt32Double()));
+ $this->assertEquals(0, count($m->getMapBoolBool()));
+ $this->assertEquals(0, count($m->getMapStringString()));
+ $this->assertEquals(0, count($m->getMapInt32Bytes()));
+ $this->assertEquals(0, count($m->getMapInt32Enum()));
+ $this->assertEquals(0, count($m->getMapInt32Message()));
+ $this->assertEquals(0, count($m->getMapRecursive()));
}
// This test is to avoid the warning of no test by php unit.
diff --git a/php/tests/test_include.pb.php b/php/tests/test_include.pb.php
deleted file mode 100644
index 2c43cc41..00000000
--- a/php/tests/test_include.pb.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-# Generated by the protocol buffer compiler. DO NOT EDIT!
-# source: test_include.proto
-
-namespace Bar;
-
-use Google\Protobuf\Internal\DescriptorPool;
-use Google\Protobuf\Internal\GPBType;
-use Google\Protobuf\Internal\RepeatedField;
-use Google\Protobuf\Internal\GPBUtil;
-
-class TestInclude extends \Google\Protobuf\Internal\Message
-{
- private $a = 0;
-
- public function getA()
- {
- return $this->a;
- }
-
- public function setA($var)
- {
- GPBUtil::checkInt32($var);
- $this->a = $var;
- }
-
-}
-
-$pool = DescriptorPool::getGeneratedPool();
-
-$pool->internalAddGeneratedFile(hex2bin(
- "0a3b0a12746573745f696e636c7564652e70726f746f120362617222180a" .
- "0b54657374496e636c75646512090a0161180120012805620670726f746f" .
- "33"
-));
-
diff --git a/php/tests/test_no_namespace.pb.php b/php/tests/test_no_namespace.pb.php
deleted file mode 100644
index 2f92c955..00000000
--- a/php/tests/test_no_namespace.pb.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-# Generated by the protocol buffer compiler. DO NOT EDIT!
-# source: test_no_namespace.proto
-
-use Google\Protobuf\Internal\DescriptorPool;
-use Google\Protobuf\Internal\GPBType;
-use Google\Protobuf\Internal\RepeatedField;
-use Google\Protobuf\Internal\GPBUtil;
-
-class NoNameSpace extends \Google\Protobuf\Internal\Message
-{
- private $a = 0;
-
- public function getA()
- {
- return $this->a;
- }
-
- public function setA($var)
- {
- GPBUtil::checkInt32($var);
- $this->a = $var;
- }
-
-}
-
-$pool = DescriptorPool::getGeneratedPool();
-
-$pool->internalAddGeneratedFile(hex2bin(
- "0a3b0a17746573745f6e6f5f6e616d6573706163652e70726f746f22180a" .
- "0b4e6f4e616d65537061636512090a0161180120012805620670726f746f" .
- "33"
-));
-
diff --git a/php/tests/test_no_namespace.proto b/php/tests/test_no_namespace.proto
deleted file mode 100644
index 4331aeab..00000000
--- a/php/tests/test_no_namespace.proto
+++ /dev/null
@@ -1,5 +0,0 @@
-syntax = "proto3";
-
-message NoNameSpace {
- int32 a = 1;
-}
diff --git a/php/tests/test_util.php b/php/tests/test_util.php
index 7f2aae15..b7db5c1d 100644
--- a/php/tests/test_util.php
+++ b/php/tests/test_util.php
@@ -118,6 +118,8 @@ class TestUtil
$m->getMapSint64Sint64()[-65] = -65;
$m->getMapFixed32Fixed32()[66] = 66;
$m->getMapFixed64Fixed64()[67] = 67;
+ $m->getMapSfixed32Sfixed32()[-68] = -68;
+ $m->getMapSfixed64Sfixed64()[-69] = -69;
$m->getMapInt32Float()[1] = 3.5;
$m->getMapInt32Double()[1] = 3.6;
$m->getMapBoolBool()[true] = true;
@@ -213,16 +215,19 @@ class TestUtil
assert('63' === $m->getMapUint64Uint64()['63']);
assert('-65' === $m->getMapSint64Sint64()['-65']);
assert('67' === $m->getMapFixed64Fixed64()['67']);
+ assert('-69' === $m->getMapSfixed64Sfixed64()['-69']);
} else {
assert(-63 === $m->getMapInt64Int64()[-63]);
assert(63 === $m->getMapUint64Uint64()[63]);
assert(-65 === $m->getMapSint64Sint64()[-65]);
assert(67 === $m->getMapFixed64Fixed64()[67]);
+ assert(-69 === $m->getMapSfixed64Sfixed64()[-69]);
}
assert(-62 === $m->getMapInt32Int32()[-62]);
assert(62 === $m->getMapUint32Uint32()[62]);
assert(-64 === $m->getMapSint32Sint32()[-64]);
assert(66 === $m->getMapFixed32Fixed32()[66]);
+ assert(-68 === $m->getMapSfixed32Sfixed32()[-68]);
assert(3.5 === $m->getMapInt32Float()[1]);
assert(3.6 === $m->getMapInt32Double()[1]);
assert(true === $m->getMapBoolBool()[true]);
@@ -296,6 +301,8 @@ class TestUtil
"E20406088101108101" .
"EA040A0D420000001542000000" .
"F20412094300000000000000114300000000000000" .
+ "FA040A0DBCFFFFFF15BCFFFFFF" .
+ "82051209BBFFFFFFFFFFFFFF11BBFFFFFFFFFFFFFF" .
"8A050708011500006040" .
"92050B080111CDCCCCCCCCCC0C40" .
"9A050408011001" .
diff --git a/php/tests/well_known_test.php b/php/tests/well_known_test.php
new file mode 100644
index 00000000..40ff1c8f
--- /dev/null
+++ b/php/tests/well_known_test.php
@@ -0,0 +1,11 @@
+<?php
+
+use Google\Protobuf\GPBEmpty;
+
+class WellKnownTest extends PHPUnit_Framework_TestCase {
+
+ public function testNone() {
+ $msg = new GPBEmpty();
+ }
+
+}
diff --git a/phpunit.xml b/phpunit.xml
deleted file mode 100644
index d311c509..00000000
--- a/phpunit.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<phpunit bootstrap="./vendor/autoload.php"
- colors="true">
- <testsuites>
- <testsuite name="protobuf-tests">
- <file>php/tests/php_implementation_test.php</file>
- <file>php/tests/array_test.php</file>
- <file>php/tests/encode_decode_test.php</file>
- <file>php/tests/generated_class_test.php</file>
- <file>php/tests/map_field_test.php</file>
- </testsuite>
- </testsuites>
-</phpunit>
diff --git a/protobuf.bzl b/protobuf.bzl
index ac448201..73c396d5 100644
--- a/protobuf.bzl
+++ b/protobuf.bzl
@@ -1,12 +1,27 @@
-# -*- mode: python; -*- PYTHON-PREPROCESSING-REQUIRED
-
def _GetPath(ctx, path):
if ctx.label.workspace_root:
return ctx.label.workspace_root + '/' + path
else:
return path
+def _IsNewExternal(ctx):
+ # Bazel 0.4.4 and older have genfiles paths that look like:
+ # bazel-out/local-fastbuild/genfiles/external/repo/foo
+ # After the exec root rearrangement, they look like:
+ # ../repo/bazel-out/local-fastbuild/genfiles/foo
+ return ctx.label.workspace_root.startswith("../")
+
def _GenDir(ctx):
+ if _IsNewExternal(ctx):
+ # We are using the fact that Bazel 0.4.4+ provides repository-relative paths
+ # for ctx.genfiles_dir.
+ return ctx.genfiles_dir.path + (
+ "/" + ctx.attr.includes[0] if ctx.attr.includes and ctx.attr.includes[0] else "")
+ # This means that we're either in the old version OR the new version in the local repo.
+ # Either way, appending the source path to the genfiles dir works.
+ return ctx.var["GENDIR"] + "/" + _SourceDir(ctx)
+
+def _SourceDir(ctx):
if not ctx.attr.includes:
return ctx.label.workspace_root
if not ctx.attr.includes[0]:
@@ -53,9 +68,10 @@ def _proto_gen_impl(ctx):
srcs = ctx.files.srcs
deps = []
deps += ctx.files.srcs
+ source_dir = _SourceDir(ctx)
gen_dir = _GenDir(ctx)
- if gen_dir:
- import_flags = ["-I" + gen_dir, "-I" + ctx.var["GENDIR"] + "/" + gen_dir]
+ if source_dir:
+ import_flags = ["-I" + source_dir, "-I" + gen_dir]
else:
import_flags = ["-I."]
@@ -65,9 +81,9 @@ def _proto_gen_impl(ctx):
args = []
if ctx.attr.gen_cc:
- args += ["--cpp_out=" + ctx.var["GENDIR"] + "/" + gen_dir]
+ args += ["--cpp_out=" + gen_dir]
if ctx.attr.gen_py:
- args += ["--python_out=" + ctx.var["GENDIR"] + "/" + gen_dir]
+ args += ["--python_out=" + gen_dir]
inputs = srcs + deps
if ctx.executable.plugin:
@@ -78,7 +94,7 @@ def _proto_gen_impl(ctx):
if not lang:
fail("cannot infer the target language of plugin", "plugin_language")
- outdir = ctx.var["GENDIR"] + "/" + gen_dir
+ outdir = gen_dir
if ctx.attr.plugin_options:
outdir = ",".join(ctx.attr.plugin_options) + ":" + outdir
args += ["--plugin=protoc-gen-%s=%s" % (lang, plugin.path)]
@@ -143,7 +159,7 @@ Args:
compiler.
plugin_language: the language of the generated sources
plugin_options: a list of options to be passed to the plugin
- gen_cc: generates C++ sources in addition to the ones from the plugin.
+ gen_cc: generates C++ sources in addition to the ones from the plugin.
gen_py: generates Python sources in addition to the ones from the plugin.
outs: a list of labels of the expected outputs from the protocol compiler.
"""
@@ -240,7 +256,6 @@ def cc_proto_library(
includes=includes,
**kargs)
-
def internal_gen_well_known_protos_java(srcs):
"""Bazel rule to generate the gen_well_known_protos_java genrule
@@ -248,10 +263,11 @@ def internal_gen_well_known_protos_java(srcs):
srcs: the well known protos
"""
root = Label("%s//protobuf_java" % (REPOSITORY_NAME)).workspace_root
+ pkg = PACKAGE_NAME + "/" if PACKAGE_NAME else ""
if root == "":
- include = " -Isrc "
+ include = " -I%ssrc " % pkg
else:
- include = " -I%s/src " % root
+ include = " -I%s/%ssrc " % (root, pkg)
native.genrule(
name = "gen_well_known_protos_java",
srcs = srcs,
@@ -264,7 +280,6 @@ def internal_gen_well_known_protos_java(srcs):
tools = [":protoc"],
)
-
def internal_copied_filegroup(name, srcs, strip_prefix, dest, **kwargs):
"""Macro to copy files to a different directory and then create a filegroup.
@@ -294,7 +309,6 @@ def internal_copied_filegroup(name, srcs, strip_prefix, dest, **kwargs):
srcs = outs,
**kwargs)
-
def py_proto_library(
name,
srcs=[],
@@ -304,6 +318,7 @@ def py_proto_library(
include=None,
default_runtime="//:protobuf_python",
protoc="//:protoc",
+ use_grpc_plugin=False,
**kargs):
"""Bazel rule to create a Python protobuf library from proto source files
@@ -323,6 +338,8 @@ def py_proto_library(
default_runtime: the implicitly default runtime which will be depended on by
the generated py_library target.
protoc: the label of the protocol compiler to generate the sources.
+ use_grpc_plugin: a flag to indicate whether to call the Python C++ plugin
+ when processing the proto files.
**kargs: other keyword arguments that are passed to cc_library.
"""
@@ -332,6 +349,13 @@ def py_proto_library(
if include != None:
includes = [include]
+ grpc_python_plugin = None
+ if use_grpc_plugin:
+ grpc_python_plugin = "//external:grpc_python_plugin"
+ # Note: Generated grpc code depends on Python grpc module. This dependency
+ # is not explicitly listed in py_libs. Instead, host system is assumed to
+ # have grpc installed.
+
proto_gen(
name=name + "_genproto",
srcs=srcs,
@@ -341,6 +365,8 @@ def py_proto_library(
gen_py=1,
outs=outs,
visibility=["//visibility:public"],
+ plugin=grpc_python_plugin,
+ plugin_language="grpc"
)
if default_runtime and not default_runtime in py_libs + deps:
diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml
index 680154b1..19c68629 100644
--- a/protoc-artifacts/pom.xml
+++ b/protoc-artifacts/pom.xml
@@ -10,7 +10,7 @@
</parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protoc</artifactId>
- <version>3.1.0</version>
+ <version>3.2.0</version>
<packaging>pom</packaging>
<name>Protobuf Compiler</name>
<description>
diff --git a/python/README.md b/python/README.md
index 57acfd94..8f3db785 100644
--- a/python/README.md
+++ b/python/README.md
@@ -92,7 +92,7 @@ Installation
error: "sem_init: Resource temporarily unavailable". This appears
to be a bug either in Cygwin or in Python:
http://www.cygwin.com/ml/cygwin/2005-07/msg01378.html
- We do not know if or when it might me fixed. We also do not know
+ We do not know if or when it might be fixed. We also do not know
how likely it is that this bug will affect users in practice.
5) Install:
diff --git a/python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/factory_test1.proto b/python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/factory_test1.proto
new file mode 100644
index 00000000..9f55e037
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/factory_test1.proto
@@ -0,0 +1,55 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// http://code.google.com/p/protobuf/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Author: matthewtoia@google.com (Matt Toia)
+
+
+package google.protobuf.python.internal;
+
+
+enum Factory1Enum {
+ FACTORY_1_VALUE_0 = 0;
+ FACTORY_1_VALUE_1 = 1;
+}
+
+message Factory1Message {
+ optional Factory1Enum factory_1_enum = 1;
+ enum NestedFactory1Enum {
+ NESTED_FACTORY_1_VALUE_0 = 0;
+ NESTED_FACTORY_1_VALUE_1 = 1;
+ }
+ optional NestedFactory1Enum nested_factory_1_enum = 2;
+ message NestedFactory1Message {
+ optional string value = 1;
+ }
+ optional NestedFactory1Message nested_factory_1_message = 3;
+ optional int32 scalar_value = 4;
+ repeated string list_value = 5;
+}
diff --git a/python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/factory_test2.proto b/python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/factory_test2.proto
new file mode 100644
index 00000000..d3ce4d7f
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/factory_test2.proto
@@ -0,0 +1,77 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// http://code.google.com/p/protobuf/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Author: matthewtoia@google.com (Matt Toia)
+
+
+package google.protobuf.python.internal;
+
+import "google/protobuf/internal/factory_test1.proto";
+
+
+enum Factory2Enum {
+ FACTORY_2_VALUE_0 = 0;
+ FACTORY_2_VALUE_1 = 1;
+}
+
+message Factory2Message {
+ required int32 mandatory = 1;
+ optional Factory2Enum factory_2_enum = 2;
+ enum NestedFactory2Enum {
+ NESTED_FACTORY_2_VALUE_0 = 0;
+ NESTED_FACTORY_2_VALUE_1 = 1;
+ }
+ optional NestedFactory2Enum nested_factory_2_enum = 3;
+ message NestedFactory2Message {
+ optional string value = 1;
+ }
+ optional NestedFactory2Message nested_factory_2_message = 4;
+ optional Factory1Message factory_1_message = 5;
+ optional Factory1Enum factory_1_enum = 6;
+ optional Factory1Message.NestedFactory1Enum nested_factory_1_enum = 7;
+ optional Factory1Message.NestedFactory1Message nested_factory_1_message = 8;
+ optional Factory2Message circular_message = 9;
+ optional string scalar_value = 10;
+ repeated string list_value = 11;
+ repeated group Grouped = 12 {
+ optional string part_1 = 13;
+ optional string part_2 = 14;
+ }
+ optional LoopMessage loop = 15;
+ optional int32 int_with_default = 16 [default = 1776];
+ optional double double_with_default = 17 [default = 9.99];
+ optional string string_with_default = 18 [default = "hello world"];
+ optional bool bool_with_default = 19 [default = false];
+ optional Factory2Enum enum_with_default = 20 [default = FACTORY_2_VALUE_1];
+}
+
+message LoopMessage {
+ optional Factory2Message loop = 1;
+}
diff --git a/python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/more_extensions.proto b/python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/more_extensions.proto
new file mode 100644
index 00000000..e2d97010
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/more_extensions.proto
@@ -0,0 +1,58 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// http://code.google.com/p/protobuf/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Author: robinson@google.com (Will Robinson)
+
+
+package google.protobuf.internal;
+
+
+message TopLevelMessage {
+ optional ExtendedMessage submessage = 1;
+}
+
+
+message ExtendedMessage {
+ extensions 1 to max;
+}
+
+
+message ForeignMessage {
+ optional int32 foreign_message_int = 1;
+}
+
+
+extend ExtendedMessage {
+ optional int32 optional_int_extension = 1;
+ optional ForeignMessage optional_message_extension = 2;
+
+ repeated int32 repeated_int_extension = 3;
+ repeated ForeignMessage repeated_message_extension = 4;
+}
diff --git a/python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/more_extensions_dynamic.proto b/python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/more_extensions_dynamic.proto
new file mode 100644
index 00000000..df98ac4b
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/more_extensions_dynamic.proto
@@ -0,0 +1,49 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// http://code.google.com/p/protobuf/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Author: jasonh@google.com (Jason Hsueh)
+//
+// This file is used to test a corner case in the CPP implementation where the
+// generated C++ type is available for the extendee, but the extension is
+// defined in a file whose C++ type is not in the binary.
+
+
+import "google/protobuf/internal/more_extensions.proto";
+
+package google.protobuf.internal;
+
+message DynamicMessageType {
+ optional int32 a = 1;
+}
+
+extend ExtendedMessage {
+ optional int32 dynamic_int32_extension = 100;
+ optional DynamicMessageType dynamic_message_extension = 101;
+}
diff --git a/python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/more_messages.proto b/python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/more_messages.proto
new file mode 100644
index 00000000..c701b446
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/more_messages.proto
@@ -0,0 +1,51 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// http://code.google.com/p/protobuf/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Author: robinson@google.com (Will Robinson)
+
+
+package google.protobuf.internal;
+
+// A message where tag numbers are listed out of order, to allow us to test our
+// canonicalization of serialized output, which should always be in tag order.
+// We also mix in some extensions for extra fun.
+message OutOfOrderFields {
+ optional sint32 optional_sint32 = 5;
+ extensions 4 to 4;
+ optional uint32 optional_uint32 = 3;
+ extensions 2 to 2;
+ optional int32 optional_int32 = 1;
+};
+
+
+extend OutOfOrderFields {
+ optional uint64 optional_uint64 = 4;
+ optional int64 optional_int64 = 2;
+}
diff --git a/python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/test_bad_identifiers.proto b/python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/test_bad_identifiers.proto
new file mode 100644
index 00000000..6a82299a
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/protos/python/google/protobuf/internal/test_bad_identifiers.proto
@@ -0,0 +1,52 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// http://code.google.com/p/protobuf/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Author: kenton@google.com (Kenton Varda)
+
+
+package protobuf_unittest;
+
+option py_generic_services = true;
+
+message TestBadIdentifiers {
+ extensions 100 to max;
+}
+
+// Make sure these reasonable extension names don't conflict with internal
+// variables.
+extend TestBadIdentifiers {
+ optional string message = 100 [default="foo"];
+ optional string descriptor = 101 [default="bar"];
+ optional string reflection = 102 [default="baz"];
+ optional string service = 103 [default="qux"];
+}
+
+message AnotherMessage {}
+service AnotherService {}
diff --git a/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/descriptor.proto b/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/descriptor.proto
new file mode 100644
index 00000000..a785f79f
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/descriptor.proto
@@ -0,0 +1,620 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// http://code.google.com/p/protobuf/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Author: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+//
+// The messages in this file describe the definitions found in .proto files.
+// A valid .proto file can be translated directly to a FileDescriptorProto
+// without any other information (e.g. without reading its imports).
+
+
+
+package google.protobuf;
+option java_package = "com.google.protobuf";
+option java_outer_classname = "DescriptorProtos";
+
+// descriptor.proto must be optimized for speed because reflection-based
+// algorithms don't work during bootstrapping.
+option optimize_for = SPEED;
+
+// The protocol compiler can output a FileDescriptorSet containing the .proto
+// files it parses.
+message FileDescriptorSet {
+ repeated FileDescriptorProto file = 1;
+}
+
+// Describes a complete .proto file.
+message FileDescriptorProto {
+ optional string name = 1; // file name, relative to root of source tree
+ optional string package = 2; // e.g. "foo", "foo.bar", etc.
+
+ // Names of files imported by this file.
+ repeated string dependency = 3;
+ // Indexes of the public imported files in the dependency list above.
+ repeated int32 public_dependency = 10;
+ // Indexes of the weak imported files in the dependency list.
+ // For Google-internal migration only. Do not use.
+ repeated int32 weak_dependency = 11;
+
+ // All top-level definitions in this file.
+ repeated DescriptorProto message_type = 4;
+ repeated EnumDescriptorProto enum_type = 5;
+ repeated ServiceDescriptorProto service = 6;
+ repeated FieldDescriptorProto extension = 7;
+
+ optional FileOptions options = 8;
+
+ // This field contains optional information about the original source code.
+ // You may safely remove this entire field whithout harming runtime
+ // functionality of the descriptors -- the information is needed only by
+ // development tools.
+ optional SourceCodeInfo source_code_info = 9;
+}
+
+// Describes a message type.
+message DescriptorProto {
+ optional string name = 1;
+
+ repeated FieldDescriptorProto field = 2;
+ repeated FieldDescriptorProto extension = 6;
+
+ repeated DescriptorProto nested_type = 3;
+ repeated EnumDescriptorProto enum_type = 4;
+
+ message ExtensionRange {
+ optional int32 start = 1;
+ optional int32 end = 2;
+ }
+ repeated ExtensionRange extension_range = 5;
+
+ optional MessageOptions options = 7;
+}
+
+// Describes a field within a message.
+message FieldDescriptorProto {
+ enum Type {
+ // 0 is reserved for errors.
+ // Order is weird for historical reasons.
+ TYPE_DOUBLE = 1;
+ TYPE_FLOAT = 2;
+ // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if
+ // negative values are likely.
+ TYPE_INT64 = 3;
+ TYPE_UINT64 = 4;
+ // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if
+ // negative values are likely.
+ TYPE_INT32 = 5;
+ TYPE_FIXED64 = 6;
+ TYPE_FIXED32 = 7;
+ TYPE_BOOL = 8;
+ TYPE_STRING = 9;
+ TYPE_GROUP = 10; // Tag-delimited aggregate.
+ TYPE_MESSAGE = 11; // Length-delimited aggregate.
+
+ // New in version 2.
+ TYPE_BYTES = 12;
+ TYPE_UINT32 = 13;
+ TYPE_ENUM = 14;
+ TYPE_SFIXED32 = 15;
+ TYPE_SFIXED64 = 16;
+ TYPE_SINT32 = 17; // Uses ZigZag encoding.
+ TYPE_SINT64 = 18; // Uses ZigZag encoding.
+ };
+
+ enum Label {
+ // 0 is reserved for errors
+ LABEL_OPTIONAL = 1;
+ LABEL_REQUIRED = 2;
+ LABEL_REPEATED = 3;
+ // TODO(sanjay): Should we add LABEL_MAP?
+ };
+
+ optional string name = 1;
+ optional int32 number = 3;
+ optional Label label = 4;
+
+ // If type_name is set, this need not be set. If both this and type_name
+ // are set, this must be either TYPE_ENUM or TYPE_MESSAGE.
+ optional Type type = 5;
+
+ // For message and enum types, this is the name of the type. If the name
+ // starts with a '.', it is fully-qualified. Otherwise, C++-like scoping
+ // rules are used to find the type (i.e. first the nested types within this
+ // message are searched, then within the parent, on up to the root
+ // namespace).
+ optional string type_name = 6;
+
+ // For extensions, this is the name of the type being extended. It is
+ // resolved in the same manner as type_name.
+ optional string extendee = 2;
+
+ // For numeric types, contains the original text representation of the value.
+ // For booleans, "true" or "false".
+ // For strings, contains the default text contents (not escaped in any way).
+ // For bytes, contains the C escaped value. All bytes >= 128 are escaped.
+ // TODO(kenton): Base-64 encode?
+ optional string default_value = 7;
+
+ optional FieldOptions options = 8;
+}
+
+// Describes an enum type.
+message EnumDescriptorProto {
+ optional string name = 1;
+
+ repeated EnumValueDescriptorProto value = 2;
+
+ optional EnumOptions options = 3;
+}
+
+// Describes a value within an enum.
+message EnumValueDescriptorProto {
+ optional string name = 1;
+ optional int32 number = 2;
+
+ optional EnumValueOptions options = 3;
+}
+
+// Describes a service.
+message ServiceDescriptorProto {
+ optional string name = 1;
+ repeated MethodDescriptorProto method = 2;
+
+ optional ServiceOptions options = 3;
+}
+
+// Describes a method of a service.
+message MethodDescriptorProto {
+ optional string name = 1;
+
+ // Input and output type names. These are resolved in the same way as
+ // FieldDescriptorProto.type_name, but must refer to a message type.
+ optional string input_type = 2;
+ optional string output_type = 3;
+
+ optional MethodOptions options = 4;
+}
+
+
+// ===================================================================
+// Options
+
+// Each of the definitions above may have "options" attached. These are
+// just annotations which may cause code to be generated slightly differently
+// or may contain hints for code that manipulates protocol messages.
+//
+// Clients may define custom options as extensions of the *Options messages.
+// These extensions may not yet be known at parsing time, so the parser cannot
+// store the values in them. Instead it stores them in a field in the *Options
+// message called uninterpreted_option. This field must have the same name
+// across all *Options messages. We then use this field to populate the
+// extensions when we build a descriptor, at which point all protos have been
+// parsed and so all extensions are known.
+//
+// Extension numbers for custom options may be chosen as follows:
+// * For options which will only be used within a single application or
+// organization, or for experimental options, use field numbers 50000
+// through 99999. It is up to you to ensure that you do not use the
+// same number for multiple options.
+// * For options which will be published and used publicly by multiple
+// independent entities, e-mail protobuf-global-extension-registry@google.com
+// to reserve extension numbers. Simply provide your project name (e.g.
+// Object-C plugin) and your porject website (if available) -- there's no need
+// to explain how you intend to use them. Usually you only need one extension
+// number. You can declare multiple options with only one extension number by
+// putting them in a sub-message. See the Custom Options section of the docs
+// for examples:
+// http://code.google.com/apis/protocolbuffers/docs/proto.html#options
+// If this turns out to be popular, a web service will be set up
+// to automatically assign option numbers.
+
+
+message FileOptions {
+
+ // Sets the Java package where classes generated from this .proto will be
+ // placed. By default, the proto package is used, but this is often
+ // inappropriate because proto packages do not normally start with backwards
+ // domain names.
+ optional string java_package = 1;
+
+
+ // If set, all the classes from the .proto file are wrapped in a single
+ // outer class with the given name. This applies to both Proto1
+ // (equivalent to the old "--one_java_file" option) and Proto2 (where
+ // a .proto always translates to a single class, but you may want to
+ // explicitly choose the class name).
+ optional string java_outer_classname = 8;
+
+ // If set true, then the Java code generator will generate a separate .java
+ // file for each top-level message, enum, and service defined in the .proto
+ // file. Thus, these types will *not* be nested inside the outer class
+ // named by java_outer_classname. However, the outer class will still be
+ // generated to contain the file's getDescriptor() method as well as any
+ // top-level extensions defined in the file.
+ optional bool java_multiple_files = 10 [default=false];
+
+ // If set true, then the Java code generator will generate equals() and
+ // hashCode() methods for all messages defined in the .proto file. This is
+ // purely a speed optimization, as the AbstractMessage base class includes
+ // reflection-based implementations of these methods.
+ optional bool java_generate_equals_and_hash = 20 [default=false];
+
+ // Generated classes can be optimized for speed or code size.
+ enum OptimizeMode {
+ SPEED = 1; // Generate complete code for parsing, serialization,
+ // etc.
+ CODE_SIZE = 2; // Use ReflectionOps to implement these methods.
+ LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime.
+ }
+ optional OptimizeMode optimize_for = 9 [default=SPEED];
+
+ // Sets the Go package where structs generated from this .proto will be
+ // placed. There is no default.
+ optional string go_package = 11;
+
+
+
+ // Should generic services be generated in each language? "Generic" services
+ // are not specific to any particular RPC system. They are generated by the
+ // main code generators in each language (without additional plugins).
+ // Generic services were the only kind of service generation supported by
+ // early versions of proto2.
+ //
+ // Generic services are now considered deprecated in favor of using plugins
+ // that generate code specific to your particular RPC system. Therefore,
+ // these default to false. Old code which depends on generic services should
+ // explicitly set them to true.
+ optional bool cc_generic_services = 16 [default=false];
+ optional bool java_generic_services = 17 [default=false];
+ optional bool py_generic_services = 18 [default=false];
+
+ // The parser stores options it doesn't recognize here. See above.
+ repeated UninterpretedOption uninterpreted_option = 999;
+
+ // Clients can define custom options in extensions of this message. See above.
+ extensions 1000 to max;
+}
+
+message MessageOptions {
+ // Set true to use the old proto1 MessageSet wire format for extensions.
+ // This is provided for backwards-compatibility with the MessageSet wire
+ // format. You should not use this for any other reason: It's less
+ // efficient, has fewer features, and is more complicated.
+ //
+ // The message must be defined exactly as follows:
+ // message Foo {
+ // option message_set_wire_format = true;
+ // extensions 4 to max;
+ // }
+ // Note that the message cannot have any defined fields; MessageSets only
+ // have extensions.
+ //
+ // All extensions of your type must be singular messages; e.g. they cannot
+ // be int32s, enums, or repeated messages.
+ //
+ // Because this is an option, the above two restrictions are not enforced by
+ // the protocol compiler.
+ optional bool message_set_wire_format = 1 [default=false];
+
+ // Disables the generation of the standard "descriptor()" accessor, which can
+ // conflict with a field of the same name. This is meant to make migration
+ // from proto1 easier; new code should avoid fields named "descriptor".
+ optional bool no_standard_descriptor_accessor = 2 [default=false];
+
+ // The parser stores options it doesn't recognize here. See above.
+ repeated UninterpretedOption uninterpreted_option = 999;
+
+ // Clients can define custom options in extensions of this message. See above.
+ extensions 1000 to max;
+}
+
+message FieldOptions {
+ // The ctype option instructs the C++ code generator to use a different
+ // representation of the field than it normally would. See the specific
+ // options below. This option is not yet implemented in the open source
+ // release -- sorry, we'll try to include it in a future version!
+ optional CType ctype = 1 [default = STRING];
+ enum CType {
+ // Default mode.
+ STRING = 0;
+
+ CORD = 1;
+
+ STRING_PIECE = 2;
+ }
+ // The packed option can be enabled for repeated primitive fields to enable
+ // a more efficient representation on the wire. Rather than repeatedly
+ // writing the tag and type for each element, the entire array is encoded as
+ // a single length-delimited blob.
+ optional bool packed = 2;
+
+
+
+ // Should this field be parsed lazily? Lazy applies only to message-type
+ // fields. It means that when the outer message is initially parsed, the
+ // inner message's contents will not be parsed but instead stored in encoded
+ // form. The inner message will actually be parsed when it is first accessed.
+ //
+ // This is only a hint. Implementations are free to choose whether to use
+ // eager or lazy parsing regardless of the value of this option. However,
+ // setting this option true suggests that the protocol author believes that
+ // using lazy parsing on this field is worth the additional bookkeeping
+ // overhead typically needed to implement it.
+ //
+ // This option does not affect the public interface of any generated code;
+ // all method signatures remain the same. Furthermore, thread-safety of the
+ // interface is not affected by this option; const methods remain safe to
+ // call from multiple threads concurrently, while non-const methods continue
+ // to require exclusive access.
+ //
+ //
+ // Note that implementations may choose not to check required fields within
+ // a lazy sub-message. That is, calling IsInitialized() on the outher message
+ // may return true even if the inner message has missing required fields.
+ // This is necessary because otherwise the inner message would have to be
+ // parsed in order to perform the check, defeating the purpose of lazy
+ // parsing. An implementation which chooses not to check required fields
+ // must be consistent about it. That is, for any particular sub-message, the
+ // implementation must either *always* check its required fields, or *never*
+ // check its required fields, regardless of whether or not the message has
+ // been parsed.
+ optional bool lazy = 5 [default=false];
+
+ // Is this field deprecated?
+ // Depending on the target platform, this can emit Deprecated annotations
+ // for accessors, or it will be completely ignored; in the very least, this
+ // is a formalization for deprecating fields.
+ optional bool deprecated = 3 [default=false];
+
+ // EXPERIMENTAL. DO NOT USE.
+ // For "map" fields, the name of the field in the enclosed type that
+ // is the key for this map. For example, suppose we have:
+ // message Item {
+ // required string name = 1;
+ // required string value = 2;
+ // }
+ // message Config {
+ // repeated Item items = 1 [experimental_map_key="name"];
+ // }
+ // In this situation, the map key for Item will be set to "name".
+ // TODO: Fully-implement this, then remove the "experimental_" prefix.
+ optional string experimental_map_key = 9;
+
+ // For Google-internal migration only. Do not use.
+ optional bool weak = 10 [default=false];
+
+ // The parser stores options it doesn't recognize here. See above.
+ repeated UninterpretedOption uninterpreted_option = 999;
+
+ // Clients can define custom options in extensions of this message. See above.
+ extensions 1000 to max;
+}
+
+message EnumOptions {
+
+ // Set this option to false to disallow mapping different tag names to a same
+ // value.
+ optional bool allow_alias = 2 [default=true];
+
+ // The parser stores options it doesn't recognize here. See above.
+ repeated UninterpretedOption uninterpreted_option = 999;
+
+ // Clients can define custom options in extensions of this message. See above.
+ extensions 1000 to max;
+}
+
+message EnumValueOptions {
+ // The parser stores options it doesn't recognize here. See above.
+ repeated UninterpretedOption uninterpreted_option = 999;
+
+ // Clients can define custom options in extensions of this message. See above.
+ extensions 1000 to max;
+}
+
+message ServiceOptions {
+
+ // Note: Field numbers 1 through 32 are reserved for Google's internal RPC
+ // framework. We apologize for hoarding these numbers to ourselves, but
+ // we were already using them long before we decided to release Protocol
+ // Buffers.
+
+ // The parser stores options it doesn't recognize here. See above.
+ repeated UninterpretedOption uninterpreted_option = 999;
+
+ // Clients can define custom options in extensions of this message. See above.
+ extensions 1000 to max;
+}
+
+message MethodOptions {
+
+ // Note: Field numbers 1 through 32 are reserved for Google's internal RPC
+ // framework. We apologize for hoarding these numbers to ourselves, but
+ // we were already using them long before we decided to release Protocol
+ // Buffers.
+
+ // The parser stores options it doesn't recognize here. See above.
+ repeated UninterpretedOption uninterpreted_option = 999;
+
+ // Clients can define custom options in extensions of this message. See above.
+ extensions 1000 to max;
+}
+
+
+// A message representing a option the parser does not recognize. This only
+// appears in options protos created by the compiler::Parser class.
+// DescriptorPool resolves these when building Descriptor objects. Therefore,
+// options protos in descriptor objects (e.g. returned by Descriptor::options(),
+// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions
+// in them.
+message UninterpretedOption {
+ // The name of the uninterpreted option. Each string represents a segment in
+ // a dot-separated name. is_extension is true iff a segment represents an
+ // extension (denoted with parentheses in options specs in .proto files).
+ // E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents
+ // "foo.(bar.baz).qux".
+ message NamePart {
+ required string name_part = 1;
+ required bool is_extension = 2;
+ }
+ repeated NamePart name = 2;
+
+ // The value of the uninterpreted option, in whatever type the tokenizer
+ // identified it as during parsing. Exactly one of these should be set.
+ optional string identifier_value = 3;
+ optional uint64 positive_int_value = 4;
+ optional int64 negative_int_value = 5;
+ optional double double_value = 6;
+ optional bytes string_value = 7;
+ optional string aggregate_value = 8;
+}
+
+// ===================================================================
+// Optional source code info
+
+// Encapsulates information about the original source file from which a
+// FileDescriptorProto was generated.
+message SourceCodeInfo {
+ // A Location identifies a piece of source code in a .proto file which
+ // corresponds to a particular definition. This information is intended
+ // to be useful to IDEs, code indexers, documentation generators, and similar
+ // tools.
+ //
+ // For example, say we have a file like:
+ // message Foo {
+ // optional string foo = 1;
+ // }
+ // Let's look at just the field definition:
+ // optional string foo = 1;
+ // ^ ^^ ^^ ^ ^^^
+ // a bc de f ghi
+ // We have the following locations:
+ // span path represents
+ // [a,i) [ 4, 0, 2, 0 ] The whole field definition.
+ // [a,b) [ 4, 0, 2, 0, 4 ] The label (optional).
+ // [c,d) [ 4, 0, 2, 0, 5 ] The type (string).
+ // [e,f) [ 4, 0, 2, 0, 1 ] The name (foo).
+ // [g,h) [ 4, 0, 2, 0, 3 ] The number (1).
+ //
+ // Notes:
+ // - A location may refer to a repeated field itself (i.e. not to any
+ // particular index within it). This is used whenever a set of elements are
+ // logically enclosed in a single code segment. For example, an entire
+ // extend block (possibly containing multiple extension definitions) will
+ // have an outer location whose path refers to the "extensions" repeated
+ // field without an index.
+ // - Multiple locations may have the same path. This happens when a single
+ // logical declaration is spread out across multiple places. The most
+ // obvious example is the "extend" block again -- there may be multiple
+ // extend blocks in the same scope, each of which will have the same path.
+ // - A location's span is not always a subset of its parent's span. For
+ // example, the "extendee" of an extension declaration appears at the
+ // beginning of the "extend" block and is shared by all extensions within
+ // the block.
+ // - Just because a location's span is a subset of some other location's span
+ // does not mean that it is a descendent. For example, a "group" defines
+ // both a type and a field in a single declaration. Thus, the locations
+ // corresponding to the type and field and their components will overlap.
+ // - Code which tries to interpret locations should probably be designed to
+ // ignore those that it doesn't understand, as more types of locations could
+ // be recorded in the future.
+ repeated Location location = 1;
+ message Location {
+ // Identifies which part of the FileDescriptorProto was defined at this
+ // location.
+ //
+ // Each element is a field number or an index. They form a path from
+ // the root FileDescriptorProto to the place where the definition. For
+ // example, this path:
+ // [ 4, 3, 2, 7, 1 ]
+ // refers to:
+ // file.message_type(3) // 4, 3
+ // .field(7) // 2, 7
+ // .name() // 1
+ // This is because FileDescriptorProto.message_type has field number 4:
+ // repeated DescriptorProto message_type = 4;
+ // and DescriptorProto.field has field number 2:
+ // repeated FieldDescriptorProto field = 2;
+ // and FieldDescriptorProto.name has field number 1:
+ // optional string name = 1;
+ //
+ // Thus, the above path gives the location of a field name. If we removed
+ // the last element:
+ // [ 4, 3, 2, 7 ]
+ // this path refers to the whole field declaration (from the beginning
+ // of the label to the terminating semicolon).
+ repeated int32 path = 1 [packed=true];
+
+ // Always has exactly three or four elements: start line, start column,
+ // end line (optional, otherwise assumed same as start line), end column.
+ // These are packed into a single field for efficiency. Note that line
+ // and column numbers are zero-based -- typically you will want to add
+ // 1 to each before displaying to a user.
+ repeated int32 span = 2 [packed=true];
+
+ // If this SourceCodeInfo represents a complete declaration, these are any
+ // comments appearing before and after the declaration which appear to be
+ // attached to the declaration.
+ //
+ // A series of line comments appearing on consecutive lines, with no other
+ // tokens appearing on those lines, will be treated as a single comment.
+ //
+ // Only the comment content is provided; comment markers (e.g. //) are
+ // stripped out. For block comments, leading whitespace and an asterisk
+ // will be stripped from the beginning of each line other than the first.
+ // Newlines are included in the output.
+ //
+ // Examples:
+ //
+ // optional int32 foo = 1; // Comment attached to foo.
+ // // Comment attached to bar.
+ // optional int32 bar = 2;
+ //
+ // optional string baz = 3;
+ // // Comment attached to baz.
+ // // Another line attached to baz.
+ //
+ // // Comment attached to qux.
+ // //
+ // // Another line attached to qux.
+ // optional double qux = 4;
+ //
+ // optional string corge = 5;
+ // /* Block comment attached
+ // * to corge. Leading asterisks
+ // * will be removed. */
+ // /* Block comment attached to
+ // * grault. */
+ // optional int32 grault = 6;
+ optional string leading_comments = 3;
+ optional string trailing_comments = 4;
+ }
+}
diff --git a/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest.proto b/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest.proto
new file mode 100644
index 00000000..6eb2d86f
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest.proto
@@ -0,0 +1,719 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// http://code.google.com/p/protobuf/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Author: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+//
+// A proto file we will use for unit testing.
+
+
+// Some generic_services option(s) added automatically.
+// See: http://go/proto2-generic-services-default
+option cc_generic_services = true; // auto-added
+option java_generic_services = true; // auto-added
+option py_generic_services = true; // auto-added
+
+import "google/protobuf/unittest_import.proto";
+
+// We don't put this in a package within proto2 because we need to make sure
+// that the generated code doesn't depend on being in the proto2 namespace.
+// In test_util.h we do "using namespace unittest = protobuf_unittest".
+package protobuf_unittest;
+
+// Protos optimized for SPEED use a strict superset of the generated code
+// of equivalent ones optimized for CODE_SIZE, so we should optimize all our
+// tests for speed unless explicitly testing code size optimization.
+option optimize_for = SPEED;
+
+option java_outer_classname = "UnittestProto";
+
+// This proto includes every type of field in both singular and repeated
+// forms.
+message TestAllTypes {
+ message NestedMessage {
+ // The field name "b" fails to compile in proto1 because it conflicts with
+ // a local variable named "b" in one of the generated methods. Doh.
+ // This file needs to compile in proto1 to test backwards-compatibility.
+ optional int32 bb = 1;
+ }
+
+ enum NestedEnum {
+ FOO = 1;
+ BAR = 2;
+ BAZ = 3;
+ }
+
+ // Singular
+ optional int32 optional_int32 = 1;
+ optional int64 optional_int64 = 2;
+ optional uint32 optional_uint32 = 3;
+ optional uint64 optional_uint64 = 4;
+ optional sint32 optional_sint32 = 5;
+ optional sint64 optional_sint64 = 6;
+ optional fixed32 optional_fixed32 = 7;
+ optional fixed64 optional_fixed64 = 8;
+ optional sfixed32 optional_sfixed32 = 9;
+ optional sfixed64 optional_sfixed64 = 10;
+ optional float optional_float = 11;
+ optional double optional_double = 12;
+ optional bool optional_bool = 13;
+ optional string optional_string = 14;
+ optional bytes optional_bytes = 15;
+
+ optional group OptionalGroup = 16 {
+ optional int32 a = 17;
+ }
+
+ optional NestedMessage optional_nested_message = 18;
+ optional ForeignMessage optional_foreign_message = 19;
+ optional protobuf_unittest_import.ImportMessage optional_import_message = 20;
+
+ optional NestedEnum optional_nested_enum = 21;
+ optional ForeignEnum optional_foreign_enum = 22;
+ optional protobuf_unittest_import.ImportEnum optional_import_enum = 23;
+
+ optional string optional_string_piece = 24 [ctype=STRING_PIECE];
+ optional string optional_cord = 25 [ctype=CORD];
+
+ // Defined in unittest_import_public.proto
+ optional protobuf_unittest_import.PublicImportMessage
+ optional_public_import_message = 26;
+
+ optional NestedMessage optional_lazy_message = 27 [lazy=true];
+
+ // Repeated
+ repeated int32 repeated_int32 = 31;
+ repeated int64 repeated_int64 = 32;
+ repeated uint32 repeated_uint32 = 33;
+ repeated uint64 repeated_uint64 = 34;
+ repeated sint32 repeated_sint32 = 35;
+ repeated sint64 repeated_sint64 = 36;
+ repeated fixed32 repeated_fixed32 = 37;
+ repeated fixed64 repeated_fixed64 = 38;
+ repeated sfixed32 repeated_sfixed32 = 39;
+ repeated sfixed64 repeated_sfixed64 = 40;
+ repeated float repeated_float = 41;
+ repeated double repeated_double = 42;
+ repeated bool repeated_bool = 43;
+ repeated string repeated_string = 44;
+ repeated bytes repeated_bytes = 45;
+
+ repeated group RepeatedGroup = 46 {
+ optional int32 a = 47;
+ }
+
+ repeated NestedMessage repeated_nested_message = 48;
+ repeated ForeignMessage repeated_foreign_message = 49;
+ repeated protobuf_unittest_import.ImportMessage repeated_import_message = 50;
+
+ repeated NestedEnum repeated_nested_enum = 51;
+ repeated ForeignEnum repeated_foreign_enum = 52;
+ repeated protobuf_unittest_import.ImportEnum repeated_import_enum = 53;
+
+ repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
+ repeated string repeated_cord = 55 [ctype=CORD];
+
+ repeated NestedMessage repeated_lazy_message = 57 [lazy=true];
+
+ // Singular with defaults
+ optional int32 default_int32 = 61 [default = 41 ];
+ optional int64 default_int64 = 62 [default = 42 ];
+ optional uint32 default_uint32 = 63 [default = 43 ];
+ optional uint64 default_uint64 = 64 [default = 44 ];
+ optional sint32 default_sint32 = 65 [default = -45 ];
+ optional sint64 default_sint64 = 66 [default = 46 ];
+ optional fixed32 default_fixed32 = 67 [default = 47 ];
+ optional fixed64 default_fixed64 = 68 [default = 48 ];
+ optional sfixed32 default_sfixed32 = 69 [default = 49 ];
+ optional sfixed64 default_sfixed64 = 70 [default = -50 ];
+ optional float default_float = 71 [default = 51.5 ];
+ optional double default_double = 72 [default = 52e3 ];
+ optional bool default_bool = 73 [default = true ];
+ optional string default_string = 74 [default = "hello"];
+ optional bytes default_bytes = 75 [default = "world"];
+
+ optional NestedEnum default_nested_enum = 81 [default = BAR ];
+ optional ForeignEnum default_foreign_enum = 82 [default = FOREIGN_BAR];
+ optional protobuf_unittest_import.ImportEnum
+ default_import_enum = 83 [default = IMPORT_BAR];
+
+ optional string default_string_piece = 84 [ctype=STRING_PIECE,default="abc"];
+ optional string default_cord = 85 [ctype=CORD,default="123"];
+}
+
+message TestDeprecatedFields {
+ optional int32 deprecated_int32 = 1 [deprecated=true];
+}
+
+// Define these after TestAllTypes to make sure the compiler can handle
+// that.
+message ForeignMessage {
+ optional int32 c = 1;
+}
+
+enum ForeignEnum {
+ FOREIGN_FOO = 4;
+ FOREIGN_BAR = 5;
+ FOREIGN_BAZ = 6;
+}
+
+message TestAllExtensions {
+ extensions 1 to max;
+}
+
+extend TestAllExtensions {
+ // Singular
+ optional int32 optional_int32_extension = 1;
+ optional int64 optional_int64_extension = 2;
+ optional uint32 optional_uint32_extension = 3;
+ optional uint64 optional_uint64_extension = 4;
+ optional sint32 optional_sint32_extension = 5;
+ optional sint64 optional_sint64_extension = 6;
+ optional fixed32 optional_fixed32_extension = 7;
+ optional fixed64 optional_fixed64_extension = 8;
+ optional sfixed32 optional_sfixed32_extension = 9;
+ optional sfixed64 optional_sfixed64_extension = 10;
+ optional float optional_float_extension = 11;
+ optional double optional_double_extension = 12;
+ optional bool optional_bool_extension = 13;
+ optional string optional_string_extension = 14;
+ optional bytes optional_bytes_extension = 15;
+
+ optional group OptionalGroup_extension = 16 {
+ optional int32 a = 17;
+ }
+
+ optional TestAllTypes.NestedMessage optional_nested_message_extension = 18;
+ optional ForeignMessage optional_foreign_message_extension = 19;
+ optional protobuf_unittest_import.ImportMessage
+ optional_import_message_extension = 20;
+
+ optional TestAllTypes.NestedEnum optional_nested_enum_extension = 21;
+ optional ForeignEnum optional_foreign_enum_extension = 22;
+ optional protobuf_unittest_import.ImportEnum
+ optional_import_enum_extension = 23;
+
+ optional string optional_string_piece_extension = 24 [ctype=STRING_PIECE];
+ optional string optional_cord_extension = 25 [ctype=CORD];
+
+ optional protobuf_unittest_import.PublicImportMessage
+ optional_public_import_message_extension = 26;
+
+ optional TestAllTypes.NestedMessage
+ optional_lazy_message_extension = 27 [lazy=true];
+
+ // Repeated
+ repeated int32 repeated_int32_extension = 31;
+ repeated int64 repeated_int64_extension = 32;
+ repeated uint32 repeated_uint32_extension = 33;
+ repeated uint64 repeated_uint64_extension = 34;
+ repeated sint32 repeated_sint32_extension = 35;
+ repeated sint64 repeated_sint64_extension = 36;
+ repeated fixed32 repeated_fixed32_extension = 37;
+ repeated fixed64 repeated_fixed64_extension = 38;
+ repeated sfixed32 repeated_sfixed32_extension = 39;
+ repeated sfixed64 repeated_sfixed64_extension = 40;
+ repeated float repeated_float_extension = 41;
+ repeated double repeated_double_extension = 42;
+ repeated bool repeated_bool_extension = 43;
+ repeated string repeated_string_extension = 44;
+ repeated bytes repeated_bytes_extension = 45;
+
+ repeated group RepeatedGroup_extension = 46 {
+ optional int32 a = 47;
+ }
+
+ repeated TestAllTypes.NestedMessage repeated_nested_message_extension = 48;
+ repeated ForeignMessage repeated_foreign_message_extension = 49;
+ repeated protobuf_unittest_import.ImportMessage
+ repeated_import_message_extension = 50;
+
+ repeated TestAllTypes.NestedEnum repeated_nested_enum_extension = 51;
+ repeated ForeignEnum repeated_foreign_enum_extension = 52;
+ repeated protobuf_unittest_import.ImportEnum
+ repeated_import_enum_extension = 53;
+
+ repeated string repeated_string_piece_extension = 54 [ctype=STRING_PIECE];
+ repeated string repeated_cord_extension = 55 [ctype=CORD];
+
+ repeated TestAllTypes.NestedMessage
+ repeated_lazy_message_extension = 57 [lazy=true];
+
+ // Singular with defaults
+ optional int32 default_int32_extension = 61 [default = 41 ];
+ optional int64 default_int64_extension = 62 [default = 42 ];
+ optional uint32 default_uint32_extension = 63 [default = 43 ];
+ optional uint64 default_uint64_extension = 64 [default = 44 ];
+ optional sint32 default_sint32_extension = 65 [default = -45 ];
+ optional sint64 default_sint64_extension = 66 [default = 46 ];
+ optional fixed32 default_fixed32_extension = 67 [default = 47 ];
+ optional fixed64 default_fixed64_extension = 68 [default = 48 ];
+ optional sfixed32 default_sfixed32_extension = 69 [default = 49 ];
+ optional sfixed64 default_sfixed64_extension = 70 [default = -50 ];
+ optional float default_float_extension = 71 [default = 51.5 ];
+ optional double default_double_extension = 72 [default = 52e3 ];
+ optional bool default_bool_extension = 73 [default = true ];
+ optional string default_string_extension = 74 [default = "hello"];
+ optional bytes default_bytes_extension = 75 [default = "world"];
+
+ optional TestAllTypes.NestedEnum
+ default_nested_enum_extension = 81 [default = BAR];
+ optional ForeignEnum
+ default_foreign_enum_extension = 82 [default = FOREIGN_BAR];
+ optional protobuf_unittest_import.ImportEnum
+ default_import_enum_extension = 83 [default = IMPORT_BAR];
+
+ optional string default_string_piece_extension = 84 [ctype=STRING_PIECE,
+ default="abc"];
+ optional string default_cord_extension = 85 [ctype=CORD, default="123"];
+}
+
+message TestNestedExtension {
+ extend TestAllExtensions {
+ // Check for bug where string extensions declared in tested scope did not
+ // compile.
+ optional string test = 1002 [default="test"];
+ }
+}
+
+// We have separate messages for testing required fields because it's
+// annoying to have to fill in required fields in TestProto in order to
+// do anything with it. Note that we don't need to test every type of
+// required filed because the code output is basically identical to
+// optional fields for all types.
+message TestRequired {
+ required int32 a = 1;
+ optional int32 dummy2 = 2;
+ required int32 b = 3;
+
+ extend TestAllExtensions {
+ optional TestRequired single = 1000;
+ repeated TestRequired multi = 1001;
+ }
+
+ // Pad the field count to 32 so that we can test that IsInitialized()
+ // properly checks multiple elements of has_bits_.
+ optional int32 dummy4 = 4;
+ optional int32 dummy5 = 5;
+ optional int32 dummy6 = 6;
+ optional int32 dummy7 = 7;
+ optional int32 dummy8 = 8;
+ optional int32 dummy9 = 9;
+ optional int32 dummy10 = 10;
+ optional int32 dummy11 = 11;
+ optional int32 dummy12 = 12;
+ optional int32 dummy13 = 13;
+ optional int32 dummy14 = 14;
+ optional int32 dummy15 = 15;
+ optional int32 dummy16 = 16;
+ optional int32 dummy17 = 17;
+ optional int32 dummy18 = 18;
+ optional int32 dummy19 = 19;
+ optional int32 dummy20 = 20;
+ optional int32 dummy21 = 21;
+ optional int32 dummy22 = 22;
+ optional int32 dummy23 = 23;
+ optional int32 dummy24 = 24;
+ optional int32 dummy25 = 25;
+ optional int32 dummy26 = 26;
+ optional int32 dummy27 = 27;
+ optional int32 dummy28 = 28;
+ optional int32 dummy29 = 29;
+ optional int32 dummy30 = 30;
+ optional int32 dummy31 = 31;
+ optional int32 dummy32 = 32;
+
+ required int32 c = 33;
+}
+
+message TestRequiredForeign {
+ optional TestRequired optional_message = 1;
+ repeated TestRequired repeated_message = 2;
+ optional int32 dummy = 3;
+}
+
+// Test that we can use NestedMessage from outside TestAllTypes.
+message TestForeignNested {
+ optional TestAllTypes.NestedMessage foreign_nested = 1;
+}
+
+// TestEmptyMessage is used to test unknown field support.
+message TestEmptyMessage {
+}
+
+// Like above, but declare all field numbers as potential extensions. No
+// actual extensions should ever be defined for this type.
+message TestEmptyMessageWithExtensions {
+ extensions 1 to max;
+}
+
+message TestMultipleExtensionRanges {
+ extensions 42;
+ extensions 4143 to 4243;
+ extensions 65536 to max;
+}
+
+// Test that really large tag numbers don't break anything.
+message TestReallyLargeTagNumber {
+ // The largest possible tag number is 2^28 - 1, since the wire format uses
+ // three bits to communicate wire type.
+ optional int32 a = 1;
+ optional int32 bb = 268435455;
+}
+
+message TestRecursiveMessage {
+ optional TestRecursiveMessage a = 1;
+ optional int32 i = 2;
+}
+
+// Test that mutual recursion works.
+message TestMutualRecursionA {
+ optional TestMutualRecursionB bb = 1;
+}
+
+message TestMutualRecursionB {
+ optional TestMutualRecursionA a = 1;
+ optional int32 optional_int32 = 2;
+}
+
+// Test that groups have disjoint field numbers from their siblings and
+// parents. This is NOT possible in proto1; only proto2. When attempting
+// to compile with proto1, this will emit an error; so we only include it
+// in protobuf_unittest_proto.
+message TestDupFieldNumber { // NO_PROTO1
+ optional int32 a = 1; // NO_PROTO1
+ optional group Foo = 2 { optional int32 a = 1; } // NO_PROTO1
+ optional group Bar = 3 { optional int32 a = 1; } // NO_PROTO1
+} // NO_PROTO1
+
+// Additional messages for testing lazy fields.
+message TestEagerMessage {
+ optional TestAllTypes sub_message = 1 [lazy=false];
+}
+message TestLazyMessage {
+ optional TestAllTypes sub_message = 1 [lazy=true];
+}
+
+// Needed for a Python test.
+message TestNestedMessageHasBits {
+ message NestedMessage {
+ repeated int32 nestedmessage_repeated_int32 = 1;
+ repeated ForeignMessage nestedmessage_repeated_foreignmessage = 2;
+ }
+ optional NestedMessage optional_nested_message = 1;
+}
+
+
+// Test an enum that has multiple values with the same number.
+enum TestEnumWithDupValue {
+ option allow_alias = true;
+ FOO1 = 1;
+ BAR1 = 2;
+ BAZ = 3;
+ FOO2 = 1;
+ BAR2 = 2;
+}
+
+// Test an enum with large, unordered values.
+enum TestSparseEnum {
+ SPARSE_A = 123;
+ SPARSE_B = 62374;
+ SPARSE_C = 12589234;
+ SPARSE_D = -15;
+ SPARSE_E = -53452;
+ SPARSE_F = 0;
+ SPARSE_G = 2;
+}
+
+// Test message with CamelCase field names. This violates Protocol Buffer
+// standard style.
+message TestCamelCaseFieldNames {
+ optional int32 PrimitiveField = 1;
+ optional string StringField = 2;
+ optional ForeignEnum EnumField = 3;
+ optional ForeignMessage MessageField = 4;
+ optional string StringPieceField = 5 [ctype=STRING_PIECE];
+ optional string CordField = 6 [ctype=CORD];
+
+ repeated int32 RepeatedPrimitiveField = 7;
+ repeated string RepeatedStringField = 8;
+ repeated ForeignEnum RepeatedEnumField = 9;
+ repeated ForeignMessage RepeatedMessageField = 10;
+ repeated string RepeatedStringPieceField = 11 [ctype=STRING_PIECE];
+ repeated string RepeatedCordField = 12 [ctype=CORD];
+}
+
+
+// We list fields out of order, to ensure that we're using field number and not
+// field index to determine serialization order.
+message TestFieldOrderings {
+ optional string my_string = 11;
+ extensions 2 to 10;
+ optional int64 my_int = 1;
+ extensions 12 to 100;
+ optional float my_float = 101;
+}
+
+
+extend TestFieldOrderings {
+ optional string my_extension_string = 50;
+ optional int32 my_extension_int = 5;
+}
+
+
+message TestExtremeDefaultValues {
+ optional bytes escaped_bytes = 1 [default = "\0\001\a\b\f\n\r\t\v\\\'\"\xfe"];
+ optional uint32 large_uint32 = 2 [default = 0xFFFFFFFF];
+ optional uint64 large_uint64 = 3 [default = 0xFFFFFFFFFFFFFFFF];
+ optional int32 small_int32 = 4 [default = -0x7FFFFFFF];
+ optional int64 small_int64 = 5 [default = -0x7FFFFFFFFFFFFFFF];
+ optional int32 really_small_int32 = 21 [default = -0x80000000];
+ optional int64 really_small_int64 = 22 [default = -0x8000000000000000];
+
+ // The default value here is UTF-8 for "\u1234". (We could also just type
+ // the UTF-8 text directly into this text file rather than escape it, but
+ // lots of people use editors that would be confused by this.)
+ optional string utf8_string = 6 [default = "\341\210\264"];
+
+ // Tests for single-precision floating-point values.
+ optional float zero_float = 7 [default = 0];
+ optional float one_float = 8 [default = 1];
+ optional float small_float = 9 [default = 1.5];
+ optional float negative_one_float = 10 [default = -1];
+ optional float negative_float = 11 [default = -1.5];
+ // Using exponents
+ optional float large_float = 12 [default = 2E8];
+ optional float small_negative_float = 13 [default = -8e-28];
+
+ // Text for nonfinite floating-point values.
+ optional double inf_double = 14 [default = inf];
+ optional double neg_inf_double = 15 [default = -inf];
+ optional double nan_double = 16 [default = nan];
+ optional float inf_float = 17 [default = inf];
+ optional float neg_inf_float = 18 [default = -inf];
+ optional float nan_float = 19 [default = nan];
+
+ // Tests for C++ trigraphs.
+ // Trigraphs should be escaped in C++ generated files, but they should not be
+ // escaped for other languages.
+ // Note that in .proto file, "\?" is a valid way to escape ? in string
+ // literals.
+ optional string cpp_trigraph = 20 [default = "? \? ?? \?? \??? ??/ ?\?-"];
+
+ // String defaults containing the character '\000'
+ optional string string_with_zero = 23 [default = "hel\000lo"];
+ optional bytes bytes_with_zero = 24 [default = "wor\000ld"];
+ optional string string_piece_with_zero = 25 [ctype=STRING_PIECE,
+ default="ab\000c"];
+ optional string cord_with_zero = 26 [ctype=CORD,
+ default="12\0003"];
+}
+
+message SparseEnumMessage {
+ optional TestSparseEnum sparse_enum = 1;
+}
+
+// Test String and Bytes: string is for valid UTF-8 strings
+message OneString {
+ optional string data = 1;
+}
+
+message MoreString {
+ repeated string data = 1;
+}
+
+message OneBytes {
+ optional bytes data = 1;
+}
+
+message MoreBytes {
+ repeated bytes data = 1;
+}
+
+
+// Test messages for packed fields
+
+message TestPackedTypes {
+ repeated int32 packed_int32 = 90 [packed = true];
+ repeated int64 packed_int64 = 91 [packed = true];
+ repeated uint32 packed_uint32 = 92 [packed = true];
+ repeated uint64 packed_uint64 = 93 [packed = true];
+ repeated sint32 packed_sint32 = 94 [packed = true];
+ repeated sint64 packed_sint64 = 95 [packed = true];
+ repeated fixed32 packed_fixed32 = 96 [packed = true];
+ repeated fixed64 packed_fixed64 = 97 [packed = true];
+ repeated sfixed32 packed_sfixed32 = 98 [packed = true];
+ repeated sfixed64 packed_sfixed64 = 99 [packed = true];
+ repeated float packed_float = 100 [packed = true];
+ repeated double packed_double = 101 [packed = true];
+ repeated bool packed_bool = 102 [packed = true];
+ repeated ForeignEnum packed_enum = 103 [packed = true];
+}
+
+// A message with the same fields as TestPackedTypes, but without packing. Used
+// to test packed <-> unpacked wire compatibility.
+message TestUnpackedTypes {
+ repeated int32 unpacked_int32 = 90 [packed = false];
+ repeated int64 unpacked_int64 = 91 [packed = false];
+ repeated uint32 unpacked_uint32 = 92 [packed = false];
+ repeated uint64 unpacked_uint64 = 93 [packed = false];
+ repeated sint32 unpacked_sint32 = 94 [packed = false];
+ repeated sint64 unpacked_sint64 = 95 [packed = false];
+ repeated fixed32 unpacked_fixed32 = 96 [packed = false];
+ repeated fixed64 unpacked_fixed64 = 97 [packed = false];
+ repeated sfixed32 unpacked_sfixed32 = 98 [packed = false];
+ repeated sfixed64 unpacked_sfixed64 = 99 [packed = false];
+ repeated float unpacked_float = 100 [packed = false];
+ repeated double unpacked_double = 101 [packed = false];
+ repeated bool unpacked_bool = 102 [packed = false];
+ repeated ForeignEnum unpacked_enum = 103 [packed = false];
+}
+
+message TestPackedExtensions {
+ extensions 1 to max;
+}
+
+extend TestPackedExtensions {
+ repeated int32 packed_int32_extension = 90 [packed = true];
+ repeated int64 packed_int64_extension = 91 [packed = true];
+ repeated uint32 packed_uint32_extension = 92 [packed = true];
+ repeated uint64 packed_uint64_extension = 93 [packed = true];
+ repeated sint32 packed_sint32_extension = 94 [packed = true];
+ repeated sint64 packed_sint64_extension = 95 [packed = true];
+ repeated fixed32 packed_fixed32_extension = 96 [packed = true];
+ repeated fixed64 packed_fixed64_extension = 97 [packed = true];
+ repeated sfixed32 packed_sfixed32_extension = 98 [packed = true];
+ repeated sfixed64 packed_sfixed64_extension = 99 [packed = true];
+ repeated float packed_float_extension = 100 [packed = true];
+ repeated double packed_double_extension = 101 [packed = true];
+ repeated bool packed_bool_extension = 102 [packed = true];
+ repeated ForeignEnum packed_enum_extension = 103 [packed = true];
+}
+
+// Used by ExtensionSetTest/DynamicExtensions. The test actually builds
+// a set of extensions to TestAllExtensions dynamically, based on the fields
+// of this message type.
+message TestDynamicExtensions {
+ enum DynamicEnumType {
+ DYNAMIC_FOO = 2200;
+ DYNAMIC_BAR = 2201;
+ DYNAMIC_BAZ = 2202;
+ }
+ message DynamicMessageType {
+ optional int32 dynamic_field = 2100;
+ }
+
+ optional fixed32 scalar_extension = 2000;
+ optional ForeignEnum enum_extension = 2001;
+ optional DynamicEnumType dynamic_enum_extension = 2002;
+
+ optional ForeignMessage message_extension = 2003;
+ optional DynamicMessageType dynamic_message_extension = 2004;
+
+ repeated string repeated_extension = 2005;
+ repeated sint32 packed_extension = 2006 [packed = true];
+}
+
+message TestRepeatedScalarDifferentTagSizes {
+ // Parsing repeated fixed size values used to fail. This message needs to be
+ // used in order to get a tag of the right size; all of the repeated fields
+ // in TestAllTypes didn't trigger the check.
+ repeated fixed32 repeated_fixed32 = 12;
+ // Check for a varint type, just for good measure.
+ repeated int32 repeated_int32 = 13;
+
+ // These have two-byte tags.
+ repeated fixed64 repeated_fixed64 = 2046;
+ repeated int64 repeated_int64 = 2047;
+
+ // Three byte tags.
+ repeated float repeated_float = 262142;
+ repeated uint64 repeated_uint64 = 262143;
+}
+
+// Test that if an optional or required message/group field appears multiple
+// times in the input, they need to be merged.
+message TestParsingMerge {
+ // RepeatedFieldsGenerator defines matching field types as TestParsingMerge,
+ // except that all fields are repeated. In the tests, we will serialize the
+ // RepeatedFieldsGenerator to bytes, and parse the bytes to TestParsingMerge.
+ // Repeated fields in RepeatedFieldsGenerator are expected to be merged into
+ // the corresponding required/optional fields in TestParsingMerge.
+ message RepeatedFieldsGenerator {
+ repeated TestAllTypes field1 = 1;
+ repeated TestAllTypes field2 = 2;
+ repeated TestAllTypes field3 = 3;
+ repeated group Group1 = 10 {
+ optional TestAllTypes field1 = 11;
+ }
+ repeated group Group2 = 20 {
+ optional TestAllTypes field1 = 21;
+ }
+ repeated TestAllTypes ext1 = 1000;
+ repeated TestAllTypes ext2 = 1001;
+ }
+ required TestAllTypes required_all_types = 1;
+ optional TestAllTypes optional_all_types = 2;
+ repeated TestAllTypes repeated_all_types = 3;
+ optional group OptionalGroup = 10 {
+ optional TestAllTypes optional_group_all_types = 11;
+ }
+ repeated group RepeatedGroup = 20 {
+ optional TestAllTypes repeated_group_all_types = 21;
+ }
+ extensions 1000 to max;
+ extend TestParsingMerge {
+ optional TestAllTypes optional_ext = 1000;
+ repeated TestAllTypes repeated_ext = 1001;
+ }
+}
+
+message TestCommentInjectionMessage {
+ // */ <- This should not close the generated doc comment
+ optional string a = 1 [default="*/ <- Neither should this."];
+}
+
+
+// Test that RPC services work.
+message FooRequest {}
+message FooResponse {}
+
+message FooClientMessage {}
+message FooServerMessage{}
+
+service TestService {
+ rpc Foo(FooRequest) returns (FooResponse);
+ rpc Bar(BarRequest) returns (BarResponse);
+}
+
+
+message BarRequest {}
+message BarResponse {}
diff --git a/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_custom_options.proto b/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_custom_options.proto
new file mode 100644
index 00000000..e591d294
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_custom_options.proto
@@ -0,0 +1,387 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// http://code.google.com/p/protobuf/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Author: benjy@google.com (Benjy Weinberger)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+//
+// A proto file used to test the "custom options" feature of proto2.
+
+
+// Some generic_services option(s) added automatically.
+// See: http://go/proto2-generic-services-default
+option cc_generic_services = true; // auto-added
+option java_generic_services = true; // auto-added
+option py_generic_services = true;
+
+// A custom file option (defined below).
+option (file_opt1) = 9876543210;
+
+import "google/protobuf/descriptor.proto";
+
+// We don't put this in a package within proto2 because we need to make sure
+// that the generated code doesn't depend on being in the proto2 namespace.
+package protobuf_unittest;
+
+
+// Some simple test custom options of various types.
+
+extend google.protobuf.FileOptions {
+ optional uint64 file_opt1 = 7736974;
+}
+
+extend google.protobuf.MessageOptions {
+ optional int32 message_opt1 = 7739036;
+}
+
+extend google.protobuf.FieldOptions {
+ optional fixed64 field_opt1 = 7740936;
+ // This is useful for testing that we correctly register default values for
+ // extension options.
+ optional int32 field_opt2 = 7753913 [default=42];
+}
+
+extend google.protobuf.EnumOptions {
+ optional sfixed32 enum_opt1 = 7753576;
+}
+
+extend google.protobuf.EnumValueOptions {
+ optional int32 enum_value_opt1 = 1560678;
+}
+
+extend google.protobuf.ServiceOptions {
+ optional sint64 service_opt1 = 7887650;
+}
+
+enum MethodOpt1 {
+ METHODOPT1_VAL1 = 1;
+ METHODOPT1_VAL2 = 2;
+}
+
+extend google.protobuf.MethodOptions {
+ optional MethodOpt1 method_opt1 = 7890860;
+}
+
+// A test message with custom options at all possible locations (and also some
+// regular options, to make sure they interact nicely).
+message TestMessageWithCustomOptions {
+ option message_set_wire_format = false;
+
+ option (message_opt1) = -56;
+
+ optional string field1 = 1 [ctype=CORD,
+ (field_opt1)=8765432109];
+
+ enum AnEnum {
+ option (enum_opt1) = -789;
+
+ ANENUM_VAL1 = 1;
+ ANENUM_VAL2 = 2 [(enum_value_opt1) = 123];
+ }
+}
+
+
+// A test RPC service with custom options at all possible locations (and also
+// some regular options, to make sure they interact nicely).
+message CustomOptionFooRequest {
+}
+
+message CustomOptionFooResponse {
+}
+
+message CustomOptionFooClientMessage {
+}
+
+message CustomOptionFooServerMessage {
+}
+
+service TestServiceWithCustomOptions {
+ option (service_opt1) = -9876543210;
+
+ rpc Foo(CustomOptionFooRequest) returns (CustomOptionFooResponse) {
+ option (method_opt1) = METHODOPT1_VAL2;
+ }
+}
+
+
+
+// Options of every possible field type, so we can test them all exhaustively.
+
+message DummyMessageContainingEnum {
+ enum TestEnumType {
+ TEST_OPTION_ENUM_TYPE1 = 22;
+ TEST_OPTION_ENUM_TYPE2 = -23;
+ }
+}
+
+message DummyMessageInvalidAsOptionType {
+}
+
+extend google.protobuf.MessageOptions {
+ optional bool bool_opt = 7706090;
+ optional int32 int32_opt = 7705709;
+ optional int64 int64_opt = 7705542;
+ optional uint32 uint32_opt = 7704880;
+ optional uint64 uint64_opt = 7702367;
+ optional sint32 sint32_opt = 7701568;
+ optional sint64 sint64_opt = 7700863;
+ optional fixed32 fixed32_opt = 7700307;
+ optional fixed64 fixed64_opt = 7700194;
+ optional sfixed32 sfixed32_opt = 7698645;
+ optional sfixed64 sfixed64_opt = 7685475;
+ optional float float_opt = 7675390;
+ optional double double_opt = 7673293;
+ optional string string_opt = 7673285;
+ optional bytes bytes_opt = 7673238;
+ optional DummyMessageContainingEnum.TestEnumType enum_opt = 7673233;
+ optional DummyMessageInvalidAsOptionType message_type_opt = 7665967;
+}
+
+message CustomOptionMinIntegerValues {
+ option (bool_opt) = false;
+ option (int32_opt) = -0x80000000;
+ option (int64_opt) = -0x8000000000000000;
+ option (uint32_opt) = 0;
+ option (uint64_opt) = 0;
+ option (sint32_opt) = -0x80000000;
+ option (sint64_opt) = -0x8000000000000000;
+ option (fixed32_opt) = 0;
+ option (fixed64_opt) = 0;
+ option (sfixed32_opt) = -0x80000000;
+ option (sfixed64_opt) = -0x8000000000000000;
+}
+
+message CustomOptionMaxIntegerValues {
+ option (bool_opt) = true;
+ option (int32_opt) = 0x7FFFFFFF;
+ option (int64_opt) = 0x7FFFFFFFFFFFFFFF;
+ option (uint32_opt) = 0xFFFFFFFF;
+ option (uint64_opt) = 0xFFFFFFFFFFFFFFFF;
+ option (sint32_opt) = 0x7FFFFFFF;
+ option (sint64_opt) = 0x7FFFFFFFFFFFFFFF;
+ option (fixed32_opt) = 0xFFFFFFFF;
+ option (fixed64_opt) = 0xFFFFFFFFFFFFFFFF;
+ option (sfixed32_opt) = 0x7FFFFFFF;
+ option (sfixed64_opt) = 0x7FFFFFFFFFFFFFFF;
+}
+
+message CustomOptionOtherValues {
+ option (int32_opt) = -100; // To test sign-extension.
+ option (float_opt) = 12.3456789;
+ option (double_opt) = 1.234567890123456789;
+ option (string_opt) = "Hello, \"World\"";
+ option (bytes_opt) = "Hello\0World";
+ option (enum_opt) = TEST_OPTION_ENUM_TYPE2;
+}
+
+message SettingRealsFromPositiveInts {
+ option (float_opt) = 12;
+ option (double_opt) = 154;
+}
+
+message SettingRealsFromNegativeInts {
+ option (float_opt) = -12;
+ option (double_opt) = -154;
+}
+
+// Options of complex message types, themselves combined and extended in
+// various ways.
+
+message ComplexOptionType1 {
+ optional int32 foo = 1;
+ optional int32 foo2 = 2;
+ optional int32 foo3 = 3;
+
+ extensions 100 to max;
+}
+
+message ComplexOptionType2 {
+ optional ComplexOptionType1 bar = 1;
+ optional int32 baz = 2;
+
+ message ComplexOptionType4 {
+ optional int32 waldo = 1;
+
+ extend google.protobuf.MessageOptions {
+ optional ComplexOptionType4 complex_opt4 = 7633546;
+ }
+ }
+
+ optional ComplexOptionType4 fred = 3;
+
+ extensions 100 to max;
+}
+
+message ComplexOptionType3 {
+ optional int32 qux = 1;
+
+ optional group ComplexOptionType5 = 2 {
+ optional int32 plugh = 3;
+ }
+}
+
+extend ComplexOptionType1 {
+ optional int32 quux = 7663707;
+ optional ComplexOptionType3 corge = 7663442;
+}
+
+extend ComplexOptionType2 {
+ optional int32 grault = 7650927;
+ optional ComplexOptionType1 garply = 7649992;
+}
+
+extend google.protobuf.MessageOptions {
+ optional protobuf_unittest.ComplexOptionType1 complex_opt1 = 7646756;
+ optional ComplexOptionType2 complex_opt2 = 7636949;
+ optional ComplexOptionType3 complex_opt3 = 7636463;
+ optional group ComplexOpt6 = 7595468 {
+ optional int32 xyzzy = 7593951;
+ }
+}
+
+// Note that we try various different ways of naming the same extension.
+message VariousComplexOptions {
+ option (.protobuf_unittest.complex_opt1).foo = 42;
+ option (protobuf_unittest.complex_opt1).(.protobuf_unittest.quux) = 324;
+ option (.protobuf_unittest.complex_opt1).(protobuf_unittest.corge).qux = 876;
+ option (complex_opt2).baz = 987;
+ option (complex_opt2).(grault) = 654;
+ option (complex_opt2).bar.foo = 743;
+ option (complex_opt2).bar.(quux) = 1999;
+ option (complex_opt2).bar.(protobuf_unittest.corge).qux = 2008;
+ option (complex_opt2).(garply).foo = 741;
+ option (complex_opt2).(garply).(.protobuf_unittest.quux) = 1998;
+ option (complex_opt2).(protobuf_unittest.garply).(corge).qux = 2121;
+ option (ComplexOptionType2.ComplexOptionType4.complex_opt4).waldo = 1971;
+ option (complex_opt2).fred.waldo = 321;
+ option (protobuf_unittest.complex_opt3).qux = 9;
+ option (complex_opt3).complexoptiontype5.plugh = 22;
+ option (complexopt6).xyzzy = 24;
+}
+
+// ------------------------------------------------------
+// Definitions for testing aggregate option parsing.
+// See descriptor_unittest.cc.
+
+message AggregateMessageSet {
+ option message_set_wire_format = true;
+ extensions 4 to max;
+}
+
+message AggregateMessageSetElement {
+ extend AggregateMessageSet {
+ optional AggregateMessageSetElement message_set_extension = 15447542;
+ }
+ optional string s = 1;
+}
+
+// A helper type used to test aggregate option parsing
+message Aggregate {
+ optional int32 i = 1;
+ optional string s = 2;
+
+ // A nested object
+ optional Aggregate sub = 3;
+
+ // To test the parsing of extensions inside aggregate values
+ optional google.protobuf.FileOptions file = 4;
+ extend google.protobuf.FileOptions {
+ optional Aggregate nested = 15476903;
+ }
+
+ // An embedded message set
+ optional AggregateMessageSet mset = 5;
+}
+
+// Allow Aggregate to be used as an option at all possible locations
+// in the .proto grammer.
+extend google.protobuf.FileOptions { optional Aggregate fileopt = 15478479; }
+extend google.protobuf.MessageOptions { optional Aggregate msgopt = 15480088; }
+extend google.protobuf.FieldOptions { optional Aggregate fieldopt = 15481374; }
+extend google.protobuf.EnumOptions { optional Aggregate enumopt = 15483218; }
+extend google.protobuf.EnumValueOptions { optional Aggregate enumvalopt = 15486921; }
+extend google.protobuf.ServiceOptions { optional Aggregate serviceopt = 15497145; }
+extend google.protobuf.MethodOptions { optional Aggregate methodopt = 15512713; }
+
+// Try using AggregateOption at different points in the proto grammar
+option (fileopt) = {
+ s: 'FileAnnotation'
+ // Also test the handling of comments
+ /* of both types */ i: 100
+
+ sub { s: 'NestedFileAnnotation' }
+
+ // Include a google.protobuf.FileOptions and recursively extend it with
+ // another fileopt.
+ file {
+ [protobuf_unittest.fileopt] {
+ s:'FileExtensionAnnotation'
+ }
+ }
+
+ // A message set inside an option value
+ mset {
+ [protobuf_unittest.AggregateMessageSetElement.message_set_extension] {
+ s: 'EmbeddedMessageSetElement'
+ }
+ }
+};
+
+message AggregateMessage {
+ option (msgopt) = { i:101 s:'MessageAnnotation' };
+ optional int32 fieldname = 1 [(fieldopt) = { s:'FieldAnnotation' }];
+}
+
+service AggregateService {
+ option (serviceopt) = { s:'ServiceAnnotation' };
+ rpc Method (AggregateMessage) returns (AggregateMessage) {
+ option (methodopt) = { s:'MethodAnnotation' };
+ }
+}
+
+enum AggregateEnum {
+ option (enumopt) = { s:'EnumAnnotation' };
+ VALUE = 1 [(enumvalopt) = { s:'EnumValueAnnotation' }];
+}
+
+// Test custom options for nested type.
+message NestedOptionType {
+ message NestedMessage {
+ option (message_opt1) = 1001;
+ optional int32 nested_field = 1 [(field_opt1) = 1002];
+ }
+ enum NestedEnum {
+ option (enum_opt1) = 1003;
+ NESTED_ENUM_VALUE = 1 [(enum_value_opt1) = 1004];
+ }
+ extend google.protobuf.FileOptions {
+ optional int32 nested_extension = 7912573 [(field_opt2) = 1005];
+ }
+}
diff --git a/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_import.proto b/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_import.proto
new file mode 100644
index 00000000..c115b111
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_import.proto
@@ -0,0 +1,64 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// http://code.google.com/p/protobuf/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Author: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+//
+// A proto file which is imported by unittest.proto to test importing.
+
+
+// We don't put this in a package within proto2 because we need to make sure
+// that the generated code doesn't depend on being in the proto2 namespace.
+// In test_util.h we do
+// "using namespace unittest_import = protobuf_unittest_import".
+package protobuf_unittest_import;
+
+option optimize_for = SPEED;
+
+// Excercise the java_package option.
+option java_package = "com.google.protobuf.test";
+
+// Do not set a java_outer_classname here to verify that Proto2 works without
+// one.
+
+// Test public import
+import public "google/protobuf/unittest_import_public.proto";
+
+message ImportMessage {
+ optional int32 d = 1;
+}
+
+enum ImportEnum {
+ IMPORT_FOO = 7;
+ IMPORT_BAR = 8;
+ IMPORT_BAZ = 9;
+}
+
diff --git a/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_import_public.proto b/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_import_public.proto
new file mode 100644
index 00000000..ea5d1b13
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_import_public.proto
@@ -0,0 +1,40 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// http://code.google.com/p/protobuf/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Author: liujisi@google.com (Pherl Liu)
+
+
+package protobuf_unittest_import;
+
+option java_package = "com.google.protobuf.test";
+
+message PublicImportMessage {
+ optional int32 e = 1;
+}
diff --git a/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_mset.proto b/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_mset.proto
new file mode 100644
index 00000000..3497f09f
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_mset.proto
@@ -0,0 +1,72 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// http://code.google.com/p/protobuf/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Author: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+//
+// This file contains messages for testing message_set_wire_format.
+
+package protobuf_unittest;
+
+option optimize_for = SPEED;
+
+// A message with message_set_wire_format.
+message TestMessageSet {
+ option message_set_wire_format = true;
+ extensions 4 to max;
+}
+
+message TestMessageSetContainer {
+ optional TestMessageSet message_set = 1;
+}
+
+message TestMessageSetExtension1 {
+ extend TestMessageSet {
+ optional TestMessageSetExtension1 message_set_extension = 1545008;
+ }
+ optional int32 i = 15;
+}
+
+message TestMessageSetExtension2 {
+ extend TestMessageSet {
+ optional TestMessageSetExtension2 message_set_extension = 1547769;
+ }
+ optional string str = 25;
+}
+
+// MessageSet wire format is equivalent to this.
+message RawMessageSet {
+ repeated group Item = 1 {
+ required int32 type_id = 2;
+ required bytes message = 3;
+ }
+}
+
diff --git a/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_no_generic_services.proto b/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_no_generic_services.proto
new file mode 100644
index 00000000..cffb4122
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/protos/src/proto/google/protobuf/unittest_no_generic_services.proto
@@ -0,0 +1,52 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// http://code.google.com/p/protobuf/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Author: kenton@google.com (Kenton Varda)
+
+package google.protobuf.no_generic_services_test;
+
+// *_generic_services are false by default.
+
+message TestMessage {
+ optional int32 a = 1;
+ extensions 1000 to max;
+}
+
+enum TestEnum {
+ FOO = 1;
+}
+
+extend TestMessage {
+ optional int32 test_extension = 1000;
+}
+
+service TestService {
+ rpc Foo(TestMessage) returns(TestMessage);
+}
diff --git a/python/compatibility_tests/v2.5.0/setup.py b/python/compatibility_tests/v2.5.0/setup.py
new file mode 100755
index 00000000..d8e34bc0
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/setup.py
@@ -0,0 +1,87 @@
+#! /usr/bin/env python
+#
+import glob
+import os
+import subprocess
+import sys
+
+from setuptools import setup, Extension, find_packages
+
+if sys.version_info[0] == 3:
+ # Python 3
+ from distutils.command.build_py import build_py_2to3 as _build_py
+else:
+ # Python 2
+ from distutils.command.build_py import build_py as _build_py
+from distutils.spawn import find_executable
+
+def generate_proto(source, code_gen):
+ """Invokes the Protocol Compiler to generate a _pb2.py from the given
+ .proto file."""
+ output = source.replace(".proto", "_pb2.py").replace("protos/src/proto/", "").replace("protos/python/", "")
+
+ if not os.path.exists(source):
+ sys.stderr.write("Can't find required file: %s\n" % source)
+ sys.exit(-1)
+
+ protoc_command = [ code_gen, "-Iprotos/src/proto", "-Iprotos/python", "--python_out=.", source ]
+ if subprocess.call(protoc_command) != 0:
+ sys.exit(-1)
+
+class build_py(_build_py):
+ def run(self):
+ # generate .proto file
+ protoc_1 = "./protoc_1"
+ protoc_2 = "./protoc_2"
+ generate_proto("protos/src/proto/google/protobuf/unittest.proto", protoc_2)
+ generate_proto("protos/src/proto/google/protobuf/unittest_custom_options.proto", protoc_1)
+ generate_proto("protos/src/proto/google/protobuf/unittest_import.proto", protoc_1)
+ generate_proto("protos/src/proto/google/protobuf/unittest_import_public.proto", protoc_1)
+ generate_proto("protos/src/proto/google/protobuf/unittest_mset.proto", protoc_1)
+ generate_proto("protos/src/proto/google/protobuf/unittest_no_generic_services.proto", protoc_1)
+ generate_proto("protos/python/google/protobuf/internal/factory_test1.proto", protoc_1)
+ generate_proto("protos/python/google/protobuf/internal/factory_test2.proto", protoc_1)
+ generate_proto("protos/python/google/protobuf/internal/more_extensions.proto", protoc_1)
+ generate_proto("protos/python/google/protobuf/internal/more_extensions_dynamic.proto", protoc_1)
+ generate_proto("protos/python/google/protobuf/internal/more_messages.proto", protoc_1)
+ generate_proto("protos/python/google/protobuf/internal/test_bad_identifiers.proto", protoc_1)
+
+ # _build_py is an old-style class, so super() doesn't work.
+ _build_py.run(self)
+
+if __name__ == '__main__':
+ # Keep this list of dependencies in sync with tox.ini.
+ install_requires = ['six>=1.9', 'setuptools']
+ if sys.version_info <= (2,7):
+ install_requires.append('ordereddict')
+ install_requires.append('unittest2')
+
+ setup(
+ name='protobuf',
+ description='Protocol Buffers',
+ download_url='https://github.com/google/protobuf/releases',
+ long_description="Protocol Buffers are Google's data interchange format",
+ url='https://developers.google.com/protocol-buffers/',
+ maintainer='protobuf@googlegroups.com',
+ maintainer_email='protobuf@googlegroups.com',
+ license='New BSD License',
+ classifiers=[
+ "Programming Language :: Python",
+ "Programming Language :: Python :: 2",
+ "Programming Language :: Python :: 2.6",
+ "Programming Language :: Python :: 2.7",
+ "Programming Language :: Python :: 3",
+ "Programming Language :: Python :: 3.3",
+ "Programming Language :: Python :: 3.4",
+ ],
+ packages=find_packages(
+ exclude=[
+ 'import_test_package',
+ ],
+ ),
+ test_suite='tests.google.protobuf.internal',
+ cmdclass={
+ 'build_py': build_py,
+ },
+ install_requires=install_requires,
+ )
diff --git a/python/compatibility_tests/v2.5.0/test.sh b/python/compatibility_tests/v2.5.0/test.sh
new file mode 100755
index 00000000..78c16ad1
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/test.sh
@@ -0,0 +1,104 @@
+#!/bin/bash
+
+set -ex
+
+# Change to the script's directory.
+cd $(dirname $0)
+
+# Version of the tests (i.e., the version of protobuf from where we extracted
+# these tests).
+TEST_VERSION=2.5.0
+
+# The old version of protobuf that we are testing compatibility against. This
+# is usually the same as TEST_VERSION (i.e., we use the tests extracted from
+# that version to test compatibility of the newest runtime against it), but it
+# is also possible to use this same test set to test the compatibiilty of the
+# latest version against other versions.
+case "$1" in
+ ""|2.5.0)
+ OLD_VERSION=2.5.0
+ OLD_VERSION_PROTOC=https://github.com/xfxyjwf/protobuf-compiler-release/raw/master/v2.5.0/linux/protoc
+ ;;
+ 2.6.1)
+ OLD_VERSION=2.6.1
+ OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/2.6.1-build2/protoc-2.6.1-build2-linux-x86_64.exe
+ ;;
+ 3.0.0-beta-1)
+ OLD_VERSION=3.0.0-beta-1
+ OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-1/protoc-3.0.0-beta-1-linux-x86_64.exe
+ ;;
+ 3.0.0-beta-2)
+ OLD_VERSION=3.0.0-beta-2
+ OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-2/protoc-3.0.0-beta-2-linux-x86_64.exe
+ ;;
+ 3.0.0-beta-3)
+ OLD_VERSION=3.0.0-beta-3
+ OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-3/protoc-3.0.0-beta-3-linux-x86_64.exe
+ ;;
+ 3.0.0-beta-4)
+ OLD_VERSION=3.0.0-beta-4
+ OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-4/protoc-3.0.0-beta-4-linux-x86_64.exe
+ ;;
+ *)
+ echo "[ERROR]: Unknown version number: $1"
+ exit 1
+ ;;
+esac
+
+# Extract the latest protobuf version number.
+VERSION_NUMBER=`grep "^__version__ = '.*'" ../../google/protobuf/__init__.py | sed "s|__version__ = '\(.*\)'|\1|"`
+
+echo "Running compatibility tests between $VERSION_NUMBER and $OLD_VERSION"
+
+# Check protoc
+[ -f ../../../src/protoc ] || {
+ echo "[ERROR]: Please build protoc first."
+ exit 1
+}
+
+# Test source compatibility. In these tests we recompile everything against
+# the new runtime (including old version generated code).
+rm google -f -r
+mkdir -p google/protobuf/internal
+# Build and copy the new runtime
+cd ../../
+python setup.py build
+cp google/protobuf/*.py compatibility_tests/v2.5.0/google/protobuf/
+cp google/protobuf/internal/*.py compatibility_tests/v2.5.0/google/protobuf/internal/
+cd compatibility_tests/v2.5.0
+cp tests/google/protobuf/internal/test_util.py google/protobuf/internal/
+cp google/protobuf/__init__.py google/
+
+# Download old version protoc compiler (for linux)
+wget $OLD_VERSION_PROTOC -O old_protoc
+chmod +x old_protoc
+
+# Test A.1:
+# proto set 1: use old version
+# proto set 2 which may import protos in set 1: use old version
+cp old_protoc protoc_1
+cp old_protoc protoc_2
+python setup.py build
+python setup.py test
+
+# Test A.2:
+# proto set 1: use new version
+# proto set 2 which may import protos in set 1: use old version
+cp ../../../src/protoc protoc_1
+cp old_protoc protoc_2
+python setup.py build
+python setup.py test
+
+# Test A.3:
+# proto set 1: use old version
+# proto set 2 which may import protos in set 1: use new version
+cp old_protoc protoc_1
+cp ../../../src/protoc protoc_2
+python setup.py build
+python setup.py test
+
+rm google -r -f
+rm build -r -f
+rm protoc_1
+rm protoc_2
+rm old_protoc
diff --git a/python/compatibility_tests/v2.5.0/tests/__init__.py b/python/compatibility_tests/v2.5.0/tests/__init__.py
new file mode 100644
index 00000000..55856141
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/tests/__init__.py
@@ -0,0 +1,4 @@
+try:
+ __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+ __path__ = __import__('pkgutil').extend_path(__path__, __name__)
diff --git a/python/compatibility_tests/v2.5.0/tests/google/__init__.py b/python/compatibility_tests/v2.5.0/tests/google/__init__.py
new file mode 100644
index 00000000..55856141
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/tests/google/__init__.py
@@ -0,0 +1,4 @@
+try:
+ __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+ __path__ = __import__('pkgutil').extend_path(__path__, __name__)
diff --git a/python/compatibility_tests/v2.5.0/tests/google/protobuf/__init__.py b/python/compatibility_tests/v2.5.0/tests/google/protobuf/__init__.py
new file mode 100644
index 00000000..55856141
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/tests/google/protobuf/__init__.py
@@ -0,0 +1,4 @@
+try:
+ __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+ __path__ = __import__('pkgutil').extend_path(__path__, __name__)
diff --git a/src/google/protobuf/arena_nc_test.py b/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/__init__.py
index 56a7dd05..64c6956f 100644
--- a/src/google/protobuf/arena_nc_test.py
+++ b/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/__init__.py
@@ -1,5 +1,3 @@
-#! /usr/bin/env python
-#
# Protocol Buffers - Google's data interchange format
# Copyright 2008 Google Inc. All rights reserved.
# https://developers.google.com/protocol-buffers/
@@ -30,32 +28,10 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-"""Negative compilation unit tests for arena API."""
-
-import unittest
-
-from google3.testing.pybase import fake_target_util
-from google3.testing.pybase import unittest
-
-
-class ArenaNcTest(unittest.TestCase):
-
- def testCompilerErrors(self):
- """Runs a list of tests to verify compiler error messages."""
-
- # Defines a list of test specs, where each element is a tuple
- # (test name, list of regexes for matching the compiler errors).
- test_specs = [
- ('ARENA_PRIVATE_CONSTRUCTOR',
- [r'calling a protected constructor']),
- ('SANITY', None)]
-
- fake_target_util.AssertCcCompilerErrors(
- self, # The current test case.
- 'google3/google/protobuf/arena_nc', # The fake target file.
- 'arena_nc.o', # The sub-target to build.
- test_specs # List of test specifications.
- )
+# Copyright 2007 Google Inc. All Rights Reserved.
-if __name__ == '__main__':
- unittest.main()
+if __name__ != '__main__':
+ try:
+ __import__('pkg_resources').declare_namespace(__name__)
+ except ImportError:
+ __path__ = __import__('pkgutil').extend_path(__path__, __name__)
diff --git a/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/descriptor_test.py b/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/descriptor_test.py
new file mode 100755
index 00000000..c74f882e
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/descriptor_test.py
@@ -0,0 +1,613 @@
+#! /usr/bin/python
+#
+# Protocol Buffers - Google's data interchange format
+# Copyright 2008 Google Inc. All rights reserved.
+# http://code.google.com/p/protobuf/
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+"""Unittest for google.protobuf.internal.descriptor."""
+
+__author__ = 'robinson@google.com (Will Robinson)'
+
+import unittest
+from google.protobuf import unittest_custom_options_pb2
+from google.protobuf import unittest_import_pb2
+from google.protobuf import unittest_pb2
+from google.protobuf import descriptor_pb2
+from google.protobuf import descriptor
+from google.protobuf import text_format
+
+
+TEST_EMPTY_MESSAGE_DESCRIPTOR_ASCII = """
+name: 'TestEmptyMessage'
+"""
+
+
+class DescriptorTest(unittest.TestCase):
+
+ def setUp(self):
+ self.my_file = descriptor.FileDescriptor(
+ name='some/filename/some.proto',
+ package='protobuf_unittest'
+ )
+ self.my_enum = descriptor.EnumDescriptor(
+ name='ForeignEnum',
+ full_name='protobuf_unittest.ForeignEnum',
+ filename=None,
+ file=self.my_file,
+ values=[
+ descriptor.EnumValueDescriptor(name='FOREIGN_FOO', index=0, number=4),
+ descriptor.EnumValueDescriptor(name='FOREIGN_BAR', index=1, number=5),
+ descriptor.EnumValueDescriptor(name='FOREIGN_BAZ', index=2, number=6),
+ ])
+ self.my_message = descriptor.Descriptor(
+ name='NestedMessage',
+ full_name='protobuf_unittest.TestAllTypes.NestedMessage',
+ filename=None,
+ file=self.my_file,
+ containing_type=None,
+ fields=[
+ descriptor.FieldDescriptor(
+ name='bb',
+ full_name='protobuf_unittest.TestAllTypes.NestedMessage.bb',
+ index=0, number=1,
+ type=5, cpp_type=1, label=1,
+ has_default_value=False, default_value=0,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None),
+ ],
+ nested_types=[],
+ enum_types=[
+ self.my_enum,
+ ],
+ extensions=[])
+ self.my_method = descriptor.MethodDescriptor(
+ name='Bar',
+ full_name='protobuf_unittest.TestService.Bar',
+ index=0,
+ containing_service=None,
+ input_type=None,
+ output_type=None)
+ self.my_service = descriptor.ServiceDescriptor(
+ name='TestServiceWithOptions',
+ full_name='protobuf_unittest.TestServiceWithOptions',
+ file=self.my_file,
+ index=0,
+ methods=[
+ self.my_method
+ ])
+
+ def testEnumValueName(self):
+ self.assertEqual(self.my_message.EnumValueName('ForeignEnum', 4),
+ 'FOREIGN_FOO')
+
+ self.assertEqual(
+ self.my_message.enum_types_by_name[
+ 'ForeignEnum'].values_by_number[4].name,
+ self.my_message.EnumValueName('ForeignEnum', 4))
+
+ def testEnumFixups(self):
+ self.assertEqual(self.my_enum, self.my_enum.values[0].type)
+
+ def testContainingTypeFixups(self):
+ self.assertEqual(self.my_message, self.my_message.fields[0].containing_type)
+ self.assertEqual(self.my_message, self.my_enum.containing_type)
+
+ def testContainingServiceFixups(self):
+ self.assertEqual(self.my_service, self.my_method.containing_service)
+
+ def testGetOptions(self):
+ self.assertEqual(self.my_enum.GetOptions(),
+ descriptor_pb2.EnumOptions())
+ self.assertEqual(self.my_enum.values[0].GetOptions(),
+ descriptor_pb2.EnumValueOptions())
+ self.assertEqual(self.my_message.GetOptions(),
+ descriptor_pb2.MessageOptions())
+ self.assertEqual(self.my_message.fields[0].GetOptions(),
+ descriptor_pb2.FieldOptions())
+ self.assertEqual(self.my_method.GetOptions(),
+ descriptor_pb2.MethodOptions())
+ self.assertEqual(self.my_service.GetOptions(),
+ descriptor_pb2.ServiceOptions())
+
+ def testSimpleCustomOptions(self):
+ file_descriptor = unittest_custom_options_pb2.DESCRIPTOR
+ message_descriptor =\
+ unittest_custom_options_pb2.TestMessageWithCustomOptions.DESCRIPTOR
+ field_descriptor = message_descriptor.fields_by_name["field1"]
+ enum_descriptor = message_descriptor.enum_types_by_name["AnEnum"]
+ enum_value_descriptor =\
+ message_descriptor.enum_values_by_name["ANENUM_VAL2"]
+ service_descriptor =\
+ unittest_custom_options_pb2.TestServiceWithCustomOptions.DESCRIPTOR
+ method_descriptor = service_descriptor.FindMethodByName("Foo")
+
+ file_options = file_descriptor.GetOptions()
+ file_opt1 = unittest_custom_options_pb2.file_opt1
+ self.assertEqual(9876543210, file_options.Extensions[file_opt1])
+ message_options = message_descriptor.GetOptions()
+ message_opt1 = unittest_custom_options_pb2.message_opt1
+ self.assertEqual(-56, message_options.Extensions[message_opt1])
+ field_options = field_descriptor.GetOptions()
+ field_opt1 = unittest_custom_options_pb2.field_opt1
+ self.assertEqual(8765432109, field_options.Extensions[field_opt1])
+ field_opt2 = unittest_custom_options_pb2.field_opt2
+ self.assertEqual(42, field_options.Extensions[field_opt2])
+ enum_options = enum_descriptor.GetOptions()
+ enum_opt1 = unittest_custom_options_pb2.enum_opt1
+ self.assertEqual(-789, enum_options.Extensions[enum_opt1])
+ enum_value_options = enum_value_descriptor.GetOptions()
+ enum_value_opt1 = unittest_custom_options_pb2.enum_value_opt1
+ self.assertEqual(123, enum_value_options.Extensions[enum_value_opt1])
+
+ service_options = service_descriptor.GetOptions()
+ service_opt1 = unittest_custom_options_pb2.service_opt1
+ self.assertEqual(-9876543210, service_options.Extensions[service_opt1])
+ method_options = method_descriptor.GetOptions()
+ method_opt1 = unittest_custom_options_pb2.method_opt1
+ self.assertEqual(unittest_custom_options_pb2.METHODOPT1_VAL2,
+ method_options.Extensions[method_opt1])
+
+ def testDifferentCustomOptionTypes(self):
+ kint32min = -2**31
+ kint64min = -2**63
+ kint32max = 2**31 - 1
+ kint64max = 2**63 - 1
+ kuint32max = 2**32 - 1
+ kuint64max = 2**64 - 1
+
+ message_descriptor =\
+ unittest_custom_options_pb2.CustomOptionMinIntegerValues.DESCRIPTOR
+ message_options = message_descriptor.GetOptions()
+ self.assertEqual(False, message_options.Extensions[
+ unittest_custom_options_pb2.bool_opt])
+ self.assertEqual(kint32min, message_options.Extensions[
+ unittest_custom_options_pb2.int32_opt])
+ self.assertEqual(kint64min, message_options.Extensions[
+ unittest_custom_options_pb2.int64_opt])
+ self.assertEqual(0, message_options.Extensions[
+ unittest_custom_options_pb2.uint32_opt])
+ self.assertEqual(0, message_options.Extensions[
+ unittest_custom_options_pb2.uint64_opt])
+ self.assertEqual(kint32min, message_options.Extensions[
+ unittest_custom_options_pb2.sint32_opt])
+ self.assertEqual(kint64min, message_options.Extensions[
+ unittest_custom_options_pb2.sint64_opt])
+ self.assertEqual(0, message_options.Extensions[
+ unittest_custom_options_pb2.fixed32_opt])
+ self.assertEqual(0, message_options.Extensions[
+ unittest_custom_options_pb2.fixed64_opt])
+ self.assertEqual(kint32min, message_options.Extensions[
+ unittest_custom_options_pb2.sfixed32_opt])
+ self.assertEqual(kint64min, message_options.Extensions[
+ unittest_custom_options_pb2.sfixed64_opt])
+
+ message_descriptor =\
+ unittest_custom_options_pb2.CustomOptionMaxIntegerValues.DESCRIPTOR
+ message_options = message_descriptor.GetOptions()
+ self.assertEqual(True, message_options.Extensions[
+ unittest_custom_options_pb2.bool_opt])
+ self.assertEqual(kint32max, message_options.Extensions[
+ unittest_custom_options_pb2.int32_opt])
+ self.assertEqual(kint64max, message_options.Extensions[
+ unittest_custom_options_pb2.int64_opt])
+ self.assertEqual(kuint32max, message_options.Extensions[
+ unittest_custom_options_pb2.uint32_opt])
+ self.assertEqual(kuint64max, message_options.Extensions[
+ unittest_custom_options_pb2.uint64_opt])
+ self.assertEqual(kint32max, message_options.Extensions[
+ unittest_custom_options_pb2.sint32_opt])
+ self.assertEqual(kint64max, message_options.Extensions[
+ unittest_custom_options_pb2.sint64_opt])
+ self.assertEqual(kuint32max, message_options.Extensions[
+ unittest_custom_options_pb2.fixed32_opt])
+ self.assertEqual(kuint64max, message_options.Extensions[
+ unittest_custom_options_pb2.fixed64_opt])
+ self.assertEqual(kint32max, message_options.Extensions[
+ unittest_custom_options_pb2.sfixed32_opt])
+ self.assertEqual(kint64max, message_options.Extensions[
+ unittest_custom_options_pb2.sfixed64_opt])
+
+ message_descriptor =\
+ unittest_custom_options_pb2.CustomOptionOtherValues.DESCRIPTOR
+ message_options = message_descriptor.GetOptions()
+ self.assertEqual(-100, message_options.Extensions[
+ unittest_custom_options_pb2.int32_opt])
+ self.assertAlmostEqual(12.3456789, message_options.Extensions[
+ unittest_custom_options_pb2.float_opt], 6)
+ self.assertAlmostEqual(1.234567890123456789, message_options.Extensions[
+ unittest_custom_options_pb2.double_opt])
+ self.assertEqual("Hello, \"World\"", message_options.Extensions[
+ unittest_custom_options_pb2.string_opt])
+ self.assertEqual("Hello\0World", message_options.Extensions[
+ unittest_custom_options_pb2.bytes_opt])
+ dummy_enum = unittest_custom_options_pb2.DummyMessageContainingEnum
+ self.assertEqual(
+ dummy_enum.TEST_OPTION_ENUM_TYPE2,
+ message_options.Extensions[unittest_custom_options_pb2.enum_opt])
+
+ message_descriptor =\
+ unittest_custom_options_pb2.SettingRealsFromPositiveInts.DESCRIPTOR
+ message_options = message_descriptor.GetOptions()
+ self.assertAlmostEqual(12, message_options.Extensions[
+ unittest_custom_options_pb2.float_opt], 6)
+ self.assertAlmostEqual(154, message_options.Extensions[
+ unittest_custom_options_pb2.double_opt])
+
+ message_descriptor =\
+ unittest_custom_options_pb2.SettingRealsFromNegativeInts.DESCRIPTOR
+ message_options = message_descriptor.GetOptions()
+ self.assertAlmostEqual(-12, message_options.Extensions[
+ unittest_custom_options_pb2.float_opt], 6)
+ self.assertAlmostEqual(-154, message_options.Extensions[
+ unittest_custom_options_pb2.double_opt])
+
+ def testComplexExtensionOptions(self):
+ descriptor =\
+ unittest_custom_options_pb2.VariousComplexOptions.DESCRIPTOR
+ options = descriptor.GetOptions()
+ self.assertEqual(42, options.Extensions[
+ unittest_custom_options_pb2.complex_opt1].foo)
+ self.assertEqual(324, options.Extensions[
+ unittest_custom_options_pb2.complex_opt1].Extensions[
+ unittest_custom_options_pb2.quux])
+ self.assertEqual(876, options.Extensions[
+ unittest_custom_options_pb2.complex_opt1].Extensions[
+ unittest_custom_options_pb2.corge].qux)
+ self.assertEqual(987, options.Extensions[
+ unittest_custom_options_pb2.complex_opt2].baz)
+ self.assertEqual(654, options.Extensions[
+ unittest_custom_options_pb2.complex_opt2].Extensions[
+ unittest_custom_options_pb2.grault])
+ self.assertEqual(743, options.Extensions[
+ unittest_custom_options_pb2.complex_opt2].bar.foo)
+ self.assertEqual(1999, options.Extensions[
+ unittest_custom_options_pb2.complex_opt2].bar.Extensions[
+ unittest_custom_options_pb2.quux])
+ self.assertEqual(2008, options.Extensions[
+ unittest_custom_options_pb2.complex_opt2].bar.Extensions[
+ unittest_custom_options_pb2.corge].qux)
+ self.assertEqual(741, options.Extensions[
+ unittest_custom_options_pb2.complex_opt2].Extensions[
+ unittest_custom_options_pb2.garply].foo)
+ self.assertEqual(1998, options.Extensions[
+ unittest_custom_options_pb2.complex_opt2].Extensions[
+ unittest_custom_options_pb2.garply].Extensions[
+ unittest_custom_options_pb2.quux])
+ self.assertEqual(2121, options.Extensions[
+ unittest_custom_options_pb2.complex_opt2].Extensions[
+ unittest_custom_options_pb2.garply].Extensions[
+ unittest_custom_options_pb2.corge].qux)
+ self.assertEqual(1971, options.Extensions[
+ unittest_custom_options_pb2.ComplexOptionType2
+ .ComplexOptionType4.complex_opt4].waldo)
+ self.assertEqual(321, options.Extensions[
+ unittest_custom_options_pb2.complex_opt2].fred.waldo)
+ self.assertEqual(9, options.Extensions[
+ unittest_custom_options_pb2.complex_opt3].qux)
+ self.assertEqual(22, options.Extensions[
+ unittest_custom_options_pb2.complex_opt3].complexoptiontype5.plugh)
+ self.assertEqual(24, options.Extensions[
+ unittest_custom_options_pb2.complexopt6].xyzzy)
+
+ # Check that aggregate options were parsed and saved correctly in
+ # the appropriate descriptors.
+ def testAggregateOptions(self):
+ file_descriptor = unittest_custom_options_pb2.DESCRIPTOR
+ message_descriptor =\
+ unittest_custom_options_pb2.AggregateMessage.DESCRIPTOR
+ field_descriptor = message_descriptor.fields_by_name["fieldname"]
+ enum_descriptor = unittest_custom_options_pb2.AggregateEnum.DESCRIPTOR
+ enum_value_descriptor = enum_descriptor.values_by_name["VALUE"]
+ service_descriptor =\
+ unittest_custom_options_pb2.AggregateService.DESCRIPTOR
+ method_descriptor = service_descriptor.FindMethodByName("Method")
+
+ # Tests for the different types of data embedded in fileopt
+ file_options = file_descriptor.GetOptions().Extensions[
+ unittest_custom_options_pb2.fileopt]
+ self.assertEqual(100, file_options.i)
+ self.assertEqual("FileAnnotation", file_options.s)
+ self.assertEqual("NestedFileAnnotation", file_options.sub.s)
+ self.assertEqual("FileExtensionAnnotation", file_options.file.Extensions[
+ unittest_custom_options_pb2.fileopt].s)
+ self.assertEqual("EmbeddedMessageSetElement", file_options.mset.Extensions[
+ unittest_custom_options_pb2.AggregateMessageSetElement
+ .message_set_extension].s)
+
+ # Simple tests for all the other types of annotations
+ self.assertEqual(
+ "MessageAnnotation",
+ message_descriptor.GetOptions().Extensions[
+ unittest_custom_options_pb2.msgopt].s)
+ self.assertEqual(
+ "FieldAnnotation",
+ field_descriptor.GetOptions().Extensions[
+ unittest_custom_options_pb2.fieldopt].s)
+ self.assertEqual(
+ "EnumAnnotation",
+ enum_descriptor.GetOptions().Extensions[
+ unittest_custom_options_pb2.enumopt].s)
+ self.assertEqual(
+ "EnumValueAnnotation",
+ enum_value_descriptor.GetOptions().Extensions[
+ unittest_custom_options_pb2.enumvalopt].s)
+ self.assertEqual(
+ "ServiceAnnotation",
+ service_descriptor.GetOptions().Extensions[
+ unittest_custom_options_pb2.serviceopt].s)
+ self.assertEqual(
+ "MethodAnnotation",
+ method_descriptor.GetOptions().Extensions[
+ unittest_custom_options_pb2.methodopt].s)
+
+ def testNestedOptions(self):
+ nested_message =\
+ unittest_custom_options_pb2.NestedOptionType.NestedMessage.DESCRIPTOR
+ self.assertEqual(1001, nested_message.GetOptions().Extensions[
+ unittest_custom_options_pb2.message_opt1])
+ nested_field = nested_message.fields_by_name["nested_field"]
+ self.assertEqual(1002, nested_field.GetOptions().Extensions[
+ unittest_custom_options_pb2.field_opt1])
+ outer_message =\
+ unittest_custom_options_pb2.NestedOptionType.DESCRIPTOR
+ nested_enum = outer_message.enum_types_by_name["NestedEnum"]
+ self.assertEqual(1003, nested_enum.GetOptions().Extensions[
+ unittest_custom_options_pb2.enum_opt1])
+ nested_enum_value = outer_message.enum_values_by_name["NESTED_ENUM_VALUE"]
+ self.assertEqual(1004, nested_enum_value.GetOptions().Extensions[
+ unittest_custom_options_pb2.enum_value_opt1])
+ nested_extension = outer_message.extensions_by_name["nested_extension"]
+ self.assertEqual(1005, nested_extension.GetOptions().Extensions[
+ unittest_custom_options_pb2.field_opt2])
+
+ def testFileDescriptorReferences(self):
+ self.assertEqual(self.my_enum.file, self.my_file)
+ self.assertEqual(self.my_message.file, self.my_file)
+
+ def testFileDescriptor(self):
+ self.assertEqual(self.my_file.name, 'some/filename/some.proto')
+ self.assertEqual(self.my_file.package, 'protobuf_unittest')
+
+
+class DescriptorCopyToProtoTest(unittest.TestCase):
+ """Tests for CopyTo functions of Descriptor."""
+
+ def _AssertProtoEqual(self, actual_proto, expected_class, expected_ascii):
+ expected_proto = expected_class()
+ text_format.Merge(expected_ascii, expected_proto)
+
+ self.assertEqual(
+ actual_proto, expected_proto,
+ 'Not equal,\nActual:\n%s\nExpected:\n%s\n'
+ % (str(actual_proto), str(expected_proto)))
+
+ def _InternalTestCopyToProto(self, desc, expected_proto_class,
+ expected_proto_ascii):
+ actual = expected_proto_class()
+ desc.CopyToProto(actual)
+ self._AssertProtoEqual(
+ actual, expected_proto_class, expected_proto_ascii)
+
+ def testCopyToProto_EmptyMessage(self):
+ self._InternalTestCopyToProto(
+ unittest_pb2.TestEmptyMessage.DESCRIPTOR,
+ descriptor_pb2.DescriptorProto,
+ TEST_EMPTY_MESSAGE_DESCRIPTOR_ASCII)
+
+ def testCopyToProto_NestedMessage(self):
+ TEST_NESTED_MESSAGE_ASCII = """
+ name: 'NestedMessage'
+ field: <
+ name: 'bb'
+ number: 1
+ label: 1 # Optional
+ type: 5 # TYPE_INT32
+ >
+ """
+
+ self._InternalTestCopyToProto(
+ unittest_pb2.TestAllTypes.NestedMessage.DESCRIPTOR,
+ descriptor_pb2.DescriptorProto,
+ TEST_NESTED_MESSAGE_ASCII)
+
+ def testCopyToProto_ForeignNestedMessage(self):
+ TEST_FOREIGN_NESTED_ASCII = """
+ name: 'TestForeignNested'
+ field: <
+ name: 'foreign_nested'
+ number: 1
+ label: 1 # Optional
+ type: 11 # TYPE_MESSAGE
+ type_name: '.protobuf_unittest.TestAllTypes.NestedMessage'
+ >
+ """
+
+ self._InternalTestCopyToProto(
+ unittest_pb2.TestForeignNested.DESCRIPTOR,
+ descriptor_pb2.DescriptorProto,
+ TEST_FOREIGN_NESTED_ASCII)
+
+ def testCopyToProto_ForeignEnum(self):
+ TEST_FOREIGN_ENUM_ASCII = """
+ name: 'ForeignEnum'
+ value: <
+ name: 'FOREIGN_FOO'
+ number: 4
+ >
+ value: <
+ name: 'FOREIGN_BAR'
+ number: 5
+ >
+ value: <
+ name: 'FOREIGN_BAZ'
+ number: 6
+ >
+ """
+
+ self._InternalTestCopyToProto(
+ unittest_pb2._FOREIGNENUM,
+ descriptor_pb2.EnumDescriptorProto,
+ TEST_FOREIGN_ENUM_ASCII)
+
+ def testCopyToProto_Options(self):
+ TEST_DEPRECATED_FIELDS_ASCII = """
+ name: 'TestDeprecatedFields'
+ field: <
+ name: 'deprecated_int32'
+ number: 1
+ label: 1 # Optional
+ type: 5 # TYPE_INT32
+ options: <
+ deprecated: true
+ >
+ >
+ """
+
+ self._InternalTestCopyToProto(
+ unittest_pb2.TestDeprecatedFields.DESCRIPTOR,
+ descriptor_pb2.DescriptorProto,
+ TEST_DEPRECATED_FIELDS_ASCII)
+
+ def testCopyToProto_AllExtensions(self):
+ TEST_EMPTY_MESSAGE_WITH_EXTENSIONS_ASCII = """
+ name: 'TestEmptyMessageWithExtensions'
+ extension_range: <
+ start: 1
+ end: 536870912
+ >
+ """
+
+ self._InternalTestCopyToProto(
+ unittest_pb2.TestEmptyMessageWithExtensions.DESCRIPTOR,
+ descriptor_pb2.DescriptorProto,
+ TEST_EMPTY_MESSAGE_WITH_EXTENSIONS_ASCII)
+
+ def testCopyToProto_SeveralExtensions(self):
+ TEST_MESSAGE_WITH_SEVERAL_EXTENSIONS_ASCII = """
+ name: 'TestMultipleExtensionRanges'
+ extension_range: <
+ start: 42
+ end: 43
+ >
+ extension_range: <
+ start: 4143
+ end: 4244
+ >
+ extension_range: <
+ start: 65536
+ end: 536870912
+ >
+ """
+
+ self._InternalTestCopyToProto(
+ unittest_pb2.TestMultipleExtensionRanges.DESCRIPTOR,
+ descriptor_pb2.DescriptorProto,
+ TEST_MESSAGE_WITH_SEVERAL_EXTENSIONS_ASCII)
+
+ def testCopyToProto_FileDescriptor(self):
+ UNITTEST_IMPORT_FILE_DESCRIPTOR_ASCII = ("""
+ name: 'google/protobuf/unittest_import.proto'
+ package: 'protobuf_unittest_import'
+ dependency: 'google/protobuf/unittest_import_public.proto'
+ message_type: <
+ name: 'ImportMessage'
+ field: <
+ name: 'd'
+ number: 1
+ label: 1 # Optional
+ type: 5 # TYPE_INT32
+ >
+ >
+ """ +
+ """enum_type: <
+ name: 'ImportEnum'
+ value: <
+ name: 'IMPORT_FOO'
+ number: 7
+ >
+ value: <
+ name: 'IMPORT_BAR'
+ number: 8
+ >
+ value: <
+ name: 'IMPORT_BAZ'
+ number: 9
+ >
+ >
+ options: <
+ java_package: 'com.google.protobuf.test'
+ optimize_for: 1 # SPEED
+ >
+ public_dependency: 0
+ """)
+
+ self._InternalTestCopyToProto(
+ unittest_import_pb2.DESCRIPTOR,
+ descriptor_pb2.FileDescriptorProto,
+ UNITTEST_IMPORT_FILE_DESCRIPTOR_ASCII)
+
+ def testCopyToProto_ServiceDescriptor(self):
+ TEST_SERVICE_ASCII = """
+ name: 'TestService'
+ method: <
+ name: 'Foo'
+ input_type: '.protobuf_unittest.FooRequest'
+ output_type: '.protobuf_unittest.FooResponse'
+ >
+ method: <
+ name: 'Bar'
+ input_type: '.protobuf_unittest.BarRequest'
+ output_type: '.protobuf_unittest.BarResponse'
+ >
+ """
+
+ self._InternalTestCopyToProto(
+ unittest_pb2.TestService.DESCRIPTOR,
+ descriptor_pb2.ServiceDescriptorProto,
+ TEST_SERVICE_ASCII)
+
+
+class MakeDescriptorTest(unittest.TestCase):
+ def testMakeDescriptorWithUnsignedIntField(self):
+ file_descriptor_proto = descriptor_pb2.FileDescriptorProto()
+ file_descriptor_proto.name = 'Foo'
+ message_type = file_descriptor_proto.message_type.add()
+ message_type.name = file_descriptor_proto.name
+ field = message_type.field.add()
+ field.number = 1
+ field.name = 'uint64_field'
+ field.label = descriptor.FieldDescriptor.LABEL_REQUIRED
+ field.type = descriptor.FieldDescriptor.TYPE_UINT64
+ result = descriptor.MakeDescriptor(message_type)
+ self.assertEqual(result.fields[0].cpp_type,
+ descriptor.FieldDescriptor.CPPTYPE_UINT64)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/generator_test.py b/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/generator_test.py
new file mode 100755
index 00000000..8343aba1
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/generator_test.py
@@ -0,0 +1,269 @@
+#! /usr/bin/python
+#
+# Protocol Buffers - Google's data interchange format
+# Copyright 2008 Google Inc. All rights reserved.
+# http://code.google.com/p/protobuf/
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# TODO(robinson): Flesh this out considerably. We focused on reflection_test.py
+# first, since it's testing the subtler code, and since it provides decent
+# indirect testing of the protocol compiler output.
+
+"""Unittest that directly tests the output of the pure-Python protocol
+compiler. See //google/protobuf/reflection_test.py for a test which
+further ensures that we can use Python protocol message objects as we expect.
+"""
+
+__author__ = 'robinson@google.com (Will Robinson)'
+
+import unittest
+from google.protobuf.internal import test_bad_identifiers_pb2
+from google.protobuf import unittest_custom_options_pb2
+from google.protobuf import unittest_import_pb2
+from google.protobuf import unittest_import_public_pb2
+from google.protobuf import unittest_mset_pb2
+from google.protobuf import unittest_pb2
+from google.protobuf import unittest_no_generic_services_pb2
+from google.protobuf import service
+
+MAX_EXTENSION = 536870912
+
+
+class GeneratorTest(unittest.TestCase):
+
+ def testNestedMessageDescriptor(self):
+ field_name = 'optional_nested_message'
+ proto_type = unittest_pb2.TestAllTypes
+ self.assertEqual(
+ proto_type.NestedMessage.DESCRIPTOR,
+ proto_type.DESCRIPTOR.fields_by_name[field_name].message_type)
+
+ def testEnums(self):
+ # We test only module-level enums here.
+ # TODO(robinson): Examine descriptors directly to check
+ # enum descriptor output.
+ self.assertEqual(4, unittest_pb2.FOREIGN_FOO)
+ self.assertEqual(5, unittest_pb2.FOREIGN_BAR)
+ self.assertEqual(6, unittest_pb2.FOREIGN_BAZ)
+
+ proto = unittest_pb2.TestAllTypes()
+ self.assertEqual(1, proto.FOO)
+ self.assertEqual(1, unittest_pb2.TestAllTypes.FOO)
+ self.assertEqual(2, proto.BAR)
+ self.assertEqual(2, unittest_pb2.TestAllTypes.BAR)
+ self.assertEqual(3, proto.BAZ)
+ self.assertEqual(3, unittest_pb2.TestAllTypes.BAZ)
+
+ def testExtremeDefaultValues(self):
+ message = unittest_pb2.TestExtremeDefaultValues()
+
+ # Python pre-2.6 does not have isinf() or isnan() functions, so we have
+ # to provide our own.
+ def isnan(val):
+ # NaN is never equal to itself.
+ return val != val
+ def isinf(val):
+ # Infinity times zero equals NaN.
+ return not isnan(val) and isnan(val * 0)
+
+ self.assertTrue(isinf(message.inf_double))
+ self.assertTrue(message.inf_double > 0)
+ self.assertTrue(isinf(message.neg_inf_double))
+ self.assertTrue(message.neg_inf_double < 0)
+ self.assertTrue(isnan(message.nan_double))
+
+ self.assertTrue(isinf(message.inf_float))
+ self.assertTrue(message.inf_float > 0)
+ self.assertTrue(isinf(message.neg_inf_float))
+ self.assertTrue(message.neg_inf_float < 0)
+ self.assertTrue(isnan(message.nan_float))
+ self.assertEqual("? ? ?? ?? ??? ??/ ??-", message.cpp_trigraph)
+
+ def testHasDefaultValues(self):
+ desc = unittest_pb2.TestAllTypes.DESCRIPTOR
+
+ expected_has_default_by_name = {
+ 'optional_int32': False,
+ 'repeated_int32': False,
+ 'optional_nested_message': False,
+ 'default_int32': True,
+ }
+
+ has_default_by_name = dict(
+ [(f.name, f.has_default_value)
+ for f in desc.fields
+ if f.name in expected_has_default_by_name])
+ self.assertEqual(expected_has_default_by_name, has_default_by_name)
+
+ def testContainingTypeBehaviorForExtensions(self):
+ self.assertEqual(unittest_pb2.optional_int32_extension.containing_type,
+ unittest_pb2.TestAllExtensions.DESCRIPTOR)
+ self.assertEqual(unittest_pb2.TestRequired.single.containing_type,
+ unittest_pb2.TestAllExtensions.DESCRIPTOR)
+
+ def testExtensionScope(self):
+ self.assertEqual(unittest_pb2.optional_int32_extension.extension_scope,
+ None)
+ self.assertEqual(unittest_pb2.TestRequired.single.extension_scope,
+ unittest_pb2.TestRequired.DESCRIPTOR)
+
+ def testIsExtension(self):
+ self.assertTrue(unittest_pb2.optional_int32_extension.is_extension)
+ self.assertTrue(unittest_pb2.TestRequired.single.is_extension)
+
+ message_descriptor = unittest_pb2.TestRequired.DESCRIPTOR
+ non_extension_descriptor = message_descriptor.fields_by_name['a']
+ self.assertTrue(not non_extension_descriptor.is_extension)
+
+ def testOptions(self):
+ proto = unittest_mset_pb2.TestMessageSet()
+ self.assertTrue(proto.DESCRIPTOR.GetOptions().message_set_wire_format)
+
+ def testMessageWithCustomOptions(self):
+ proto = unittest_custom_options_pb2.TestMessageWithCustomOptions()
+ enum_options = proto.DESCRIPTOR.enum_types_by_name['AnEnum'].GetOptions()
+ self.assertTrue(enum_options is not None)
+ # TODO(gps): We really should test for the presense of the enum_opt1
+ # extension and for its value to be set to -789.
+
+ def testNestedTypes(self):
+ self.assertEquals(
+ set(unittest_pb2.TestAllTypes.DESCRIPTOR.nested_types),
+ set([
+ unittest_pb2.TestAllTypes.NestedMessage.DESCRIPTOR,
+ unittest_pb2.TestAllTypes.OptionalGroup.DESCRIPTOR,
+ unittest_pb2.TestAllTypes.RepeatedGroup.DESCRIPTOR,
+ ]))
+ self.assertEqual(unittest_pb2.TestEmptyMessage.DESCRIPTOR.nested_types, [])
+ self.assertEqual(
+ unittest_pb2.TestAllTypes.NestedMessage.DESCRIPTOR.nested_types, [])
+
+ def testContainingType(self):
+ self.assertTrue(
+ unittest_pb2.TestEmptyMessage.DESCRIPTOR.containing_type is None)
+ self.assertTrue(
+ unittest_pb2.TestAllTypes.DESCRIPTOR.containing_type is None)
+ self.assertEqual(
+ unittest_pb2.TestAllTypes.NestedMessage.DESCRIPTOR.containing_type,
+ unittest_pb2.TestAllTypes.DESCRIPTOR)
+ self.assertEqual(
+ unittest_pb2.TestAllTypes.NestedMessage.DESCRIPTOR.containing_type,
+ unittest_pb2.TestAllTypes.DESCRIPTOR)
+ self.assertEqual(
+ unittest_pb2.TestAllTypes.RepeatedGroup.DESCRIPTOR.containing_type,
+ unittest_pb2.TestAllTypes.DESCRIPTOR)
+
+ def testContainingTypeInEnumDescriptor(self):
+ self.assertTrue(unittest_pb2._FOREIGNENUM.containing_type is None)
+ self.assertEqual(unittest_pb2._TESTALLTYPES_NESTEDENUM.containing_type,
+ unittest_pb2.TestAllTypes.DESCRIPTOR)
+
+ def testPackage(self):
+ self.assertEqual(
+ unittest_pb2.TestAllTypes.DESCRIPTOR.file.package,
+ 'protobuf_unittest')
+ desc = unittest_pb2.TestAllTypes.NestedMessage.DESCRIPTOR
+ self.assertEqual(desc.file.package, 'protobuf_unittest')
+ self.assertEqual(
+ unittest_import_pb2.ImportMessage.DESCRIPTOR.file.package,
+ 'protobuf_unittest_import')
+
+ self.assertEqual(
+ unittest_pb2._FOREIGNENUM.file.package, 'protobuf_unittest')
+ self.assertEqual(
+ unittest_pb2._TESTALLTYPES_NESTEDENUM.file.package,
+ 'protobuf_unittest')
+ self.assertEqual(
+ unittest_import_pb2._IMPORTENUM.file.package,
+ 'protobuf_unittest_import')
+
+ def testExtensionRange(self):
+ self.assertEqual(
+ unittest_pb2.TestAllTypes.DESCRIPTOR.extension_ranges, [])
+ self.assertEqual(
+ unittest_pb2.TestAllExtensions.DESCRIPTOR.extension_ranges,
+ [(1, MAX_EXTENSION)])
+ self.assertEqual(
+ unittest_pb2.TestMultipleExtensionRanges.DESCRIPTOR.extension_ranges,
+ [(42, 43), (4143, 4244), (65536, MAX_EXTENSION)])
+
+ def testFileDescriptor(self):
+ self.assertEqual(unittest_pb2.DESCRIPTOR.name,
+ 'google/protobuf/unittest.proto')
+ self.assertEqual(unittest_pb2.DESCRIPTOR.package, 'protobuf_unittest')
+ self.assertFalse(unittest_pb2.DESCRIPTOR.serialized_pb is None)
+
+ def testNoGenericServices(self):
+ self.assertTrue(hasattr(unittest_no_generic_services_pb2, "TestMessage"))
+ self.assertTrue(hasattr(unittest_no_generic_services_pb2, "FOO"))
+ self.assertTrue(hasattr(unittest_no_generic_services_pb2, "test_extension"))
+
+ # Make sure unittest_no_generic_services_pb2 has no services subclassing
+ # Proto2 Service class.
+ if hasattr(unittest_no_generic_services_pb2, "TestService"):
+ self.assertFalse(issubclass(unittest_no_generic_services_pb2.TestService,
+ service.Service))
+
+ def testMessageTypesByName(self):
+ file_type = unittest_pb2.DESCRIPTOR
+ self.assertEqual(
+ unittest_pb2._TESTALLTYPES,
+ file_type.message_types_by_name[unittest_pb2._TESTALLTYPES.name])
+
+ # Nested messages shouldn't be included in the message_types_by_name
+ # dictionary (like in the C++ API).
+ self.assertFalse(
+ unittest_pb2._TESTALLTYPES_NESTEDMESSAGE.name in
+ file_type.message_types_by_name)
+
+ def testPublicImports(self):
+ # Test public imports as embedded message.
+ all_type_proto = unittest_pb2.TestAllTypes()
+ self.assertEqual(0, all_type_proto.optional_public_import_message.e)
+
+ # PublicImportMessage is actually defined in unittest_import_public_pb2
+ # module, and is public imported by unittest_import_pb2 module.
+ public_import_proto = unittest_import_pb2.PublicImportMessage()
+ self.assertEqual(0, public_import_proto.e)
+ self.assertTrue(unittest_import_public_pb2.PublicImportMessage is
+ unittest_import_pb2.PublicImportMessage)
+
+ def testBadIdentifiers(self):
+ # We're just testing that the code was imported without problems.
+ message = test_bad_identifiers_pb2.TestBadIdentifiers()
+ self.assertEqual(message.Extensions[test_bad_identifiers_pb2.message],
+ "foo")
+ self.assertEqual(message.Extensions[test_bad_identifiers_pb2.descriptor],
+ "bar")
+ self.assertEqual(message.Extensions[test_bad_identifiers_pb2.reflection],
+ "baz")
+ self.assertEqual(message.Extensions[test_bad_identifiers_pb2.service],
+ "qux")
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/golden_message b/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/golden_message
new file mode 100644
index 00000000..4dd62cd3
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/golden_message
Binary files differ
diff --git a/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/golden_packed_fields_message b/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/golden_packed_fields_message
new file mode 100644
index 00000000..ee28d388
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/golden_packed_fields_message
Binary files differ
diff --git a/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/message_test.py b/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/message_test.py
new file mode 100755
index 00000000..53e9d507
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/message_test.py
@@ -0,0 +1,494 @@
+#! /usr/bin/python
+#
+# Protocol Buffers - Google's data interchange format
+# Copyright 2008 Google Inc. All rights reserved.
+# http://code.google.com/p/protobuf/
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+"""Tests python protocol buffers against the golden message.
+
+Note that the golden messages exercise every known field type, thus this
+test ends up exercising and verifying nearly all of the parsing and
+serialization code in the whole library.
+
+TODO(kenton): Merge with wire_format_test? It doesn't make a whole lot of
+sense to call this a test of the "message" module, which only declares an
+abstract interface.
+"""
+
+__author__ = 'gps@google.com (Gregory P. Smith)'
+
+import copy
+import math
+import operator
+import pickle
+
+import unittest
+from google.protobuf import unittest_import_pb2
+from google.protobuf import unittest_pb2
+from google.protobuf.internal import api_implementation
+from google.protobuf.internal import test_util
+from google.protobuf import message
+
+# Python pre-2.6 does not have isinf() or isnan() functions, so we have
+# to provide our own.
+def isnan(val):
+ # NaN is never equal to itself.
+ return val != val
+def isinf(val):
+ # Infinity times zero equals NaN.
+ return not isnan(val) and isnan(val * 0)
+def IsPosInf(val):
+ return isinf(val) and (val > 0)
+def IsNegInf(val):
+ return isinf(val) and (val < 0)
+
+class MessageTest(unittest.TestCase):
+
+ def testGoldenMessage(self):
+ golden_data = test_util.GoldenFile('golden_message').read()
+ golden_message = unittest_pb2.TestAllTypes()
+ golden_message.ParseFromString(golden_data)
+ test_util.ExpectAllFieldsSet(self, golden_message)
+ self.assertEqual(golden_data, golden_message.SerializeToString())
+ golden_copy = copy.deepcopy(golden_message)
+ self.assertEqual(golden_data, golden_copy.SerializeToString())
+
+ def testGoldenExtensions(self):
+ golden_data = test_util.GoldenFile('golden_message').read()
+ golden_message = unittest_pb2.TestAllExtensions()
+ golden_message.ParseFromString(golden_data)
+ all_set = unittest_pb2.TestAllExtensions()
+ test_util.SetAllExtensions(all_set)
+ self.assertEquals(all_set, golden_message)
+ self.assertEqual(golden_data, golden_message.SerializeToString())
+ golden_copy = copy.deepcopy(golden_message)
+ self.assertEqual(golden_data, golden_copy.SerializeToString())
+
+ def testGoldenPackedMessage(self):
+ golden_data = test_util.GoldenFile('golden_packed_fields_message').read()
+ golden_message = unittest_pb2.TestPackedTypes()
+ golden_message.ParseFromString(golden_data)
+ all_set = unittest_pb2.TestPackedTypes()
+ test_util.SetAllPackedFields(all_set)
+ self.assertEquals(all_set, golden_message)
+ self.assertEqual(golden_data, all_set.SerializeToString())
+ golden_copy = copy.deepcopy(golden_message)
+ self.assertEqual(golden_data, golden_copy.SerializeToString())
+
+ def testGoldenPackedExtensions(self):
+ golden_data = test_util.GoldenFile('golden_packed_fields_message').read()
+ golden_message = unittest_pb2.TestPackedExtensions()
+ golden_message.ParseFromString(golden_data)
+ all_set = unittest_pb2.TestPackedExtensions()
+ test_util.SetAllPackedExtensions(all_set)
+ self.assertEquals(all_set, golden_message)
+ self.assertEqual(golden_data, all_set.SerializeToString())
+ golden_copy = copy.deepcopy(golden_message)
+ self.assertEqual(golden_data, golden_copy.SerializeToString())
+
+ def testPickleSupport(self):
+ golden_data = test_util.GoldenFile('golden_message').read()
+ golden_message = unittest_pb2.TestAllTypes()
+ golden_message.ParseFromString(golden_data)
+ pickled_message = pickle.dumps(golden_message)
+
+ unpickled_message = pickle.loads(pickled_message)
+ self.assertEquals(unpickled_message, golden_message)
+
+ def testPickleIncompleteProto(self):
+ golden_message = unittest_pb2.TestRequired(a=1)
+ pickled_message = pickle.dumps(golden_message)
+
+ unpickled_message = pickle.loads(pickled_message)
+ self.assertEquals(unpickled_message, golden_message)
+ self.assertEquals(unpickled_message.a, 1)
+ # This is still an incomplete proto - so serializing should fail
+ self.assertRaises(message.EncodeError, unpickled_message.SerializeToString)
+
+ def testPositiveInfinity(self):
+ golden_data = ('\x5D\x00\x00\x80\x7F'
+ '\x61\x00\x00\x00\x00\x00\x00\xF0\x7F'
+ '\xCD\x02\x00\x00\x80\x7F'
+ '\xD1\x02\x00\x00\x00\x00\x00\x00\xF0\x7F')
+ golden_message = unittest_pb2.TestAllTypes()
+ golden_message.ParseFromString(golden_data)
+ self.assertTrue(IsPosInf(golden_message.optional_float))
+ self.assertTrue(IsPosInf(golden_message.optional_double))
+ self.assertTrue(IsPosInf(golden_message.repeated_float[0]))
+ self.assertTrue(IsPosInf(golden_message.repeated_double[0]))
+ self.assertEqual(golden_data, golden_message.SerializeToString())
+
+ def testNegativeInfinity(self):
+ golden_data = ('\x5D\x00\x00\x80\xFF'
+ '\x61\x00\x00\x00\x00\x00\x00\xF0\xFF'
+ '\xCD\x02\x00\x00\x80\xFF'
+ '\xD1\x02\x00\x00\x00\x00\x00\x00\xF0\xFF')
+ golden_message = unittest_pb2.TestAllTypes()
+ golden_message.ParseFromString(golden_data)
+ self.assertTrue(IsNegInf(golden_message.optional_float))
+ self.assertTrue(IsNegInf(golden_message.optional_double))
+ self.assertTrue(IsNegInf(golden_message.repeated_float[0]))
+ self.assertTrue(IsNegInf(golden_message.repeated_double[0]))
+ self.assertEqual(golden_data, golden_message.SerializeToString())
+
+ def testNotANumber(self):
+ golden_data = ('\x5D\x00\x00\xC0\x7F'
+ '\x61\x00\x00\x00\x00\x00\x00\xF8\x7F'
+ '\xCD\x02\x00\x00\xC0\x7F'
+ '\xD1\x02\x00\x00\x00\x00\x00\x00\xF8\x7F')
+ golden_message = unittest_pb2.TestAllTypes()
+ golden_message.ParseFromString(golden_data)
+ self.assertTrue(isnan(golden_message.optional_float))
+ self.assertTrue(isnan(golden_message.optional_double))
+ self.assertTrue(isnan(golden_message.repeated_float[0]))
+ self.assertTrue(isnan(golden_message.repeated_double[0]))
+
+ # The protocol buffer may serialize to any one of multiple different
+ # representations of a NaN. Rather than verify a specific representation,
+ # verify the serialized string can be converted into a correctly
+ # behaving protocol buffer.
+ serialized = golden_message.SerializeToString()
+ message = unittest_pb2.TestAllTypes()
+ message.ParseFromString(serialized)
+ self.assertTrue(isnan(message.optional_float))
+ self.assertTrue(isnan(message.optional_double))
+ self.assertTrue(isnan(message.repeated_float[0]))
+ self.assertTrue(isnan(message.repeated_double[0]))
+
+ def testPositiveInfinityPacked(self):
+ golden_data = ('\xA2\x06\x04\x00\x00\x80\x7F'
+ '\xAA\x06\x08\x00\x00\x00\x00\x00\x00\xF0\x7F')
+ golden_message = unittest_pb2.TestPackedTypes()
+ golden_message.ParseFromString(golden_data)
+ self.assertTrue(IsPosInf(golden_message.packed_float[0]))
+ self.assertTrue(IsPosInf(golden_message.packed_double[0]))
+ self.assertEqual(golden_data, golden_message.SerializeToString())
+
+ def testNegativeInfinityPacked(self):
+ golden_data = ('\xA2\x06\x04\x00\x00\x80\xFF'
+ '\xAA\x06\x08\x00\x00\x00\x00\x00\x00\xF0\xFF')
+ golden_message = unittest_pb2.TestPackedTypes()
+ golden_message.ParseFromString(golden_data)
+ self.assertTrue(IsNegInf(golden_message.packed_float[0]))
+ self.assertTrue(IsNegInf(golden_message.packed_double[0]))
+ self.assertEqual(golden_data, golden_message.SerializeToString())
+
+ def testNotANumberPacked(self):
+ golden_data = ('\xA2\x06\x04\x00\x00\xC0\x7F'
+ '\xAA\x06\x08\x00\x00\x00\x00\x00\x00\xF8\x7F')
+ golden_message = unittest_pb2.TestPackedTypes()
+ golden_message.ParseFromString(golden_data)
+ self.assertTrue(isnan(golden_message.packed_float[0]))
+ self.assertTrue(isnan(golden_message.packed_double[0]))
+
+ serialized = golden_message.SerializeToString()
+ message = unittest_pb2.TestPackedTypes()
+ message.ParseFromString(serialized)
+ self.assertTrue(isnan(message.packed_float[0]))
+ self.assertTrue(isnan(message.packed_double[0]))
+
+ def testExtremeFloatValues(self):
+ message = unittest_pb2.TestAllTypes()
+
+ # Most positive exponent, no significand bits set.
+ kMostPosExponentNoSigBits = math.pow(2, 127)
+ message.optional_float = kMostPosExponentNoSigBits
+ message.ParseFromString(message.SerializeToString())
+ self.assertTrue(message.optional_float == kMostPosExponentNoSigBits)
+
+ # Most positive exponent, one significand bit set.
+ kMostPosExponentOneSigBit = 1.5 * math.pow(2, 127)
+ message.optional_float = kMostPosExponentOneSigBit
+ message.ParseFromString(message.SerializeToString())
+ self.assertTrue(message.optional_float == kMostPosExponentOneSigBit)
+
+ # Repeat last two cases with values of same magnitude, but negative.
+ message.optional_float = -kMostPosExponentNoSigBits
+ message.ParseFromString(message.SerializeToString())
+ self.assertTrue(message.optional_float == -kMostPosExponentNoSigBits)
+
+ message.optional_float = -kMostPosExponentOneSigBit
+ message.ParseFromString(message.SerializeToString())
+ self.assertTrue(message.optional_float == -kMostPosExponentOneSigBit)
+
+ # Most negative exponent, no significand bits set.
+ kMostNegExponentNoSigBits = math.pow(2, -127)
+ message.optional_float = kMostNegExponentNoSigBits
+ message.ParseFromString(message.SerializeToString())
+ self.assertTrue(message.optional_float == kMostNegExponentNoSigBits)
+
+ # Most negative exponent, one significand bit set.
+ kMostNegExponentOneSigBit = 1.5 * math.pow(2, -127)
+ message.optional_float = kMostNegExponentOneSigBit
+ message.ParseFromString(message.SerializeToString())
+ self.assertTrue(message.optional_float == kMostNegExponentOneSigBit)
+
+ # Repeat last two cases with values of the same magnitude, but negative.
+ message.optional_float = -kMostNegExponentNoSigBits
+ message.ParseFromString(message.SerializeToString())
+ self.assertTrue(message.optional_float == -kMostNegExponentNoSigBits)
+
+ message.optional_float = -kMostNegExponentOneSigBit
+ message.ParseFromString(message.SerializeToString())
+ self.assertTrue(message.optional_float == -kMostNegExponentOneSigBit)
+
+ def testExtremeDoubleValues(self):
+ message = unittest_pb2.TestAllTypes()
+
+ # Most positive exponent, no significand bits set.
+ kMostPosExponentNoSigBits = math.pow(2, 1023)
+ message.optional_double = kMostPosExponentNoSigBits
+ message.ParseFromString(message.SerializeToString())
+ self.assertTrue(message.optional_double == kMostPosExponentNoSigBits)
+
+ # Most positive exponent, one significand bit set.
+ kMostPosExponentOneSigBit = 1.5 * math.pow(2, 1023)
+ message.optional_double = kMostPosExponentOneSigBit
+ message.ParseFromString(message.SerializeToString())
+ self.assertTrue(message.optional_double == kMostPosExponentOneSigBit)
+
+ # Repeat last two cases with values of same magnitude, but negative.
+ message.optional_double = -kMostPosExponentNoSigBits
+ message.ParseFromString(message.SerializeToString())
+ self.assertTrue(message.optional_double == -kMostPosExponentNoSigBits)
+
+ message.optional_double = -kMostPosExponentOneSigBit
+ message.ParseFromString(message.SerializeToString())
+ self.assertTrue(message.optional_double == -kMostPosExponentOneSigBit)
+
+ # Most negative exponent, no significand bits set.
+ kMostNegExponentNoSigBits = math.pow(2, -1023)
+ message.optional_double = kMostNegExponentNoSigBits
+ message.ParseFromString(message.SerializeToString())
+ self.assertTrue(message.optional_double == kMostNegExponentNoSigBits)
+
+ # Most negative exponent, one significand bit set.
+ kMostNegExponentOneSigBit = 1.5 * math.pow(2, -1023)
+ message.optional_double = kMostNegExponentOneSigBit
+ message.ParseFromString(message.SerializeToString())
+ self.assertTrue(message.optional_double == kMostNegExponentOneSigBit)
+
+ # Repeat last two cases with values of the same magnitude, but negative.
+ message.optional_double = -kMostNegExponentNoSigBits
+ message.ParseFromString(message.SerializeToString())
+ self.assertTrue(message.optional_double == -kMostNegExponentNoSigBits)
+
+ message.optional_double = -kMostNegExponentOneSigBit
+ message.ParseFromString(message.SerializeToString())
+ self.assertTrue(message.optional_double == -kMostNegExponentOneSigBit)
+
+ def testSortingRepeatedScalarFieldsDefaultComparator(self):
+ """Check some different types with the default comparator."""
+ message = unittest_pb2.TestAllTypes()
+
+ # TODO(mattp): would testing more scalar types strengthen test?
+ message.repeated_int32.append(1)
+ message.repeated_int32.append(3)
+ message.repeated_int32.append(2)
+ message.repeated_int32.sort()
+ self.assertEqual(message.repeated_int32[0], 1)
+ self.assertEqual(message.repeated_int32[1], 2)
+ self.assertEqual(message.repeated_int32[2], 3)
+
+ message.repeated_float.append(1.1)
+ message.repeated_float.append(1.3)
+ message.repeated_float.append(1.2)
+ message.repeated_float.sort()
+ self.assertAlmostEqual(message.repeated_float[0], 1.1)
+ self.assertAlmostEqual(message.repeated_float[1], 1.2)
+ self.assertAlmostEqual(message.repeated_float[2], 1.3)
+
+ message.repeated_string.append('a')
+ message.repeated_string.append('c')
+ message.repeated_string.append('b')
+ message.repeated_string.sort()
+ self.assertEqual(message.repeated_string[0], 'a')
+ self.assertEqual(message.repeated_string[1], 'b')
+ self.assertEqual(message.repeated_string[2], 'c')
+
+ message.repeated_bytes.append('a')
+ message.repeated_bytes.append('c')
+ message.repeated_bytes.append('b')
+ message.repeated_bytes.sort()
+ self.assertEqual(message.repeated_bytes[0], 'a')
+ self.assertEqual(message.repeated_bytes[1], 'b')
+ self.assertEqual(message.repeated_bytes[2], 'c')
+
+ def testSortingRepeatedScalarFieldsCustomComparator(self):
+ """Check some different types with custom comparator."""
+ message = unittest_pb2.TestAllTypes()
+
+ message.repeated_int32.append(-3)
+ message.repeated_int32.append(-2)
+ message.repeated_int32.append(-1)
+ message.repeated_int32.sort(lambda x,y: cmp(abs(x), abs(y)))
+ self.assertEqual(message.repeated_int32[0], -1)
+ self.assertEqual(message.repeated_int32[1], -2)
+ self.assertEqual(message.repeated_int32[2], -3)
+
+ message.repeated_string.append('aaa')
+ message.repeated_string.append('bb')
+ message.repeated_string.append('c')
+ message.repeated_string.sort(lambda x,y: cmp(len(x), len(y)))
+ self.assertEqual(message.repeated_string[0], 'c')
+ self.assertEqual(message.repeated_string[1], 'bb')
+ self.assertEqual(message.repeated_string[2], 'aaa')
+
+ def testSortingRepeatedCompositeFieldsCustomComparator(self):
+ """Check passing a custom comparator to sort a repeated composite field."""
+ message = unittest_pb2.TestAllTypes()
+
+ message.repeated_nested_message.add().bb = 1
+ message.repeated_nested_message.add().bb = 3
+ message.repeated_nested_message.add().bb = 2
+ message.repeated_nested_message.add().bb = 6
+ message.repeated_nested_message.add().bb = 5
+ message.repeated_nested_message.add().bb = 4
+ message.repeated_nested_message.sort(lambda x,y: cmp(x.bb, y.bb))
+ self.assertEqual(message.repeated_nested_message[0].bb, 1)
+ self.assertEqual(message.repeated_nested_message[1].bb, 2)
+ self.assertEqual(message.repeated_nested_message[2].bb, 3)
+ self.assertEqual(message.repeated_nested_message[3].bb, 4)
+ self.assertEqual(message.repeated_nested_message[4].bb, 5)
+ self.assertEqual(message.repeated_nested_message[5].bb, 6)
+
+ def testRepeatedCompositeFieldSortArguments(self):
+ """Check sorting a repeated composite field using list.sort() arguments."""
+ message = unittest_pb2.TestAllTypes()
+
+ get_bb = operator.attrgetter('bb')
+ cmp_bb = lambda a, b: cmp(a.bb, b.bb)
+ message.repeated_nested_message.add().bb = 1
+ message.repeated_nested_message.add().bb = 3
+ message.repeated_nested_message.add().bb = 2
+ message.repeated_nested_message.add().bb = 6
+ message.repeated_nested_message.add().bb = 5
+ message.repeated_nested_message.add().bb = 4
+ message.repeated_nested_message.sort(key=get_bb)
+ self.assertEqual([k.bb for k in message.repeated_nested_message],
+ [1, 2, 3, 4, 5, 6])
+ message.repeated_nested_message.sort(key=get_bb, reverse=True)
+ self.assertEqual([k.bb for k in message.repeated_nested_message],
+ [6, 5, 4, 3, 2, 1])
+ message.repeated_nested_message.sort(sort_function=cmp_bb)
+ self.assertEqual([k.bb for k in message.repeated_nested_message],
+ [1, 2, 3, 4, 5, 6])
+ message.repeated_nested_message.sort(cmp=cmp_bb, reverse=True)
+ self.assertEqual([k.bb for k in message.repeated_nested_message],
+ [6, 5, 4, 3, 2, 1])
+
+ def testRepeatedScalarFieldSortArguments(self):
+ """Check sorting a scalar field using list.sort() arguments."""
+ message = unittest_pb2.TestAllTypes()
+
+ abs_cmp = lambda a, b: cmp(abs(a), abs(b))
+ message.repeated_int32.append(-3)
+ message.repeated_int32.append(-2)
+ message.repeated_int32.append(-1)
+ message.repeated_int32.sort(key=abs)
+ self.assertEqual(list(message.repeated_int32), [-1, -2, -3])
+ message.repeated_int32.sort(key=abs, reverse=True)
+ self.assertEqual(list(message.repeated_int32), [-3, -2, -1])
+ message.repeated_int32.sort(sort_function=abs_cmp)
+ self.assertEqual(list(message.repeated_int32), [-1, -2, -3])
+ message.repeated_int32.sort(cmp=abs_cmp, reverse=True)
+ self.assertEqual(list(message.repeated_int32), [-3, -2, -1])
+
+ len_cmp = lambda a, b: cmp(len(a), len(b))
+ message.repeated_string.append('aaa')
+ message.repeated_string.append('bb')
+ message.repeated_string.append('c')
+ message.repeated_string.sort(key=len)
+ self.assertEqual(list(message.repeated_string), ['c', 'bb', 'aaa'])
+ message.repeated_string.sort(key=len, reverse=True)
+ self.assertEqual(list(message.repeated_string), ['aaa', 'bb', 'c'])
+ message.repeated_string.sort(sort_function=len_cmp)
+ self.assertEqual(list(message.repeated_string), ['c', 'bb', 'aaa'])
+ message.repeated_string.sort(cmp=len_cmp, reverse=True)
+ self.assertEqual(list(message.repeated_string), ['aaa', 'bb', 'c'])
+
+ def testParsingMerge(self):
+ """Check the merge behavior when a required or optional field appears
+ multiple times in the input."""
+ messages = [
+ unittest_pb2.TestAllTypes(),
+ unittest_pb2.TestAllTypes(),
+ unittest_pb2.TestAllTypes() ]
+ messages[0].optional_int32 = 1
+ messages[1].optional_int64 = 2
+ messages[2].optional_int32 = 3
+ messages[2].optional_string = 'hello'
+
+ merged_message = unittest_pb2.TestAllTypes()
+ merged_message.optional_int32 = 3
+ merged_message.optional_int64 = 2
+ merged_message.optional_string = 'hello'
+
+ generator = unittest_pb2.TestParsingMerge.RepeatedFieldsGenerator()
+ generator.field1.extend(messages)
+ generator.field2.extend(messages)
+ generator.field3.extend(messages)
+ generator.ext1.extend(messages)
+ generator.ext2.extend(messages)
+ generator.group1.add().field1.MergeFrom(messages[0])
+ generator.group1.add().field1.MergeFrom(messages[1])
+ generator.group1.add().field1.MergeFrom(messages[2])
+ generator.group2.add().field1.MergeFrom(messages[0])
+ generator.group2.add().field1.MergeFrom(messages[1])
+ generator.group2.add().field1.MergeFrom(messages[2])
+
+ data = generator.SerializeToString()
+ parsing_merge = unittest_pb2.TestParsingMerge()
+ parsing_merge.ParseFromString(data)
+
+ # Required and optional fields should be merged.
+ self.assertEqual(parsing_merge.required_all_types, merged_message)
+ self.assertEqual(parsing_merge.optional_all_types, merged_message)
+ self.assertEqual(parsing_merge.optionalgroup.optional_group_all_types,
+ merged_message)
+ self.assertEqual(parsing_merge.Extensions[
+ unittest_pb2.TestParsingMerge.optional_ext],
+ merged_message)
+
+ # Repeated fields should not be merged.
+ self.assertEqual(len(parsing_merge.repeated_all_types), 3)
+ self.assertEqual(len(parsing_merge.repeatedgroup), 3)
+ self.assertEqual(len(parsing_merge.Extensions[
+ unittest_pb2.TestParsingMerge.repeated_ext]), 3)
+
+
+ def testSortEmptyRepeatedCompositeContainer(self):
+ """Exercise a scenario that has led to segfaults in the past.
+ """
+ m = unittest_pb2.TestAllTypes()
+ m.repeated_nested_message.sort()
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/service_reflection_test.py b/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/service_reflection_test.py
new file mode 100755
index 00000000..e04f8252
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/service_reflection_test.py
@@ -0,0 +1,136 @@
+#! /usr/bin/python
+#
+# Protocol Buffers - Google's data interchange format
+# Copyright 2008 Google Inc. All rights reserved.
+# http://code.google.com/p/protobuf/
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+"""Tests for google.protobuf.internal.service_reflection."""
+
+__author__ = 'petar@google.com (Petar Petrov)'
+
+import unittest
+from google.protobuf import unittest_pb2
+from google.protobuf import service_reflection
+from google.protobuf import service
+
+
+class FooUnitTest(unittest.TestCase):
+
+ def testService(self):
+ class MockRpcChannel(service.RpcChannel):
+ def CallMethod(self, method, controller, request, response, callback):
+ self.method = method
+ self.controller = controller
+ self.request = request
+ callback(response)
+
+ class MockRpcController(service.RpcController):
+ def SetFailed(self, msg):
+ self.failure_message = msg
+
+ self.callback_response = None
+
+ class MyService(unittest_pb2.TestService):
+ pass
+
+ self.callback_response = None
+
+ def MyCallback(response):
+ self.callback_response = response
+
+ rpc_controller = MockRpcController()
+ channel = MockRpcChannel()
+ srvc = MyService()
+ srvc.Foo(rpc_controller, unittest_pb2.FooRequest(), MyCallback)
+ self.assertEqual('Method Foo not implemented.',
+ rpc_controller.failure_message)
+ self.assertEqual(None, self.callback_response)
+
+ rpc_controller.failure_message = None
+
+ service_descriptor = unittest_pb2.TestService.GetDescriptor()
+ srvc.CallMethod(service_descriptor.methods[1], rpc_controller,
+ unittest_pb2.BarRequest(), MyCallback)
+ self.assertEqual('Method Bar not implemented.',
+ rpc_controller.failure_message)
+ self.assertEqual(None, self.callback_response)
+
+ class MyServiceImpl(unittest_pb2.TestService):
+ def Foo(self, rpc_controller, request, done):
+ self.foo_called = True
+ def Bar(self, rpc_controller, request, done):
+ self.bar_called = True
+
+ srvc = MyServiceImpl()
+ rpc_controller.failure_message = None
+ srvc.Foo(rpc_controller, unittest_pb2.FooRequest(), MyCallback)
+ self.assertEqual(None, rpc_controller.failure_message)
+ self.assertEqual(True, srvc.foo_called)
+
+ rpc_controller.failure_message = None
+ srvc.CallMethod(service_descriptor.methods[1], rpc_controller,
+ unittest_pb2.BarRequest(), MyCallback)
+ self.assertEqual(None, rpc_controller.failure_message)
+ self.assertEqual(True, srvc.bar_called)
+
+ def testServiceStub(self):
+ class MockRpcChannel(service.RpcChannel):
+ def CallMethod(self, method, controller, request,
+ response_class, callback):
+ self.method = method
+ self.controller = controller
+ self.request = request
+ callback(response_class())
+
+ self.callback_response = None
+
+ def MyCallback(response):
+ self.callback_response = response
+
+ channel = MockRpcChannel()
+ stub = unittest_pb2.TestService_Stub(channel)
+ rpc_controller = 'controller'
+ request = 'request'
+
+ # GetDescriptor now static, still works as instance method for compatability
+ self.assertEqual(unittest_pb2.TestService_Stub.GetDescriptor(),
+ stub.GetDescriptor())
+
+ # Invoke method.
+ stub.Foo(rpc_controller, request, MyCallback)
+
+ self.assertTrue(isinstance(self.callback_response,
+ unittest_pb2.FooResponse))
+ self.assertEqual(request, channel.request)
+ self.assertEqual(rpc_controller, channel.controller)
+ self.assertEqual(stub.GetDescriptor().methods[0], channel.method)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/test_util.py b/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/test_util.py
new file mode 100755
index 00000000..e2c9db03
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/test_util.py
@@ -0,0 +1,651 @@
+# Protocol Buffers - Google's data interchange format
+# Copyright 2008 Google Inc. All rights reserved.
+# http://code.google.com/p/protobuf/
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+"""Utilities for Python proto2 tests.
+
+This is intentionally modeled on C++ code in
+//google/protobuf/test_util.*.
+"""
+
+__author__ = 'robinson@google.com (Will Robinson)'
+
+import os.path
+
+from google.protobuf import unittest_import_pb2
+from google.protobuf import unittest_pb2
+
+
+def SetAllNonLazyFields(message):
+ """Sets every non-lazy field in the message to a unique value.
+
+ Args:
+ message: A unittest_pb2.TestAllTypes instance.
+ """
+
+ #
+ # Optional fields.
+ #
+
+ message.optional_int32 = 101
+ message.optional_int64 = 102
+ message.optional_uint32 = 103
+ message.optional_uint64 = 104
+ message.optional_sint32 = 105
+ message.optional_sint64 = 106
+ message.optional_fixed32 = 107
+ message.optional_fixed64 = 108
+ message.optional_sfixed32 = 109
+ message.optional_sfixed64 = 110
+ message.optional_float = 111
+ message.optional_double = 112
+ message.optional_bool = True
+ # TODO(robinson): Firmly spec out and test how
+ # protos interact with unicode. One specific example:
+ # what happens if we change the literal below to
+ # u'115'? What *should* happen? Still some discussion
+ # to finish with Kenton about bytes vs. strings
+ # and forcing everything to be utf8. :-/
+ message.optional_string = '115'
+ message.optional_bytes = '116'
+
+ message.optionalgroup.a = 117
+ message.optional_nested_message.bb = 118
+ message.optional_foreign_message.c = 119
+ message.optional_import_message.d = 120
+ message.optional_public_import_message.e = 126
+
+ message.optional_nested_enum = unittest_pb2.TestAllTypes.BAZ
+ message.optional_foreign_enum = unittest_pb2.FOREIGN_BAZ
+ message.optional_import_enum = unittest_import_pb2.IMPORT_BAZ
+
+ message.optional_string_piece = '124'
+ message.optional_cord = '125'
+
+ #
+ # Repeated fields.
+ #
+
+ message.repeated_int32.append(201)
+ message.repeated_int64.append(202)
+ message.repeated_uint32.append(203)
+ message.repeated_uint64.append(204)
+ message.repeated_sint32.append(205)
+ message.repeated_sint64.append(206)
+ message.repeated_fixed32.append(207)
+ message.repeated_fixed64.append(208)
+ message.repeated_sfixed32.append(209)
+ message.repeated_sfixed64.append(210)
+ message.repeated_float.append(211)
+ message.repeated_double.append(212)
+ message.repeated_bool.append(True)
+ message.repeated_string.append('215')
+ message.repeated_bytes.append('216')
+
+ message.repeatedgroup.add().a = 217
+ message.repeated_nested_message.add().bb = 218
+ message.repeated_foreign_message.add().c = 219
+ message.repeated_import_message.add().d = 220
+ message.repeated_lazy_message.add().bb = 227
+
+ message.repeated_nested_enum.append(unittest_pb2.TestAllTypes.BAR)
+ message.repeated_foreign_enum.append(unittest_pb2.FOREIGN_BAR)
+ message.repeated_import_enum.append(unittest_import_pb2.IMPORT_BAR)
+
+ message.repeated_string_piece.append('224')
+ message.repeated_cord.append('225')
+
+ # Add a second one of each field.
+ message.repeated_int32.append(301)
+ message.repeated_int64.append(302)
+ message.repeated_uint32.append(303)
+ message.repeated_uint64.append(304)
+ message.repeated_sint32.append(305)
+ message.repeated_sint64.append(306)
+ message.repeated_fixed32.append(307)
+ message.repeated_fixed64.append(308)
+ message.repeated_sfixed32.append(309)
+ message.repeated_sfixed64.append(310)
+ message.repeated_float.append(311)
+ message.repeated_double.append(312)
+ message.repeated_bool.append(False)
+ message.repeated_string.append('315')
+ message.repeated_bytes.append('316')
+
+ message.repeatedgroup.add().a = 317
+ message.repeated_nested_message.add().bb = 318
+ message.repeated_foreign_message.add().c = 319
+ message.repeated_import_message.add().d = 320
+ message.repeated_lazy_message.add().bb = 327
+
+ message.repeated_nested_enum.append(unittest_pb2.TestAllTypes.BAZ)
+ message.repeated_foreign_enum.append(unittest_pb2.FOREIGN_BAZ)
+ message.repeated_import_enum.append(unittest_import_pb2.IMPORT_BAZ)
+
+ message.repeated_string_piece.append('324')
+ message.repeated_cord.append('325')
+
+ #
+ # Fields that have defaults.
+ #
+
+ message.default_int32 = 401
+ message.default_int64 = 402
+ message.default_uint32 = 403
+ message.default_uint64 = 404
+ message.default_sint32 = 405
+ message.default_sint64 = 406
+ message.default_fixed32 = 407
+ message.default_fixed64 = 408
+ message.default_sfixed32 = 409
+ message.default_sfixed64 = 410
+ message.default_float = 411
+ message.default_double = 412
+ message.default_bool = False
+ message.default_string = '415'
+ message.default_bytes = '416'
+
+ message.default_nested_enum = unittest_pb2.TestAllTypes.FOO
+ message.default_foreign_enum = unittest_pb2.FOREIGN_FOO
+ message.default_import_enum = unittest_import_pb2.IMPORT_FOO
+
+ message.default_string_piece = '424'
+ message.default_cord = '425'
+
+
+def SetAllFields(message):
+ SetAllNonLazyFields(message)
+ message.optional_lazy_message.bb = 127
+
+
+def SetAllExtensions(message):
+ """Sets every extension in the message to a unique value.
+
+ Args:
+ message: A unittest_pb2.TestAllExtensions instance.
+ """
+
+ extensions = message.Extensions
+ pb2 = unittest_pb2
+ import_pb2 = unittest_import_pb2
+
+ #
+ # Optional fields.
+ #
+
+ extensions[pb2.optional_int32_extension] = 101
+ extensions[pb2.optional_int64_extension] = 102
+ extensions[pb2.optional_uint32_extension] = 103
+ extensions[pb2.optional_uint64_extension] = 104
+ extensions[pb2.optional_sint32_extension] = 105
+ extensions[pb2.optional_sint64_extension] = 106
+ extensions[pb2.optional_fixed32_extension] = 107
+ extensions[pb2.optional_fixed64_extension] = 108
+ extensions[pb2.optional_sfixed32_extension] = 109
+ extensions[pb2.optional_sfixed64_extension] = 110
+ extensions[pb2.optional_float_extension] = 111
+ extensions[pb2.optional_double_extension] = 112
+ extensions[pb2.optional_bool_extension] = True
+ extensions[pb2.optional_string_extension] = '115'
+ extensions[pb2.optional_bytes_extension] = '116'
+
+ extensions[pb2.optionalgroup_extension].a = 117
+ extensions[pb2.optional_nested_message_extension].bb = 118
+ extensions[pb2.optional_foreign_message_extension].c = 119
+ extensions[pb2.optional_import_message_extension].d = 120
+ extensions[pb2.optional_public_import_message_extension].e = 126
+ extensions[pb2.optional_lazy_message_extension].bb = 127
+
+ extensions[pb2.optional_nested_enum_extension] = pb2.TestAllTypes.BAZ
+ extensions[pb2.optional_nested_enum_extension] = pb2.TestAllTypes.BAZ
+ extensions[pb2.optional_foreign_enum_extension] = pb2.FOREIGN_BAZ
+ extensions[pb2.optional_import_enum_extension] = import_pb2.IMPORT_BAZ
+
+ extensions[pb2.optional_string_piece_extension] = '124'
+ extensions[pb2.optional_cord_extension] = '125'
+
+ #
+ # Repeated fields.
+ #
+
+ extensions[pb2.repeated_int32_extension].append(201)
+ extensions[pb2.repeated_int64_extension].append(202)
+ extensions[pb2.repeated_uint32_extension].append(203)
+ extensions[pb2.repeated_uint64_extension].append(204)
+ extensions[pb2.repeated_sint32_extension].append(205)
+ extensions[pb2.repeated_sint64_extension].append(206)
+ extensions[pb2.repeated_fixed32_extension].append(207)
+ extensions[pb2.repeated_fixed64_extension].append(208)
+ extensions[pb2.repeated_sfixed32_extension].append(209)
+ extensions[pb2.repeated_sfixed64_extension].append(210)
+ extensions[pb2.repeated_float_extension].append(211)
+ extensions[pb2.repeated_double_extension].append(212)
+ extensions[pb2.repeated_bool_extension].append(True)
+ extensions[pb2.repeated_string_extension].append('215')
+ extensions[pb2.repeated_bytes_extension].append('216')
+
+ extensions[pb2.repeatedgroup_extension].add().a = 217
+ extensions[pb2.repeated_nested_message_extension].add().bb = 218
+ extensions[pb2.repeated_foreign_message_extension].add().c = 219
+ extensions[pb2.repeated_import_message_extension].add().d = 220
+ extensions[pb2.repeated_lazy_message_extension].add().bb = 227
+
+ extensions[pb2.repeated_nested_enum_extension].append(pb2.TestAllTypes.BAR)
+ extensions[pb2.repeated_foreign_enum_extension].append(pb2.FOREIGN_BAR)
+ extensions[pb2.repeated_import_enum_extension].append(import_pb2.IMPORT_BAR)
+
+ extensions[pb2.repeated_string_piece_extension].append('224')
+ extensions[pb2.repeated_cord_extension].append('225')
+
+ # Append a second one of each field.
+ extensions[pb2.repeated_int32_extension].append(301)
+ extensions[pb2.repeated_int64_extension].append(302)
+ extensions[pb2.repeated_uint32_extension].append(303)
+ extensions[pb2.repeated_uint64_extension].append(304)
+ extensions[pb2.repeated_sint32_extension].append(305)
+ extensions[pb2.repeated_sint64_extension].append(306)
+ extensions[pb2.repeated_fixed32_extension].append(307)
+ extensions[pb2.repeated_fixed64_extension].append(308)
+ extensions[pb2.repeated_sfixed32_extension].append(309)
+ extensions[pb2.repeated_sfixed64_extension].append(310)
+ extensions[pb2.repeated_float_extension].append(311)
+ extensions[pb2.repeated_double_extension].append(312)
+ extensions[pb2.repeated_bool_extension].append(False)
+ extensions[pb2.repeated_string_extension].append('315')
+ extensions[pb2.repeated_bytes_extension].append('316')
+
+ extensions[pb2.repeatedgroup_extension].add().a = 317
+ extensions[pb2.repeated_nested_message_extension].add().bb = 318
+ extensions[pb2.repeated_foreign_message_extension].add().c = 319
+ extensions[pb2.repeated_import_message_extension].add().d = 320
+ extensions[pb2.repeated_lazy_message_extension].add().bb = 327
+
+ extensions[pb2.repeated_nested_enum_extension].append(pb2.TestAllTypes.BAZ)
+ extensions[pb2.repeated_foreign_enum_extension].append(pb2.FOREIGN_BAZ)
+ extensions[pb2.repeated_import_enum_extension].append(import_pb2.IMPORT_BAZ)
+
+ extensions[pb2.repeated_string_piece_extension].append('324')
+ extensions[pb2.repeated_cord_extension].append('325')
+
+ #
+ # Fields with defaults.
+ #
+
+ extensions[pb2.default_int32_extension] = 401
+ extensions[pb2.default_int64_extension] = 402
+ extensions[pb2.default_uint32_extension] = 403
+ extensions[pb2.default_uint64_extension] = 404
+ extensions[pb2.default_sint32_extension] = 405
+ extensions[pb2.default_sint64_extension] = 406
+ extensions[pb2.default_fixed32_extension] = 407
+ extensions[pb2.default_fixed64_extension] = 408
+ extensions[pb2.default_sfixed32_extension] = 409
+ extensions[pb2.default_sfixed64_extension] = 410
+ extensions[pb2.default_float_extension] = 411
+ extensions[pb2.default_double_extension] = 412
+ extensions[pb2.default_bool_extension] = False
+ extensions[pb2.default_string_extension] = '415'
+ extensions[pb2.default_bytes_extension] = '416'
+
+ extensions[pb2.default_nested_enum_extension] = pb2.TestAllTypes.FOO
+ extensions[pb2.default_foreign_enum_extension] = pb2.FOREIGN_FOO
+ extensions[pb2.default_import_enum_extension] = import_pb2.IMPORT_FOO
+
+ extensions[pb2.default_string_piece_extension] = '424'
+ extensions[pb2.default_cord_extension] = '425'
+
+
+def SetAllFieldsAndExtensions(message):
+ """Sets every field and extension in the message to a unique value.
+
+ Args:
+ message: A unittest_pb2.TestAllExtensions message.
+ """
+ message.my_int = 1
+ message.my_string = 'foo'
+ message.my_float = 1.0
+ message.Extensions[unittest_pb2.my_extension_int] = 23
+ message.Extensions[unittest_pb2.my_extension_string] = 'bar'
+
+
+def ExpectAllFieldsAndExtensionsInOrder(serialized):
+ """Ensures that serialized is the serialization we expect for a message
+ filled with SetAllFieldsAndExtensions(). (Specifically, ensures that the
+ serialization is in canonical, tag-number order).
+ """
+ my_extension_int = unittest_pb2.my_extension_int
+ my_extension_string = unittest_pb2.my_extension_string
+ expected_strings = []
+ message = unittest_pb2.TestFieldOrderings()
+ message.my_int = 1 # Field 1.
+ expected_strings.append(message.SerializeToString())
+ message.Clear()
+ message.Extensions[my_extension_int] = 23 # Field 5.
+ expected_strings.append(message.SerializeToString())
+ message.Clear()
+ message.my_string = 'foo' # Field 11.
+ expected_strings.append(message.SerializeToString())
+ message.Clear()
+ message.Extensions[my_extension_string] = 'bar' # Field 50.
+ expected_strings.append(message.SerializeToString())
+ message.Clear()
+ message.my_float = 1.0
+ expected_strings.append(message.SerializeToString())
+ message.Clear()
+ expected = ''.join(expected_strings)
+
+ if expected != serialized:
+ raise ValueError('Expected %r, found %r' % (expected, serialized))
+
+
+def ExpectAllFieldsSet(test_case, message):
+ """Check all fields for correct values have after Set*Fields() is called."""
+ test_case.assertTrue(message.HasField('optional_int32'))
+ test_case.assertTrue(message.HasField('optional_int64'))
+ test_case.assertTrue(message.HasField('optional_uint32'))
+ test_case.assertTrue(message.HasField('optional_uint64'))
+ test_case.assertTrue(message.HasField('optional_sint32'))
+ test_case.assertTrue(message.HasField('optional_sint64'))
+ test_case.assertTrue(message.HasField('optional_fixed32'))
+ test_case.assertTrue(message.HasField('optional_fixed64'))
+ test_case.assertTrue(message.HasField('optional_sfixed32'))
+ test_case.assertTrue(message.HasField('optional_sfixed64'))
+ test_case.assertTrue(message.HasField('optional_float'))
+ test_case.assertTrue(message.HasField('optional_double'))
+ test_case.assertTrue(message.HasField('optional_bool'))
+ test_case.assertTrue(message.HasField('optional_string'))
+ test_case.assertTrue(message.HasField('optional_bytes'))
+
+ test_case.assertTrue(message.HasField('optionalgroup'))
+ test_case.assertTrue(message.HasField('optional_nested_message'))
+ test_case.assertTrue(message.HasField('optional_foreign_message'))
+ test_case.assertTrue(message.HasField('optional_import_message'))
+
+ test_case.assertTrue(message.optionalgroup.HasField('a'))
+ test_case.assertTrue(message.optional_nested_message.HasField('bb'))
+ test_case.assertTrue(message.optional_foreign_message.HasField('c'))
+ test_case.assertTrue(message.optional_import_message.HasField('d'))
+
+ test_case.assertTrue(message.HasField('optional_nested_enum'))
+ test_case.assertTrue(message.HasField('optional_foreign_enum'))
+ test_case.assertTrue(message.HasField('optional_import_enum'))
+
+ test_case.assertTrue(message.HasField('optional_string_piece'))
+ test_case.assertTrue(message.HasField('optional_cord'))
+
+ test_case.assertEqual(101, message.optional_int32)
+ test_case.assertEqual(102, message.optional_int64)
+ test_case.assertEqual(103, message.optional_uint32)
+ test_case.assertEqual(104, message.optional_uint64)
+ test_case.assertEqual(105, message.optional_sint32)
+ test_case.assertEqual(106, message.optional_sint64)
+ test_case.assertEqual(107, message.optional_fixed32)
+ test_case.assertEqual(108, message.optional_fixed64)
+ test_case.assertEqual(109, message.optional_sfixed32)
+ test_case.assertEqual(110, message.optional_sfixed64)
+ test_case.assertEqual(111, message.optional_float)
+ test_case.assertEqual(112, message.optional_double)
+ test_case.assertEqual(True, message.optional_bool)
+ test_case.assertEqual('115', message.optional_string)
+ test_case.assertEqual('116', message.optional_bytes)
+
+ test_case.assertEqual(117, message.optionalgroup.a)
+ test_case.assertEqual(118, message.optional_nested_message.bb)
+ test_case.assertEqual(119, message.optional_foreign_message.c)
+ test_case.assertEqual(120, message.optional_import_message.d)
+ test_case.assertEqual(126, message.optional_public_import_message.e)
+ test_case.assertEqual(127, message.optional_lazy_message.bb)
+
+ test_case.assertEqual(unittest_pb2.TestAllTypes.BAZ,
+ message.optional_nested_enum)
+ test_case.assertEqual(unittest_pb2.FOREIGN_BAZ,
+ message.optional_foreign_enum)
+ test_case.assertEqual(unittest_import_pb2.IMPORT_BAZ,
+ message.optional_import_enum)
+
+ # -----------------------------------------------------------------
+
+ test_case.assertEqual(2, len(message.repeated_int32))
+ test_case.assertEqual(2, len(message.repeated_int64))
+ test_case.assertEqual(2, len(message.repeated_uint32))
+ test_case.assertEqual(2, len(message.repeated_uint64))
+ test_case.assertEqual(2, len(message.repeated_sint32))
+ test_case.assertEqual(2, len(message.repeated_sint64))
+ test_case.assertEqual(2, len(message.repeated_fixed32))
+ test_case.assertEqual(2, len(message.repeated_fixed64))
+ test_case.assertEqual(2, len(message.repeated_sfixed32))
+ test_case.assertEqual(2, len(message.repeated_sfixed64))
+ test_case.assertEqual(2, len(message.repeated_float))
+ test_case.assertEqual(2, len(message.repeated_double))
+ test_case.assertEqual(2, len(message.repeated_bool))
+ test_case.assertEqual(2, len(message.repeated_string))
+ test_case.assertEqual(2, len(message.repeated_bytes))
+
+ test_case.assertEqual(2, len(message.repeatedgroup))
+ test_case.assertEqual(2, len(message.repeated_nested_message))
+ test_case.assertEqual(2, len(message.repeated_foreign_message))
+ test_case.assertEqual(2, len(message.repeated_import_message))
+ test_case.assertEqual(2, len(message.repeated_nested_enum))
+ test_case.assertEqual(2, len(message.repeated_foreign_enum))
+ test_case.assertEqual(2, len(message.repeated_import_enum))
+
+ test_case.assertEqual(2, len(message.repeated_string_piece))
+ test_case.assertEqual(2, len(message.repeated_cord))
+
+ test_case.assertEqual(201, message.repeated_int32[0])
+ test_case.assertEqual(202, message.repeated_int64[0])
+ test_case.assertEqual(203, message.repeated_uint32[0])
+ test_case.assertEqual(204, message.repeated_uint64[0])
+ test_case.assertEqual(205, message.repeated_sint32[0])
+ test_case.assertEqual(206, message.repeated_sint64[0])
+ test_case.assertEqual(207, message.repeated_fixed32[0])
+ test_case.assertEqual(208, message.repeated_fixed64[0])
+ test_case.assertEqual(209, message.repeated_sfixed32[0])
+ test_case.assertEqual(210, message.repeated_sfixed64[0])
+ test_case.assertEqual(211, message.repeated_float[0])
+ test_case.assertEqual(212, message.repeated_double[0])
+ test_case.assertEqual(True, message.repeated_bool[0])
+ test_case.assertEqual('215', message.repeated_string[0])
+ test_case.assertEqual('216', message.repeated_bytes[0])
+
+ test_case.assertEqual(217, message.repeatedgroup[0].a)
+ test_case.assertEqual(218, message.repeated_nested_message[0].bb)
+ test_case.assertEqual(219, message.repeated_foreign_message[0].c)
+ test_case.assertEqual(220, message.repeated_import_message[0].d)
+ test_case.assertEqual(227, message.repeated_lazy_message[0].bb)
+
+ test_case.assertEqual(unittest_pb2.TestAllTypes.BAR,
+ message.repeated_nested_enum[0])
+ test_case.assertEqual(unittest_pb2.FOREIGN_BAR,
+ message.repeated_foreign_enum[0])
+ test_case.assertEqual(unittest_import_pb2.IMPORT_BAR,
+ message.repeated_import_enum[0])
+
+ test_case.assertEqual(301, message.repeated_int32[1])
+ test_case.assertEqual(302, message.repeated_int64[1])
+ test_case.assertEqual(303, message.repeated_uint32[1])
+ test_case.assertEqual(304, message.repeated_uint64[1])
+ test_case.assertEqual(305, message.repeated_sint32[1])
+ test_case.assertEqual(306, message.repeated_sint64[1])
+ test_case.assertEqual(307, message.repeated_fixed32[1])
+ test_case.assertEqual(308, message.repeated_fixed64[1])
+ test_case.assertEqual(309, message.repeated_sfixed32[1])
+ test_case.assertEqual(310, message.repeated_sfixed64[1])
+ test_case.assertEqual(311, message.repeated_float[1])
+ test_case.assertEqual(312, message.repeated_double[1])
+ test_case.assertEqual(False, message.repeated_bool[1])
+ test_case.assertEqual('315', message.repeated_string[1])
+ test_case.assertEqual('316', message.repeated_bytes[1])
+
+ test_case.assertEqual(317, message.repeatedgroup[1].a)
+ test_case.assertEqual(318, message.repeated_nested_message[1].bb)
+ test_case.assertEqual(319, message.repeated_foreign_message[1].c)
+ test_case.assertEqual(320, message.repeated_import_message[1].d)
+ test_case.assertEqual(327, message.repeated_lazy_message[1].bb)
+
+ test_case.assertEqual(unittest_pb2.TestAllTypes.BAZ,
+ message.repeated_nested_enum[1])
+ test_case.assertEqual(unittest_pb2.FOREIGN_BAZ,
+ message.repeated_foreign_enum[1])
+ test_case.assertEqual(unittest_import_pb2.IMPORT_BAZ,
+ message.repeated_import_enum[1])
+
+ # -----------------------------------------------------------------
+
+ test_case.assertTrue(message.HasField('default_int32'))
+ test_case.assertTrue(message.HasField('default_int64'))
+ test_case.assertTrue(message.HasField('default_uint32'))
+ test_case.assertTrue(message.HasField('default_uint64'))
+ test_case.assertTrue(message.HasField('default_sint32'))
+ test_case.assertTrue(message.HasField('default_sint64'))
+ test_case.assertTrue(message.HasField('default_fixed32'))
+ test_case.assertTrue(message.HasField('default_fixed64'))
+ test_case.assertTrue(message.HasField('default_sfixed32'))
+ test_case.assertTrue(message.HasField('default_sfixed64'))
+ test_case.assertTrue(message.HasField('default_float'))
+ test_case.assertTrue(message.HasField('default_double'))
+ test_case.assertTrue(message.HasField('default_bool'))
+ test_case.assertTrue(message.HasField('default_string'))
+ test_case.assertTrue(message.HasField('default_bytes'))
+
+ test_case.assertTrue(message.HasField('default_nested_enum'))
+ test_case.assertTrue(message.HasField('default_foreign_enum'))
+ test_case.assertTrue(message.HasField('default_import_enum'))
+
+ test_case.assertEqual(401, message.default_int32)
+ test_case.assertEqual(402, message.default_int64)
+ test_case.assertEqual(403, message.default_uint32)
+ test_case.assertEqual(404, message.default_uint64)
+ test_case.assertEqual(405, message.default_sint32)
+ test_case.assertEqual(406, message.default_sint64)
+ test_case.assertEqual(407, message.default_fixed32)
+ test_case.assertEqual(408, message.default_fixed64)
+ test_case.assertEqual(409, message.default_sfixed32)
+ test_case.assertEqual(410, message.default_sfixed64)
+ test_case.assertEqual(411, message.default_float)
+ test_case.assertEqual(412, message.default_double)
+ test_case.assertEqual(False, message.default_bool)
+ test_case.assertEqual('415', message.default_string)
+ test_case.assertEqual('416', message.default_bytes)
+
+ test_case.assertEqual(unittest_pb2.TestAllTypes.FOO,
+ message.default_nested_enum)
+ test_case.assertEqual(unittest_pb2.FOREIGN_FOO,
+ message.default_foreign_enum)
+ test_case.assertEqual(unittest_import_pb2.IMPORT_FOO,
+ message.default_import_enum)
+
+def GoldenFile(filename):
+ """Finds the given golden file and returns a file object representing it."""
+
+ # Search up the directory tree looking for the C++ protobuf source code.
+ path = '.'
+ while os.path.exists(path):
+ if os.path.exists(os.path.join(path, 'tests/google/protobuf/internal')):
+ # Found it. Load the golden file from the testdata directory.
+ full_path = os.path.join(path, 'tests/google/protobuf/internal', filename)
+ return open(full_path, 'rb')
+ path = os.path.join(path, '..')
+
+ raise RuntimeError(
+ 'Could not find golden files. This test must be run from within the '
+ 'protobuf source package so that it can read test data files from the '
+ 'C++ source tree.')
+
+
+def SetAllPackedFields(message):
+ """Sets every field in the message to a unique value.
+
+ Args:
+ message: A unittest_pb2.TestPackedTypes instance.
+ """
+ message.packed_int32.extend([601, 701])
+ message.packed_int64.extend([602, 702])
+ message.packed_uint32.extend([603, 703])
+ message.packed_uint64.extend([604, 704])
+ message.packed_sint32.extend([605, 705])
+ message.packed_sint64.extend([606, 706])
+ message.packed_fixed32.extend([607, 707])
+ message.packed_fixed64.extend([608, 708])
+ message.packed_sfixed32.extend([609, 709])
+ message.packed_sfixed64.extend([610, 710])
+ message.packed_float.extend([611.0, 711.0])
+ message.packed_double.extend([612.0, 712.0])
+ message.packed_bool.extend([True, False])
+ message.packed_enum.extend([unittest_pb2.FOREIGN_BAR,
+ unittest_pb2.FOREIGN_BAZ])
+
+
+def SetAllPackedExtensions(message):
+ """Sets every extension in the message to a unique value.
+
+ Args:
+ message: A unittest_pb2.TestPackedExtensions instance.
+ """
+ extensions = message.Extensions
+ pb2 = unittest_pb2
+
+ extensions[pb2.packed_int32_extension].extend([601, 701])
+ extensions[pb2.packed_int64_extension].extend([602, 702])
+ extensions[pb2.packed_uint32_extension].extend([603, 703])
+ extensions[pb2.packed_uint64_extension].extend([604, 704])
+ extensions[pb2.packed_sint32_extension].extend([605, 705])
+ extensions[pb2.packed_sint64_extension].extend([606, 706])
+ extensions[pb2.packed_fixed32_extension].extend([607, 707])
+ extensions[pb2.packed_fixed64_extension].extend([608, 708])
+ extensions[pb2.packed_sfixed32_extension].extend([609, 709])
+ extensions[pb2.packed_sfixed64_extension].extend([610, 710])
+ extensions[pb2.packed_float_extension].extend([611.0, 711.0])
+ extensions[pb2.packed_double_extension].extend([612.0, 712.0])
+ extensions[pb2.packed_bool_extension].extend([True, False])
+ extensions[pb2.packed_enum_extension].extend([unittest_pb2.FOREIGN_BAR,
+ unittest_pb2.FOREIGN_BAZ])
+
+
+def SetAllUnpackedFields(message):
+ """Sets every field in the message to a unique value.
+
+ Args:
+ message: A unittest_pb2.TestUnpackedTypes instance.
+ """
+ message.unpacked_int32.extend([601, 701])
+ message.unpacked_int64.extend([602, 702])
+ message.unpacked_uint32.extend([603, 703])
+ message.unpacked_uint64.extend([604, 704])
+ message.unpacked_sint32.extend([605, 705])
+ message.unpacked_sint64.extend([606, 706])
+ message.unpacked_fixed32.extend([607, 707])
+ message.unpacked_fixed64.extend([608, 708])
+ message.unpacked_sfixed32.extend([609, 709])
+ message.unpacked_sfixed64.extend([610, 710])
+ message.unpacked_float.extend([611.0, 711.0])
+ message.unpacked_double.extend([612.0, 712.0])
+ message.unpacked_bool.extend([True, False])
+ message.unpacked_enum.extend([unittest_pb2.FOREIGN_BAR,
+ unittest_pb2.FOREIGN_BAZ])
diff --git a/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/text_format_test.py b/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/text_format_test.py
new file mode 100755
index 00000000..6bf7befb
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/text_format_test.py
@@ -0,0 +1,620 @@
+#! /usr/bin/python
+#
+# Protocol Buffers - Google's data interchange format
+# Copyright 2008 Google Inc. All rights reserved.
+# http://code.google.com/p/protobuf/
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+"""Test for google.protobuf.text_format."""
+
+__author__ = 'kenton@google.com (Kenton Varda)'
+
+import difflib
+import re
+
+import unittest
+from google.protobuf import text_format
+from google.protobuf.internal import test_util
+from google.protobuf import unittest_pb2
+from google.protobuf import unittest_mset_pb2
+
+
+class TextFormatTest(unittest.TestCase):
+ def ReadGolden(self, golden_filename):
+ f = test_util.GoldenFile(golden_filename)
+ golden_lines = f.readlines()
+ f.close()
+ return golden_lines
+
+ def CompareToGoldenFile(self, text, golden_filename):
+ golden_lines = self.ReadGolden(golden_filename)
+ self.CompareToGoldenLines(text, golden_lines)
+
+ def CompareToGoldenText(self, text, golden_text):
+ self.CompareToGoldenLines(text, golden_text.splitlines(1))
+
+ def CompareToGoldenLines(self, text, golden_lines):
+ actual_lines = text.splitlines(1)
+ self.assertEqual(golden_lines, actual_lines,
+ "Text doesn't match golden. Diff:\n" +
+ ''.join(difflib.ndiff(golden_lines, actual_lines)))
+
+ def testPrintAllFields(self):
+ message = unittest_pb2.TestAllTypes()
+ test_util.SetAllFields(message)
+ self.CompareToGoldenFile(
+ self.RemoveRedundantZeros(text_format.MessageToString(message)),
+ 'text_format_unittest_data.txt')
+
+ def testPrintAllExtensions(self):
+ message = unittest_pb2.TestAllExtensions()
+ test_util.SetAllExtensions(message)
+ self.CompareToGoldenFile(
+ self.RemoveRedundantZeros(text_format.MessageToString(message)),
+ 'text_format_unittest_extensions_data.txt')
+
+ def testPrintMessageSet(self):
+ message = unittest_mset_pb2.TestMessageSetContainer()
+ ext1 = unittest_mset_pb2.TestMessageSetExtension1.message_set_extension
+ ext2 = unittest_mset_pb2.TestMessageSetExtension2.message_set_extension
+ message.message_set.Extensions[ext1].i = 23
+ message.message_set.Extensions[ext2].str = 'foo'
+ self.CompareToGoldenText(text_format.MessageToString(message),
+ 'message_set {\n'
+ ' [protobuf_unittest.TestMessageSetExtension1] {\n'
+ ' i: 23\n'
+ ' }\n'
+ ' [protobuf_unittest.TestMessageSetExtension2] {\n'
+ ' str: \"foo\"\n'
+ ' }\n'
+ '}\n')
+
+ """
+ def testPrintBadEnumValue(self):
+ message = unittest_pb2.TestAllTypes()
+ message.optional_nested_enum = 100
+ message.optional_foreign_enum = 101
+ message.optional_import_enum = 102
+ self.CompareToGoldenText(
+ text_format.MessageToString(message),
+ 'optional_nested_enum: 100\n'
+ 'optional_foreign_enum: 101\n'
+ 'optional_import_enum: 102\n')
+
+ def testPrintBadEnumValueExtensions(self):
+ message = unittest_pb2.TestAllExtensions()
+ message.Extensions[unittest_pb2.optional_nested_enum_extension] = 100
+ message.Extensions[unittest_pb2.optional_foreign_enum_extension] = 101
+ message.Extensions[unittest_pb2.optional_import_enum_extension] = 102
+ self.CompareToGoldenText(
+ text_format.MessageToString(message),
+ '[protobuf_unittest.optional_nested_enum_extension]: 100\n'
+ '[protobuf_unittest.optional_foreign_enum_extension]: 101\n'
+ '[protobuf_unittest.optional_import_enum_extension]: 102\n')
+ """
+
+ def testPrintExotic(self):
+ message = unittest_pb2.TestAllTypes()
+ message.repeated_int64.append(-9223372036854775808)
+ message.repeated_uint64.append(18446744073709551615)
+ message.repeated_double.append(123.456)
+ message.repeated_double.append(1.23e22)
+ message.repeated_double.append(1.23e-18)
+ message.repeated_string.append('\000\001\a\b\f\n\r\t\v\\\'"')
+ message.repeated_string.append(u'\u00fc\ua71f')
+ self.CompareToGoldenText(
+ self.RemoveRedundantZeros(text_format.MessageToString(message)),
+ 'repeated_int64: -9223372036854775808\n'
+ 'repeated_uint64: 18446744073709551615\n'
+ 'repeated_double: 123.456\n'
+ 'repeated_double: 1.23e+22\n'
+ 'repeated_double: 1.23e-18\n'
+ 'repeated_string: '
+ '"\\000\\001\\007\\010\\014\\n\\r\\t\\013\\\\\\\'\\""\n'
+ 'repeated_string: "\\303\\274\\352\\234\\237"\n')
+
+ def testPrintNestedMessageAsOneLine(self):
+ message = unittest_pb2.TestAllTypes()
+ msg = message.repeated_nested_message.add()
+ msg.bb = 42;
+ self.CompareToGoldenText(
+ text_format.MessageToString(message, as_one_line=True),
+ 'repeated_nested_message { bb: 42 }')
+
+ def testPrintRepeatedFieldsAsOneLine(self):
+ message = unittest_pb2.TestAllTypes()
+ message.repeated_int32.append(1)
+ message.repeated_int32.append(1)
+ message.repeated_int32.append(3)
+ message.repeated_string.append("Google")
+ message.repeated_string.append("Zurich")
+ self.CompareToGoldenText(
+ text_format.MessageToString(message, as_one_line=True),
+ 'repeated_int32: 1 repeated_int32: 1 repeated_int32: 3 '
+ 'repeated_string: "Google" repeated_string: "Zurich"')
+
+ def testPrintNestedNewLineInStringAsOneLine(self):
+ message = unittest_pb2.TestAllTypes()
+ message.optional_string = "a\nnew\nline"
+ self.CompareToGoldenText(
+ text_format.MessageToString(message, as_one_line=True),
+ 'optional_string: "a\\nnew\\nline"')
+
+ def testPrintMessageSetAsOneLine(self):
+ message = unittest_mset_pb2.TestMessageSetContainer()
+ ext1 = unittest_mset_pb2.TestMessageSetExtension1.message_set_extension
+ ext2 = unittest_mset_pb2.TestMessageSetExtension2.message_set_extension
+ message.message_set.Extensions[ext1].i = 23
+ message.message_set.Extensions[ext2].str = 'foo'
+ self.CompareToGoldenText(
+ text_format.MessageToString(message, as_one_line=True),
+ 'message_set {'
+ ' [protobuf_unittest.TestMessageSetExtension1] {'
+ ' i: 23'
+ ' }'
+ ' [protobuf_unittest.TestMessageSetExtension2] {'
+ ' str: \"foo\"'
+ ' }'
+ ' }')
+
+ def testPrintExoticAsOneLine(self):
+ message = unittest_pb2.TestAllTypes()
+ message.repeated_int64.append(-9223372036854775808)
+ message.repeated_uint64.append(18446744073709551615)
+ message.repeated_double.append(123.456)
+ message.repeated_double.append(1.23e22)
+ message.repeated_double.append(1.23e-18)
+ message.repeated_string.append('\000\001\a\b\f\n\r\t\v\\\'"')
+ message.repeated_string.append(u'\u00fc\ua71f')
+ self.CompareToGoldenText(
+ self.RemoveRedundantZeros(
+ text_format.MessageToString(message, as_one_line=True)),
+ 'repeated_int64: -9223372036854775808'
+ ' repeated_uint64: 18446744073709551615'
+ ' repeated_double: 123.456'
+ ' repeated_double: 1.23e+22'
+ ' repeated_double: 1.23e-18'
+ ' repeated_string: '
+ '"\\000\\001\\007\\010\\014\\n\\r\\t\\013\\\\\\\'\\""'
+ ' repeated_string: "\\303\\274\\352\\234\\237"')
+
+ def testRoundTripExoticAsOneLine(self):
+ message = unittest_pb2.TestAllTypes()
+ message.repeated_int64.append(-9223372036854775808)
+ message.repeated_uint64.append(18446744073709551615)
+ message.repeated_double.append(123.456)
+ message.repeated_double.append(1.23e22)
+ message.repeated_double.append(1.23e-18)
+ message.repeated_string.append('\000\001\a\b\f\n\r\t\v\\\'"')
+ message.repeated_string.append(u'\u00fc\ua71f')
+
+ # Test as_utf8 = False.
+ wire_text = text_format.MessageToString(
+ message, as_one_line=True, as_utf8=False)
+ parsed_message = unittest_pb2.TestAllTypes()
+ text_format.Merge(wire_text, parsed_message)
+ self.assertEquals(message, parsed_message)
+
+ # Test as_utf8 = True.
+ wire_text = text_format.MessageToString(
+ message, as_one_line=True, as_utf8=True)
+ parsed_message = unittest_pb2.TestAllTypes()
+ text_format.Merge(wire_text, parsed_message)
+ self.assertEquals(message, parsed_message)
+
+ def testPrintRawUtf8String(self):
+ message = unittest_pb2.TestAllTypes()
+ message.repeated_string.append(u'\u00fc\ua71f')
+ text = text_format.MessageToString(message, as_utf8 = True)
+ self.CompareToGoldenText(text, 'repeated_string: "\303\274\352\234\237"\n')
+ parsed_message = unittest_pb2.TestAllTypes()
+ text_format.Merge(text, parsed_message)
+ self.assertEquals(message, parsed_message)
+
+ def testMessageToString(self):
+ message = unittest_pb2.ForeignMessage()
+ message.c = 123
+ self.assertEqual('c: 123\n', str(message))
+
+ def RemoveRedundantZeros(self, text):
+ # Some platforms print 1e+5 as 1e+005. This is fine, but we need to remove
+ # these zeros in order to match the golden file.
+ text = text.replace('e+0','e+').replace('e+0','e+') \
+ .replace('e-0','e-').replace('e-0','e-')
+ # Floating point fields are printed with .0 suffix even if they are
+ # actualy integer numbers.
+ text = re.compile('\.0$', re.MULTILINE).sub('', text)
+ return text
+
+ def testMergeGolden(self):
+ golden_text = '\n'.join(self.ReadGolden('text_format_unittest_data.txt'))
+ parsed_message = unittest_pb2.TestAllTypes()
+ text_format.Merge(golden_text, parsed_message)
+
+ message = unittest_pb2.TestAllTypes()
+ test_util.SetAllFields(message)
+ self.assertEquals(message, parsed_message)
+
+ def testMergeGoldenExtensions(self):
+ golden_text = '\n'.join(self.ReadGolden(
+ 'text_format_unittest_extensions_data.txt'))
+ parsed_message = unittest_pb2.TestAllExtensions()
+ text_format.Merge(golden_text, parsed_message)
+
+ message = unittest_pb2.TestAllExtensions()
+ test_util.SetAllExtensions(message)
+ self.assertEquals(message, parsed_message)
+
+ def testMergeAllFields(self):
+ message = unittest_pb2.TestAllTypes()
+ test_util.SetAllFields(message)
+ ascii_text = text_format.MessageToString(message)
+
+ parsed_message = unittest_pb2.TestAllTypes()
+ text_format.Merge(ascii_text, parsed_message)
+ self.assertEqual(message, parsed_message)
+ test_util.ExpectAllFieldsSet(self, message)
+
+ def testMergeAllExtensions(self):
+ message = unittest_pb2.TestAllExtensions()
+ test_util.SetAllExtensions(message)
+ ascii_text = text_format.MessageToString(message)
+
+ parsed_message = unittest_pb2.TestAllExtensions()
+ text_format.Merge(ascii_text, parsed_message)
+ self.assertEqual(message, parsed_message)
+
+ def testMergeMessageSet(self):
+ message = unittest_pb2.TestAllTypes()
+ text = ('repeated_uint64: 1\n'
+ 'repeated_uint64: 2\n')
+ text_format.Merge(text, message)
+ self.assertEqual(1, message.repeated_uint64[0])
+ self.assertEqual(2, message.repeated_uint64[1])
+
+ message = unittest_mset_pb2.TestMessageSetContainer()
+ text = ('message_set {\n'
+ ' [protobuf_unittest.TestMessageSetExtension1] {\n'
+ ' i: 23\n'
+ ' }\n'
+ ' [protobuf_unittest.TestMessageSetExtension2] {\n'
+ ' str: \"foo\"\n'
+ ' }\n'
+ '}\n')
+ text_format.Merge(text, message)
+ ext1 = unittest_mset_pb2.TestMessageSetExtension1.message_set_extension
+ ext2 = unittest_mset_pb2.TestMessageSetExtension2.message_set_extension
+ self.assertEquals(23, message.message_set.Extensions[ext1].i)
+ self.assertEquals('foo', message.message_set.Extensions[ext2].str)
+
+ def testMergeExotic(self):
+ message = unittest_pb2.TestAllTypes()
+ text = ('repeated_int64: -9223372036854775808\n'
+ 'repeated_uint64: 18446744073709551615\n'
+ 'repeated_double: 123.456\n'
+ 'repeated_double: 1.23e+22\n'
+ 'repeated_double: 1.23e-18\n'
+ 'repeated_string: \n'
+ '"\\000\\001\\007\\010\\014\\n\\r\\t\\013\\\\\\\'\\""\n'
+ 'repeated_string: "foo" \'corge\' "grault"\n'
+ 'repeated_string: "\\303\\274\\352\\234\\237"\n'
+ 'repeated_string: "\\xc3\\xbc"\n'
+ 'repeated_string: "\xc3\xbc"\n')
+ text_format.Merge(text, message)
+
+ self.assertEqual(-9223372036854775808, message.repeated_int64[0])
+ self.assertEqual(18446744073709551615, message.repeated_uint64[0])
+ self.assertEqual(123.456, message.repeated_double[0])
+ self.assertEqual(1.23e22, message.repeated_double[1])
+ self.assertEqual(1.23e-18, message.repeated_double[2])
+ self.assertEqual(
+ '\000\001\a\b\f\n\r\t\v\\\'"', message.repeated_string[0])
+ self.assertEqual('foocorgegrault', message.repeated_string[1])
+ self.assertEqual(u'\u00fc\ua71f', message.repeated_string[2])
+ self.assertEqual(u'\u00fc', message.repeated_string[3])
+
+ def testMergeEmptyText(self):
+ message = unittest_pb2.TestAllTypes()
+ text = ''
+ text_format.Merge(text, message)
+ self.assertEquals(unittest_pb2.TestAllTypes(), message)
+
+ def testMergeInvalidUtf8(self):
+ message = unittest_pb2.TestAllTypes()
+ text = 'repeated_string: "\\xc3\\xc3"'
+ self.assertRaises(text_format.ParseError, text_format.Merge, text, message)
+
+ def testMergeSingleWord(self):
+ message = unittest_pb2.TestAllTypes()
+ text = 'foo'
+ self.assertRaisesWithMessage(
+ text_format.ParseError,
+ ('1:1 : Message type "protobuf_unittest.TestAllTypes" has no field named '
+ '"foo".'),
+ text_format.Merge, text, message)
+
+ def testMergeUnknownField(self):
+ message = unittest_pb2.TestAllTypes()
+ text = 'unknown_field: 8\n'
+ self.assertRaisesWithMessage(
+ text_format.ParseError,
+ ('1:1 : Message type "protobuf_unittest.TestAllTypes" has no field named '
+ '"unknown_field".'),
+ text_format.Merge, text, message)
+
+ def testMergeBadExtension(self):
+ message = unittest_pb2.TestAllExtensions()
+ text = '[unknown_extension]: 8\n'
+ self.assertRaisesWithMessage(
+ text_format.ParseError,
+ '1:2 : Extension "unknown_extension" not registered.',
+ text_format.Merge, text, message)
+ message = unittest_pb2.TestAllTypes()
+ self.assertRaisesWithMessage(
+ text_format.ParseError,
+ ('1:2 : Message type "protobuf_unittest.TestAllTypes" does not have '
+ 'extensions.'),
+ text_format.Merge, text, message)
+
+ def testMergeGroupNotClosed(self):
+ message = unittest_pb2.TestAllTypes()
+ text = 'RepeatedGroup: <'
+ self.assertRaisesWithMessage(
+ text_format.ParseError, '1:16 : Expected ">".',
+ text_format.Merge, text, message)
+
+ text = 'RepeatedGroup: {'
+ self.assertRaisesWithMessage(
+ text_format.ParseError, '1:16 : Expected "}".',
+ text_format.Merge, text, message)
+
+ def testMergeEmptyGroup(self):
+ message = unittest_pb2.TestAllTypes()
+ text = 'OptionalGroup: {}'
+ text_format.Merge(text, message)
+ self.assertTrue(message.HasField('optionalgroup'))
+
+ message.Clear()
+
+ message = unittest_pb2.TestAllTypes()
+ text = 'OptionalGroup: <>'
+ text_format.Merge(text, message)
+ self.assertTrue(message.HasField('optionalgroup'))
+
+ def testMergeBadEnumValue(self):
+ message = unittest_pb2.TestAllTypes()
+ text = 'optional_nested_enum: BARR'
+ self.assertRaisesWithMessage(
+ text_format.ParseError,
+ ('1:23 : Enum type "protobuf_unittest.TestAllTypes.NestedEnum" '
+ 'has no value named BARR.'),
+ text_format.Merge, text, message)
+
+ message = unittest_pb2.TestAllTypes()
+ text = 'optional_nested_enum: 100'
+ self.assertRaisesWithMessage(
+ text_format.ParseError,
+ ('1:23 : Enum type "protobuf_unittest.TestAllTypes.NestedEnum" '
+ 'has no value with number 100.'),
+ text_format.Merge, text, message)
+
+ def testMergeBadIntValue(self):
+ message = unittest_pb2.TestAllTypes()
+ text = 'optional_int32: bork'
+ self.assertRaisesWithMessage(
+ text_format.ParseError,
+ ('1:17 : Couldn\'t parse integer: bork'),
+ text_format.Merge, text, message)
+
+ def testMergeStringFieldUnescape(self):
+ message = unittest_pb2.TestAllTypes()
+ text = r'''repeated_string: "\xf\x62"
+ repeated_string: "\\xf\\x62"
+ repeated_string: "\\\xf\\\x62"
+ repeated_string: "\\\\xf\\\\x62"
+ repeated_string: "\\\\\xf\\\\\x62"
+ repeated_string: "\x5cx20"'''
+ text_format.Merge(text, message)
+
+ SLASH = '\\'
+ self.assertEqual('\x0fb', message.repeated_string[0])
+ self.assertEqual(SLASH + 'xf' + SLASH + 'x62', message.repeated_string[1])
+ self.assertEqual(SLASH + '\x0f' + SLASH + 'b', message.repeated_string[2])
+ self.assertEqual(SLASH + SLASH + 'xf' + SLASH + SLASH + 'x62',
+ message.repeated_string[3])
+ self.assertEqual(SLASH + SLASH + '\x0f' + SLASH + SLASH + 'b',
+ message.repeated_string[4])
+ self.assertEqual(SLASH + 'x20', message.repeated_string[5])
+
+ def assertRaisesWithMessage(self, e_class, e, func, *args, **kwargs):
+ """Same as assertRaises, but also compares the exception message."""
+ if hasattr(e_class, '__name__'):
+ exc_name = e_class.__name__
+ else:
+ exc_name = str(e_class)
+
+ try:
+ func(*args, **kwargs)
+ except e_class as expr:
+ if str(expr) != e:
+ msg = '%s raised, but with wrong message: "%s" instead of "%s"'
+ raise self.failureException(msg % (exc_name,
+ str(expr).encode('string_escape'),
+ e.encode('string_escape')))
+ return
+ else:
+ raise self.failureException('%s not raised' % exc_name)
+
+
+class TokenizerTest(unittest.TestCase):
+ """
+ def testSimpleTokenCases(self):
+ text = ('identifier1:"string1"\n \n\n'
+ 'identifier2 : \n \n123 \n identifier3 :\'string\'\n'
+ 'identifiER_4 : 1.1e+2 ID5:-0.23 ID6:\'aaaa\\\'bbbb\'\n'
+ 'ID7 : "aa\\"bb"\n\n\n\n ID8: {A:inf B:-inf C:true D:false}\n'
+ 'ID9: 22 ID10: -111111111111111111 ID11: -22\n'
+ 'ID12: 2222222222222222222 ID13: 1.23456f ID14: 1.2e+2f '
+ 'false_bool: 0 true_BOOL:t \n true_bool1: 1 false_BOOL1:f ' )
+ tokenizer = text_format._Tokenizer(text)
+ methods = [(tokenizer.ConsumeIdentifier, 'identifier1'),
+ ':',
+ (tokenizer.ConsumeString, 'string1'),
+ (tokenizer.ConsumeIdentifier, 'identifier2'),
+ ':',
+ (tokenizer.ConsumeInt32, 123),
+ (tokenizer.ConsumeIdentifier, 'identifier3'),
+ ':',
+ (tokenizer.ConsumeString, 'string'),
+ (tokenizer.ConsumeIdentifier, 'identifiER_4'),
+ ':',
+ (tokenizer.ConsumeFloat, 1.1e+2),
+ (tokenizer.ConsumeIdentifier, 'ID5'),
+ ':',
+ (tokenizer.ConsumeFloat, -0.23),
+ (tokenizer.ConsumeIdentifier, 'ID6'),
+ ':',
+ (tokenizer.ConsumeString, 'aaaa\'bbbb'),
+ (tokenizer.ConsumeIdentifier, 'ID7'),
+ ':',
+ (tokenizer.ConsumeString, 'aa\"bb'),
+ (tokenizer.ConsumeIdentifier, 'ID8'),
+ ':',
+ '{',
+ (tokenizer.ConsumeIdentifier, 'A'),
+ ':',
+ (tokenizer.ConsumeFloat, float('inf')),
+ (tokenizer.ConsumeIdentifier, 'B'),
+ ':',
+ (tokenizer.ConsumeFloat, -float('inf')),
+ (tokenizer.ConsumeIdentifier, 'C'),
+ ':',
+ (tokenizer.ConsumeBool, True),
+ (tokenizer.ConsumeIdentifier, 'D'),
+ ':',
+ (tokenizer.ConsumeBool, False),
+ '}',
+ (tokenizer.ConsumeIdentifier, 'ID9'),
+ ':',
+ (tokenizer.ConsumeUint32, 22),
+ (tokenizer.ConsumeIdentifier, 'ID10'),
+ ':',
+ (tokenizer.ConsumeInt64, -111111111111111111),
+ (tokenizer.ConsumeIdentifier, 'ID11'),
+ ':',
+ (tokenizer.ConsumeInt32, -22),
+ (tokenizer.ConsumeIdentifier, 'ID12'),
+ ':',
+ (tokenizer.ConsumeUint64, 2222222222222222222),
+ (tokenizer.ConsumeIdentifier, 'ID13'),
+ ':',
+ (tokenizer.ConsumeFloat, 1.23456),
+ (tokenizer.ConsumeIdentifier, 'ID14'),
+ ':',
+ (tokenizer.ConsumeFloat, 1.2e+2),
+ (tokenizer.ConsumeIdentifier, 'false_bool'),
+ ':',
+ (tokenizer.ConsumeBool, False),
+ (tokenizer.ConsumeIdentifier, 'true_BOOL'),
+ ':',
+ (tokenizer.ConsumeBool, True),
+ (tokenizer.ConsumeIdentifier, 'true_bool1'),
+ ':',
+ (tokenizer.ConsumeBool, True),
+ (tokenizer.ConsumeIdentifier, 'false_BOOL1'),
+ ':',
+ (tokenizer.ConsumeBool, False)]
+
+ i = 0
+ while not tokenizer.AtEnd():
+ m = methods[i]
+ if type(m) == str:
+ token = tokenizer.token
+ self.assertEqual(token, m)
+ tokenizer.NextToken()
+ else:
+ self.assertEqual(m[1], m[0]())
+ i += 1
+
+ def testConsumeIntegers(self):
+ # This test only tests the failures in the integer parsing methods as well
+ # as the '0' special cases.
+ int64_max = (1 << 63) - 1
+ uint32_max = (1 << 32) - 1
+ text = '-1 %d %d' % (uint32_max + 1, int64_max + 1)
+ tokenizer = text_format._Tokenizer(text)
+ self.assertRaises(text_format.ParseError, tokenizer.ConsumeUint32)
+ self.assertRaises(text_format.ParseError, tokenizer.ConsumeUint64)
+ self.assertEqual(-1, tokenizer.ConsumeInt32())
+
+ self.assertRaises(text_format.ParseError, tokenizer.ConsumeUint32)
+ self.assertRaises(text_format.ParseError, tokenizer.ConsumeInt32)
+ self.assertEqual(uint32_max + 1, tokenizer.ConsumeInt64())
+
+ self.assertRaises(text_format.ParseError, tokenizer.ConsumeInt64)
+ self.assertEqual(int64_max + 1, tokenizer.ConsumeUint64())
+ self.assertTrue(tokenizer.AtEnd())
+
+ text = '-0 -0 0 0'
+ tokenizer = text_format._Tokenizer(text)
+ self.assertEqual(0, tokenizer.ConsumeUint32())
+ self.assertEqual(0, tokenizer.ConsumeUint64())
+ self.assertEqual(0, tokenizer.ConsumeUint32())
+ self.assertEqual(0, tokenizer.ConsumeUint64())
+ self.assertTrue(tokenizer.AtEnd())
+ """
+
+ def testConsumeByteString(self):
+ text = '"string1\''
+ tokenizer = text_format._Tokenizer(text)
+ self.assertRaises(text_format.ParseError, tokenizer.ConsumeByteString)
+
+ text = 'string1"'
+ tokenizer = text_format._Tokenizer(text)
+ self.assertRaises(text_format.ParseError, tokenizer.ConsumeByteString)
+
+ text = '\n"\\xt"'
+ tokenizer = text_format._Tokenizer(text)
+ self.assertRaises(text_format.ParseError, tokenizer.ConsumeByteString)
+
+ text = '\n"\\"'
+ tokenizer = text_format._Tokenizer(text)
+ self.assertRaises(text_format.ParseError, tokenizer.ConsumeByteString)
+
+ text = '\n"\\x"'
+ tokenizer = text_format._Tokenizer(text)
+ self.assertRaises(text_format.ParseError, tokenizer.ConsumeByteString)
+
+ def testConsumeBool(self):
+ text = 'not-a-bool'
+ tokenizer = text_format._Tokenizer(text)
+ self.assertRaises(text_format.ParseError, tokenizer.ConsumeBool)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/text_format_unittest_data.txt b/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/text_format_unittest_data.txt
new file mode 100644
index 00000000..bbe58826
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/text_format_unittest_data.txt
@@ -0,0 +1,128 @@
+optional_int32: 101
+optional_int64: 102
+optional_uint32: 103
+optional_uint64: 104
+optional_sint32: 105
+optional_sint64: 106
+optional_fixed32: 107
+optional_fixed64: 108
+optional_sfixed32: 109
+optional_sfixed64: 110
+optional_float: 111
+optional_double: 112
+optional_bool: true
+optional_string: "115"
+optional_bytes: "116"
+OptionalGroup {
+ a: 117
+}
+optional_nested_message {
+ bb: 118
+}
+optional_foreign_message {
+ c: 119
+}
+optional_import_message {
+ d: 120
+}
+optional_nested_enum: BAZ
+optional_foreign_enum: FOREIGN_BAZ
+optional_import_enum: IMPORT_BAZ
+optional_string_piece: "124"
+optional_cord: "125"
+optional_public_import_message {
+ e: 126
+}
+optional_lazy_message {
+ bb: 127
+}
+repeated_int32: 201
+repeated_int32: 301
+repeated_int64: 202
+repeated_int64: 302
+repeated_uint32: 203
+repeated_uint32: 303
+repeated_uint64: 204
+repeated_uint64: 304
+repeated_sint32: 205
+repeated_sint32: 305
+repeated_sint64: 206
+repeated_sint64: 306
+repeated_fixed32: 207
+repeated_fixed32: 307
+repeated_fixed64: 208
+repeated_fixed64: 308
+repeated_sfixed32: 209
+repeated_sfixed32: 309
+repeated_sfixed64: 210
+repeated_sfixed64: 310
+repeated_float: 211
+repeated_float: 311
+repeated_double: 212
+repeated_double: 312
+repeated_bool: true
+repeated_bool: false
+repeated_string: "215"
+repeated_string: "315"
+repeated_bytes: "216"
+repeated_bytes: "316"
+RepeatedGroup {
+ a: 217
+}
+RepeatedGroup {
+ a: 317
+}
+repeated_nested_message {
+ bb: 218
+}
+repeated_nested_message {
+ bb: 318
+}
+repeated_foreign_message {
+ c: 219
+}
+repeated_foreign_message {
+ c: 319
+}
+repeated_import_message {
+ d: 220
+}
+repeated_import_message {
+ d: 320
+}
+repeated_nested_enum: BAR
+repeated_nested_enum: BAZ
+repeated_foreign_enum: FOREIGN_BAR
+repeated_foreign_enum: FOREIGN_BAZ
+repeated_import_enum: IMPORT_BAR
+repeated_import_enum: IMPORT_BAZ
+repeated_string_piece: "224"
+repeated_string_piece: "324"
+repeated_cord: "225"
+repeated_cord: "325"
+repeated_lazy_message {
+ bb: 227
+}
+repeated_lazy_message {
+ bb: 327
+}
+default_int32: 401
+default_int64: 402
+default_uint32: 403
+default_uint64: 404
+default_sint32: 405
+default_sint64: 406
+default_fixed32: 407
+default_fixed64: 408
+default_sfixed32: 409
+default_sfixed64: 410
+default_float: 411
+default_double: 412
+default_bool: false
+default_string: "415"
+default_bytes: "416"
+default_nested_enum: FOO
+default_foreign_enum: FOREIGN_FOO
+default_import_enum: IMPORT_FOO
+default_string_piece: "424"
+default_cord: "425"
diff --git a/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/text_format_unittest_extensions_data.txt b/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/text_format_unittest_extensions_data.txt
new file mode 100644
index 00000000..0a217f02
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/text_format_unittest_extensions_data.txt
@@ -0,0 +1,128 @@
+[protobuf_unittest.optional_int32_extension]: 101
+[protobuf_unittest.optional_int64_extension]: 102
+[protobuf_unittest.optional_uint32_extension]: 103
+[protobuf_unittest.optional_uint64_extension]: 104
+[protobuf_unittest.optional_sint32_extension]: 105
+[protobuf_unittest.optional_sint64_extension]: 106
+[protobuf_unittest.optional_fixed32_extension]: 107
+[protobuf_unittest.optional_fixed64_extension]: 108
+[protobuf_unittest.optional_sfixed32_extension]: 109
+[protobuf_unittest.optional_sfixed64_extension]: 110
+[protobuf_unittest.optional_float_extension]: 111
+[protobuf_unittest.optional_double_extension]: 112
+[protobuf_unittest.optional_bool_extension]: true
+[protobuf_unittest.optional_string_extension]: "115"
+[protobuf_unittest.optional_bytes_extension]: "116"
+[protobuf_unittest.optionalgroup_extension] {
+ a: 117
+}
+[protobuf_unittest.optional_nested_message_extension] {
+ bb: 118
+}
+[protobuf_unittest.optional_foreign_message_extension] {
+ c: 119
+}
+[protobuf_unittest.optional_import_message_extension] {
+ d: 120
+}
+[protobuf_unittest.optional_nested_enum_extension]: BAZ
+[protobuf_unittest.optional_foreign_enum_extension]: FOREIGN_BAZ
+[protobuf_unittest.optional_import_enum_extension]: IMPORT_BAZ
+[protobuf_unittest.optional_string_piece_extension]: "124"
+[protobuf_unittest.optional_cord_extension]: "125"
+[protobuf_unittest.optional_public_import_message_extension] {
+ e: 126
+}
+[protobuf_unittest.optional_lazy_message_extension] {
+ bb: 127
+}
+[protobuf_unittest.repeated_int32_extension]: 201
+[protobuf_unittest.repeated_int32_extension]: 301
+[protobuf_unittest.repeated_int64_extension]: 202
+[protobuf_unittest.repeated_int64_extension]: 302
+[protobuf_unittest.repeated_uint32_extension]: 203
+[protobuf_unittest.repeated_uint32_extension]: 303
+[protobuf_unittest.repeated_uint64_extension]: 204
+[protobuf_unittest.repeated_uint64_extension]: 304
+[protobuf_unittest.repeated_sint32_extension]: 205
+[protobuf_unittest.repeated_sint32_extension]: 305
+[protobuf_unittest.repeated_sint64_extension]: 206
+[protobuf_unittest.repeated_sint64_extension]: 306
+[protobuf_unittest.repeated_fixed32_extension]: 207
+[protobuf_unittest.repeated_fixed32_extension]: 307
+[protobuf_unittest.repeated_fixed64_extension]: 208
+[protobuf_unittest.repeated_fixed64_extension]: 308
+[protobuf_unittest.repeated_sfixed32_extension]: 209
+[protobuf_unittest.repeated_sfixed32_extension]: 309
+[protobuf_unittest.repeated_sfixed64_extension]: 210
+[protobuf_unittest.repeated_sfixed64_extension]: 310
+[protobuf_unittest.repeated_float_extension]: 211
+[protobuf_unittest.repeated_float_extension]: 311
+[protobuf_unittest.repeated_double_extension]: 212
+[protobuf_unittest.repeated_double_extension]: 312
+[protobuf_unittest.repeated_bool_extension]: true
+[protobuf_unittest.repeated_bool_extension]: false
+[protobuf_unittest.repeated_string_extension]: "215"
+[protobuf_unittest.repeated_string_extension]: "315"
+[protobuf_unittest.repeated_bytes_extension]: "216"
+[protobuf_unittest.repeated_bytes_extension]: "316"
+[protobuf_unittest.repeatedgroup_extension] {
+ a: 217
+}
+[protobuf_unittest.repeatedgroup_extension] {
+ a: 317
+}
+[protobuf_unittest.repeated_nested_message_extension] {
+ bb: 218
+}
+[protobuf_unittest.repeated_nested_message_extension] {
+ bb: 318
+}
+[protobuf_unittest.repeated_foreign_message_extension] {
+ c: 219
+}
+[protobuf_unittest.repeated_foreign_message_extension] {
+ c: 319
+}
+[protobuf_unittest.repeated_import_message_extension] {
+ d: 220
+}
+[protobuf_unittest.repeated_import_message_extension] {
+ d: 320
+}
+[protobuf_unittest.repeated_nested_enum_extension]: BAR
+[protobuf_unittest.repeated_nested_enum_extension]: BAZ
+[protobuf_unittest.repeated_foreign_enum_extension]: FOREIGN_BAR
+[protobuf_unittest.repeated_foreign_enum_extension]: FOREIGN_BAZ
+[protobuf_unittest.repeated_import_enum_extension]: IMPORT_BAR
+[protobuf_unittest.repeated_import_enum_extension]: IMPORT_BAZ
+[protobuf_unittest.repeated_string_piece_extension]: "224"
+[protobuf_unittest.repeated_string_piece_extension]: "324"
+[protobuf_unittest.repeated_cord_extension]: "225"
+[protobuf_unittest.repeated_cord_extension]: "325"
+[protobuf_unittest.repeated_lazy_message_extension] {
+ bb: 227
+}
+[protobuf_unittest.repeated_lazy_message_extension] {
+ bb: 327
+}
+[protobuf_unittest.default_int32_extension]: 401
+[protobuf_unittest.default_int64_extension]: 402
+[protobuf_unittest.default_uint32_extension]: 403
+[protobuf_unittest.default_uint64_extension]: 404
+[protobuf_unittest.default_sint32_extension]: 405
+[protobuf_unittest.default_sint64_extension]: 406
+[protobuf_unittest.default_fixed32_extension]: 407
+[protobuf_unittest.default_fixed64_extension]: 408
+[protobuf_unittest.default_sfixed32_extension]: 409
+[protobuf_unittest.default_sfixed64_extension]: 410
+[protobuf_unittest.default_float_extension]: 411
+[protobuf_unittest.default_double_extension]: 412
+[protobuf_unittest.default_bool_extension]: false
+[protobuf_unittest.default_string_extension]: "415"
+[protobuf_unittest.default_bytes_extension]: "416"
+[protobuf_unittest.default_nested_enum_extension]: FOO
+[protobuf_unittest.default_foreign_enum_extension]: FOREIGN_FOO
+[protobuf_unittest.default_import_enum_extension]: IMPORT_FOO
+[protobuf_unittest.default_string_piece_extension]: "424"
+[protobuf_unittest.default_cord_extension]: "425"
diff --git a/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/wire_format_test.py b/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/wire_format_test.py
new file mode 100755
index 00000000..76007786
--- /dev/null
+++ b/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/wire_format_test.py
@@ -0,0 +1,253 @@
+#! /usr/bin/python
+#
+# Protocol Buffers - Google's data interchange format
+# Copyright 2008 Google Inc. All rights reserved.
+# http://code.google.com/p/protobuf/
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+"""Test for google.protobuf.internal.wire_format."""
+
+__author__ = 'robinson@google.com (Will Robinson)'
+
+import unittest
+from google.protobuf import message
+from google.protobuf.internal import wire_format
+
+
+class WireFormatTest(unittest.TestCase):
+
+ def testPackTag(self):
+ field_number = 0xabc
+ tag_type = 2
+ self.assertEqual((field_number << 3) | tag_type,
+ wire_format.PackTag(field_number, tag_type))
+ PackTag = wire_format.PackTag
+ # Number too high.
+ self.assertRaises(message.EncodeError, PackTag, field_number, 6)
+ # Number too low.
+ self.assertRaises(message.EncodeError, PackTag, field_number, -1)
+
+ def testUnpackTag(self):
+ # Test field numbers that will require various varint sizes.
+ for expected_field_number in (1, 15, 16, 2047, 2048):
+ for expected_wire_type in range(6): # Highest-numbered wiretype is 5.
+ field_number, wire_type = wire_format.UnpackTag(
+ wire_format.PackTag(expected_field_number, expected_wire_type))
+ self.assertEqual(expected_field_number, field_number)
+ self.assertEqual(expected_wire_type, wire_type)
+
+ self.assertRaises(TypeError, wire_format.UnpackTag, None)
+ self.assertRaises(TypeError, wire_format.UnpackTag, 'abc')
+ self.assertRaises(TypeError, wire_format.UnpackTag, 0.0)
+ self.assertRaises(TypeError, wire_format.UnpackTag, object())
+
+ def testZigZagEncode(self):
+ Z = wire_format.ZigZagEncode
+ self.assertEqual(0, Z(0))
+ self.assertEqual(1, Z(-1))
+ self.assertEqual(2, Z(1))
+ self.assertEqual(3, Z(-2))
+ self.assertEqual(4, Z(2))
+ self.assertEqual(0xfffffffe, Z(0x7fffffff))
+ self.assertEqual(0xffffffff, Z(-0x80000000))
+ self.assertEqual(0xfffffffffffffffe, Z(0x7fffffffffffffff))
+ self.assertEqual(0xffffffffffffffff, Z(-0x8000000000000000))
+
+ self.assertRaises(TypeError, Z, None)
+ self.assertRaises(TypeError, Z, 'abcd')
+ self.assertRaises(TypeError, Z, 0.0)
+ self.assertRaises(TypeError, Z, object())
+
+ def testZigZagDecode(self):
+ Z = wire_format.ZigZagDecode
+ self.assertEqual(0, Z(0))
+ self.assertEqual(-1, Z(1))
+ self.assertEqual(1, Z(2))
+ self.assertEqual(-2, Z(3))
+ self.assertEqual(2, Z(4))
+ self.assertEqual(0x7fffffff, Z(0xfffffffe))
+ self.assertEqual(-0x80000000, Z(0xffffffff))
+ self.assertEqual(0x7fffffffffffffff, Z(0xfffffffffffffffe))
+ self.assertEqual(-0x8000000000000000, Z(0xffffffffffffffff))
+
+ self.assertRaises(TypeError, Z, None)
+ self.assertRaises(TypeError, Z, 'abcd')
+ self.assertRaises(TypeError, Z, 0.0)
+ self.assertRaises(TypeError, Z, object())
+
+ def NumericByteSizeTestHelper(self, byte_size_fn, value, expected_value_size):
+ # Use field numbers that cause various byte sizes for the tag information.
+ for field_number, tag_bytes in ((15, 1), (16, 2), (2047, 2), (2048, 3)):
+ expected_size = expected_value_size + tag_bytes
+ actual_size = byte_size_fn(field_number, value)
+ self.assertEqual(expected_size, actual_size,
+ 'byte_size_fn: %s, field_number: %d, value: %r\n'
+ 'Expected: %d, Actual: %d'% (
+ byte_size_fn, field_number, value, expected_size, actual_size))
+
+ def testByteSizeFunctions(self):
+ # Test all numeric *ByteSize() functions.
+ NUMERIC_ARGS = [
+ # Int32ByteSize().
+ [wire_format.Int32ByteSize, 0, 1],
+ [wire_format.Int32ByteSize, 127, 1],
+ [wire_format.Int32ByteSize, 128, 2],
+ [wire_format.Int32ByteSize, -1, 10],
+ # Int64ByteSize().
+ [wire_format.Int64ByteSize, 0, 1],
+ [wire_format.Int64ByteSize, 127, 1],
+ [wire_format.Int64ByteSize, 128, 2],
+ [wire_format.Int64ByteSize, -1, 10],
+ # UInt32ByteSize().
+ [wire_format.UInt32ByteSize, 0, 1],
+ [wire_format.UInt32ByteSize, 127, 1],
+ [wire_format.UInt32ByteSize, 128, 2],
+ [wire_format.UInt32ByteSize, wire_format.UINT32_MAX, 5],
+ # UInt64ByteSize().
+ [wire_format.UInt64ByteSize, 0, 1],
+ [wire_format.UInt64ByteSize, 127, 1],
+ [wire_format.UInt64ByteSize, 128, 2],
+ [wire_format.UInt64ByteSize, wire_format.UINT64_MAX, 10],
+ # SInt32ByteSize().
+ [wire_format.SInt32ByteSize, 0, 1],
+ [wire_format.SInt32ByteSize, -1, 1],
+ [wire_format.SInt32ByteSize, 1, 1],
+ [wire_format.SInt32ByteSize, -63, 1],
+ [wire_format.SInt32ByteSize, 63, 1],
+ [wire_format.SInt32ByteSize, -64, 1],
+ [wire_format.SInt32ByteSize, 64, 2],
+ # SInt64ByteSize().
+ [wire_format.SInt64ByteSize, 0, 1],
+ [wire_format.SInt64ByteSize, -1, 1],
+ [wire_format.SInt64ByteSize, 1, 1],
+ [wire_format.SInt64ByteSize, -63, 1],
+ [wire_format.SInt64ByteSize, 63, 1],
+ [wire_format.SInt64ByteSize, -64, 1],
+ [wire_format.SInt64ByteSize, 64, 2],
+ # Fixed32ByteSize().
+ [wire_format.Fixed32ByteSize, 0, 4],
+ [wire_format.Fixed32ByteSize, wire_format.UINT32_MAX, 4],
+ # Fixed64ByteSize().
+ [wire_format.Fixed64ByteSize, 0, 8],
+ [wire_format.Fixed64ByteSize, wire_format.UINT64_MAX, 8],
+ # SFixed32ByteSize().
+ [wire_format.SFixed32ByteSize, 0, 4],
+ [wire_format.SFixed32ByteSize, wire_format.INT32_MIN, 4],
+ [wire_format.SFixed32ByteSize, wire_format.INT32_MAX, 4],
+ # SFixed64ByteSize().
+ [wire_format.SFixed64ByteSize, 0, 8],
+ [wire_format.SFixed64ByteSize, wire_format.INT64_MIN, 8],
+ [wire_format.SFixed64ByteSize, wire_format.INT64_MAX, 8],
+ # FloatByteSize().
+ [wire_format.FloatByteSize, 0.0, 4],
+ [wire_format.FloatByteSize, 1000000000.0, 4],
+ [wire_format.FloatByteSize, -1000000000.0, 4],
+ # DoubleByteSize().
+ [wire_format.DoubleByteSize, 0.0, 8],
+ [wire_format.DoubleByteSize, 1000000000.0, 8],
+ [wire_format.DoubleByteSize, -1000000000.0, 8],
+ # BoolByteSize().
+ [wire_format.BoolByteSize, False, 1],
+ [wire_format.BoolByteSize, True, 1],
+ # EnumByteSize().
+ [wire_format.EnumByteSize, 0, 1],
+ [wire_format.EnumByteSize, 127, 1],
+ [wire_format.EnumByteSize, 128, 2],
+ [wire_format.EnumByteSize, wire_format.UINT32_MAX, 5],
+ ]
+ for args in NUMERIC_ARGS:
+ self.NumericByteSizeTestHelper(*args)
+
+ # Test strings and bytes.
+ for byte_size_fn in (wire_format.StringByteSize, wire_format.BytesByteSize):
+ # 1 byte for tag, 1 byte for length, 3 bytes for contents.
+ self.assertEqual(5, byte_size_fn(10, 'abc'))
+ # 2 bytes for tag, 1 byte for length, 3 bytes for contents.
+ self.assertEqual(6, byte_size_fn(16, 'abc'))
+ # 2 bytes for tag, 2 bytes for length, 128 bytes for contents.
+ self.assertEqual(132, byte_size_fn(16, 'a' * 128))
+
+ # Test UTF-8 string byte size calculation.
+ # 1 byte for tag, 1 byte for length, 8 bytes for content.
+ self.assertEqual(10, wire_format.StringByteSize(
+ 5, unicode('\xd0\xa2\xd0\xb5\xd1\x81\xd1\x82', 'utf-8')))
+
+ class MockMessage(object):
+ def __init__(self, byte_size):
+ self.byte_size = byte_size
+ def ByteSize(self):
+ return self.byte_size
+
+ message_byte_size = 10
+ mock_message = MockMessage(byte_size=message_byte_size)
+ # Test groups.
+ # (2 * 1) bytes for begin and end tags, plus message_byte_size.
+ self.assertEqual(2 + message_byte_size,
+ wire_format.GroupByteSize(1, mock_message))
+ # (2 * 2) bytes for begin and end tags, plus message_byte_size.
+ self.assertEqual(4 + message_byte_size,
+ wire_format.GroupByteSize(16, mock_message))
+
+ # Test messages.
+ # 1 byte for tag, plus 1 byte for length, plus contents.
+ self.assertEqual(2 + mock_message.byte_size,
+ wire_format.MessageByteSize(1, mock_message))
+ # 2 bytes for tag, plus 1 byte for length, plus contents.
+ self.assertEqual(3 + mock_message.byte_size,
+ wire_format.MessageByteSize(16, mock_message))
+ # 2 bytes for tag, plus 2 bytes for length, plus contents.
+ mock_message.byte_size = 128
+ self.assertEqual(4 + mock_message.byte_size,
+ wire_format.MessageByteSize(16, mock_message))
+
+
+ # Test message set item byte size.
+ # 4 bytes for tags, plus 1 byte for length, plus 1 byte for type_id,
+ # plus contents.
+ mock_message.byte_size = 10
+ self.assertEqual(mock_message.byte_size + 6,
+ wire_format.MessageSetItemByteSize(1, mock_message))
+
+ # 4 bytes for tags, plus 2 bytes for length, plus 1 byte for type_id,
+ # plus contents.
+ mock_message.byte_size = 128
+ self.assertEqual(mock_message.byte_size + 7,
+ wire_format.MessageSetItemByteSize(1, mock_message))
+
+ # 4 bytes for tags, plus 2 bytes for length, plus 2 byte for type_id,
+ # plus contents.
+ self.assertEqual(mock_message.byte_size + 8,
+ wire_format.MessageSetItemByteSize(128, mock_message))
+
+ # Too-long varint.
+ self.assertRaises(message.EncodeError,
+ wire_format.UInt64ByteSize, 1, 1 << 128)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/python/google/protobuf/__init__.py b/python/google/protobuf/__init__.py
index 0e2a89ff..7fd9e5a4 100755
--- a/python/google/protobuf/__init__.py
+++ b/python/google/protobuf/__init__.py
@@ -30,7 +30,7 @@
# Copyright 2007 Google Inc. All Rights Reserved.
-__version__ = '3.1.0'
+__version__ = '3.2.0'
if __name__ != '__main__':
try:
diff --git a/python/google/protobuf/descriptor_pool.py b/python/google/protobuf/descriptor_pool.py
index 5f43ee5f..fc3a7f44 100644
--- a/python/google/protobuf/descriptor_pool.py
+++ b/python/google/protobuf/descriptor_pool.py
@@ -57,6 +57,8 @@ directly instead of this class.
__author__ = 'matthewtoia@google.com (Matt Toia)'
+import collections
+
from google.protobuf import descriptor
from google.protobuf import descriptor_database
from google.protobuf import text_encoding
@@ -88,6 +90,14 @@ def _OptionsOrNone(descriptor_proto):
return None
+def _IsMessageSetExtension(field):
+ return (field.is_extension and
+ field.containing_type.has_options and
+ field.containing_type.GetOptions().message_set_wire_format and
+ field.type == descriptor.FieldDescriptor.TYPE_MESSAGE and
+ field.label == descriptor.FieldDescriptor.LABEL_OPTIONAL)
+
+
class DescriptorPool(object):
"""A collection of protobufs dynamically constructed by descriptor protos."""
@@ -115,6 +125,12 @@ class DescriptorPool(object):
self._descriptors = {}
self._enum_descriptors = {}
self._file_descriptors = {}
+ self._toplevel_extensions = {}
+ # We store extensions in two two-level mappings: The first key is the
+ # descriptor of the message being extended, the second key is the extension
+ # full name or its tag number.
+ self._extensions_by_name = collections.defaultdict(dict)
+ self._extensions_by_number = collections.defaultdict(dict)
def Add(self, file_desc_proto):
"""Adds the FileDescriptorProto and its types to this pool.
@@ -170,6 +186,48 @@ class DescriptorPool(object):
self._enum_descriptors[enum_desc.full_name] = enum_desc
self.AddFileDescriptor(enum_desc.file)
+ def AddExtensionDescriptor(self, extension):
+ """Adds a FieldDescriptor describing an extension to the pool.
+
+ Args:
+ extension: A FieldDescriptor.
+
+ Raises:
+ AssertionError: when another extension with the same number extends the
+ same message.
+ TypeError: when the specified extension is not a
+ descriptor.FieldDescriptor.
+ """
+ if not (isinstance(extension, descriptor.FieldDescriptor) and
+ extension.is_extension):
+ raise TypeError('Expected an extension descriptor.')
+
+ if extension.extension_scope is None:
+ self._toplevel_extensions[extension.full_name] = extension
+
+ try:
+ existing_desc = self._extensions_by_number[
+ extension.containing_type][extension.number]
+ except KeyError:
+ pass
+ else:
+ if extension is not existing_desc:
+ raise AssertionError(
+ 'Extensions "%s" and "%s" both try to extend message type "%s" '
+ 'with field number %d.' %
+ (extension.full_name, existing_desc.full_name,
+ extension.containing_type.full_name, extension.number))
+
+ self._extensions_by_number[extension.containing_type][
+ extension.number] = extension
+ self._extensions_by_name[extension.containing_type][
+ extension.full_name] = extension
+
+ # Also register MessageSet extensions with the type name.
+ if _IsMessageSetExtension(extension):
+ self._extensions_by_name[extension.containing_type][
+ extension.message_type.full_name] = extension
+
def AddFileDescriptor(self, file_desc):
"""Adds a FileDescriptor to the pool, non-recursively.
@@ -302,6 +360,14 @@ class DescriptorPool(object):
A FieldDescriptor, describing the named extension.
"""
full_name = _NormalizeFullyQualifiedName(full_name)
+ try:
+ # The proto compiler does not give any link between the FileDescriptor
+ # and top-level extensions unless the FileDescriptorProto is added to
+ # the DescriptorDatabase, but this can impact memory usage.
+ # So we registered these extensions by name explicitly.
+ return self._toplevel_extensions[full_name]
+ except KeyError:
+ pass
message_name, _, extension_name = full_name.rpartition('.')
try:
# Most extensions are nested inside a message.
@@ -311,6 +377,39 @@ class DescriptorPool(object):
scope = self.FindFileContainingSymbol(full_name)
return scope.extensions_by_name[extension_name]
+ def FindExtensionByNumber(self, message_descriptor, number):
+ """Gets the extension of the specified message with the specified number.
+
+ Extensions have to be registered to this pool by calling
+ AddExtensionDescriptor.
+
+ Args:
+ message_descriptor: descriptor of the extended message.
+ number: integer, number of the extension field.
+
+ Returns:
+ A FieldDescriptor describing the extension.
+
+ Raise:
+ KeyError: when no extension with the given number is known for the
+ specified message.
+ """
+ return self._extensions_by_number[message_descriptor][number]
+
+ def FindAllExtensions(self, message_descriptor):
+ """Gets all the known extension of a given message.
+
+ Extensions have to be registered to this pool by calling
+ AddExtensionDescriptor.
+
+ Args:
+ message_descriptor: descriptor of the extended message.
+
+ Returns:
+ A list of FieldDescriptor describing the extensions.
+ """
+ return list(self._extensions_by_number[message_descriptor].values())
+
def _ConvertFileProtoToFileDescriptor(self, file_proto):
"""Creates a FileDescriptor from a proto or returns a cached copy.
diff --git a/python/google/protobuf/internal/decoder.py b/python/google/protobuf/internal/decoder.py
index 31869e45..ff3e6d30 100755
--- a/python/google/protobuf/internal/decoder.py
+++ b/python/google/protobuf/internal/decoder.py
@@ -131,9 +131,12 @@ def _VarintDecoder(mask, result_type):
return DecodeVarint
-def _SignedVarintDecoder(mask, result_type):
+def _SignedVarintDecoder(bits, result_type):
"""Like _VarintDecoder() but decodes signed values."""
+ signbit = 1 << (bits - 1)
+ mask = (1 << bits) - 1
+
def DecodeVarint(buffer, pos):
result = 0
shift = 0
@@ -142,11 +145,8 @@ def _SignedVarintDecoder(mask, result_type):
result |= ((b & 0x7f) << shift)
pos += 1
if not (b & 0x80):
- if result > 0x7fffffffffffffff:
- result -= (1 << 64)
- result |= ~mask
- else:
- result &= mask
+ result &= mask
+ result = (result ^ signbit) - signbit
result = result_type(result)
return (result, pos)
shift += 7
@@ -159,11 +159,11 @@ def _SignedVarintDecoder(mask, result_type):
# (e.g. the C++ implementation) simpler.
_DecodeVarint = _VarintDecoder((1 << 64) - 1, long)
-_DecodeSignedVarint = _SignedVarintDecoder((1 << 64) - 1, long)
+_DecodeSignedVarint = _SignedVarintDecoder(64, long)
# Use these versions for values which must be limited to 32 bits.
_DecodeVarint32 = _VarintDecoder((1 << 32) - 1, int)
-_DecodeSignedVarint32 = _SignedVarintDecoder((1 << 32) - 1, int)
+_DecodeSignedVarint32 = _SignedVarintDecoder(32, int)
def ReadTag(buffer, pos):
@@ -642,10 +642,10 @@ def MessageDecoder(field_number, is_repeated, is_packed, key, new_default):
MESSAGE_SET_ITEM_TAG = encoder.TagBytes(1, wire_format.WIRETYPE_START_GROUP)
-def MessageSetItemDecoder(extensions_by_number):
+def MessageSetItemDecoder(descriptor):
"""Returns a decoder for a MessageSet item.
- The parameter is the _extensions_by_number map for the message class.
+ The parameter is the message Descriptor.
The message set message looks like this:
message MessageSet {
@@ -694,7 +694,7 @@ def MessageSetItemDecoder(extensions_by_number):
if message_start == -1:
raise _DecodeError('MessageSet item missing message.')
- extension = extensions_by_number.get(type_id)
+ extension = message.Extensions._FindExtensionByNumber(type_id)
if extension is not None:
value = field_dict.get(extension)
if value is None:
diff --git a/python/google/protobuf/internal/descriptor_pool_test.py b/python/google/protobuf/internal/descriptor_pool_test.py
index d4de2d81..1e710dcf 100644
--- a/python/google/protobuf/internal/descriptor_pool_test.py
+++ b/python/google/protobuf/internal/descriptor_pool_test.py
@@ -254,6 +254,53 @@ class DescriptorPoolTest(unittest.TestCase):
with self.assertRaises(KeyError):
self.pool.FindFieldByName('Does not exist')
+ def testFindAllExtensions(self):
+ factory1_message = self.pool.FindMessageTypeByName(
+ 'google.protobuf.python.internal.Factory1Message')
+ factory2_message = self.pool.FindMessageTypeByName(
+ 'google.protobuf.python.internal.Factory2Message')
+ # An extension defined in a message.
+ one_more_field = factory2_message.extensions_by_name['one_more_field']
+ self.pool.AddExtensionDescriptor(one_more_field)
+ # An extension defined at file scope.
+ factory_test2 = self.pool.FindFileByName(
+ 'google/protobuf/internal/factory_test2.proto')
+ another_field = factory_test2.extensions_by_name['another_field']
+ self.pool.AddExtensionDescriptor(another_field)
+
+ extensions = self.pool.FindAllExtensions(factory1_message)
+ expected_extension_numbers = set([one_more_field, another_field])
+ self.assertEqual(expected_extension_numbers, set(extensions))
+ # Verify that mutating the returned list does not affect the pool.
+ extensions.append('unexpected_element')
+ # Get the extensions again, the returned value does not contain the
+ # 'unexpected_element'.
+ extensions = self.pool.FindAllExtensions(factory1_message)
+ self.assertEqual(expected_extension_numbers, set(extensions))
+
+ def testFindExtensionByNumber(self):
+ factory1_message = self.pool.FindMessageTypeByName(
+ 'google.protobuf.python.internal.Factory1Message')
+ factory2_message = self.pool.FindMessageTypeByName(
+ 'google.protobuf.python.internal.Factory2Message')
+ # An extension defined in a message.
+ one_more_field = factory2_message.extensions_by_name['one_more_field']
+ self.pool.AddExtensionDescriptor(one_more_field)
+ # An extension defined at file scope.
+ factory_test2 = self.pool.FindFileByName(
+ 'google/protobuf/internal/factory_test2.proto')
+ another_field = factory_test2.extensions_by_name['another_field']
+ self.pool.AddExtensionDescriptor(another_field)
+
+ # An extension defined in a message.
+ extension = self.pool.FindExtensionByNumber(factory1_message, 1001)
+ self.assertEqual(extension.name, 'one_more_field')
+ # An extension defined at file scope.
+ extension = self.pool.FindExtensionByNumber(factory1_message, 1002)
+ self.assertEqual(extension.name, 'another_field')
+ with self.assertRaises(KeyError):
+ extension = self.pool.FindExtensionByNumber(factory1_message, 1234567)
+
def testExtensionsAreNotFields(self):
with self.assertRaises(KeyError):
self.pool.FindFieldByName('google.protobuf.python.internal.another_field')
diff --git a/python/google/protobuf/internal/message_factory_test.py b/python/google/protobuf/internal/message_factory_test.py
index 7bb7d1ac..4caa2443 100644
--- a/python/google/protobuf/internal/message_factory_test.py
+++ b/python/google/protobuf/internal/message_factory_test.py
@@ -114,18 +114,18 @@ class MessageFactoryTest(unittest.TestCase):
).issubset(set(messages.keys())))
self._ExerciseDynamicClass(
messages['google.protobuf.python.internal.Factory2Message'])
- self.assertTrue(
- set(['google.protobuf.python.internal.Factory2Message.one_more_field',
- 'google.protobuf.python.internal.another_field'],
- ).issubset(
- set(messages['google.protobuf.python.internal.Factory1Message']
- ._extensions_by_name.keys())))
factory_msg1 = messages['google.protobuf.python.internal.Factory1Message']
+ self.assertTrue(set(
+ ['google.protobuf.python.internal.Factory2Message.one_more_field',
+ 'google.protobuf.python.internal.another_field'],).issubset(set(
+ ext.full_name
+ for ext in factory_msg1.DESCRIPTOR.file.pool.FindAllExtensions(
+ factory_msg1.DESCRIPTOR))))
msg1 = messages['google.protobuf.python.internal.Factory1Message']()
- ext1 = factory_msg1._extensions_by_name[
- 'google.protobuf.python.internal.Factory2Message.one_more_field']
- ext2 = factory_msg1._extensions_by_name[
- 'google.protobuf.python.internal.another_field']
+ ext1 = msg1.Extensions._FindExtensionByName(
+ 'google.protobuf.python.internal.Factory2Message.one_more_field')
+ ext2 = msg1.Extensions._FindExtensionByName(
+ 'google.protobuf.python.internal.another_field')
msg1.Extensions[ext1] = 'test1'
msg1.Extensions[ext2] = 'test2'
self.assertEqual('test1', msg1.Extensions[ext1])
diff --git a/python/google/protobuf/internal/python_message.py b/python/google/protobuf/internal/python_message.py
index dc6565d4..4b701039 100755
--- a/python/google/protobuf/internal/python_message.py
+++ b/python/google/protobuf/internal/python_message.py
@@ -51,22 +51,11 @@ this file*.
__author__ = 'robinson@google.com (Will Robinson)'
from io import BytesIO
-import sys
import struct
+import sys
import weakref
import six
-try:
- import six.moves.copyreg as copyreg
-except ImportError:
- # On some platforms, for example gMac, we run native Python because there is
- # nothing like hermetic Python. This means lesser control on the system and
- # the six.moves package may be missing (is missing on 20150321 on gMac). Be
- # extra conservative and try to load the old replacement if it fails.
- try:
- import copy_reg as copyreg #PY26
- except ImportError:
- import copyreg
# We use "as" to avoid name collisions with variables.
from google.protobuf.internal import containers
@@ -162,12 +151,10 @@ class GeneratedProtocolMessageType(type):
"""
descriptor = dictionary[GeneratedProtocolMessageType._DESCRIPTOR_KEY]
cls._decoders_by_tag = {}
- cls._extensions_by_name = {}
- cls._extensions_by_number = {}
if (descriptor.has_options and
descriptor.GetOptions().message_set_wire_format):
cls._decoders_by_tag[decoder.MESSAGE_SET_ITEM_TAG] = (
- decoder.MessageSetItemDecoder(cls._extensions_by_number), None)
+ decoder.MessageSetItemDecoder(descriptor), None)
# Attach stuff to each FieldDescriptor for quick lookup later on.
for field in descriptor.fields:
@@ -181,7 +168,6 @@ class GeneratedProtocolMessageType(type):
_AddStaticMethods(cls)
_AddMessageMethods(descriptor, cls)
_AddPrivateHelperMethods(descriptor, cls)
- copyreg.pickle(cls, lambda obj: (cls, (), obj.__getstate__()))
superclass = super(GeneratedProtocolMessageType, cls)
superclass.__init__(name, bases, dictionary)
@@ -747,32 +733,21 @@ def _AddPropertiesForExtensions(descriptor, cls):
constant_name = extension_name.upper() + "_FIELD_NUMBER"
setattr(cls, constant_name, extension_field.number)
+ # TODO(amauryfa): Migrate all users of these attributes to functions like
+ # pool.FindExtensionByNumber(descriptor).
+ if descriptor.file is not None:
+ # TODO(amauryfa): Use cls.MESSAGE_FACTORY.pool when available.
+ pool = descriptor.file.pool
+ cls._extensions_by_number = pool._extensions_by_number[descriptor]
+ cls._extensions_by_name = pool._extensions_by_name[descriptor]
def _AddStaticMethods(cls):
# TODO(robinson): This probably needs to be thread-safe(?)
def RegisterExtension(extension_handle):
extension_handle.containing_type = cls.DESCRIPTOR
+ # TODO(amauryfa): Use cls.MESSAGE_FACTORY.pool when available.
+ cls.DESCRIPTOR.file.pool.AddExtensionDescriptor(extension_handle)
_AttachFieldHelpers(cls, extension_handle)
-
- # Try to insert our extension, failing if an extension with the same number
- # already exists.
- actual_handle = cls._extensions_by_number.setdefault(
- extension_handle.number, extension_handle)
- if actual_handle is not extension_handle:
- raise AssertionError(
- 'Extensions "%s" and "%s" both try to extend message type "%s" with '
- 'field number %d.' %
- (extension_handle.full_name, actual_handle.full_name,
- cls.DESCRIPTOR.full_name, extension_handle.number))
-
- cls._extensions_by_name[extension_handle.full_name] = extension_handle
-
- handle = extension_handle # avoid line wrapping
- if _IsMessageSetExtension(handle):
- # MessageSet extension. Also register under type name.
- cls._extensions_by_name[
- extension_handle.message_type.full_name] = extension_handle
-
cls.RegisterExtension = staticmethod(RegisterExtension)
def FromString(s):
@@ -1230,7 +1205,7 @@ def _AddMergeFromMethod(cls):
if not isinstance(msg, cls):
raise TypeError(
"Parameter to MergeFrom() must be instance of same class: "
- "expected %s got %s." % (cls.__name__, type(msg).__name__))
+ 'expected %s got %s.' % (cls.__name__, msg.__class__.__name__))
assert msg is not self
self._Modified()
@@ -1284,6 +1259,12 @@ def _AddWhichOneofMethod(message_descriptor, cls):
cls.WhichOneof = WhichOneof
+def _AddReduceMethod(cls):
+ def __reduce__(self): # pylint: disable=invalid-name
+ return (type(self), (), self.__getstate__())
+ cls.__reduce__ = __reduce__
+
+
def _Clear(self):
# Clear fields.
self._fields = {}
@@ -1329,6 +1310,7 @@ def _AddMessageMethods(message_descriptor, cls):
_AddIsInitializedMethod(message_descriptor, cls)
_AddMergeFromMethod(cls)
_AddWhichOneofMethod(message_descriptor, cls)
+ _AddReduceMethod(cls)
# Adds methods which do not depend on cls.
cls.Clear = _Clear
cls.DiscardUnknownFields = _DiscardUnknownFields
diff --git a/python/google/protobuf/internal/reflection_test.py b/python/google/protobuf/internal/reflection_test.py
index dad79c37..0e881015 100755
--- a/python/google/protobuf/internal/reflection_test.py
+++ b/python/google/protobuf/internal/reflection_test.py
@@ -99,12 +99,12 @@ class _MiniDecoder(object):
return wire_format.UnpackTag(self.ReadVarint())
def ReadFloat(self):
- result = struct.unpack("<f", self._bytes[self._pos:self._pos+4])[0]
+ result = struct.unpack('<f', self._bytes[self._pos:self._pos+4])[0]
self._pos += 4
return result
def ReadDouble(self):
- result = struct.unpack("<d", self._bytes[self._pos:self._pos+8])[0]
+ result = struct.unpack('<d', self._bytes[self._pos:self._pos+8])[0]
self._pos += 8
return result
@@ -621,9 +621,15 @@ class ReflectionTest(BaseTestCase):
self.assertRaises(TypeError, setattr, proto, 'optional_string', 10)
self.assertRaises(TypeError, setattr, proto, 'optional_bytes', 10)
- def testIntegerTypes(self):
+ def assertIntegerTypes(self, integer_fn):
+ """Verifies setting of scalar integers.
+
+ Args:
+ integer_fn: A function to wrap the integers that will be assigned.
+ """
def TestGetAndDeserialize(field_name, value, expected_type):
proto = unittest_pb2.TestAllTypes()
+ value = integer_fn(value)
setattr(proto, field_name, value)
self.assertIsInstance(getattr(proto, field_name), expected_type)
proto2 = unittest_pb2.TestAllTypes()
@@ -635,7 +641,7 @@ class ReflectionTest(BaseTestCase):
TestGetAndDeserialize('optional_uint32', 1 << 30, int)
try:
integer_64 = long
- except NameError: # Python3
+ except NameError: # Python3
integer_64 = int
if struct.calcsize('L') == 4:
# Python only has signed ints, so 32-bit python can't fit an uint32
@@ -649,9 +655,33 @@ class ReflectionTest(BaseTestCase):
TestGetAndDeserialize('optional_uint64', 1 << 30, integer_64)
TestGetAndDeserialize('optional_uint64', 1 << 60, integer_64)
- def testSingleScalarBoundsChecking(self):
+ def testIntegerTypes(self):
+ self.assertIntegerTypes(lambda x: x)
+
+ def testNonStandardIntegerTypes(self):
+ self.assertIntegerTypes(test_util.NonStandardInteger)
+
+ def testIllegalValuesForIntegers(self):
+ pb = unittest_pb2.TestAllTypes()
+
+ # Strings are illegal, even when the represent an integer.
+ with self.assertRaises(TypeError):
+ pb.optional_uint64 = '2'
+
+ # The exact error should propagate with a poorly written custom integer.
+ with self.assertRaisesRegexp(RuntimeError, 'my_error'):
+ pb.optional_uint64 = test_util.NonStandardInteger(5, 'my_error')
+
+ def assetIntegerBoundsChecking(self, integer_fn):
+ """Verifies bounds checking for scalar integer fields.
+
+ Args:
+ integer_fn: A function to wrap the integers that will be assigned.
+ """
def TestMinAndMaxIntegers(field_name, expected_min, expected_max):
pb = unittest_pb2.TestAllTypes()
+ expected_min = integer_fn(expected_min)
+ expected_max = integer_fn(expected_max)
setattr(pb, field_name, expected_min)
self.assertEqual(expected_min, getattr(pb, field_name))
setattr(pb, field_name, expected_max)
@@ -663,11 +693,22 @@ class ReflectionTest(BaseTestCase):
TestMinAndMaxIntegers('optional_uint32', 0, 0xffffffff)
TestMinAndMaxIntegers('optional_int64', -(1 << 63), (1 << 63) - 1)
TestMinAndMaxIntegers('optional_uint64', 0, 0xffffffffffffffff)
+ # A bit of white-box testing since -1 is an int and not a long in C++ and
+ # so goes down a different path.
+ pb = unittest_pb2.TestAllTypes()
+ with self.assertRaises(ValueError):
+ pb.optional_uint64 = integer_fn(-(1 << 63))
pb = unittest_pb2.TestAllTypes()
- pb.optional_nested_enum = 1
+ pb.optional_nested_enum = integer_fn(1)
self.assertEqual(1, pb.optional_nested_enum)
+ def testSingleScalarBoundsChecking(self):
+ self.assetIntegerBoundsChecking(lambda x: x)
+
+ def testNonStandardSingleScalarBoundsChecking(self):
+ self.assetIntegerBoundsChecking(test_util.NonStandardInteger)
+
def testRepeatedScalarTypeSafety(self):
proto = unittest_pb2.TestAllTypes()
self.assertRaises(TypeError, proto.repeated_int32.append, 1.1)
@@ -1187,12 +1228,18 @@ class ReflectionTest(BaseTestCase):
self.assertTrue(not extendee_proto.HasExtension(extension))
def testRegisteredExtensions(self):
- self.assertTrue('protobuf_unittest.optional_int32_extension' in
- unittest_pb2.TestAllExtensions._extensions_by_name)
- self.assertTrue(1 in unittest_pb2.TestAllExtensions._extensions_by_number)
+ pool = unittest_pb2.DESCRIPTOR.pool
+ self.assertTrue(
+ pool.FindExtensionByNumber(
+ unittest_pb2.TestAllExtensions.DESCRIPTOR, 1))
+ self.assertIs(
+ pool.FindExtensionByName(
+ 'protobuf_unittest.optional_int32_extension').containing_type,
+ unittest_pb2.TestAllExtensions.DESCRIPTOR)
# Make sure extensions haven't been registered into types that shouldn't
# have any.
- self.assertEqual(0, len(unittest_pb2.TestAllTypes._extensions_by_name))
+ self.assertEqual(0, len(
+ pool.FindAllExtensions(unittest_pb2.TestAllTypes.DESCRIPTOR)))
# If message A directly contains message B, and
# a.HasField('b') is currently False, then mutating any
diff --git a/python/google/protobuf/internal/test_util.py b/python/google/protobuf/internal/test_util.py
index 2c805599..269d0e2d 100755
--- a/python/google/protobuf/internal/test_util.py
+++ b/python/google/protobuf/internal/test_util.py
@@ -36,8 +36,9 @@ This is intentionally modeled on C++ code in
__author__ = 'robinson@google.com (Will Robinson)'
+import numbers
+import operator
import os.path
-
import sys
from google.protobuf import unittest_import_pb2
@@ -694,3 +695,154 @@ def SetAllUnpackedFields(message):
message.unpacked_bool.extend([True, False])
message.unpacked_enum.extend([unittest_pb2.FOREIGN_BAR,
unittest_pb2.FOREIGN_BAZ])
+
+
+class NonStandardInteger(numbers.Integral):
+ """An integer object that does not subclass int.
+
+ This is used to verify that both C++ and regular proto systems can handle
+ integer others than int and long and that they handle them in predictable
+ ways.
+
+ NonStandardInteger is the minimal legal specification for a custom Integral.
+ As such, it does not support 0 < x < 5 and it is not hashable.
+
+ Note: This is added here instead of relying on numpy or a similar library with
+ custom integers to limit dependencies.
+ """
+
+ def __init__(self, val, error_string_on_conversion=None):
+ assert isinstance(val, numbers.Integral)
+ if isinstance(val, NonStandardInteger):
+ val = val.val
+ self.val = val
+ self.error_string_on_conversion = error_string_on_conversion
+
+ def __long__(self):
+ if self.error_string_on_conversion:
+ raise RuntimeError(self.error_string_on_conversion)
+ return long(self.val)
+
+ def __abs__(self):
+ return NonStandardInteger(operator.abs(self.val))
+
+ def __add__(self, y):
+ return NonStandardInteger(operator.add(self.val, y))
+
+ def __div__(self, y):
+ return NonStandardInteger(operator.div(self.val, y))
+
+ def __eq__(self, y):
+ return operator.eq(self.val, y)
+
+ def __floordiv__(self, y):
+ return NonStandardInteger(operator.floordiv(self.val, y))
+
+ def __truediv__(self, y):
+ return NonStandardInteger(operator.truediv(self.val, y))
+
+ def __invert__(self):
+ return NonStandardInteger(operator.invert(self.val))
+
+ def __mod__(self, y):
+ return NonStandardInteger(operator.mod(self.val, y))
+
+ def __mul__(self, y):
+ return NonStandardInteger(operator.mul(self.val, y))
+
+ def __neg__(self):
+ return NonStandardInteger(operator.neg(self.val))
+
+ def __pos__(self):
+ return NonStandardInteger(operator.pos(self.val))
+
+ def __pow__(self, y):
+ return NonStandardInteger(operator.pow(self.val, y))
+
+ def __trunc__(self):
+ return int(self.val)
+
+ def __radd__(self, y):
+ return NonStandardInteger(operator.add(y, self.val))
+
+ def __rdiv__(self, y):
+ return NonStandardInteger(operator.div(y, self.val))
+
+ def __rmod__(self, y):
+ return NonStandardInteger(operator.mod(y, self.val))
+
+ def __rmul__(self, y):
+ return NonStandardInteger(operator.mul(y, self.val))
+
+ def __rpow__(self, y):
+ return NonStandardInteger(operator.pow(y, self.val))
+
+ def __rfloordiv__(self, y):
+ return NonStandardInteger(operator.floordiv(y, self.val))
+
+ def __rtruediv__(self, y):
+ return NonStandardInteger(operator.truediv(y, self.val))
+
+ def __lshift__(self, y):
+ return NonStandardInteger(operator.lshift(self.val, y))
+
+ def __rshift__(self, y):
+ return NonStandardInteger(operator.rshift(self.val, y))
+
+ def __rlshift__(self, y):
+ return NonStandardInteger(operator.lshift(y, self.val))
+
+ def __rrshift__(self, y):
+ return NonStandardInteger(operator.rshift(y, self.val))
+
+ def __le__(self, y):
+ if isinstance(y, NonStandardInteger):
+ y = y.val
+ return operator.le(self.val, y)
+
+ def __lt__(self, y):
+ if isinstance(y, NonStandardInteger):
+ y = y.val
+ return operator.lt(self.val, y)
+
+ def __and__(self, y):
+ return NonStandardInteger(operator.and_(self.val, y))
+
+ def __or__(self, y):
+ return NonStandardInteger(operator.or_(self.val, y))
+
+ def __xor__(self, y):
+ return NonStandardInteger(operator.xor(self.val, y))
+
+ def __rand__(self, y):
+ return NonStandardInteger(operator.and_(y, self.val))
+
+ def __ror__(self, y):
+ return NonStandardInteger(operator.or_(y, self.val))
+
+ def __rxor__(self, y):
+ return NonStandardInteger(operator.xor(y, self.val))
+
+ def __bool__(self):
+ return self.val
+
+ def __nonzero__(self):
+ return self.val
+
+ def __ceil__(self):
+ return self
+
+ def __floor__(self):
+ return self
+
+ def __int__(self):
+ if self.error_string_on_conversion:
+ raise RuntimeError(self.error_string_on_conversion)
+ return int(self.val)
+
+ def __round__(self):
+ return self
+
+ def __repr__(self):
+ return 'NonStandardInteger(%s)' % self.val
+
diff --git a/python/google/protobuf/internal/testing_refleaks.py b/python/google/protobuf/internal/testing_refleaks.py
index c461a9f4..8ce06519 100644
--- a/python/google/protobuf/internal/testing_refleaks.py
+++ b/python/google/protobuf/internal/testing_refleaks.py
@@ -124,5 +124,3 @@ else:
def Same(func):
return func
return Same
-
-
diff --git a/python/google/protobuf/internal/text_format_test.py b/python/google/protobuf/internal/text_format_test.py
index ab481ab4..176cbd15 100755
--- a/python/google/protobuf/internal/text_format_test.py
+++ b/python/google/protobuf/internal/text_format_test.py
@@ -582,22 +582,20 @@ class OnlyWorksWithProto2RightNowTests(TextFormatBase):
% (letter,) for letter in string.ascii_uppercase))
self.CompareToGoldenText(text_format.MessageToString(message), golden)
- def testMapOrderSemantics(self):
- golden_lines = self.ReadGolden('map_test_data.txt')
- # The C++ implementation emits defaulted-value fields, while the Python
- # implementation does not. Adjusting for this is awkward, but it is
- # valuable to test against a common golden file.
- line_blacklist = (' key: 0\n', ' value: 0\n', ' key: false\n',
- ' value: false\n')
- golden_lines = [line for line in golden_lines if line not in line_blacklist]
-
- message = map_unittest_pb2.TestMap()
- text_format.ParseLines(golden_lines, message)
- candidate = text_format.MessageToString(message)
- # The Python implementation emits "1.0" for the double value that the C++
- # implementation emits as "1".
- candidate = candidate.replace('1.0', '1', 2)
- self.assertMultiLineEqual(candidate, ''.join(golden_lines))
+ # TODO(teboring): In c/137553523, not serializing default value for map entry
+ # message has been fixed. This test needs to be disabled in order to submit
+ # that cl. Add this back when c/137553523 has been submitted.
+ # def testMapOrderSemantics(self):
+ # golden_lines = self.ReadGolden('map_test_data.txt')
+
+ # message = map_unittest_pb2.TestMap()
+ # text_format.ParseLines(golden_lines, message)
+ # candidate = text_format.MessageToString(message)
+ # # The Python implementation emits "1.0" for the double value that the C++
+ # # implementation emits as "1".
+ # candidate = candidate.replace('1.0', '1', 2)
+ # candidate = candidate.replace('0.0', '0', 2)
+ # self.assertMultiLineEqual(candidate, ''.join(golden_lines))
# Tests of proto2-only features (MessageSet, extensions, etc.).
diff --git a/python/google/protobuf/internal/type_checkers.py b/python/google/protobuf/internal/type_checkers.py
index 1be3ad9a..4a76cd4e 100755
--- a/python/google/protobuf/internal/type_checkers.py
+++ b/python/google/protobuf/internal/type_checkers.py
@@ -45,6 +45,7 @@ TYPE_TO_DESERIALIZE_METHOD: A dictionary with field types and deserialization
__author__ = 'robinson@google.com (Will Robinson)'
+import numbers
import six
if six.PY3:
@@ -126,11 +127,11 @@ class IntValueChecker(object):
"""Checker used for integer fields. Performs type-check and range check."""
def CheckValue(self, proposed_value):
- if not isinstance(proposed_value, six.integer_types):
+ if not isinstance(proposed_value, numbers.Integral):
message = ('%.1024r has type %s, but expected one of: %s' %
(proposed_value, type(proposed_value), six.integer_types))
raise TypeError(message)
- if not self._MIN <= proposed_value <= self._MAX:
+ if not self._MIN <= int(proposed_value) <= self._MAX:
raise ValueError('Value out of range: %d' % proposed_value)
# We force 32-bit values to int and 64-bit values to long to make
# alternate implementations where the distinction is more significant
@@ -150,11 +151,11 @@ class EnumValueChecker(object):
self._enum_type = enum_type
def CheckValue(self, proposed_value):
- if not isinstance(proposed_value, six.integer_types):
+ if not isinstance(proposed_value, numbers.Integral):
message = ('%.1024r has type %s, but expected one of: %s' %
(proposed_value, type(proposed_value), six.integer_types))
raise TypeError(message)
- if proposed_value not in self._enum_type.values_by_number:
+ if int(proposed_value) not in self._enum_type.values_by_number:
raise ValueError('Unknown enum value: %d' % proposed_value)
return proposed_value
@@ -223,11 +224,11 @@ _VALUE_CHECKERS = {
_FieldDescriptor.CPPTYPE_UINT32: Uint32ValueChecker(),
_FieldDescriptor.CPPTYPE_UINT64: Uint64ValueChecker(),
_FieldDescriptor.CPPTYPE_DOUBLE: TypeCheckerWithDefault(
- 0.0, float, int, long),
+ 0.0, numbers.Real),
_FieldDescriptor.CPPTYPE_FLOAT: TypeCheckerWithDefault(
- 0.0, float, int, long),
+ 0.0, numbers.Real),
_FieldDescriptor.CPPTYPE_BOOL: TypeCheckerWithDefault(
- False, bool, int),
+ False, bool, numbers.Integral),
_FieldDescriptor.CPPTYPE_STRING: TypeCheckerWithDefault(b'', bytes),
}
diff --git a/python/google/protobuf/json_format.py b/python/google/protobuf/json_format.py
index c42371d0..d02cb091 100644
--- a/python/google/protobuf/json_format.py
+++ b/python/google/protobuf/json_format.py
@@ -43,9 +43,9 @@ Simple usage example:
__author__ = 'jieluo@google.com (Jie Luo)'
try:
- from collections import OrderedDict
+ from collections import OrderedDict
except ImportError:
- from ordereddict import OrderedDict #PY26
+ from ordereddict import OrderedDict #PY26
import base64
import json
import math
diff --git a/python/google/protobuf/pyext/descriptor_pool.cc b/python/google/protobuf/pyext/descriptor_pool.cc
index a42e5431..fa66bf9a 100644
--- a/python/google/protobuf/pyext/descriptor_pool.cc
+++ b/python/google/protobuf/pyext/descriptor_pool.cc
@@ -319,6 +319,51 @@ PyObject* FindFileContainingSymbol(PyDescriptorPool* self, PyObject* arg) {
return PyFileDescriptor_FromDescriptor(file_descriptor);
}
+PyObject* FindExtensionByNumber(PyDescriptorPool* self, PyObject* args) {
+ PyObject* message_descriptor;
+ int number;
+ if (!PyArg_ParseTuple(args, "Oi", &message_descriptor, &number)) {
+ return NULL;
+ }
+ const Descriptor* descriptor = PyMessageDescriptor_AsDescriptor(
+ message_descriptor);
+ if (descriptor == NULL) {
+ return NULL;
+ }
+
+ const FieldDescriptor* extension_descriptor =
+ self->pool->FindExtensionByNumber(descriptor, number);
+ if (extension_descriptor == NULL) {
+ PyErr_Format(PyExc_KeyError, "Couldn't find extension %d", number);
+ return NULL;
+ }
+
+ return PyFieldDescriptor_FromDescriptor(extension_descriptor);
+}
+
+PyObject* FindAllExtensions(PyDescriptorPool* self, PyObject* arg) {
+ const Descriptor* descriptor = PyMessageDescriptor_AsDescriptor(arg);
+ if (descriptor == NULL) {
+ return NULL;
+ }
+
+ std::vector<const FieldDescriptor*> extensions;
+ self->pool->FindAllExtensions(descriptor, &extensions);
+
+ ScopedPyObjectPtr result(PyList_New(extensions.size()));
+ if (result == NULL) {
+ return NULL;
+ }
+ for (int i = 0; i < extensions.size(); i++) {
+ PyObject* extension = PyFieldDescriptor_FromDescriptor(extensions[i]);
+ if (extension == NULL) {
+ return NULL;
+ }
+ PyList_SET_ITEM(result.get(), i, extension); // Steals the reference.
+ }
+ return result.release();
+}
+
// These functions should not exist -- the only valid way to create
// descriptors is to call Add() or AddSerializedFile().
// But these AddDescriptor() functions were created in Python and some people
@@ -376,6 +421,22 @@ PyObject* AddEnumDescriptor(PyDescriptorPool* self, PyObject* descriptor) {
Py_RETURN_NONE;
}
+PyObject* AddExtensionDescriptor(PyDescriptorPool* self, PyObject* descriptor) {
+ const FieldDescriptor* extension_descriptor =
+ PyFieldDescriptor_AsDescriptor(descriptor);
+ if (!extension_descriptor) {
+ return NULL;
+ }
+ if (extension_descriptor !=
+ self->pool->FindExtensionByName(extension_descriptor->full_name())) {
+ PyErr_Format(PyExc_ValueError,
+ "The extension descriptor %s does not belong to this pool",
+ extension_descriptor->full_name().c_str());
+ return NULL;
+ }
+ Py_RETURN_NONE;
+}
+
// The code below loads new Descriptors from a serialized FileDescriptorProto.
@@ -475,6 +536,8 @@ static PyMethodDef Methods[] = {
"No-op. Add() must have been called before." },
{ "AddEnumDescriptor", (PyCFunction)AddEnumDescriptor, METH_O,
"No-op. Add() must have been called before." },
+ { "AddExtensionDescriptor", (PyCFunction)AddExtensionDescriptor, METH_O,
+ "No-op. Add() must have been called before." },
{ "FindFileByName", (PyCFunction)FindFileByName, METH_O,
"Searches for a file descriptor by its .proto name." },
@@ -495,6 +558,10 @@ static PyMethodDef Methods[] = {
{ "FindFileContainingSymbol", (PyCFunction)FindFileContainingSymbol, METH_O,
"Gets the FileDescriptor containing the specified symbol." },
+ { "FindExtensionByNumber", (PyCFunction)FindExtensionByNumber, METH_VARARGS,
+ "Gets the extension descriptor for the given number." },
+ { "FindAllExtensions", (PyCFunction)FindAllExtensions, METH_O,
+ "Gets all known extensions of the given message descriptor." },
{NULL}
};
diff --git a/python/google/protobuf/pyext/extension_dict.cc b/python/google/protobuf/pyext/extension_dict.cc
index dbb7bca0..43ee5d15 100644
--- a/python/google/protobuf/pyext/extension_dict.cc
+++ b/python/google/protobuf/pyext/extension_dict.cc
@@ -38,6 +38,7 @@
#include <google/protobuf/descriptor.h>
#include <google/protobuf/dynamic_message.h>
#include <google/protobuf/message.h>
+#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/pyext/descriptor.h>
#include <google/protobuf/pyext/message.h>
#include <google/protobuf/pyext/message_factory.h>
@@ -46,6 +47,16 @@
#include <google/protobuf/pyext/scoped_pyobject_ptr.h>
#include <google/protobuf/stubs/shared_ptr.h>
+#if PY_MAJOR_VERSION >= 3
+ #if PY_VERSION_HEX < 0x03030000
+ #error "Python 3.0 - 3.2 are not supported."
+ #endif
+ #define PyString_AsStringAndSize(ob, charpp, sizep) \
+ (PyUnicode_Check(ob)? \
+ ((*(charpp) = PyUnicode_AsUTF8AndSize(ob, (sizep))) == NULL? -1: 0): \
+ PyBytes_AsStringAndSize(ob, (charpp), (sizep)))
+#endif
+
namespace google {
namespace protobuf {
namespace python {
@@ -90,6 +101,7 @@ PyObject* subscript(ExtensionDict* self, PyObject* key) {
if (descriptor->label() != FieldDescriptor::LABEL_REPEATED &&
descriptor->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
+ // TODO(plabatut): consider building the class on the fly!
PyObject* sub_message = cmessage::InternalGetSubMessage(
self->parent, descriptor);
if (sub_message == NULL) {
@@ -101,9 +113,21 @@ PyObject* subscript(ExtensionDict* self, PyObject* key) {
if (descriptor->label() == FieldDescriptor::LABEL_REPEATED) {
if (descriptor->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
- CMessageClass* message_class = message_factory::GetMessageClass(
+ // On the fly message class creation is needed to support the following
+ // situation:
+ // 1- add FileDescriptor to the pool that contains extensions of a message
+ // defined by another proto file. Do not create any message classes.
+ // 2- instantiate an extended message, and access the extension using
+ // the field descriptor.
+ // 3- the extension submessage fails to be returned, because no class has
+ // been created.
+ // It happens when deserializing text proto format, or when enumerating
+ // fields of a deserialized message.
+ CMessageClass* message_class = message_factory::GetOrCreateMessageClass(
cmessage::GetFactoryForMessage(self->parent),
descriptor->message_type());
+ ScopedPyObjectPtr message_class_handler(
+ reinterpret_cast<PyObject*>(message_class));
if (message_class == NULL) {
return NULL;
}
@@ -154,34 +178,51 @@ int ass_subscript(ExtensionDict* self, PyObject* key, PyObject* value) {
return 0;
}
-PyObject* _FindExtensionByName(ExtensionDict* self, PyObject* name) {
- ScopedPyObjectPtr extensions_by_name(PyObject_GetAttrString(
- reinterpret_cast<PyObject*>(self->parent), "_extensions_by_name"));
- if (extensions_by_name == NULL) {
+PyObject* _FindExtensionByName(ExtensionDict* self, PyObject* arg) {
+ char* name;
+ Py_ssize_t name_size;
+ if (PyString_AsStringAndSize(arg, &name, &name_size) < 0) {
return NULL;
}
- PyObject* result = PyDict_GetItem(extensions_by_name.get(), name);
- if (result == NULL) {
+
+ PyDescriptorPool* pool = cmessage::GetFactoryForMessage(self->parent)->pool;
+ const FieldDescriptor* message_extension =
+ pool->pool->FindExtensionByName(string(name, name_size));
+ if (message_extension == NULL) {
+ // Is is the name of a message set extension?
+ const Descriptor* message_descriptor = pool->pool->FindMessageTypeByName(
+ string(name, name_size));
+ if (message_descriptor && message_descriptor->extension_count() > 0) {
+ const FieldDescriptor* extension = message_descriptor->extension(0);
+ if (extension->is_extension() &&
+ extension->containing_type()->options().message_set_wire_format() &&
+ extension->type() == FieldDescriptor::TYPE_MESSAGE &&
+ extension->label() == FieldDescriptor::LABEL_OPTIONAL) {
+ message_extension = extension;
+ }
+ }
+ }
+ if (message_extension == NULL) {
Py_RETURN_NONE;
- } else {
- Py_INCREF(result);
- return result;
}
+
+ return PyFieldDescriptor_FromDescriptor(message_extension);
}
-PyObject* _FindExtensionByNumber(ExtensionDict* self, PyObject* number) {
- ScopedPyObjectPtr extensions_by_number(PyObject_GetAttrString(
- reinterpret_cast<PyObject*>(self->parent), "_extensions_by_number"));
- if (extensions_by_number == NULL) {
+PyObject* _FindExtensionByNumber(ExtensionDict* self, PyObject* arg) {
+ int64 number = PyLong_AsLong(arg);
+ if (number == -1 && PyErr_Occurred()) {
return NULL;
}
- PyObject* result = PyDict_GetItem(extensions_by_number.get(), number);
- if (result == NULL) {
+
+ PyDescriptorPool* pool = cmessage::GetFactoryForMessage(self->parent)->pool;
+ const FieldDescriptor* message_extension = pool->pool->FindExtensionByNumber(
+ self->parent->message->GetDescriptor(), number);
+ if (message_extension == NULL) {
Py_RETURN_NONE;
- } else {
- Py_INCREF(result);
- return result;
}
+
+ return PyFieldDescriptor_FromDescriptor(message_extension);
}
ExtensionDict* NewExtensionDict(CMessage *parent) {
diff --git a/python/google/protobuf/pyext/map_container.cc b/python/google/protobuf/pyext/map_container.cc
index 318c2e7c..088ddf93 100644
--- a/python/google/protobuf/pyext/map_container.cc
+++ b/python/google/protobuf/pyext/map_container.cc
@@ -374,7 +374,7 @@ static int InitializeAndCopyToParentContainer(MapContainer* from,
// A somewhat roundabout way of copying just one field from old_message to
// new_message. This is the best we can do with what Reflection gives us.
Message* mutable_old = from->GetMutableMessage();
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
fields.push_back(from->parent_field_descriptor);
// Move the map field into the new message.
diff --git a/python/google/protobuf/pyext/message.cc b/python/google/protobuf/pyext/message.cc
index 6626ddef..c810b788 100644
--- a/python/google/protobuf/pyext/message.cc
+++ b/python/google/protobuf/pyext/message.cc
@@ -64,11 +64,11 @@
#include <google/protobuf/pyext/repeated_scalar_container.h>
#include <google/protobuf/pyext/map_container.h>
#include <google/protobuf/pyext/message_factory.h>
+#include <google/protobuf/pyext/safe_numerics.h>
#include <google/protobuf/pyext/scoped_pyobject_ptr.h>
#include <google/protobuf/stubs/strutil.h>
#if PY_MAJOR_VERSION >= 3
- #define PyInt_Check PyLong_Check
#define PyInt_AsLong PyLong_AsLong
#define PyInt_FromLong PyLong_FromLong
#define PyInt_FromSize_t PyLong_FromSize_t
@@ -92,8 +92,6 @@ namespace protobuf {
namespace python {
static PyObject* kDESCRIPTOR;
-static PyObject* k_extensions_by_name;
-static PyObject* k_extensions_by_number;
PyObject* EnumTypeWrapper_class;
static PyObject* PythonMessage_class;
static PyObject* kEmptyWeakref;
@@ -128,19 +126,6 @@ static bool AddFieldNumberToClass(
// Finalize the creation of the Message class.
static int AddDescriptors(PyObject* cls, const Descriptor* descriptor) {
- // If there are extension_ranges, the message is "extendable", and extension
- // classes will register themselves in this class.
- if (descriptor->extension_range_count() > 0) {
- ScopedPyObjectPtr by_name(PyDict_New());
- if (PyObject_SetAttr(cls, k_extensions_by_name, by_name.get()) < 0) {
- return -1;
- }
- ScopedPyObjectPtr by_number(PyDict_New());
- if (PyObject_SetAttr(cls, k_extensions_by_number, by_number.get()) < 0) {
- return -1;
- }
- }
-
// For each field set: cls.<field>_FIELD_NUMBER = <number>
for (int i = 0; i < descriptor->field_count(); ++i) {
if (!AddFieldNumberToClass(cls, descriptor->field(i))) {
@@ -357,6 +342,61 @@ static int InsertEmptyWeakref(PyTypeObject *base_type) {
#endif // PY_MAJOR_VERSION >= 3
}
+// The _extensions_by_name dictionary is built on every access.
+// TODO(amauryfa): Migrate all users to pool.FindAllExtensions()
+static PyObject* GetExtensionsByName(CMessageClass *self, void *closure) {
+ const PyDescriptorPool* pool = self->py_message_factory->pool;
+
+ std::vector<const FieldDescriptor*> extensions;
+ pool->pool->FindAllExtensions(self->message_descriptor, &extensions);
+
+ ScopedPyObjectPtr result(PyDict_New());
+ for (int i = 0; i < extensions.size(); i++) {
+ ScopedPyObjectPtr extension(
+ PyFieldDescriptor_FromDescriptor(extensions[i]));
+ if (extension == NULL) {
+ return NULL;
+ }
+ if (PyDict_SetItemString(result.get(), extensions[i]->full_name().c_str(),
+ extension.get()) < 0) {
+ return NULL;
+ }
+ }
+ return result.release();
+}
+
+// The _extensions_by_number dictionary is built on every access.
+// TODO(amauryfa): Migrate all users to pool.FindExtensionByNumber()
+static PyObject* GetExtensionsByNumber(CMessageClass *self, void *closure) {
+ const PyDescriptorPool* pool = self->py_message_factory->pool;
+
+ std::vector<const FieldDescriptor*> extensions;
+ pool->pool->FindAllExtensions(self->message_descriptor, &extensions);
+
+ ScopedPyObjectPtr result(PyDict_New());
+ for (int i = 0; i < extensions.size(); i++) {
+ ScopedPyObjectPtr extension(
+ PyFieldDescriptor_FromDescriptor(extensions[i]));
+ if (extension == NULL) {
+ return NULL;
+ }
+ ScopedPyObjectPtr number(PyInt_FromLong(extensions[i]->number()));
+ if (number == NULL) {
+ return NULL;
+ }
+ if (PyDict_SetItem(result.get(), number.get(), extension.get()) < 0) {
+ return NULL;
+ }
+ }
+ return result.release();
+}
+
+static PyGetSetDef Getters[] = {
+ {"_extensions_by_name", (getter)GetExtensionsByName, NULL},
+ {"_extensions_by_number", (getter)GetExtensionsByNumber, NULL},
+ {NULL}
+};
+
} // namespace message_meta
PyTypeObject CMessageClass_Type = {
@@ -389,7 +429,7 @@ PyTypeObject CMessageClass_Type = {
0, // tp_iternext
0, // tp_methods
0, // tp_members
- 0, // tp_getset
+ message_meta::Getters, // tp_getset
0, // tp_base
0, // tp_dict
0, // tp_descr_get
@@ -525,23 +565,10 @@ int ForEachCompositeField(CMessage* self, Visitor visitor) {
// ---------------------------------------------------------------------
-// Constants used for integer type range checking.
-PyObject* kPythonZero;
-PyObject* kint32min_py;
-PyObject* kint32max_py;
-PyObject* kuint32max_py;
-PyObject* kint64min_py;
-PyObject* kint64max_py;
-PyObject* kuint64max_py;
-
PyObject* EncodeError_class;
PyObject* DecodeError_class;
PyObject* PickleError_class;
-// Constant PyString values used for GetAttr/GetItem.
-static PyObject* k_cdescriptor;
-static PyObject* kfull_name;
-
/* Is 64bit */
void FormatTypeError(PyObject* arg, char* expected_types) {
PyObject* repr = PyObject_Repr(arg);
@@ -555,68 +582,126 @@ void FormatTypeError(PyObject* arg, char* expected_types) {
}
}
-template<class T>
-bool CheckAndGetInteger(
- PyObject* arg, T* value, PyObject* min, PyObject* max) {
- bool is_long = PyLong_Check(arg);
-#if PY_MAJOR_VERSION < 3
- if (!PyInt_Check(arg) && !is_long) {
- FormatTypeError(arg, "int, long");
- return false;
+void OutOfRangeError(PyObject* arg) {
+ PyObject *s = PyObject_Str(arg);
+ if (s) {
+ PyErr_Format(PyExc_ValueError,
+ "Value out of range: %s",
+ PyString_AsString(s));
+ Py_DECREF(s);
}
- if (PyObject_Compare(min, arg) > 0 || PyObject_Compare(max, arg) < 0) {
-#else
- if (!is_long) {
- FormatTypeError(arg, "int");
+}
+
+template<class RangeType, class ValueType>
+bool VerifyIntegerCastAndRange(PyObject* arg, ValueType value) {
+ if GOOGLE_PREDICT_FALSE(value == -1 && PyErr_Occurred()) {
+ if (PyErr_ExceptionMatches(PyExc_OverflowError)) {
+ // Replace it with the same ValueError as pure python protos instead of
+ // the default one.
+ PyErr_Clear();
+ OutOfRangeError(arg);
+ } // Otherwise propagate existing error.
return false;
}
- if (PyObject_RichCompareBool(min, arg, Py_LE) != 1 ||
- PyObject_RichCompareBool(max, arg, Py_GE) != 1) {
-#endif
- if (!PyErr_Occurred()) {
- PyObject *s = PyObject_Str(arg);
- if (s) {
- PyErr_Format(PyExc_ValueError,
- "Value out of range: %s",
- PyString_AsString(s));
- Py_DECREF(s);
- }
- }
+ if GOOGLE_PREDICT_FALSE(!IsValidNumericCast<RangeType>(value)) {
+ OutOfRangeError(arg);
return false;
}
+ return true;
+}
+
+template<class T>
+bool CheckAndGetInteger(PyObject* arg, T* value) {
+ // The fast path.
#if PY_MAJOR_VERSION < 3
- if (!is_long) {
- *value = static_cast<T>(PyInt_AsLong(arg));
- } else // NOLINT
+ // For the typical case, offer a fast path.
+ if GOOGLE_PREDICT_TRUE(PyInt_Check(arg)) {
+ long int_result = PyInt_AsLong(arg);
+ if GOOGLE_PREDICT_TRUE(IsValidNumericCast<T>(int_result)) {
+ *value = static_cast<T>(int_result);
+ return true;
+ } else {
+ OutOfRangeError(arg);
+ return false;
+ }
+ }
#endif
- {
- if (min == kPythonZero) {
- *value = static_cast<T>(PyLong_AsUnsignedLongLong(arg));
+ // This effectively defines an integer as "an object that can be cast as
+ // an integer and can be used as an ordinal number".
+ // This definition includes everything that implements numbers.Integral
+ // and shouldn't cast the net too wide.
+ if GOOGLE_PREDICT_FALSE(!PyIndex_Check(arg)) {
+ FormatTypeError(arg, "int, long");
+ return false;
+ }
+
+ // Now we have an integral number so we can safely use PyLong_ functions.
+ // We need to treat the signed and unsigned cases differently in case arg is
+ // holding a value above the maximum for signed longs.
+ if (std::numeric_limits<T>::min() == 0) {
+ // Unsigned case.
+ unsigned PY_LONG_LONG ulong_result;
+ if (PyLong_Check(arg)) {
+ ulong_result = PyLong_AsUnsignedLongLong(arg);
+ } else {
+ // Unlike PyLong_AsLongLong, PyLong_AsUnsignedLongLong is very
+ // picky about the exact type.
+ PyObject* casted = PyNumber_Long(arg);
+ if GOOGLE_PREDICT_FALSE(casted == NULL) {
+ // Propagate existing error.
+ return false;
+ }
+ ulong_result = PyLong_AsUnsignedLongLong(casted);
+ Py_DECREF(casted);
+ }
+ if (VerifyIntegerCastAndRange<T, unsigned PY_LONG_LONG>(arg,
+ ulong_result)) {
+ *value = static_cast<T>(ulong_result);
+ } else {
+ return false;
+ }
+ } else {
+ // Signed case.
+ PY_LONG_LONG long_result;
+ PyNumberMethods *nb;
+ if ((nb = arg->ob_type->tp_as_number) != NULL && nb->nb_int != NULL) {
+ // PyLong_AsLongLong requires it to be a long or to have an __int__()
+ // method.
+ long_result = PyLong_AsLongLong(arg);
} else {
- *value = static_cast<T>(PyLong_AsLongLong(arg));
+ // Valid subclasses of numbers.Integral should have a __long__() method
+ // so fall back to that.
+ PyObject* casted = PyNumber_Long(arg);
+ if GOOGLE_PREDICT_FALSE(casted == NULL) {
+ // Propagate existing error.
+ return false;
+ }
+ long_result = PyLong_AsLongLong(casted);
+ Py_DECREF(casted);
+ }
+ if (VerifyIntegerCastAndRange<T, PY_LONG_LONG>(arg, long_result)) {
+ *value = static_cast<T>(long_result);
+ } else {
+ return false;
}
}
+
return true;
}
// These are referenced by repeated_scalar_container, and must
// be explicitly instantiated.
-template bool CheckAndGetInteger<int32>(
- PyObject*, int32*, PyObject*, PyObject*);
-template bool CheckAndGetInteger<int64>(
- PyObject*, int64*, PyObject*, PyObject*);
-template bool CheckAndGetInteger<uint32>(
- PyObject*, uint32*, PyObject*, PyObject*);
-template bool CheckAndGetInteger<uint64>(
- PyObject*, uint64*, PyObject*, PyObject*);
+template bool CheckAndGetInteger<int32>(PyObject*, int32*);
+template bool CheckAndGetInteger<int64>(PyObject*, int64*);
+template bool CheckAndGetInteger<uint32>(PyObject*, uint32*);
+template bool CheckAndGetInteger<uint64>(PyObject*, uint64*);
bool CheckAndGetDouble(PyObject* arg, double* value) {
- if (!PyInt_Check(arg) && !PyLong_Check(arg) &&
- !PyFloat_Check(arg)) {
+ *value = PyFloat_AsDouble(arg);
+ if GOOGLE_PREDICT_FALSE(*value == -1 && PyErr_Occurred()) {
FormatTypeError(arg, "int, long, float");
return false;
}
- *value = PyFloat_AsDouble(arg);
return true;
}
@@ -630,11 +715,13 @@ bool CheckAndGetFloat(PyObject* arg, float* value) {
}
bool CheckAndGetBool(PyObject* arg, bool* value) {
- if (!PyInt_Check(arg) && !PyBool_Check(arg) && !PyLong_Check(arg)) {
+ long long_value = PyInt_AsLong(arg);
+ if (long_value == -1 && PyErr_Occurred()) {
FormatTypeError(arg, "int, long, bool");
return false;
}
- *value = static_cast<bool>(PyInt_AsLong(arg));
+ *value = static_cast<bool>(long_value);
+
return true;
}
@@ -966,20 +1053,7 @@ int InternalDeleteRepeatedField(
int min, max;
length = reflection->FieldSize(*message, field_descriptor);
- if (PyInt_Check(slice) || PyLong_Check(slice)) {
- from = to = PyLong_AsLong(slice);
- if (from < 0) {
- from = to = length + from;
- }
- step = 1;
- min = max = from;
-
- // Range check.
- if (from < 0 || from >= length) {
- PyErr_Format(PyExc_IndexError, "list assignment index out of range");
- return -1;
- }
- } else if (PySlice_Check(slice)) {
+ if (PySlice_Check(slice)) {
from = to = step = slice_length = 0;
PySlice_GetIndicesEx(
#if PY_MAJOR_VERSION < 3
@@ -996,8 +1070,23 @@ int InternalDeleteRepeatedField(
max = from;
}
} else {
- PyErr_SetString(PyExc_TypeError, "list indices must be integers");
- return -1;
+ from = to = PyLong_AsLong(slice);
+ if (from == -1 && PyErr_Occurred()) {
+ PyErr_SetString(PyExc_TypeError, "list indices must be integers");
+ return -1;
+ }
+
+ if (from < 0) {
+ from = to = length + from;
+ }
+ step = 1;
+ min = max = from;
+
+ // Range check.
+ if (from < 0 || from >= length) {
+ PyErr_Format(PyExc_IndexError, "list assignment index out of range");
+ return -1;
+ }
}
Py_ssize_t i = from;
@@ -1962,99 +2051,29 @@ static PyObject* ByteSize(CMessage* self, PyObject* args) {
return PyLong_FromLong(self->message->ByteSize());
}
-static PyObject* RegisterExtension(PyObject* cls,
- PyObject* extension_handle) {
+PyObject* RegisterExtension(PyObject* cls, PyObject* extension_handle) {
const FieldDescriptor* descriptor =
GetExtensionDescriptor(extension_handle);
if (descriptor == NULL) {
return NULL;
}
-
- ScopedPyObjectPtr extensions_by_name(
- PyObject_GetAttr(cls, k_extensions_by_name));
- if (extensions_by_name == NULL) {
- PyErr_SetString(PyExc_TypeError, "no extensions_by_name on class");
+ if (!PyObject_TypeCheck(cls, &CMessageClass_Type)) {
+ PyErr_Format(PyExc_TypeError, "Expected a message class, got %s",
+ cls->ob_type->tp_name);
return NULL;
}
- ScopedPyObjectPtr full_name(PyObject_GetAttr(extension_handle, kfull_name));
- if (full_name == NULL) {
+ CMessageClass *message_class = reinterpret_cast<CMessageClass*>(cls);
+ if (message_class == NULL) {
return NULL;
}
-
// If the extension was already registered, check that it is the same.
- PyObject* existing_extension =
- PyDict_GetItem(extensions_by_name.get(), full_name.get());
- if (existing_extension != NULL) {
- const FieldDescriptor* existing_extension_descriptor =
- GetExtensionDescriptor(existing_extension);
- if (existing_extension_descriptor != descriptor) {
- PyErr_SetString(PyExc_ValueError, "Double registration of Extensions");
- return NULL;
- }
- // Nothing else to do.
- Py_RETURN_NONE;
- }
-
- if (PyDict_SetItem(extensions_by_name.get(), full_name.get(),
- extension_handle) < 0) {
- return NULL;
- }
-
- // Also store a mapping from extension number to implementing class.
- ScopedPyObjectPtr extensions_by_number(
- PyObject_GetAttr(cls, k_extensions_by_number));
- if (extensions_by_number == NULL) {
- PyErr_SetString(PyExc_TypeError, "no extensions_by_number on class");
- return NULL;
- }
-
- ScopedPyObjectPtr number(PyObject_GetAttrString(extension_handle, "number"));
- if (number == NULL) {
- return NULL;
- }
-
- // If the extension was already registered by number, check that it is the
- // same.
- existing_extension = PyDict_GetItem(extensions_by_number.get(), number.get());
- if (existing_extension != NULL) {
- const FieldDescriptor* existing_extension_descriptor =
- GetExtensionDescriptor(existing_extension);
- if (existing_extension_descriptor != descriptor) {
- const Descriptor* msg_desc = GetMessageDescriptor(
- reinterpret_cast<PyTypeObject*>(cls));
- PyErr_Format(
- PyExc_ValueError,
- "Extensions \"%s\" and \"%s\" both try to extend message type "
- "\"%s\" with field number %ld.",
- existing_extension_descriptor->full_name().c_str(),
- descriptor->full_name().c_str(),
- msg_desc->full_name().c_str(),
- PyInt_AsLong(number.get()));
- return NULL;
- }
- // Nothing else to do.
- Py_RETURN_NONE;
- }
- if (PyDict_SetItem(extensions_by_number.get(), number.get(),
- extension_handle) < 0) {
+ const FieldDescriptor* existing_extension =
+ message_class->py_message_factory->pool->pool->FindExtensionByNumber(
+ descriptor->containing_type(), descriptor->number());
+ if (existing_extension != NULL && existing_extension != descriptor) {
+ PyErr_SetString(PyExc_ValueError, "Double registration of Extensions");
return NULL;
}
-
- // Check if it's a message set
- if (descriptor->is_extension() &&
- descriptor->containing_type()->options().message_set_wire_format() &&
- descriptor->type() == FieldDescriptor::TYPE_MESSAGE &&
- descriptor->label() == FieldDescriptor::LABEL_OPTIONAL) {
- ScopedPyObjectPtr message_name(PyString_FromStringAndSize(
- descriptor->message_type()->full_name().c_str(),
- descriptor->message_type()->full_name().size()));
- if (message_name == NULL) {
- return NULL;
- }
- PyDict_SetItem(extensions_by_name.get(), message_name.get(),
- extension_handle);
- }
-
Py_RETURN_NONE;
}
@@ -2091,7 +2110,7 @@ static PyObject* WhichOneof(CMessage* self, PyObject* arg) {
static PyObject* GetExtensionDict(CMessage* self, void *closure);
static PyObject* ListFields(CMessage* self) {
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
self->message->GetReflection()->ListFields(*self->message, &fields);
// Normally, the list will be exactly the size of the fields.
@@ -2182,7 +2201,7 @@ static PyObject* DiscardUnknownFields(CMessage* self) {
PyObject* FindInitializationErrors(CMessage* self) {
Message* message = self->message;
- vector<string> errors;
+ std::vector<string> errors;
message->FindInitializationErrors(&errors);
PyObject* error_list = PyList_New(errors.size());
@@ -2323,8 +2342,10 @@ PyObject* InternalGetSubMessage(
const Message& sub_message = reflection->GetMessage(
*self->message, field_descriptor, factory->message_factory);
- CMessageClass* message_class = message_factory::GetMessageClass(
+ CMessageClass* message_class = message_factory::GetOrCreateMessageClass(
factory, field_descriptor->message_type());
+ ScopedPyObjectPtr message_class_handler(
+ reinterpret_cast<PyObject*>(message_class));
if (message_class == NULL) {
return NULL;
}
@@ -2574,11 +2595,24 @@ static PyObject* GetExtensionDict(CMessage* self, void *closure) {
return NULL;
}
+static PyObject* GetExtensionsByName(CMessage *self, void *closure) {
+ return message_meta::GetExtensionsByName(
+ reinterpret_cast<CMessageClass*>(Py_TYPE(self)), closure);
+}
+
+static PyObject* GetExtensionsByNumber(CMessage *self, void *closure) {
+ return message_meta::GetExtensionsByNumber(
+ reinterpret_cast<CMessageClass*>(Py_TYPE(self)), closure);
+}
+
static PyGetSetDef Getters[] = {
{"Extensions", (getter)GetExtensionDict, NULL, "Extension dict"},
+ {"_extensions_by_name", (getter)GetExtensionsByName, NULL},
+ {"_extensions_by_number", (getter)GetExtensionsByNumber, NULL},
{NULL}
};
+
static PyMethodDef Methods[] = {
{ "__deepcopy__", (PyCFunction)DeepCopy, METH_VARARGS,
"Makes a deep copy of the class." },
@@ -2839,19 +2873,7 @@ void InitGlobals() {
// TODO(gps): Check all return values in this function for NULL and propagate
// the error (MemoryError) on up to result in an import failure. These should
// also be freed and reset to NULL during finalization.
- kPythonZero = PyInt_FromLong(0);
- kint32min_py = PyInt_FromLong(kint32min);
- kint32max_py = PyInt_FromLong(kint32max);
- kuint32max_py = PyLong_FromLongLong(kuint32max);
- kint64min_py = PyLong_FromLongLong(kint64min);
- kint64max_py = PyLong_FromLongLong(kint64max);
- kuint64max_py = PyLong_FromUnsignedLongLong(kuint64max);
-
kDESCRIPTOR = PyString_FromString("DESCRIPTOR");
- k_cdescriptor = PyString_FromString("_cdescriptor");
- kfull_name = PyString_FromString("full_name");
- k_extensions_by_name = PyString_FromString("_extensions_by_name");
- k_extensions_by_number = PyString_FromString("_extensions_by_number");
PyObject *dummy_obj = PySet_New(NULL);
kEmptyWeakref = PyWeakref_NewRef(dummy_obj, NULL);
@@ -2891,25 +2913,6 @@ bool InitProto2MessageModule(PyObject *m) {
// DESCRIPTOR is set on each protocol buffer message class elsewhere, but set
// it here as well to document that subclasses need to set it.
PyDict_SetItem(CMessage_Type.tp_dict, kDESCRIPTOR, Py_None);
- // Subclasses with message extensions will override _extensions_by_name and
- // _extensions_by_number with fresh mutable dictionaries in AddDescriptors.
- // All other classes can share this same immutable mapping.
- ScopedPyObjectPtr empty_dict(PyDict_New());
- if (empty_dict == NULL) {
- return false;
- }
- ScopedPyObjectPtr immutable_dict(PyDictProxy_New(empty_dict.get()));
- if (immutable_dict == NULL) {
- return false;
- }
- if (PyDict_SetItem(CMessage_Type.tp_dict,
- k_extensions_by_name, immutable_dict.get()) < 0) {
- return false;
- }
- if (PyDict_SetItem(CMessage_Type.tp_dict,
- k_extensions_by_number, immutable_dict.get()) < 0) {
- return false;
- }
PyModule_AddObject(m, "Message", reinterpret_cast<PyObject*>(&CMessage_Type));
diff --git a/python/google/protobuf/pyext/message.h b/python/google/protobuf/pyext/message.h
index 1550724c..ce80497e 100644
--- a/python/google/protobuf/pyext/message.h
+++ b/python/google/protobuf/pyext/message.h
@@ -117,6 +117,7 @@ typedef struct CMessage {
PyObject* weakreflist;
} CMessage;
+extern PyTypeObject CMessageClass_Type;
extern PyTypeObject CMessage_Type;
@@ -235,6 +236,10 @@ int InitAttributes(CMessage* self, PyObject* args, PyObject* kwargs);
PyObject* MergeFrom(CMessage* self, PyObject* arg);
+// This method does not do anything beyond checking that no other extension
+// has been registered with the same field number on this class.
+PyObject* RegisterExtension(PyObject* cls, PyObject* extension_handle);
+
// Retrieves an attribute named 'name' from CMessage 'self'. Returns
// the attribute value on success, or NULL on failure.
//
@@ -275,25 +280,25 @@ PyObject* SetAllowOversizeProtos(PyObject* m, PyObject* arg);
#define GOOGLE_CHECK_GET_INT32(arg, value, err) \
int32 value; \
- if (!CheckAndGetInteger(arg, &value, kint32min_py, kint32max_py)) { \
+ if (!CheckAndGetInteger(arg, &value)) { \
return err; \
}
#define GOOGLE_CHECK_GET_INT64(arg, value, err) \
int64 value; \
- if (!CheckAndGetInteger(arg, &value, kint64min_py, kint64max_py)) { \
+ if (!CheckAndGetInteger(arg, &value)) { \
return err; \
}
#define GOOGLE_CHECK_GET_UINT32(arg, value, err) \
uint32 value; \
- if (!CheckAndGetInteger(arg, &value, kPythonZero, kuint32max_py)) { \
+ if (!CheckAndGetInteger(arg, &value)) { \
return err; \
}
#define GOOGLE_CHECK_GET_UINT64(arg, value, err) \
uint64 value; \
- if (!CheckAndGetInteger(arg, &value, kPythonZero, kuint64max_py)) { \
+ if (!CheckAndGetInteger(arg, &value)) { \
return err; \
}
@@ -316,20 +321,11 @@ PyObject* SetAllowOversizeProtos(PyObject* m, PyObject* arg);
}
-extern PyObject* kPythonZero;
-extern PyObject* kint32min_py;
-extern PyObject* kint32max_py;
-extern PyObject* kuint32max_py;
-extern PyObject* kint64min_py;
-extern PyObject* kint64max_py;
-extern PyObject* kuint64max_py;
-
#define FULL_MODULE_NAME "google.protobuf.pyext._message"
void FormatTypeError(PyObject* arg, char* expected_types);
template<class T>
-bool CheckAndGetInteger(
- PyObject* arg, T* value, PyObject* min, PyObject* max);
+bool CheckAndGetInteger(PyObject* arg, T* value);
bool CheckAndGetDouble(PyObject* arg, double* value);
bool CheckAndGetFloat(PyObject* arg, float* value);
bool CheckAndGetBool(PyObject* arg, bool* value);
diff --git a/python/google/protobuf/pyext/message_factory.cc b/python/google/protobuf/pyext/message_factory.cc
index 2ad89022..e0b45bf2 100644
--- a/python/google/protobuf/pyext/message_factory.cc
+++ b/python/google/protobuf/pyext/message_factory.cc
@@ -130,6 +130,72 @@ int RegisterMessageClass(PyMessageFactory* self,
return 0;
}
+CMessageClass* GetOrCreateMessageClass(PyMessageFactory* self,
+ const Descriptor* descriptor) {
+ // This is the same implementation as MessageFactory.GetPrototype().
+ ScopedPyObjectPtr py_descriptor(
+ PyMessageDescriptor_FromDescriptor(descriptor));
+ if (py_descriptor == NULL) {
+ return NULL;
+ }
+ // Do not create a MessageClass that already exists.
+ hash_map<const Descriptor*, CMessageClass*>::iterator it =
+ self->classes_by_descriptor->find(descriptor);
+ if (it != self->classes_by_descriptor->end()) {
+ Py_INCREF(it->second);
+ return it->second;
+ }
+ // Create a new message class.
+ ScopedPyObjectPtr args(Py_BuildValue(
+ "s(){sOsOsO}", descriptor->name().c_str(),
+ "DESCRIPTOR", py_descriptor.get(),
+ "__module__", Py_None,
+ "message_factory", self));
+ if (args == NULL) {
+ return NULL;
+ }
+ ScopedPyObjectPtr message_class(PyObject_CallObject(
+ reinterpret_cast<PyObject*>(&CMessageClass_Type), args.get()));
+ if (message_class == NULL) {
+ return NULL;
+ }
+ // Create messages class for the messages used by the fields, and registers
+ // all extensions for these messages during the recursion.
+ for (int field_idx = 0; field_idx < descriptor->field_count(); field_idx++) {
+ const Descriptor* sub_descriptor =
+ descriptor->field(field_idx)->message_type();
+ // It is NULL if the field type is not a message.
+ if (sub_descriptor != NULL) {
+ CMessageClass* result = GetOrCreateMessageClass(self, sub_descriptor);
+ if (result == NULL) {
+ return NULL;
+ }
+ Py_DECREF(result);
+ }
+ }
+
+ // Register extensions defined in this message.
+ for (int ext_idx = 0 ; ext_idx < descriptor->extension_count() ; ext_idx++) {
+ const FieldDescriptor* extension = descriptor->extension(ext_idx);
+ ScopedPyObjectPtr py_extended_class(
+ GetOrCreateMessageClass(self, extension->containing_type())
+ ->AsPyObject());
+ if (py_extended_class == NULL) {
+ return NULL;
+ }
+ ScopedPyObjectPtr py_extension(PyFieldDescriptor_FromDescriptor(extension));
+ if (py_extension == NULL) {
+ return NULL;
+ }
+ ScopedPyObjectPtr result(cmessage::RegisterExtension(
+ py_extended_class.get(), py_extension.get()));
+ if (result == NULL) {
+ return NULL;
+ }
+ }
+ return reinterpret_cast<CMessageClass*>(message_class.release());
+}
+
// Retrieve the message class added to our database.
CMessageClass* GetMessageClass(PyMessageFactory* self,
const Descriptor* message_descriptor) {
diff --git a/python/google/protobuf/pyext/message_factory.h b/python/google/protobuf/pyext/message_factory.h
index 07cccbfb..36092f7e 100644
--- a/python/google/protobuf/pyext/message_factory.h
+++ b/python/google/protobuf/pyext/message_factory.h
@@ -82,14 +82,14 @@ PyMessageFactory* NewMessageFactory(PyTypeObject* type, PyDescriptorPool* pool);
int RegisterMessageClass(PyMessageFactory* self,
const Descriptor* message_descriptor,
CMessageClass* message_class);
-
-// Retrieves the Python class registered with the given message descriptor.
-//
-// Returns a *borrowed* reference if found, otherwise returns NULL with an
-// exception set.
+// Retrieves the Python class registered with the given message descriptor, or
+// fail with a TypeError. Returns a *borrowed* reference.
CMessageClass* GetMessageClass(PyMessageFactory* self,
const Descriptor* message_descriptor);
-
+// Retrieves the Python class registered with the given message descriptor.
+// The class is created if not done yet. Returns a *new* reference.
+CMessageClass* GetOrCreateMessageClass(PyMessageFactory* self,
+ const Descriptor* message_descriptor);
} // namespace message_factory
// Initialize objects used by this module.
diff --git a/python/google/protobuf/pyext/safe_numerics.h b/python/google/protobuf/pyext/safe_numerics.h
new file mode 100644
index 00000000..639ba2c8
--- /dev/null
+++ b/python/google/protobuf/pyext/safe_numerics.h
@@ -0,0 +1,164 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef GOOGLE_PROTOBUF_PYTHON_CPP_SAFE_NUMERICS_H__
+#define GOOGLE_PROTOBUF_PYTHON_CPP_SAFE_NUMERICS_H__
+// Copied from chromium with only changes to the namespace.
+
+#include <limits>
+
+#include <google/protobuf/stubs/logging.h>
+#include <google/protobuf/stubs/common.h>
+
+namespace google {
+namespace protobuf {
+namespace python {
+
+template <bool SameSize, bool DestLarger,
+ bool DestIsSigned, bool SourceIsSigned>
+struct IsValidNumericCastImpl;
+
+#define BASE_NUMERIC_CAST_CASE_SPECIALIZATION(A, B, C, D, Code) \
+template <> struct IsValidNumericCastImpl<A, B, C, D> { \
+ template <class Source, class DestBounds> static inline bool Test( \
+ Source source, DestBounds min, DestBounds max) { \
+ return Code; \
+ } \
+}
+
+#define BASE_NUMERIC_CAST_CASE_SAME_SIZE(DestSigned, SourceSigned, Code) \
+ BASE_NUMERIC_CAST_CASE_SPECIALIZATION( \
+ true, true, DestSigned, SourceSigned, Code); \
+ BASE_NUMERIC_CAST_CASE_SPECIALIZATION( \
+ true, false, DestSigned, SourceSigned, Code)
+
+#define BASE_NUMERIC_CAST_CASE_SOURCE_LARGER(DestSigned, SourceSigned, Code) \
+ BASE_NUMERIC_CAST_CASE_SPECIALIZATION( \
+ false, false, DestSigned, SourceSigned, Code); \
+
+#define BASE_NUMERIC_CAST_CASE_DEST_LARGER(DestSigned, SourceSigned, Code) \
+ BASE_NUMERIC_CAST_CASE_SPECIALIZATION( \
+ false, true, DestSigned, SourceSigned, Code); \
+
+// The three top level cases are:
+// - Same size
+// - Source larger
+// - Dest larger
+// And for each of those three cases, we handle the 4 different possibilities
+// of signed and unsigned. This gives 12 cases to handle, which we enumerate
+// below.
+//
+// The last argument in each of the macros is the actual comparison code. It
+// has three arguments available, source (the value), and min/max which are
+// the ranges of the destination.
+
+
+// These are the cases where both types have the same size.
+
+// Both signed.
+BASE_NUMERIC_CAST_CASE_SAME_SIZE(true, true, true);
+// Both unsigned.
+BASE_NUMERIC_CAST_CASE_SAME_SIZE(false, false, true);
+// Dest unsigned, Source signed.
+BASE_NUMERIC_CAST_CASE_SAME_SIZE(false, true, source >= 0);
+// Dest signed, Source unsigned.
+// This cast is OK because Dest's max must be less than Source's.
+BASE_NUMERIC_CAST_CASE_SAME_SIZE(true, false,
+ source <= static_cast<Source>(max));
+
+
+// These are the cases where Source is larger.
+
+// Both unsigned.
+BASE_NUMERIC_CAST_CASE_SOURCE_LARGER(false, false, source <= max);
+// Both signed.
+BASE_NUMERIC_CAST_CASE_SOURCE_LARGER(true, true,
+ source >= min && source <= max);
+// Dest is unsigned, Source is signed.
+BASE_NUMERIC_CAST_CASE_SOURCE_LARGER(false, true,
+ source >= 0 && source <= max);
+// Dest is signed, Source is unsigned.
+// This cast is OK because Dest's max must be less than Source's.
+BASE_NUMERIC_CAST_CASE_SOURCE_LARGER(true, false,
+ source <= static_cast<Source>(max));
+
+
+// These are the cases where Dest is larger.
+
+// Both unsigned.
+BASE_NUMERIC_CAST_CASE_DEST_LARGER(false, false, true);
+// Both signed.
+BASE_NUMERIC_CAST_CASE_DEST_LARGER(true, true, true);
+// Dest is unsigned, Source is signed.
+BASE_NUMERIC_CAST_CASE_DEST_LARGER(false, true, source >= 0);
+// Dest is signed, Source is unsigned.
+BASE_NUMERIC_CAST_CASE_DEST_LARGER(true, false, true);
+
+#undef BASE_NUMERIC_CAST_CASE_SPECIALIZATION
+#undef BASE_NUMERIC_CAST_CASE_SAME_SIZE
+#undef BASE_NUMERIC_CAST_CASE_SOURCE_LARGER
+#undef BASE_NUMERIC_CAST_CASE_DEST_LARGER
+
+
+// The main test for whether the conversion will under or overflow.
+template <class Dest, class Source>
+inline bool IsValidNumericCast(Source source) {
+ typedef std::numeric_limits<Source> SourceLimits;
+ typedef std::numeric_limits<Dest> DestLimits;
+ GOOGLE_COMPILE_ASSERT(SourceLimits::is_specialized, argument_must_be_numeric);
+ GOOGLE_COMPILE_ASSERT(SourceLimits::is_integer, argument_must_be_integral);
+ GOOGLE_COMPILE_ASSERT(DestLimits::is_specialized, result_must_be_numeric);
+ GOOGLE_COMPILE_ASSERT(DestLimits::is_integer, result_must_be_integral);
+
+ return IsValidNumericCastImpl<
+ sizeof(Dest) == sizeof(Source),
+ (sizeof(Dest) > sizeof(Source)),
+ DestLimits::is_signed,
+ SourceLimits::is_signed>::Test(
+ source,
+ DestLimits::min(),
+ DestLimits::max());
+}
+
+// checked_numeric_cast<> is analogous to static_cast<> for numeric types,
+// except that it CHECKs that the specified numeric conversion will not
+// overflow or underflow. Floating point arguments are not currently allowed
+// (this is COMPILE_ASSERTd), though this could be supported if necessary.
+template <class Dest, class Source>
+inline Dest checked_numeric_cast(Source source) {
+ GOOGLE_CHECK(IsValidNumericCast<Dest>(source));
+ return static_cast<Dest>(source);
+}
+
+} // namespace python
+} // namespace protobuf
+
+} // namespace google
+#endif // GOOGLE_PROTOBUF_PYTHON_CPP_SAFE_NUMERICS_H__
diff --git a/python/setup.py b/python/setup.py
index 524a312f..64e318f1 100755
--- a/python/setup.py
+++ b/python/setup.py
@@ -5,6 +5,7 @@ import glob
import os
import subprocess
import sys
+import platform
# We must use setuptools, not distutils, because we need to use the
# namespace_packages option for the "google" package.
@@ -78,6 +79,7 @@ def generate_proto(source, require = True):
def GenerateUnittestProtos():
generate_proto("../src/google/protobuf/any_test.proto", False)
generate_proto("../src/google/protobuf/map_unittest.proto", False)
+ generate_proto("../src/google/protobuf/test_messages_proto3.proto", False)
generate_proto("../src/google/protobuf/unittest_arena.proto", False)
generate_proto("../src/google/protobuf/unittest_no_arena.proto", False)
generate_proto("../src/google/protobuf/unittest_no_arena_import.proto", False)
@@ -188,6 +190,12 @@ if __name__ == '__main__':
if "clang" in os.popen('$CC --version 2> /dev/null').read():
extra_compile_args.append('-Wno-shorten-64-to-32')
+ v, _, _ = platform.mac_ver()
+ if v:
+ v = float('.'.join(v.split('.')[:2]))
+ if v >= 10.12:
+ extra_compile_args.append('-std=c++11')
+
if warnings_as_errors in sys.argv:
extra_compile_args.append('-Werror')
sys.argv.remove(warnings_as_errors)
diff --git a/ruby/Rakefile b/ruby/Rakefile
index ba1cf4cf..40d0a314 100644
--- a/ruby/Rakefile
+++ b/ruby/Rakefile
@@ -44,11 +44,11 @@ if RUBY_PLATFORM == "java"
raise ArgumentError, "maven needs to be installed"
end
task :clean do
- system("mvn clean")
+ system("mvn --batch-mode clean")
end
task :compile do
- system("mvn package")
+ system("mvn --batch-mode package")
end
else
Rake::ExtensionTask.new("protobuf_c", spec) do |ext|
diff --git a/ruby/ext/google/protobuf_c/defs.c b/ruby/ext/google/protobuf_c/defs.c
index 7e93bafb..845c0225 100644
--- a/ruby/ext/google/protobuf_c/defs.c
+++ b/ruby/ext/google/protobuf_c/defs.c
@@ -101,7 +101,7 @@ void DescriptorPool_mark(void* _self) {
void DescriptorPool_free(void* _self) {
DescriptorPool* self = _self;
- upb_symtab_unref(self->symtab, &self->symtab);
+ upb_symtab_free(self->symtab);
xfree(self);
}
@@ -113,7 +113,7 @@ void DescriptorPool_free(void* _self) {
*/
VALUE DescriptorPool_alloc(VALUE klass) {
DescriptorPool* self = ALLOC(DescriptorPool);
- self->symtab = upb_symtab_new(&self->symtab);
+ self->symtab = upb_symtab_new();
return TypedData_Wrap_Struct(klass, &_DescriptorPool_type, self);
}
diff --git a/ruby/ext/google/protobuf_c/encode_decode.c b/ruby/ext/google/protobuf_c/encode_decode.c
index 08c72bcc..d86a1145 100644
--- a/ruby/ext/google/protobuf_c/encode_decode.c
+++ b/ruby/ext/google/protobuf_c/encode_decode.c
@@ -514,7 +514,7 @@ static void add_handlers_for_singular_field(upb_handlers *h,
case UPB_TYPE_INT64:
case UPB_TYPE_UINT64:
case UPB_TYPE_DOUBLE:
- upb_shim_set(h, f, offset, -1);
+ upb_msg_setscalarhandler(h, f, offset, -1);
break;
case UPB_TYPE_STRING:
case UPB_TYPE_BYTES: {
@@ -925,7 +925,7 @@ static void putmsg(VALUE msg, const Descriptor* desc,
static upb_selector_t getsel(const upb_fielddef *f, upb_handlertype_t type) {
upb_selector_t ret;
bool ok = upb_handlers_getselector(f, type, &ret);
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
return ret;
}
@@ -939,9 +939,9 @@ static void putstr(VALUE str, const upb_fielddef *f, upb_sink *sink) {
// We should be guaranteed that the string has the correct encoding because
// we ensured this at assignment time and then froze the string.
if (upb_fielddef_type(f) == UPB_TYPE_STRING) {
- assert(rb_enc_from_index(ENCODING_GET(value)) == kRubyStringUtf8Encoding);
+ assert(rb_enc_from_index(ENCODING_GET(str)) == kRubyStringUtf8Encoding);
} else {
- assert(rb_enc_from_index(ENCODING_GET(value)) == kRubyString8bitEncoding);
+ assert(rb_enc_from_index(ENCODING_GET(str)) == kRubyString8bitEncoding);
}
upb_sink_startstr(sink, getsel(f, UPB_HANDLER_STARTSTR), RSTRING_LEN(str),
diff --git a/ruby/ext/google/protobuf_c/message.c b/ruby/ext/google/protobuf_c/message.c
index e16250f3..837a974b 100644
--- a/ruby/ext/google/protobuf_c/message.c
+++ b/ruby/ext/google/protobuf_c/message.c
@@ -178,6 +178,45 @@ VALUE Message_method_missing(int argc, VALUE* argv, VALUE _self) {
}
}
+VALUE Message_respond_to_missing(int argc, VALUE* argv, VALUE _self) {
+ MessageHeader* self;
+ VALUE method_name, method_str;
+ char* name;
+ size_t name_len;
+ bool setter;
+ const upb_oneofdef* o;
+ const upb_fielddef* f;
+
+ TypedData_Get_Struct(_self, MessageHeader, &Message_type, self);
+ if (argc < 1) {
+ rb_raise(rb_eArgError, "Expected method name as first argument.");
+ }
+ method_name = argv[0];
+ if (!SYMBOL_P(method_name)) {
+ rb_raise(rb_eArgError, "Expected symbol as method name.");
+ }
+ method_str = rb_id2str(SYM2ID(method_name));
+ name = RSTRING_PTR(method_str);
+ name_len = RSTRING_LEN(method_str);
+ setter = false;
+
+ // Setters have names that end in '='.
+ if (name[name_len - 1] == '=') {
+ setter = true;
+ name_len--;
+ }
+
+ // See if this name corresponds to either a oneof or field in this message.
+ if (!upb_msgdef_lookupname(self->descriptor->msgdef, name, name_len, &f,
+ &o)) {
+ return rb_call_super(argc, argv);
+ }
+ if (o != NULL) {
+ return setter ? Qfalse : Qtrue;
+ }
+ return Qtrue;
+}
+
int Message_initialize_kwarg(VALUE key, VALUE val, VALUE _self) {
MessageHeader* self;
VALUE method_str;
@@ -305,6 +344,9 @@ VALUE Message_deep_copy(VALUE _self) {
VALUE Message_eq(VALUE _self, VALUE _other) {
MessageHeader* self;
MessageHeader* other;
+ if (TYPE(_self) != TYPE(_other)) {
+ return Qfalse;
+ }
TypedData_Get_Struct(_self, MessageHeader, &Message_type, self);
TypedData_Get_Struct(_other, MessageHeader, &Message_type, other);
@@ -459,6 +501,8 @@ VALUE build_class_from_descriptor(Descriptor* desc) {
rb_define_method(klass, "method_missing",
Message_method_missing, -1);
+ rb_define_method(klass, "respond_to_missing?",
+ Message_respond_to_missing, -1);
rb_define_method(klass, "initialize", Message_initialize, -1);
rb_define_method(klass, "dup", Message_dup, 0);
// Also define #clone so that we don't inherit Object#clone.
diff --git a/ruby/ext/google/protobuf_c/upb.c b/ruby/ext/google/protobuf_c/upb.c
index 544ebc04..e0c56f8e 100644
--- a/ruby/ext/google/protobuf_c/upb.c
+++ b/ruby/ext/google/protobuf_c/upb.c
@@ -103,7 +103,7 @@ const char *upb_def_name(const upb_def *d) {
}
bool upb_def_setfullname(upb_def *def, const char *fullname, upb_status *s) {
- assert(!upb_def_isfrozen(def));
+ UPB_ASSERT(!upb_def_isfrozen(def));
if (!upb_isident(fullname, strlen(fullname), true, s)) {
return false;
}
@@ -121,21 +121,6 @@ bool upb_def_setfullname(upb_def *def, const char *fullname, upb_status *s) {
const upb_filedef *upb_def_file(const upb_def *d) { return d->file; }
-upb_def *upb_def_dup(const upb_def *def, const void *o) {
- switch (def->type) {
- case UPB_DEF_MSG:
- return upb_msgdef_upcast_mutable(
- upb_msgdef_dup(upb_downcast_msgdef(def), o));
- case UPB_DEF_FIELD:
- return upb_fielddef_upcast_mutable(
- upb_fielddef_dup(upb_downcast_fielddef(def), o));
- case UPB_DEF_ENUM:
- return upb_enumdef_upcast_mutable(
- upb_enumdef_dup(upb_downcast_enumdef(def), o));
- default: assert(false); return NULL;
- }
-}
-
static bool upb_def_init(upb_def *def, upb_deftype_t type,
const struct upb_refcounted_vtbl *vtbl,
const void *owner) {
@@ -203,14 +188,14 @@ static bool upb_validate_field(upb_fielddef *f, upb_status *s) {
bool has_default_number = upb_fielddef_enumhasdefaultint32(f);
/* Previously verified by upb_validate_enumdef(). */
- assert(upb_enumdef_numvals(upb_fielddef_enumsubdef(f)) > 0);
+ UPB_ASSERT(upb_enumdef_numvals(upb_fielddef_enumsubdef(f)) > 0);
/* We've already validated that we have an associated enumdef and that it
* has at least one member, so at least one of these should be true.
* Because if the user didn't set anything, we'll pick up the enum's
* default, but if the user *did* set something we should at least pick up
* the one they set (int32 or string). */
- assert(has_default_name || has_default_number);
+ UPB_ASSERT(has_default_name || has_default_number);
if (!has_default_name) {
upb_status_seterrf(s,
@@ -266,7 +251,7 @@ static bool upb_validate_enumdef(const upb_enumdef *e, upb_status *s) {
uint32_t field_rank(const upb_fielddef *f) {
uint32_t ret = upb_fielddef_number(f);
const uint32_t high_bit = 1 << 30;
- assert(ret < high_bit);
+ UPB_ASSERT(ret < high_bit);
if (!upb_fielddef_issubmsg(f))
ret |= high_bit;
return ret;
@@ -282,6 +267,7 @@ static bool assign_msg_indices(upb_msgdef *m, upb_status *s) {
/* Sort fields. upb internally relies on UPB_TYPE_MESSAGE fields having the
* lowest indexes, but we do not publicly guarantee this. */
upb_msg_field_iter j;
+ upb_msg_oneof_iter k;
int i;
uint32_t selector;
int n = upb_msgdef_numfields(m);
@@ -304,7 +290,7 @@ static bool assign_msg_indices(upb_msgdef *m, upb_status *s) {
!upb_msg_field_done(&j);
upb_msg_field_next(&j), i++) {
upb_fielddef *f = upb_msg_iter_field(&j);
- assert(f->msg.def == m);
+ UPB_ASSERT(f->msg.def == m);
if (!upb_validate_field(f, s)) {
upb_gfree(fields);
return false;
@@ -366,6 +352,13 @@ static bool assign_msg_indices(upb_msgdef *m, upb_status *s) {
#undef TRY
#endif
+ for(upb_msg_oneof_begin(&k, m), i = 0;
+ !upb_msg_oneof_done(&k);
+ upb_msg_oneof_next(&k), i++) {
+ upb_oneofdef *o = upb_msg_iter_oneof(&k);
+ o->index = i;
+ }
+
upb_gfree(fields);
return true;
}
@@ -417,7 +410,7 @@ err:
upb_def *def = defs[i];
def->came_from_user = false;
}
- assert(!(s && upb_ok(s)));
+ UPB_ASSERT(!(s && upb_ok(s)));
return false;
}
@@ -438,7 +431,16 @@ bool upb_def_freeze(upb_def *const* defs, size_t n, upb_status *s) {
/* upb_enumdef ****************************************************************/
-static void upb_enumdef_free(upb_refcounted *r) {
+static void visitenum(const upb_refcounted *r, upb_refcounted_visit *visit,
+ void *closure) {
+ const upb_enumdef *e = (const upb_enumdef*)r;
+ const upb_def *def = upb_enumdef_upcast(e);
+ if (upb_def_file(def)) {
+ visit(r, upb_filedef_upcast(upb_def_file(def)), closure);
+ }
+}
+
+static void freeenum(upb_refcounted *r) {
upb_enumdef *e = (upb_enumdef*)r;
upb_inttable_iter i;
upb_inttable_begin(&i, &e->iton);
@@ -452,7 +454,7 @@ static void upb_enumdef_free(upb_refcounted *r) {
upb_gfree(e);
}
-const struct upb_refcounted_vtbl upb_enumdef_vtbl = {NULL, &upb_enumdef_free};
+const struct upb_refcounted_vtbl upb_enumdef_vtbl = {&visitenum, &freeenum};
upb_enumdef *upb_enumdef_new(const void *owner) {
upb_enumdef *e = upb_gmalloc(sizeof(*e));
@@ -474,21 +476,6 @@ err2:
return NULL;
}
-upb_enumdef *upb_enumdef_dup(const upb_enumdef *e, const void *owner) {
- upb_enum_iter i;
- upb_enumdef *new_e = upb_enumdef_new(owner);
- if (!new_e) return NULL;
- for(upb_enum_begin(&i, e); !upb_enum_done(&i); upb_enum_next(&i)) {
- bool success = upb_enumdef_addval(
- new_e, upb_enum_iter_name(&i),upb_enum_iter_number(&i), NULL);
- if (!success) {
- upb_enumdef_unref(new_e, owner);
- return NULL;
- }
- }
- return new_e;
-}
-
bool upb_enumdef_freeze(upb_enumdef *e, upb_status *status) {
upb_def *d = upb_enumdef_upcast_mutable(e);
return upb_def_freeze(&d, 1, status);
@@ -536,19 +523,19 @@ bool upb_enumdef_addval(upb_enumdef *e, const char *name, int32_t num,
if (upb_enumdef_numvals(e) == 1) {
bool ok = upb_enumdef_setdefault(e, num, NULL);
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
}
return true;
}
int32_t upb_enumdef_default(const upb_enumdef *e) {
- assert(upb_enumdef_iton(e, e->defaultval));
+ UPB_ASSERT(upb_enumdef_iton(e, e->defaultval));
return e->defaultval;
}
bool upb_enumdef_setdefault(upb_enumdef *e, int32_t val, upb_status *s) {
- assert(!upb_enumdef_isfrozen(e));
+ UPB_ASSERT(!upb_enumdef_isfrozen(e));
if (!upb_enumdef_iton(e, val)) {
upb_status_seterrf(s, "number '%d' is not in the enum.", val);
return false;
@@ -610,6 +597,7 @@ const char *upb_fielddef_fullname(const upb_fielddef *e) {
static void visitfield(const upb_refcounted *r, upb_refcounted_visit *visit,
void *closure) {
const upb_fielddef *f = (const upb_fielddef*)r;
+ const upb_def *def = upb_fielddef_upcast(f);
if (upb_fielddef_containingtype(f)) {
visit(r, upb_msgdef_upcast2(upb_fielddef_containingtype(f)), closure);
}
@@ -619,6 +607,9 @@ static void visitfield(const upb_refcounted *r, upb_refcounted_visit *visit,
if (upb_fielddef_subdef(f)) {
visit(r, upb_def_upcast(upb_fielddef_subdef(f)), closure);
}
+ if (upb_def_file(def)) {
+ visit(r, upb_filedef_upcast(upb_def_file(def)), closure);
+ }
}
static void freefield(upb_refcounted *r) {
@@ -632,7 +623,7 @@ static void freefield(upb_refcounted *r) {
static const char *enumdefaultstr(const upb_fielddef *f) {
const upb_enumdef *e;
- assert(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM);
+ UPB_ASSERT(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM);
e = upb_fielddef_enumsubdef(f);
if (f->default_is_string && f->defaultval.bytes) {
/* Default was explicitly set as a string. */
@@ -649,7 +640,7 @@ static const char *enumdefaultstr(const upb_fielddef *f) {
/* Default is completely unset; pull enumdef default. */
if (upb_enumdef_numvals(e) > 0) {
const char *name = upb_enumdef_iton(e, upb_enumdef_default(e));
- assert(name);
+ UPB_ASSERT(name);
return name;
}
}
@@ -659,7 +650,7 @@ static const char *enumdefaultstr(const upb_fielddef *f) {
static bool enumdefaultint32(const upb_fielddef *f, int32_t *val) {
const upb_enumdef *e;
- assert(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM);
+ UPB_ASSERT(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM);
e = upb_fielddef_enumsubdef(f);
if (!f->default_is_string) {
/* Default was explicitly set as an integer. */
@@ -719,7 +710,8 @@ upb_fielddef *upb_fielddef_new(const void *o) {
return f;
}
-upb_fielddef *upb_fielddef_dup(const upb_fielddef *f, const void *owner) {
+static upb_fielddef *upb_fielddef_dup(const upb_fielddef *f,
+ const void *owner) {
const char *srcname;
upb_fielddef *newf = upb_fielddef_new(owner);
if (!newf) return NULL;
@@ -760,7 +752,7 @@ bool upb_fielddef_typeisset(const upb_fielddef *f) {
}
upb_fieldtype_t upb_fielddef_type(const upb_fielddef *f) {
- assert(f->type_is_set_);
+ UPB_ASSERT(f->type_is_set_);
return f->type_;
}
@@ -862,7 +854,7 @@ static void release_containingtype(upb_fielddef *f) {
bool upb_fielddef_setcontainingtypename(upb_fielddef *f, const char *name,
upb_status *s) {
char *name_copy;
- assert(!upb_fielddef_isfrozen(f));
+ UPB_ASSERT(!upb_fielddef_isfrozen(f));
if (upb_fielddef_containingtype(f)) {
upb_status_seterrmsg(s, "field has already been added to a message.");
return false;
@@ -893,7 +885,7 @@ bool upb_fielddef_setname(upb_fielddef *f, const char *name, upb_status *s) {
static void chkdefaulttype(const upb_fielddef *f, upb_fieldtype_t type) {
UPB_UNUSED(f);
UPB_UNUSED(type);
- assert(f->type_is_set_ && upb_fielddef_type(f) == type);
+ UPB_ASSERT(f->type_is_set_ && upb_fielddef_type(f) == type);
}
int64_t upb_fielddef_defaultint64(const upb_fielddef *f) {
@@ -905,7 +897,7 @@ int32_t upb_fielddef_defaultint32(const upb_fielddef *f) {
if (f->type_is_set_ && upb_fielddef_type(f) == UPB_TYPE_ENUM) {
int32_t val;
bool ok = enumdefaultint32(f, &val);
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
return val;
} else {
chkdefaulttype(f, UPB_TYPE_INT32);
@@ -939,14 +931,14 @@ double upb_fielddef_defaultdouble(const upb_fielddef *f) {
}
const char *upb_fielddef_defaultstr(const upb_fielddef *f, size_t *len) {
- assert(f->type_is_set_);
- assert(upb_fielddef_type(f) == UPB_TYPE_STRING ||
+ UPB_ASSERT(f->type_is_set_);
+ UPB_ASSERT(upb_fielddef_type(f) == UPB_TYPE_STRING ||
upb_fielddef_type(f) == UPB_TYPE_BYTES ||
upb_fielddef_type(f) == UPB_TYPE_ENUM);
if (upb_fielddef_type(f) == UPB_TYPE_ENUM) {
const char *ret = enumdefaultstr(f);
- assert(ret);
+ UPB_ASSERT(ret);
/* Enum defaults can't have embedded NULLs. */
if (len) *len = strlen(ret);
return ret;
@@ -1028,8 +1020,8 @@ bool upb_fielddef_setnumber(upb_fielddef *f, uint32_t number, upb_status *s) {
}
void upb_fielddef_settype(upb_fielddef *f, upb_fieldtype_t type) {
- assert(!upb_fielddef_isfrozen(f));
- assert(upb_fielddef_checktype(type));
+ UPB_ASSERT(!upb_fielddef_isfrozen(f));
+ UPB_ASSERT(upb_fielddef_checktype(type));
upb_fielddef_uninit_default(f);
f->type_ = type;
f->type_is_set_ = true;
@@ -1037,7 +1029,7 @@ void upb_fielddef_settype(upb_fielddef *f, upb_fieldtype_t type) {
}
void upb_fielddef_setdescriptortype(upb_fielddef *f, int type) {
- assert(!upb_fielddef_isfrozen(f));
+ UPB_ASSERT(!upb_fielddef_isfrozen(f));
switch (type) {
case UPB_DESCRIPTOR_TYPE_DOUBLE:
upb_fielddef_settype(f, UPB_TYPE_DOUBLE);
@@ -1079,7 +1071,7 @@ void upb_fielddef_setdescriptortype(upb_fielddef *f, int type) {
case UPB_DESCRIPTOR_TYPE_ENUM:
upb_fielddef_settype(f, UPB_TYPE_ENUM);
break;
- default: assert(false);
+ default: UPB_ASSERT(false);
}
if (type == UPB_DESCRIPTOR_TYPE_FIXED64 ||
@@ -1137,34 +1129,34 @@ upb_descriptortype_t upb_fielddef_descriptortype(const upb_fielddef *f) {
}
void upb_fielddef_setisextension(upb_fielddef *f, bool is_extension) {
- assert(!upb_fielddef_isfrozen(f));
+ UPB_ASSERT(!upb_fielddef_isfrozen(f));
f->is_extension_ = is_extension;
}
void upb_fielddef_setlazy(upb_fielddef *f, bool lazy) {
- assert(!upb_fielddef_isfrozen(f));
+ UPB_ASSERT(!upb_fielddef_isfrozen(f));
f->lazy_ = lazy;
}
void upb_fielddef_setpacked(upb_fielddef *f, bool packed) {
- assert(!upb_fielddef_isfrozen(f));
+ UPB_ASSERT(!upb_fielddef_isfrozen(f));
f->packed_ = packed;
}
void upb_fielddef_setlabel(upb_fielddef *f, upb_label_t label) {
- assert(!upb_fielddef_isfrozen(f));
- assert(upb_fielddef_checklabel(label));
+ UPB_ASSERT(!upb_fielddef_isfrozen(f));
+ UPB_ASSERT(upb_fielddef_checklabel(label));
f->label_ = label;
}
void upb_fielddef_setintfmt(upb_fielddef *f, upb_intfmt_t fmt) {
- assert(!upb_fielddef_isfrozen(f));
- assert(upb_fielddef_checkintfmt(fmt));
+ UPB_ASSERT(!upb_fielddef_isfrozen(f));
+ UPB_ASSERT(upb_fielddef_checkintfmt(fmt));
f->intfmt = fmt;
}
void upb_fielddef_settagdelim(upb_fielddef *f, bool tag_delim) {
- assert(!upb_fielddef_isfrozen(f));
+ UPB_ASSERT(!upb_fielddef_isfrozen(f));
f->tagdelim = tag_delim;
f->tagdelim = tag_delim;
}
@@ -1172,12 +1164,12 @@ void upb_fielddef_settagdelim(upb_fielddef *f, bool tag_delim) {
static bool checksetdefault(upb_fielddef *f, upb_fieldtype_t type) {
if (!f->type_is_set_ || upb_fielddef_isfrozen(f) ||
upb_fielddef_type(f) != type) {
- assert(false);
+ UPB_ASSERT(false);
return false;
}
if (f->default_is_string) {
str_t *s = f->defaultval.bytes;
- assert(s || type == UPB_TYPE_ENUM);
+ UPB_ASSERT(s || type == UPB_TYPE_ENUM);
if (s) freestr(s);
}
f->default_is_string = false;
@@ -1225,16 +1217,16 @@ void upb_fielddef_setdefaultdouble(upb_fielddef *f, double value) {
bool upb_fielddef_setdefaultstr(upb_fielddef *f, const void *str, size_t len,
upb_status *s) {
str_t *str2;
- assert(upb_fielddef_isstring(f) || f->type_ == UPB_TYPE_ENUM);
+ UPB_ASSERT(upb_fielddef_isstring(f) || f->type_ == UPB_TYPE_ENUM);
if (f->type_ == UPB_TYPE_ENUM && !upb_isident(str, len, false, s))
return false;
if (f->default_is_string) {
str_t *s = f->defaultval.bytes;
- assert(s || f->type_ == UPB_TYPE_ENUM);
+ UPB_ASSERT(s || f->type_ == UPB_TYPE_ENUM);
if (s) freestr(s);
} else {
- assert(f->type_ == UPB_TYPE_ENUM);
+ UPB_ASSERT(f->type_ == UPB_TYPE_ENUM);
}
str2 = newstr(str, len);
@@ -1245,18 +1237,18 @@ bool upb_fielddef_setdefaultstr(upb_fielddef *f, const void *str, size_t len,
void upb_fielddef_setdefaultcstr(upb_fielddef *f, const char *str,
upb_status *s) {
- assert(f->type_is_set_);
+ UPB_ASSERT(f->type_is_set_);
upb_fielddef_setdefaultstr(f, str, str ? strlen(str) : 0, s);
}
bool upb_fielddef_enumhasdefaultint32(const upb_fielddef *f) {
int32_t val;
- assert(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM);
+ UPB_ASSERT(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM);
return enumdefaultint32(f, &val);
}
bool upb_fielddef_enumhasdefaultstr(const upb_fielddef *f) {
- assert(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM);
+ UPB_ASSERT(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM);
return enumdefaultstr(f) != NULL;
}
@@ -1286,8 +1278,8 @@ static void release_subdef(upb_fielddef *f) {
bool upb_fielddef_setsubdef(upb_fielddef *f, const upb_def *subdef,
upb_status *s) {
- assert(!upb_fielddef_isfrozen(f));
- assert(upb_fielddef_hassubdef(f));
+ UPB_ASSERT(!upb_fielddef_isfrozen(f));
+ UPB_ASSERT(upb_fielddef_hassubdef(f));
if (subdef && !upb_subdef_typecheck(f, subdef, s)) return false;
release_subdef(f);
f->sub.def = subdef;
@@ -1309,7 +1301,7 @@ bool upb_fielddef_setenumsubdef(upb_fielddef *f, const upb_enumdef *subdef,
bool upb_fielddef_setsubdefname(upb_fielddef *f, const char *name,
upb_status *s) {
char *name_copy;
- assert(!upb_fielddef_isfrozen(f));
+ UPB_ASSERT(!upb_fielddef_isfrozen(f));
if (!upb_fielddef_hassubdef(f)) {
upb_status_seterrmsg(s, "field type does not accept a subdef");
return false;
@@ -1383,6 +1375,7 @@ static void visitmsg(const upb_refcounted *r, upb_refcounted_visit *visit,
void *closure) {
upb_msg_oneof_iter o;
const upb_msgdef *m = (const upb_msgdef*)r;
+ const upb_def *def = upb_msgdef_upcast(m);
upb_msg_field_iter i;
for(upb_msg_field_begin(&i, m);
!upb_msg_field_done(&i);
@@ -1396,6 +1389,9 @@ static void visitmsg(const upb_refcounted *r, upb_refcounted_visit *visit,
upb_oneofdef *f = upb_msg_iter_oneof(&o);
visit(r, upb_oneofdef_upcast(f), closure);
}
+ if (upb_def_file(def)) {
+ visit(r, upb_filedef_upcast(upb_def_file(def)), closure);
+ }
}
static void freemsg(upb_refcounted *r) {
@@ -1430,7 +1426,9 @@ err2:
return NULL;
}
-upb_msgdef *upb_msgdef_dup(const upb_msgdef *m, const void *owner) {
+static upb_oneofdef *upb_oneofdef_dup(const upb_oneofdef *o, const void *owner);
+
+static upb_msgdef *upb_msgdef_dup(const upb_msgdef *m, const void *owner) {
bool ok;
upb_msg_field_iter i;
upb_msg_oneof_iter o;
@@ -1442,7 +1440,7 @@ upb_msgdef *upb_msgdef_dup(const upb_msgdef *m, const void *owner) {
NULL);
newm->map_entry = m->map_entry;
newm->syntax = m->syntax;
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
for(upb_msg_field_begin(&i, m);
!upb_msg_field_done(&i);
upb_msg_field_next(&i)) {
@@ -1544,6 +1542,7 @@ bool upb_msgdef_addfield(upb_msgdef *m, upb_fielddef *f, const void *ref_donor,
* This method is idempotent. Check if |f| is already part of this msgdef and
* return immediately if so. */
if (upb_fielddef_containingtype(f) == m) {
+ if (ref_donor) upb_fielddef_unref(f, ref_donor);
return true;
}
@@ -1643,7 +1642,7 @@ bool upb_msgdef_lookupname(const upb_msgdef *m, const char *name, size_t len,
*o = upb_trygetoneof(upb_value_getptr(val));
*f = upb_trygetfield(upb_value_getptr(val));
- assert((*o != NULL) ^ (*f != NULL)); /* Exactly one of the two should be set. */
+ UPB_ASSERT((*o != NULL) ^ (*f != NULL)); /* Exactly one of the two should be set. */
return true;
}
@@ -1658,7 +1657,7 @@ int upb_msgdef_numoneofs(const upb_msgdef *m) {
}
void upb_msgdef_setmapentry(upb_msgdef *m, bool map_entry) {
- assert(!upb_msgdef_isfrozen(m));
+ UPB_ASSERT(!upb_msgdef_isfrozen(m));
m->map_entry = map_entry;
}
@@ -1765,13 +1764,14 @@ err2:
return NULL;
}
-upb_oneofdef *upb_oneofdef_dup(const upb_oneofdef *o, const void *owner) {
+static upb_oneofdef *upb_oneofdef_dup(const upb_oneofdef *o,
+ const void *owner) {
bool ok;
upb_oneof_iter i;
upb_oneofdef *newo = upb_oneofdef_new(owner);
if (!newo) return NULL;
ok = upb_oneofdef_setname(newo, upb_oneofdef_name(o), NULL);
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
for (upb_oneof_begin(&i, o); !upb_oneof_done(&i); upb_oneof_next(&i)) {
upb_fielddef *f = upb_fielddef_dup(upb_oneof_iter_field(&i), &f);
if (!f || !upb_oneofdef_addfield(newo, f, &f, NULL)) {
@@ -1785,7 +1785,7 @@ upb_oneofdef *upb_oneofdef_dup(const upb_oneofdef *o, const void *owner) {
const char *upb_oneofdef_name(const upb_oneofdef *o) { return o->name; }
bool upb_oneofdef_setname(upb_oneofdef *o, const char *name, upb_status *s) {
- assert(!upb_oneofdef_isfrozen(o));
+ UPB_ASSERT(!upb_oneofdef_isfrozen(o));
if (upb_oneofdef_containingtype(o)) {
upb_status_seterrmsg(s, "oneof already added to a message");
return false;
@@ -1814,11 +1814,15 @@ int upb_oneofdef_numfields(const upb_oneofdef *o) {
return upb_strtable_count(&o->ntof);
}
+uint32_t upb_oneofdef_index(const upb_oneofdef *o) {
+ return o->index;
+}
+
bool upb_oneofdef_addfield(upb_oneofdef *o, upb_fielddef *f,
const void *ref_donor,
upb_status *s) {
- assert(!upb_oneofdef_isfrozen(o));
- assert(!o->parent || !upb_msgdef_isfrozen(o->parent));
+ UPB_ASSERT(!upb_oneofdef_isfrozen(o));
+ UPB_ASSERT(!o->parent || !upb_msgdef_isfrozen(o->parent));
/* This method is idempotent. Check if |f| is already part of this oneofdef
* and return immediately if so. */
@@ -2088,6 +2092,7 @@ bool upb_filedef_adddef(upb_filedef *f, upb_def *def, const void *ref_donor,
if (upb_inttable_push(&f->defs, upb_value_constptr(def))) {
def->file = f;
upb_ref2(def, f);
+ upb_ref2(f, def);
if (ref_donor) upb_def_unref(def, ref_donor);
if (def->type == UPB_DEF_MSG) {
upb_downcast_msgdef_mutable(def)->syntax = f->syntax;
@@ -2108,9 +2113,357 @@ bool upb_filedef_adddep(upb_filedef *f, const upb_filedef *dep) {
return false;
}
}
+
+void upb_symtab_free(upb_symtab *s) {
+ upb_strtable_iter i;
+ upb_strtable_begin(&i, &s->symtab);
+ for (; !upb_strtable_done(&i); upb_strtable_next(&i)) {
+ const upb_def *def = upb_value_getptr(upb_strtable_iter_value(&i));
+ upb_def_unref(def, s);
+ }
+ upb_strtable_uninit(&s->symtab);
+ upb_gfree(s);
+}
+
+upb_symtab *upb_symtab_new() {
+ upb_symtab *s = upb_gmalloc(sizeof(*s));
+ if (!s) {
+ return NULL;
+ }
+
+ upb_strtable_init(&s->symtab, UPB_CTYPE_PTR);
+ return s;
+}
+
+const upb_def *upb_symtab_lookup(const upb_symtab *s, const char *sym) {
+ upb_value v;
+ upb_def *ret = upb_strtable_lookup(&s->symtab, sym, &v) ?
+ upb_value_getptr(v) : NULL;
+ return ret;
+}
+
+const upb_msgdef *upb_symtab_lookupmsg(const upb_symtab *s, const char *sym) {
+ upb_value v;
+ upb_def *def = upb_strtable_lookup(&s->symtab, sym, &v) ?
+ upb_value_getptr(v) : NULL;
+ return def ? upb_dyncast_msgdef(def) : NULL;
+}
+
+const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym) {
+ upb_value v;
+ upb_def *def = upb_strtable_lookup(&s->symtab, sym, &v) ?
+ upb_value_getptr(v) : NULL;
+ return def ? upb_dyncast_enumdef(def) : NULL;
+}
+
+/* Given a symbol and the base symbol inside which it is defined, find the
+ * symbol's definition in t. */
+static upb_def *upb_resolvename(const upb_strtable *t,
+ const char *base, const char *sym) {
+ if(strlen(sym) == 0) return NULL;
+ if(sym[0] == '.') {
+ /* Symbols starting with '.' are absolute, so we do a single lookup.
+ * Slice to omit the leading '.' */
+ upb_value v;
+ return upb_strtable_lookup(t, sym + 1, &v) ? upb_value_getptr(v) : NULL;
+ } else {
+ /* Remove components from base until we find an entry or run out.
+ * TODO: This branch is totally broken, but currently not used. */
+ (void)base;
+ UPB_ASSERT(false);
+ return NULL;
+ }
+}
+
+const upb_def *upb_symtab_resolve(const upb_symtab *s, const char *base,
+ const char *sym) {
+ upb_def *ret = upb_resolvename(&s->symtab, base, sym);
+ return ret;
+}
+
+/* TODO(haberman): we need a lot more testing of error conditions. */
+static bool symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
+ void *ref_donor, upb_refcounted *freeze_also,
+ upb_status *status) {
+ size_t i;
+ size_t add_n;
+ size_t freeze_n;
+ upb_strtable_iter iter;
+ upb_refcounted **add_objs = NULL;
+ upb_def **add_defs = NULL;
+ size_t add_objs_size;
+ upb_strtable addtab;
+
+ if (n == 0 && !freeze_also) {
+ return true;
+ }
+
+ if (!upb_strtable_init(&addtab, UPB_CTYPE_PTR)) {
+ upb_status_seterrmsg(status, "out of memory");
+ return false;
+ }
+
+ /* Add new defs to our "add" set. */
+ for (i = 0; i < n; i++) {
+ upb_def *def = defs[i];
+ const char *fullname;
+ upb_fielddef *f;
+
+ if (upb_def_isfrozen(def)) {
+ upb_status_seterrmsg(status, "added defs must be mutable");
+ goto err;
+ }
+ UPB_ASSERT(!upb_def_isfrozen(def));
+ fullname = upb_def_fullname(def);
+ if (!fullname) {
+ upb_status_seterrmsg(
+ status, "Anonymous defs cannot be added to a symtab");
+ goto err;
+ }
+
+ f = upb_dyncast_fielddef_mutable(def);
+
+ if (f) {
+ if (!upb_fielddef_containingtypename(f)) {
+ upb_status_seterrmsg(status,
+ "Standalone fielddefs must have a containing type "
+ "(extendee) name set");
+ goto err;
+ }
+ } else {
+ if (upb_strtable_lookup(&addtab, fullname, NULL)) {
+ upb_status_seterrf(status, "Conflicting defs named '%s'", fullname);
+ goto err;
+ }
+ if (upb_strtable_lookup(&s->symtab, fullname, NULL)) {
+ upb_status_seterrf(status, "Symtab already has a def named '%s'",
+ fullname);
+ goto err;
+ }
+ upb_def_donateref(def, ref_donor, s);
+ if (!upb_strtable_insert(&addtab, fullname, upb_value_ptr(def)))
+ goto oom_err;
+ def->came_from_user = true;
+ }
+ }
+
+ /* Add standalone fielddefs (ie. extensions) to the appropriate messages.
+ * If the appropriate message only exists in the existing symtab, duplicate
+ * it so we have a mutable copy we can add the fields to. */
+ for (i = 0; i < n; i++) {
+ upb_def *def = defs[i];
+ upb_fielddef *f = upb_dyncast_fielddef_mutable(def);
+ const char *msgname;
+ upb_value v;
+ upb_msgdef *m;
+
+ if (!f) continue;
+ msgname = upb_fielddef_containingtypename(f);
+ /* We validated this earlier in this function. */
+ UPB_ASSERT(msgname);
+
+ /* If the extendee name is absolutely qualified, move past the initial ".".
+ * TODO(haberman): it is not obvious what it would mean if this was not
+ * absolutely qualified. */
+ if (msgname[0] == '.') {
+ msgname++;
+ }
+
+ if (upb_strtable_lookup(&addtab, msgname, &v)) {
+ /* Extendee is in the set of defs the user asked us to add. */
+ m = upb_value_getptr(v);
+ } else {
+ /* Need to find and dup the extendee from the existing symtab. */
+ const upb_msgdef *frozen_m = upb_symtab_lookupmsg(s, msgname);
+ if (!frozen_m) {
+ upb_status_seterrf(status,
+ "Tried to extend message %s that does not exist "
+ "in this SymbolTable.",
+ msgname);
+ goto err;
+ }
+ m = upb_msgdef_dup(frozen_m, s);
+ if (!m) goto oom_err;
+ if (!upb_strtable_insert(&addtab, msgname, upb_value_ptr(m))) {
+ upb_msgdef_unref(m, s);
+ goto oom_err;
+ }
+ }
+
+ if (!upb_msgdef_addfield(m, f, ref_donor, status)) {
+ goto err;
+ }
+ }
+
+ /* Now using the table, resolve symbolic references for subdefs. */
+ upb_strtable_begin(&iter, &addtab);
+ for (; !upb_strtable_done(&iter); upb_strtable_next(&iter)) {
+ const char *base;
+ upb_def *def = upb_value_getptr(upb_strtable_iter_value(&iter));
+ upb_msgdef *m = upb_dyncast_msgdef_mutable(def);
+ upb_msg_field_iter j;
+
+ if (!m) continue;
+ /* Type names are resolved relative to the message in which they appear. */
+ base = upb_msgdef_fullname(m);
+
+ for(upb_msg_field_begin(&j, m);
+ !upb_msg_field_done(&j);
+ upb_msg_field_next(&j)) {
+ upb_fielddef *f = upb_msg_iter_field(&j);
+ const char *name = upb_fielddef_subdefname(f);
+ if (name && !upb_fielddef_subdef(f)) {
+ /* Try the lookup in the current set of to-be-added defs first. If not
+ * there, try existing defs. */
+ upb_def *subdef = upb_resolvename(&addtab, base, name);
+ if (subdef == NULL) {
+ subdef = upb_resolvename(&s->symtab, base, name);
+ }
+ if (subdef == NULL) {
+ upb_status_seterrf(
+ status, "couldn't resolve name '%s' in message '%s'", name, base);
+ goto err;
+ } else if (!upb_fielddef_setsubdef(f, subdef, status)) {
+ goto err;
+ }
+ }
+ }
+ }
+
+ /* We need an array of the defs in addtab, for passing to
+ * upb_refcounted_freeze(). */
+ add_objs_size = upb_strtable_count(&addtab);
+ if (freeze_also) {
+ add_objs_size++;
+ }
+
+ add_defs = upb_gmalloc(sizeof(void*) * add_objs_size);
+ if (add_defs == NULL) goto oom_err;
+ upb_strtable_begin(&iter, &addtab);
+ for (add_n = 0; !upb_strtable_done(&iter); upb_strtable_next(&iter)) {
+ add_defs[add_n++] = upb_value_getptr(upb_strtable_iter_value(&iter));
+ }
+
+ /* Validate defs. */
+ if (!_upb_def_validate(add_defs, add_n, status)) {
+ goto err;
+ }
+
+ /* Cheat a little and give the array a new type.
+ * This is probably undefined behavior, but this code will be deleted soon. */
+ add_objs = (upb_refcounted**)add_defs;
+
+ freeze_n = add_n;
+ if (freeze_also) {
+ add_objs[freeze_n++] = freeze_also;
+ }
+
+ if (!upb_refcounted_freeze(add_objs, freeze_n, status,
+ UPB_MAX_MESSAGE_DEPTH * 2)) {
+ goto err;
+ }
+
+ /* This must be delayed until all errors have been detected, since error
+ * recovery code uses this table to cleanup defs. */
+ upb_strtable_uninit(&addtab);
+
+ /* TODO(haberman) we don't properly handle errors after this point (like
+ * OOM in upb_strtable_insert() below). */
+ for (i = 0; i < add_n; i++) {
+ upb_def *def = (upb_def*)add_objs[i];
+ const char *name = upb_def_fullname(def);
+ upb_value v;
+ bool success;
+
+ if (upb_strtable_remove(&s->symtab, name, &v)) {
+ const upb_def *def = upb_value_getptr(v);
+ upb_def_unref(def, s);
+ }
+ success = upb_strtable_insert(&s->symtab, name, upb_value_ptr(def));
+ UPB_ASSERT(success == true);
+ }
+ upb_gfree(add_defs);
+ return true;
+
+oom_err:
+ upb_status_seterrmsg(status, "out of memory");
+err: {
+ /* We need to donate the refs back. */
+ upb_strtable_begin(&iter, &addtab);
+ for (; !upb_strtable_done(&iter); upb_strtable_next(&iter)) {
+ upb_def *def = upb_value_getptr(upb_strtable_iter_value(&iter));
+ upb_def_donateref(def, s, ref_donor);
+ }
+ }
+ upb_strtable_uninit(&addtab);
+ upb_gfree(add_defs);
+ UPB_ASSERT(!upb_ok(status));
+ return false;
+}
+
+bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
+ void *ref_donor, upb_status *status) {
+ return symtab_add(s, defs, n, ref_donor, NULL, status);
+}
+
+bool upb_symtab_addfile(upb_symtab *s, upb_filedef *file, upb_status *status) {
+ size_t n;
+ size_t i;
+ upb_def **defs;
+ bool ret;
+
+ n = upb_filedef_defcount(file);
+ defs = upb_gmalloc(sizeof(*defs) * n);
+
+ if (defs == NULL) {
+ upb_status_seterrmsg(status, "Out of memory");
+ return false;
+ }
+
+ for (i = 0; i < n; i++) {
+ defs[i] = upb_filedef_mutabledef(file, i);
+ }
+
+ ret = symtab_add(s, defs, n, NULL, upb_filedef_upcast_mutable(file), status);
+
+ upb_gfree(defs);
+ return ret;
+}
+
+/* Iteration. */
+
+static void advance_to_matching(upb_symtab_iter *iter) {
+ if (iter->type == UPB_DEF_ANY)
+ return;
+
+ while (!upb_strtable_done(&iter->iter) &&
+ iter->type != upb_symtab_iter_def(iter)->type) {
+ upb_strtable_next(&iter->iter);
+ }
+}
+
+void upb_symtab_begin(upb_symtab_iter *iter, const upb_symtab *s,
+ upb_deftype_t type) {
+ upb_strtable_begin(&iter->iter, &s->symtab);
+ iter->type = type;
+ advance_to_matching(iter);
+}
+
+void upb_symtab_next(upb_symtab_iter *iter) {
+ upb_strtable_next(&iter->iter);
+ advance_to_matching(iter);
+}
+
+bool upb_symtab_done(const upb_symtab_iter *iter) {
+ return upb_strtable_done(&iter->iter);
+}
+
+const upb_def *upb_symtab_iter_def(const upb_symtab_iter *iter) {
+ return upb_value_getptr(upb_strtable_iter_value(&iter->iter));
+}
/*
** TODO(haberman): it's unclear whether a lot of the consistency checks should
-** assert() or return false.
+** UPB_ASSERT() or return false.
*/
@@ -2220,7 +2573,7 @@ oom:
static int32_t trygetsel(upb_handlers *h, const upb_fielddef *f,
upb_handlertype_t type) {
upb_selector_t sel;
- assert(!upb_handlers_isfrozen(h));
+ UPB_ASSERT(!upb_handlers_isfrozen(h));
if (upb_handlers_msgdef(h) != upb_fielddef_containingtype(f)) {
upb_status_seterrf(
&h->status_, "type mismatch: field %s does not belong to message %s",
@@ -2240,7 +2593,7 @@ static int32_t trygetsel(upb_handlers *h, const upb_fielddef *f,
static upb_selector_t handlers_getsel(upb_handlers *h, const upb_fielddef *f,
upb_handlertype_t type) {
int32_t sel = trygetsel(h, f, type);
- assert(sel >= 0);
+ UPB_ASSERT(sel >= 0);
return sel;
}
@@ -2256,7 +2609,7 @@ static bool doset(upb_handlers *h, int32_t sel, const upb_fielddef *f,
const void *closure_type;
const void **context_closure_type;
- assert(!upb_handlers_isfrozen(h));
+ UPB_ASSERT(!upb_handlers_isfrozen(h));
if (sel < 0) {
upb_status_seterrmsg(&h->status_,
@@ -2336,7 +2689,7 @@ const void *effective_closure_type(upb_handlers *h, const upb_fielddef *f,
const void *ret;
upb_selector_t sel;
- assert(type != UPB_HANDLER_STRING);
+ UPB_ASSERT(type != UPB_HANDLER_STRING);
ret = h->top_closure_type;
if (upb_fielddef_isseq(f) &&
@@ -2391,7 +2744,7 @@ upb_handlers *upb_handlers_new(const upb_msgdef *md, const void *owner) {
int extra;
upb_handlers *h;
- assert(upb_msgdef_isfrozen(md));
+ UPB_ASSERT(upb_msgdef_isfrozen(md));
extra = sizeof(upb_handlers_tabent) * (md->selector_count - 1);
h = upb_calloc(sizeof(*h) + extra);
@@ -2440,18 +2793,18 @@ const upb_handlers *upb_handlers_newfrozen(const upb_msgdef *m,
r = upb_handlers_upcast_mutable(ret);
ok = upb_refcounted_freeze(&r, 1, NULL, UPB_MAX_HANDLER_DEPTH);
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
return ret;
}
const upb_status *upb_handlers_status(upb_handlers *h) {
- assert(!upb_handlers_isfrozen(h));
+ UPB_ASSERT(!upb_handlers_isfrozen(h));
return &h->status_;
}
void upb_handlers_clearerr(upb_handlers *h) {
- assert(!upb_handlers_isfrozen(h));
+ UPB_ASSERT(!upb_handlers_isfrozen(h));
upb_status_clear(&h->status_);
}
@@ -2487,16 +2840,16 @@ bool upb_handlers_setstartmsg(upb_handlers *h, upb_startmsg_handlerfunc *func,
bool upb_handlers_setendmsg(upb_handlers *h, upb_endmsg_handlerfunc *func,
upb_handlerattr *attr) {
- assert(!upb_handlers_isfrozen(h));
+ UPB_ASSERT(!upb_handlers_isfrozen(h));
return doset(h, UPB_ENDMSG_SELECTOR, NULL, UPB_HANDLER_INT32,
(upb_func *)func, attr);
}
bool upb_handlers_setsubhandlers(upb_handlers *h, const upb_fielddef *f,
const upb_handlers *sub) {
- assert(sub);
- assert(!upb_handlers_isfrozen(h));
- assert(upb_fielddef_issubmsg(f));
+ UPB_ASSERT(sub);
+ UPB_ASSERT(!upb_handlers_isfrozen(h));
+ UPB_ASSERT(upb_fielddef_issubmsg(f));
if (SUBH_F(h, f)) return false; /* Can't reset. */
if (upb_msgdef_upcast(upb_handlers_msgdef(sub)) != upb_fielddef_subdef(f)) {
return false;
@@ -2508,7 +2861,7 @@ bool upb_handlers_setsubhandlers(upb_handlers *h, const upb_fielddef *f,
const upb_handlers *upb_handlers_getsubhandlers(const upb_handlers *h,
const upb_fielddef *f) {
- assert(upb_fielddef_issubmsg(f));
+ UPB_ASSERT(upb_fielddef_issubmsg(f));
return SUBH_F(h, f);
}
@@ -2534,7 +2887,7 @@ bool upb_handlers_addcleanup(upb_handlers *h, void *p, upb_handlerfree *func) {
return false;
}
ok = upb_inttable_insertptr(&h->cleanup_, p, upb_value_fptr(func));
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
return true;
}
@@ -2635,7 +2988,7 @@ upb_handlertype_t upb_handlers_getprimitivehandlertype(const upb_fielddef *f) {
case UPB_TYPE_FLOAT: return UPB_HANDLER_FLOAT;
case UPB_TYPE_DOUBLE: return UPB_HANDLER_DOUBLE;
case UPB_TYPE_BOOL: return UPB_HANDLER_BOOL;
- default: assert(false); return -1; /* Invalid input. */
+ default: UPB_ASSERT(false); return -1; /* Invalid input. */
}
}
@@ -2698,7 +3051,7 @@ bool upb_handlers_getselector(const upb_fielddef *f, upb_handlertype_t type,
*s = f->selector_base;
break;
}
- assert((size_t)*s < upb_fielddef_containingtype(f)->selector_count);
+ UPB_ASSERT((size_t)*s < upb_fielddef_containingtype(f)->selector_count);
return true;
}
@@ -2803,6 +3156,1216 @@ bool upb_byteshandler_setendstr(upb_byteshandler *h,
h->table[UPB_ENDSTR_SELECTOR].attr.handler_data_ = d;
return true;
}
+
+
+static bool is_power_of_two(size_t val) {
+ return (val & (val - 1)) == 0;
+}
+
+/* Align up to the given power of 2. */
+static size_t align_up(size_t val, size_t align) {
+ UPB_ASSERT(is_power_of_two(align));
+ return (val + align - 1) & ~(align - 1);
+}
+
+static size_t div_round_up(size_t n, size_t d) {
+ return (n + d - 1) / d;
+}
+
+bool upb_fieldtype_mapkeyok(upb_fieldtype_t type) {
+ return type == UPB_TYPE_BOOL || type == UPB_TYPE_INT32 ||
+ type == UPB_TYPE_UINT32 || type == UPB_TYPE_INT64 ||
+ type == UPB_TYPE_UINT64 || type == UPB_TYPE_STRING;
+}
+
+void *upb_array_pack(const upb_array *arr, void *p, size_t *ofs, size_t size);
+void *upb_map_pack(const upb_map *map, void *p, size_t *ofs, size_t size);
+
+#define CHARPTR_AT(msg, ofs) ((char*)msg + ofs)
+#define ENCODE_MAX_NESTING 64
+#define CHECK_TRUE(x) if (!(x)) { return false; }
+
+/** upb_msgval ****************************************************************/
+
+#define upb_alignof(t) offsetof(struct { char c; t x; }, x)
+
+/* These functions will generate real memcpy() calls on ARM sadly, because
+ * the compiler assumes they might not be aligned. */
+
+static upb_msgval upb_msgval_read(const void *p, size_t ofs,
+ uint8_t size) {
+ upb_msgval val;
+ p = (char*)p + ofs;
+ memcpy(&val, p, size);
+ return val;
+}
+
+static void upb_msgval_write(void *p, size_t ofs, upb_msgval val,
+ uint8_t size) {
+ p = (char*)p + ofs;
+ memcpy(p, &val, size);
+}
+
+static size_t upb_msgval_sizeof(upb_fieldtype_t type) {
+ switch (type) {
+ case UPB_TYPE_DOUBLE:
+ case UPB_TYPE_INT64:
+ case UPB_TYPE_UINT64:
+ return 8;
+ case UPB_TYPE_ENUM:
+ case UPB_TYPE_INT32:
+ case UPB_TYPE_UINT32:
+ case UPB_TYPE_FLOAT:
+ return 4;
+ case UPB_TYPE_BOOL:
+ return 1;
+ case UPB_TYPE_BYTES:
+ case UPB_TYPE_MESSAGE:
+ return sizeof(void*);
+ case UPB_TYPE_STRING:
+ return sizeof(char*) + sizeof(size_t);
+ }
+ UPB_UNREACHABLE();
+}
+
+static uint8_t upb_msg_fieldsize(const upb_fielddef *f) {
+ if (upb_fielddef_isseq(f)) {
+ return sizeof(void*);
+ } else {
+ return upb_msgval_sizeof(upb_fielddef_type(f));
+ }
+}
+
+/* TODO(haberman): this is broken right now because upb_msgval can contain
+ * a char* / size_t pair, which is too big for a upb_value. To fix this
+ * we'll probably need to dynamically allocate a upb_msgval and store a
+ * pointer to that in the tables for extensions/maps. */
+static upb_value upb_toval(upb_msgval val) {
+ upb_value ret;
+ UPB_UNUSED(val);
+ memset(&ret, 0, sizeof(upb_value)); /* XXX */
+ return ret;
+}
+
+static upb_msgval upb_msgval_fromval(upb_value val) {
+ upb_msgval ret;
+ UPB_UNUSED(val);
+ memset(&ret, 0, sizeof(upb_msgval)); /* XXX */
+ return ret;
+}
+
+static upb_ctype_t upb_fieldtotabtype(upb_fieldtype_t type) {
+ switch (type) {
+ case UPB_TYPE_FLOAT: return UPB_CTYPE_FLOAT;
+ case UPB_TYPE_DOUBLE: return UPB_CTYPE_DOUBLE;
+ case UPB_TYPE_BOOL: return UPB_CTYPE_BOOL;
+ case UPB_TYPE_BYTES:
+ case UPB_TYPE_MESSAGE:
+ case UPB_TYPE_STRING: return UPB_CTYPE_CONSTPTR;
+ case UPB_TYPE_ENUM:
+ case UPB_TYPE_INT32: return UPB_CTYPE_INT32;
+ case UPB_TYPE_UINT32: return UPB_CTYPE_UINT32;
+ case UPB_TYPE_INT64: return UPB_CTYPE_INT64;
+ case UPB_TYPE_UINT64: return UPB_CTYPE_UINT64;
+ default: UPB_ASSERT(false); return 0;
+ }
+}
+
+static upb_msgval upb_msgval_fromdefault(const upb_fielddef *f) {
+ /* TODO(haberman): improve/optimize this (maybe use upb_msgval in fielddef) */
+ switch (upb_fielddef_type(f)) {
+ case UPB_TYPE_FLOAT:
+ return upb_msgval_float(upb_fielddef_defaultfloat(f));
+ case UPB_TYPE_DOUBLE:
+ return upb_msgval_double(upb_fielddef_defaultdouble(f));
+ case UPB_TYPE_BOOL:
+ return upb_msgval_bool(upb_fielddef_defaultbool(f));
+ case UPB_TYPE_STRING:
+ case UPB_TYPE_BYTES: {
+ size_t len;
+ const char *ptr = upb_fielddef_defaultstr(f, &len);
+ return upb_msgval_str(ptr, len);
+ }
+ case UPB_TYPE_MESSAGE:
+ return upb_msgval_msg(NULL);
+ case UPB_TYPE_ENUM:
+ case UPB_TYPE_INT32:
+ return upb_msgval_int32(upb_fielddef_defaultint32(f));
+ case UPB_TYPE_UINT32:
+ return upb_msgval_uint32(upb_fielddef_defaultuint32(f));
+ case UPB_TYPE_INT64:
+ return upb_msgval_int64(upb_fielddef_defaultint64(f));
+ case UPB_TYPE_UINT64:
+ return upb_msgval_uint64(upb_fielddef_defaultuint64(f));
+ default:
+ UPB_ASSERT(false);
+ return upb_msgval_msg(NULL);
+ }
+}
+
+
+/** upb_msglayout *************************************************************/
+
+struct upb_msglayout {
+ upb_msgfactory *factory;
+ const upb_msgdef *msgdef;
+ size_t size;
+ size_t extdict_offset;
+ void *default_msg;
+ uint32_t *field_offsets;
+ uint32_t *case_offsets;
+ uint32_t *hasbits;
+ bool has_extdict;
+ uint8_t align;
+};
+
+static void upb_msg_checkfield(const upb_msglayout *l, const upb_fielddef *f) {
+ UPB_ASSERT(l->msgdef == upb_fielddef_containingtype(f));
+}
+
+static void upb_msglayout_free(upb_msglayout *l) {
+ upb_gfree(l->default_msg);
+ upb_gfree(l);
+}
+
+const upb_msgdef *upb_msglayout_msgdef(const upb_msglayout *l) {
+ return l->msgdef;
+}
+
+static size_t upb_msglayout_place(upb_msglayout *l, size_t size) {
+ size_t ret;
+
+ l->size = align_up(l->size, size);
+ l->align = align_up(l->align, size);
+ ret = l->size;
+ l->size += size;
+ return ret;
+}
+
+static uint32_t upb_msglayout_offset(const upb_msglayout *l,
+ const upb_fielddef *f) {
+ return l->field_offsets[upb_fielddef_index(f)];
+}
+
+static uint32_t upb_msglayout_hasbit(const upb_msglayout *l,
+ const upb_fielddef *f) {
+ return l->hasbits[upb_fielddef_index(f)];
+}
+
+static bool upb_msglayout_initdefault(upb_msglayout *l) {
+ const upb_msgdef *m = l->msgdef;
+ upb_msg_field_iter it;
+
+ if (upb_msgdef_syntax(m) == UPB_SYNTAX_PROTO2 && l->size) {
+ /* Allocate default message and set default values in it. */
+ l->default_msg = upb_gmalloc(l->size);
+ if (!l->default_msg) {
+ return false;
+ }
+
+ memset(l->default_msg, 0, l->size);
+
+ for (upb_msg_field_begin(&it, m); !upb_msg_field_done(&it);
+ upb_msg_field_next(&it)) {
+ const upb_fielddef* f = upb_msg_iter_field(&it);
+
+ if (upb_fielddef_containingoneof(f)) {
+ continue;
+ }
+
+ if (!upb_fielddef_isstring(f) &&
+ !upb_fielddef_issubmsg(f) &&
+ !upb_fielddef_isseq(f)) {
+ upb_msg_set(l->default_msg, f, upb_msgval_fromdefault(f), l);
+ }
+ }
+ }
+
+ return true;
+}
+
+static upb_msglayout *upb_msglayout_new(const upb_msgdef *m) {
+ upb_msg_field_iter it;
+ upb_msg_oneof_iter oit;
+ upb_msglayout *l;
+ size_t hasbit;
+ size_t array_size = upb_msgdef_numfields(m) + upb_msgdef_numoneofs(m);
+
+ if (upb_msgdef_syntax(m) == UPB_SYNTAX_PROTO2) {
+ array_size += upb_msgdef_numfields(m); /* hasbits. */
+ }
+
+ l = upb_gmalloc(sizeof(*l) + (sizeof(uint32_t) * array_size));
+ if (!l) return NULL;
+
+ memset(l, 0, sizeof(*l));
+
+ l->msgdef = m;
+ l->align = 1;
+ l->field_offsets = (uint32_t*)CHARPTR_AT(l, sizeof(*l));
+ l->case_offsets = l->field_offsets + upb_msgdef_numfields(m);
+ l->hasbits = l->case_offsets + upb_msgdef_numoneofs(m);
+
+ /* Allocate data offsets in three stages:
+ *
+ * 1. hasbits.
+ * 2. regular fields.
+ * 3. oneof fields.
+ *
+ * OPT: There is a lot of room for optimization here to minimize the size.
+ */
+
+ /* Allocate hasbits. Start at sizeof(void*) for upb_alloc*. */
+ for (upb_msg_field_begin(&it, m), hasbit = sizeof(void*) * 8;
+ !upb_msg_field_done(&it);
+ upb_msg_field_next(&it)) {
+ const upb_fielddef* f = upb_msg_iter_field(&it);
+
+ if (upb_fielddef_haspresence(f) && !upb_fielddef_containingoneof(f)) {
+ l->hasbits[upb_fielddef_index(f)] = hasbit++;
+ }
+ }
+
+ /* Account for space used by hasbits. */
+ l->size = div_round_up(hasbit, 8);
+
+ /* Allocate non-oneof fields. */
+ for (upb_msg_field_begin(&it, m); !upb_msg_field_done(&it);
+ upb_msg_field_next(&it)) {
+ const upb_fielddef* f = upb_msg_iter_field(&it);
+ size_t field_size = upb_msg_fieldsize(f);
+ size_t index = upb_fielddef_index(f);
+
+
+ if (upb_fielddef_containingoneof(f)) {
+ /* Oneofs are handled separately below. */
+ continue;
+ }
+
+ l->field_offsets[index] = upb_msglayout_place(l, field_size);
+ }
+
+ /* Allocate oneof fields. Each oneof field consists of a uint32 for the case
+ * and space for the actual data. */
+ for (upb_msg_oneof_begin(&oit, m); !upb_msg_oneof_done(&oit);
+ upb_msg_oneof_next(&oit)) {
+ const upb_oneofdef* oneof = upb_msg_iter_oneof(&oit);
+ upb_oneof_iter fit;
+ size_t case_size = sizeof(uint32_t); /* Could potentially optimize this. */
+ size_t field_size = 0;
+ size_t case_offset;
+ size_t val_offset;
+
+ /* Calculate field size: the max of all field sizes. */
+ for (upb_oneof_begin(&fit, oneof);
+ !upb_oneof_done(&fit);
+ upb_oneof_next(&fit)) {
+ const upb_fielddef* f = upb_oneof_iter_field(&fit);
+ field_size = UPB_MAX(field_size, upb_msg_fieldsize(f));
+ }
+
+ /* Align and allocate case offset. */
+ case_offset = upb_msglayout_place(l, case_size);
+ val_offset = upb_msglayout_place(l, field_size);
+
+ l->case_offsets[upb_oneofdef_index(oneof)] = case_offset;
+
+ /* Assign all fields in the oneof this same offset. */
+ for (upb_oneof_begin(&fit, oneof); !upb_oneof_done(&fit);
+ upb_oneof_next(&fit)) {
+ const upb_fielddef* f = upb_oneof_iter_field(&fit);
+ l->field_offsets[upb_fielddef_index(f)] = val_offset;
+ }
+ }
+
+ /* Size of the entire structure should be a multiple of its greatest
+ * alignment. */
+ l->size = align_up(l->size, l->align);
+
+ if (upb_msglayout_initdefault(l)) {
+ return l;
+ } else {
+ upb_msglayout_free(l);
+ return NULL;
+ }
+}
+
+upb_msgfactory *upb_msglayout_factory(const upb_msglayout *layout) {
+ return layout->factory;
+}
+
+
+/** upb_msgfactory ************************************************************/
+
+struct upb_msgfactory {
+ const upb_symtab *symtab; /* We own a ref. */
+ upb_inttable layouts;
+ upb_inttable mergehandlers;
+};
+
+upb_msgfactory *upb_msgfactory_new(const upb_symtab *symtab) {
+ upb_msgfactory *ret = upb_gmalloc(sizeof(*ret));
+
+ ret->symtab = symtab;
+ upb_inttable_init(&ret->layouts, UPB_CTYPE_PTR);
+ upb_inttable_init(&ret->mergehandlers, UPB_CTYPE_CONSTPTR);
+
+ return ret;
+}
+
+void upb_msgfactory_free(upb_msgfactory *f) {
+ upb_inttable_iter i;
+ upb_inttable_begin(&i, &f->layouts);
+ for(; !upb_inttable_done(&i); upb_inttable_next(&i)) {
+ upb_msglayout *l = upb_value_getptr(upb_inttable_iter_value(&i));
+ upb_msglayout_free(l);
+ }
+
+ upb_inttable_begin(&i, &f->mergehandlers);
+ for(; !upb_inttable_done(&i); upb_inttable_next(&i)) {
+ const upb_handlers *h = upb_value_getconstptr(upb_inttable_iter_value(&i));
+ upb_handlers_unref(h, f);
+ }
+
+ upb_inttable_uninit(&f->layouts);
+ upb_inttable_uninit(&f->mergehandlers);
+ upb_gfree(f);
+}
+
+const upb_symtab *upb_msgfactory_symtab(const upb_msgfactory *f) {
+ return f->symtab;
+}
+
+const upb_msglayout *upb_msgfactory_getlayout(upb_msgfactory *f,
+ const upb_msgdef *m) {
+ upb_value v;
+ UPB_ASSERT(upb_symtab_lookupmsg(f->symtab, upb_msgdef_fullname(m)) == m);
+ UPB_ASSERT(!upb_msgdef_mapentry(m));
+
+ if (upb_inttable_lookupptr(&f->layouts, m, &v)) {
+ UPB_ASSERT(upb_value_getptr(v));
+ return upb_value_getptr(v);
+ } else {
+ upb_msgfactory *mutable_f = (void*)f;
+ upb_msglayout *l = upb_msglayout_new(m);
+ upb_inttable_insertptr(&mutable_f->layouts, m, upb_value_ptr(l));
+ UPB_ASSERT(l);
+ l->factory = f;
+ return l;
+ }
+}
+
+/* Our handlers that we don't expose externally. */
+
+void *upb_msg_startstr(void *msg, const void *hd, size_t size_hint) {
+ uint32_t ofs = (uintptr_t)hd;
+ /* We pass NULL here because we know we can get away with it. */
+ upb_alloc *alloc = upb_msg_alloc(msg, NULL);
+ upb_msgval val;
+ UPB_UNUSED(size_hint);
+
+ val = upb_msgval_read(msg, ofs, upb_msgval_sizeof(UPB_TYPE_STRING));
+
+ upb_free(alloc, (void*)val.str.ptr);
+ val.str.ptr = NULL;
+ val.str.len = 0;
+
+ upb_msgval_write(msg, ofs, val, upb_msgval_sizeof(UPB_TYPE_STRING));
+ return msg;
+}
+
+size_t upb_msg_str(void *msg, const void *hd, const char *ptr, size_t size,
+ const upb_bufhandle *handle) {
+ uint32_t ofs = (uintptr_t)hd;
+ /* We pass NULL here because we know we can get away with it. */
+ upb_alloc *alloc = upb_msg_alloc(msg, NULL);
+ upb_msgval val;
+ size_t newsize;
+ UPB_UNUSED(handle);
+
+ val = upb_msgval_read(msg, ofs, upb_msgval_sizeof(UPB_TYPE_STRING));
+
+ newsize = val.str.len + size;
+ val.str.ptr = upb_realloc(alloc, (void*)val.str.ptr, val.str.len, newsize);
+
+ if (!val.str.ptr) {
+ return false;
+ }
+
+ memcpy((char*)val.str.ptr + val.str.len, ptr, size);
+ val.str.len = newsize;
+ upb_msgval_write(msg, ofs, val, upb_msgval_sizeof(UPB_TYPE_STRING));
+ return size;
+}
+
+static void callback(const void *closure, upb_handlers *h) {
+ upb_msgfactory *factory = (upb_msgfactory*)closure;
+ const upb_msgdef *md = upb_handlers_msgdef(h);
+ const upb_msglayout* layout = upb_msgfactory_getlayout(factory, md);
+ upb_msg_field_iter i;
+ UPB_UNUSED(factory);
+
+ for(upb_msg_field_begin(&i, md);
+ !upb_msg_field_done(&i);
+ upb_msg_field_next(&i)) {
+ const upb_fielddef *f = upb_msg_iter_field(&i);
+ size_t offset = upb_msglayout_offset(layout, f);
+ upb_handlerattr attr = UPB_HANDLERATTR_INITIALIZER;
+ upb_handlerattr_sethandlerdata(&attr, (void*)offset);
+
+ if (upb_fielddef_isseq(f)) {
+ } else if (upb_fielddef_isstring(f)) {
+ upb_handlers_setstartstr(h, f, upb_msg_startstr, &attr);
+ upb_handlers_setstring(h, f, upb_msg_str, &attr);
+ } else {
+ upb_msg_setscalarhandler(
+ h, f, offset, upb_msglayout_hasbit(layout, f));
+ }
+ }
+}
+
+const upb_handlers *upb_msgfactory_getmergehandlers(upb_msgfactory *f,
+ const upb_msgdef *m) {
+ upb_msgfactory *mutable_f = (void*)f;
+
+ /* TODO(haberman): properly cache these. */
+ const upb_handlers *ret = upb_handlers_newfrozen(m, f, callback, f);
+ upb_inttable_push(&mutable_f->mergehandlers, upb_value_constptr(ret));
+
+ return ret;
+}
+
+const upb_visitorplan *upb_msgfactory_getvisitorplan(upb_msgfactory *f,
+ const upb_handlers *h) {
+ const upb_msgdef *md = upb_handlers_msgdef(h);
+ return (const upb_visitorplan*)upb_msgfactory_getlayout(f, md);
+}
+
+
+/** upb_visitor ***************************************************************/
+
+struct upb_visitor {
+ const upb_msglayout *layout;
+ upb_sink *sink;
+};
+
+static upb_selector_t getsel2(const upb_fielddef *f, upb_handlertype_t type) {
+ upb_selector_t ret;
+ bool ok = upb_handlers_getselector(f, type, &ret);
+ UPB_ASSERT(ok);
+ return ret;
+}
+
+static bool upb_visitor_hasfield(const upb_msg *msg, const upb_fielddef *f,
+ const upb_msglayout *layout) {
+ if (upb_fielddef_isseq(f)) {
+ return upb_msgval_getarr(upb_msg_get(msg, f, layout)) != NULL;
+ } else if (upb_msgdef_syntax(upb_fielddef_containingtype(f)) ==
+ UPB_SYNTAX_PROTO2) {
+ return upb_msg_has(msg, f, layout);
+ } else {
+ upb_msgval val = upb_msg_get(msg, f, layout);
+ switch (upb_fielddef_type(f)) {
+ case UPB_TYPE_FLOAT:
+ return upb_msgval_getfloat(val) != 0;
+ case UPB_TYPE_DOUBLE:
+ return upb_msgval_getdouble(val) != 0;
+ case UPB_TYPE_BOOL:
+ return upb_msgval_getbool(val);
+ case UPB_TYPE_ENUM:
+ case UPB_TYPE_INT32:
+ return upb_msgval_getint32(val) != 0;
+ case UPB_TYPE_UINT32:
+ return upb_msgval_getuint32(val) != 0;
+ case UPB_TYPE_INT64:
+ return upb_msgval_getint64(val) != 0;
+ case UPB_TYPE_UINT64:
+ return upb_msgval_getuint64(val) != 0;
+ case UPB_TYPE_STRING:
+ case UPB_TYPE_BYTES:
+ return upb_msgval_getstr(val) && upb_msgval_getstrlen(val) > 0;
+ case UPB_TYPE_MESSAGE:
+ return upb_msgval_getmsg(val) != NULL;
+ }
+ UPB_UNREACHABLE();
+ }
+}
+
+static bool upb_visitor_visitmsg2(const upb_msg *msg,
+ const upb_msglayout *layout, upb_sink *sink,
+ int depth) {
+ const upb_msgdef *md = upb_msglayout_msgdef(layout);
+ upb_msg_field_iter i;
+ upb_status status;
+
+ upb_sink_startmsg(sink);
+
+ /* Protect against cycles (possible because users may freely reassign message
+ * and repeated fields) by imposing a maximum recursion depth. */
+ if (depth > ENCODE_MAX_NESTING) {
+ return false;
+ }
+
+ for (upb_msg_field_begin(&i, md);
+ !upb_msg_field_done(&i);
+ upb_msg_field_next(&i)) {
+ upb_fielddef *f = upb_msg_iter_field(&i);
+ upb_msgval val;
+
+ if (!upb_visitor_hasfield(msg, f, layout)) {
+ continue;
+ }
+
+ val = upb_msg_get(msg, f, layout);
+
+ if (upb_fielddef_isseq(f)) {
+ const upb_array *arr = upb_msgval_getarr(val);
+ UPB_ASSERT(arr);
+ /* TODO: putary(ary, f, sink, depth);*/
+ } else if (upb_fielddef_issubmsg(f)) {
+ const upb_map *map = upb_msgval_getmap(val);
+ UPB_ASSERT(map);
+ /* TODO: putmap(map, f, sink, depth);*/
+ } else if (upb_fielddef_isstring(f)) {
+ /* TODO putstr(); */
+ } else {
+ upb_selector_t sel = getsel2(f, upb_handlers_getprimitivehandlertype(f));
+ UPB_ASSERT(upb_fielddef_isprimitive(f));
+
+ switch (upb_fielddef_type(f)) {
+ case UPB_TYPE_FLOAT:
+ CHECK_TRUE(upb_sink_putfloat(sink, sel, upb_msgval_getfloat(val)));
+ break;
+ case UPB_TYPE_DOUBLE:
+ CHECK_TRUE(
+ upb_sink_putdouble(sink, sel, upb_msgval_getdouble(val)));
+ break;
+ case UPB_TYPE_BOOL:
+ CHECK_TRUE(upb_sink_putbool(sink, sel, upb_msgval_getbool(val)));
+ break;
+ case UPB_TYPE_ENUM:
+ case UPB_TYPE_INT32:
+ CHECK_TRUE(upb_sink_putint32(sink, sel, upb_msgval_getint32(val)));
+ break;
+ case UPB_TYPE_UINT32:
+ CHECK_TRUE(
+ upb_sink_putuint32(sink, sel, upb_msgval_getuint32(val)));
+ break;
+ case UPB_TYPE_INT64:
+ CHECK_TRUE(upb_sink_putint64(sink, sel, upb_msgval_getint64(val)));
+ break;
+ case UPB_TYPE_UINT64:
+ CHECK_TRUE(
+ upb_sink_putuint64(sink, sel, upb_msgval_getuint64(val)));
+ break;
+ case UPB_TYPE_STRING:
+ case UPB_TYPE_BYTES:
+ case UPB_TYPE_MESSAGE:
+ UPB_UNREACHABLE();
+ }
+ }
+ }
+
+ upb_sink_endmsg(sink, &status);
+ return true;
+}
+
+upb_visitor *upb_visitor_create(upb_env *e, const upb_visitorplan *vp,
+ upb_sink *output) {
+ upb_visitor *visitor = upb_env_malloc(e, sizeof(*visitor));
+ visitor->layout = (const upb_msglayout*)vp;
+ visitor->sink = output;
+ return visitor;
+}
+
+bool upb_visitor_visitmsg(upb_visitor *visitor, const upb_msg *msg) {
+ return upb_visitor_visitmsg2(msg, visitor->layout, visitor->sink, 0);
+}
+
+
+/** upb_msg *******************************************************************/
+
+/* If we always read/write as a consistent type to each address, this shouldn't
+ * violate aliasing.
+ */
+#define DEREF(msg, ofs, type) *(type*)CHARPTR_AT(msg, ofs)
+
+static upb_inttable *upb_msg_trygetextdict(const upb_msg *msg,
+ const upb_msglayout *l) {
+ return l->has_extdict ? DEREF(msg, l->extdict_offset, upb_inttable*) : NULL;
+}
+
+static upb_inttable *upb_msg_getextdict(upb_msg *msg,
+ const upb_msglayout *l,
+ upb_alloc *a) {
+ upb_inttable *ext_dict;
+ UPB_ASSERT(l->has_extdict);
+
+ ext_dict = upb_msg_trygetextdict(msg, l);
+
+ if (!ext_dict) {
+ ext_dict = upb_malloc(a, sizeof(upb_inttable));
+
+ if (!ext_dict) {
+ return NULL;
+ }
+
+ /* Use an 8-byte type to ensure all bytes are copied. */
+ if (!upb_inttable_init2(ext_dict, UPB_CTYPE_INT64, a)) {
+ upb_free(a, ext_dict);
+ return NULL;
+ }
+
+ DEREF(msg, l->extdict_offset, upb_inttable*) = ext_dict;
+ }
+
+ return ext_dict;
+}
+
+static uint32_t upb_msg_getoneofint(const upb_msg *msg,
+ const upb_oneofdef *o,
+ const upb_msglayout *l) {
+ size_t oneof_ofs = l->case_offsets[upb_oneofdef_index(o)];
+ return DEREF(msg, oneof_ofs, uint8_t);
+}
+
+static void upb_msg_setoneofcase(const upb_msg *msg,
+ const upb_oneofdef *o,
+ const upb_msglayout *l,
+ uint32_t val) {
+ size_t oneof_ofs = l->case_offsets[upb_oneofdef_index(o)];
+ DEREF(msg, oneof_ofs, uint8_t) = val;
+}
+
+
+static bool upb_msg_oneofis(const upb_msg *msg, const upb_msglayout *l,
+ const upb_oneofdef *o, const upb_fielddef *f) {
+ return upb_msg_getoneofint(msg, o, l) == upb_fielddef_number(f);
+}
+
+size_t upb_msg_sizeof(const upb_msglayout *l) { return l->size; }
+
+void upb_msg_init(upb_msg *msg, const upb_msglayout *l, upb_alloc *a) {
+ if (l->default_msg) {
+ memcpy(msg, l->default_msg, l->size);
+ } else {
+ memset(msg, 0, l->size);
+ }
+
+ /* Set arena pointer. */
+ memcpy(msg, &a, sizeof(a));
+}
+
+void upb_msg_uninit(upb_msg *msg, const upb_msglayout *l) {
+ upb_inttable *ext_dict = upb_msg_trygetextdict(msg, l);
+ if (ext_dict) {
+ upb_inttable_uninit2(ext_dict, upb_msg_alloc(msg, l));
+ }
+}
+
+upb_msg *upb_msg_new(const upb_msglayout *l, upb_alloc *a) {
+ upb_msg *msg = upb_malloc(a, upb_msg_sizeof(l));
+
+ if (msg) {
+ upb_msg_init(msg, l, a);
+ }
+
+ return msg;
+}
+
+void upb_msg_free(upb_msg *msg, const upb_msglayout *l) {
+ upb_msg_uninit(msg, l);
+ upb_free(upb_msg_alloc(msg, l), msg);
+}
+
+upb_alloc *upb_msg_alloc(const upb_msg *msg, const upb_msglayout *l) {
+ upb_alloc *alloc;
+ UPB_UNUSED(l);
+ memcpy(&alloc, msg, sizeof(alloc));
+ return alloc;
+}
+
+bool upb_msg_has(const upb_msg *msg,
+ const upb_fielddef *f,
+ const upb_msglayout *l) {
+ const upb_oneofdef *o;
+ upb_msg_checkfield(l, f);
+ UPB_ASSERT(upb_fielddef_haspresence(f));
+
+ if (upb_fielddef_isextension(f)) {
+ /* Extensions are set when they are present in the extension dict. */
+ upb_inttable *ext_dict = upb_msg_trygetextdict(msg, l);
+ upb_value v;
+ return ext_dict != NULL &&
+ upb_inttable_lookup32(ext_dict, upb_fielddef_number(f), &v);
+ } else if ((o = upb_fielddef_containingoneof(f)) != NULL) {
+ /* Oneofs are set when the oneof number is set to this field. */
+ return upb_msg_getoneofint(msg, o, l) == upb_fielddef_number(f);
+ } else {
+ /* Other fields are set when their hasbit is set. */
+ uint32_t hasbit = l->hasbits[upb_fielddef_index(f)];
+ return DEREF(msg, hasbit / 8, char) | (1 << (hasbit % 8));
+ }
+}
+
+upb_msgval upb_msg_get(const upb_msg *msg, const upb_fielddef *f,
+ const upb_msglayout *l) {
+ upb_msg_checkfield(l, f);
+
+ if (upb_fielddef_isextension(f)) {
+ upb_inttable *ext_dict = upb_msg_trygetextdict(msg, l);
+ upb_value val;
+ if (upb_inttable_lookup32(ext_dict, upb_fielddef_number(f), &val)) {
+ return upb_msgval_fromval(val);
+ } else {
+ return upb_msgval_fromdefault(f);
+ }
+ } else {
+ size_t ofs = l->field_offsets[upb_fielddef_index(f)];
+ const upb_oneofdef *o = upb_fielddef_containingoneof(f);
+ upb_msgval ret;
+
+ if (o && !upb_msg_oneofis(msg, l, o, f)) {
+ /* Oneof defaults can't come from the message because the memory is reused
+ * by all types in the oneof. */
+ return upb_msgval_fromdefault(f);
+ }
+
+ ret = upb_msgval_read(msg, ofs, upb_msg_fieldsize(f));
+ return ret;
+ }
+}
+
+bool upb_msg_set(upb_msg *msg,
+ const upb_fielddef *f,
+ upb_msgval val,
+ const upb_msglayout *l) {
+ upb_alloc *a = upb_msg_alloc(msg, l);
+ upb_msg_checkfield(l, f);
+
+ if (upb_fielddef_isextension(f)) {
+ /* TODO(haberman): introduce table API that can do this in one call. */
+ upb_inttable *ext = upb_msg_getextdict(msg, l, a);
+ upb_value val2 = upb_toval(val);
+ if (!upb_inttable_replace(ext, upb_fielddef_number(f), val2) &&
+ !upb_inttable_insert2(ext, upb_fielddef_number(f), val2, a)) {
+ return false;
+ }
+ } else {
+ size_t ofs = l->field_offsets[upb_fielddef_index(f)];
+ const upb_oneofdef *o = upb_fielddef_containingoneof(f);
+
+ if (o) {
+ upb_msg_setoneofcase(msg, o, l, upb_fielddef_number(f));
+ }
+
+ upb_msgval_write(msg, ofs, val, upb_msg_fieldsize(f));
+ }
+ return true;
+}
+
+
+/** upb_array *****************************************************************/
+
+struct upb_array {
+ upb_fieldtype_t type;
+ uint8_t element_size;
+ void *data; /* Each element is element_size. */
+ size_t len; /* Measured in elements. */
+ size_t size; /* Measured in elements. */
+ upb_alloc *alloc;
+};
+
+#define DEREF_ARR(arr, i, type) ((type*)arr->data)[i]
+
+size_t upb_array_sizeof(upb_fieldtype_t type) {
+ UPB_UNUSED(type);
+ return sizeof(upb_array);
+}
+
+void upb_array_init(upb_array *arr, upb_fieldtype_t type, upb_alloc *alloc) {
+ arr->type = type;
+ arr->data = NULL;
+ arr->len = 0;
+ arr->size = 0;
+ arr->element_size = upb_msgval_sizeof(type);
+ arr->alloc = alloc;
+}
+
+void upb_array_uninit(upb_array *arr) {
+ upb_free(arr->alloc, arr->data);
+}
+
+upb_array *upb_array_new(upb_fieldtype_t type, upb_alloc *a) {
+ upb_array *ret = upb_malloc(a, upb_array_sizeof(type));
+
+ if (ret) {
+ upb_array_init(ret, type, a);
+ }
+
+ return ret;
+}
+
+void upb_array_free(upb_array *arr) {
+ upb_array_uninit(arr);
+ upb_free(arr->alloc, arr);
+}
+
+size_t upb_array_size(const upb_array *arr) {
+ return arr->len;
+}
+
+upb_fieldtype_t upb_array_type(const upb_array *arr) {
+ return arr->type;
+}
+
+upb_msgval upb_array_get(const upb_array *arr, size_t i) {
+ UPB_ASSERT(i < arr->len);
+ return upb_msgval_read(arr->data, i * arr->element_size, arr->element_size);
+}
+
+bool upb_array_set(upb_array *arr, size_t i, upb_msgval val) {
+ UPB_ASSERT(i <= arr->len);
+
+ if (i == arr->len) {
+ /* Extending the array. */
+
+ if (i == arr->size) {
+ /* Need to reallocate. */
+ size_t new_size = UPB_MAX(arr->size * 2, 8);
+ size_t new_bytes = new_size * arr->element_size;
+ size_t old_bytes = arr->size * arr->element_size;
+ upb_msgval *new_data =
+ upb_realloc(arr->alloc, arr->data, old_bytes, new_bytes);
+
+ if (!new_data) {
+ return false;
+ }
+
+ arr->data = new_data;
+ arr->size = new_size;
+ }
+
+ arr->len = i + 1;
+ }
+
+ upb_msgval_write(arr->data, i * arr->element_size, val, arr->element_size);
+ return true;
+}
+
+
+/** upb_map *******************************************************************/
+
+struct upb_map {
+ upb_fieldtype_t key_type;
+ upb_fieldtype_t val_type;
+ /* We may want to optimize this to use inttable where possible, for greater
+ * efficiency and lower memory footprint. */
+ upb_strtable strtab;
+ upb_alloc *alloc;
+};
+
+static void upb_map_tokey(upb_fieldtype_t type, upb_msgval *key,
+ const char **out_key, size_t *out_len) {
+ switch (type) {
+ case UPB_TYPE_STRING:
+ /* Point to string data of the input key. */
+ *out_key = key->str.ptr;
+ *out_len = key->str.len;
+ return;
+ case UPB_TYPE_BOOL:
+ case UPB_TYPE_INT32:
+ case UPB_TYPE_UINT32:
+ case UPB_TYPE_INT64:
+ case UPB_TYPE_UINT64:
+ /* Point to the key itself. XXX: big-endian. */
+ *out_key = (const char*)key;
+ *out_len = upb_msgval_sizeof(type);
+ return;
+ case UPB_TYPE_BYTES:
+ case UPB_TYPE_DOUBLE:
+ case UPB_TYPE_ENUM:
+ case UPB_TYPE_FLOAT:
+ case UPB_TYPE_MESSAGE:
+ break; /* Cannot be a map key. */
+ }
+ UPB_UNREACHABLE();
+}
+
+static upb_msgval upb_map_fromkey(upb_fieldtype_t type, const char *key,
+ size_t len) {
+ switch (type) {
+ case UPB_TYPE_STRING:
+ return upb_msgval_str(key, len);
+ case UPB_TYPE_BOOL:
+ case UPB_TYPE_INT32:
+ case UPB_TYPE_UINT32:
+ case UPB_TYPE_INT64:
+ case UPB_TYPE_UINT64:
+ return upb_msgval_read(key, 0, upb_msgval_sizeof(type));
+ case UPB_TYPE_BYTES:
+ case UPB_TYPE_DOUBLE:
+ case UPB_TYPE_ENUM:
+ case UPB_TYPE_FLOAT:
+ case UPB_TYPE_MESSAGE:
+ break; /* Cannot be a map key. */
+ }
+ UPB_UNREACHABLE();
+}
+
+size_t upb_map_sizeof(upb_fieldtype_t ktype, upb_fieldtype_t vtype) {
+ /* Size does not currently depend on key/value type. */
+ UPB_UNUSED(ktype);
+ UPB_UNUSED(vtype);
+ return sizeof(upb_map);
+}
+
+bool upb_map_init(upb_map *map, upb_fieldtype_t ktype, upb_fieldtype_t vtype,
+ upb_alloc *a) {
+ upb_ctype_t vtabtype = upb_fieldtotabtype(vtype);
+ UPB_ASSERT(upb_fieldtype_mapkeyok(ktype));
+ map->key_type = ktype;
+ map->val_type = vtype;
+ map->alloc = a;
+
+ if (!upb_strtable_init2(&map->strtab, vtabtype, a)) {
+ return false;
+ }
+
+ return true;
+}
+
+void upb_map_uninit(upb_map *map) {
+ upb_strtable_uninit2(&map->strtab, map->alloc);
+}
+
+upb_map *upb_map_new(upb_fieldtype_t ktype, upb_fieldtype_t vtype,
+ upb_alloc *a) {
+ upb_map *map = upb_malloc(a, upb_map_sizeof(ktype, vtype));
+
+ if (!map) {
+ return NULL;
+ }
+
+ if (!upb_map_init(map, ktype, vtype, a)) {
+ return NULL;
+ }
+
+ return map;
+}
+
+void upb_map_free(upb_map *map) {
+ upb_map_uninit(map);
+ upb_free(map->alloc, map);
+}
+
+size_t upb_map_size(const upb_map *map) {
+ return upb_strtable_count(&map->strtab);
+}
+
+upb_fieldtype_t upb_map_keytype(const upb_map *map) {
+ return map->key_type;
+}
+
+upb_fieldtype_t upb_map_valuetype(const upb_map *map) {
+ return map->val_type;
+}
+
+bool upb_map_get(const upb_map *map, upb_msgval key, upb_msgval *val) {
+ upb_value tabval;
+ const char *key_str;
+ size_t key_len;
+ bool ret;
+
+ upb_map_tokey(map->key_type, &key, &key_str, &key_len);
+ ret = upb_strtable_lookup2(&map->strtab, key_str, key_len, &tabval);
+ if (ret) {
+ memcpy(val, &tabval, sizeof(tabval));
+ }
+
+ return ret;
+}
+
+bool upb_map_set(upb_map *map, upb_msgval key, upb_msgval val,
+ upb_msgval *removed) {
+ const char *key_str;
+ size_t key_len;
+ upb_value tabval = upb_toval(val);
+ upb_value removedtabval;
+ upb_alloc *a = map->alloc;
+
+ upb_map_tokey(map->key_type, &key, &key_str, &key_len);
+
+ /* TODO(haberman): add overwrite operation to minimize number of lookups. */
+ if (upb_strtable_lookup2(&map->strtab, key_str, key_len, NULL)) {
+ upb_strtable_remove3(&map->strtab, key_str, key_len, &removedtabval, a);
+ memcpy(&removed, &removedtabval, sizeof(removed));
+ }
+
+ return upb_strtable_insert3(&map->strtab, key_str, key_len, tabval, a);
+}
+
+bool upb_map_del(upb_map *map, upb_msgval key) {
+ const char *key_str;
+ size_t key_len;
+ upb_alloc *a = map->alloc;
+
+ upb_map_tokey(map->key_type, &key, &key_str, &key_len);
+ return upb_strtable_remove3(&map->strtab, key_str, key_len, NULL, a);
+}
+
+
+/** upb_mapiter ***************************************************************/
+
+struct upb_mapiter {
+ upb_strtable_iter iter;
+ upb_fieldtype_t key_type;
+};
+
+size_t upb_mapiter_sizeof() {
+ return sizeof(upb_mapiter);
+}
+
+void upb_mapiter_begin(upb_mapiter *i, const upb_map *map) {
+ upb_strtable_begin(&i->iter, &map->strtab);
+ i->key_type = map->key_type;
+}
+
+upb_mapiter *upb_mapiter_new(const upb_map *t, upb_alloc *a) {
+ upb_mapiter *ret = upb_malloc(a, upb_mapiter_sizeof());
+
+ if (!ret) {
+ return NULL;
+ }
+
+ upb_mapiter_begin(ret, t);
+ return ret;
+}
+
+void upb_mapiter_free(upb_mapiter *i, upb_alloc *a) {
+ upb_free(a, i);
+}
+
+void upb_mapiter_next(upb_mapiter *i) {
+ upb_strtable_next(&i->iter);
+}
+
+bool upb_mapiter_done(const upb_mapiter *i) {
+ return upb_strtable_done(&i->iter);
+}
+
+upb_msgval upb_mapiter_key(const upb_mapiter *i) {
+ return upb_map_fromkey(i->key_type, upb_strtable_iter_key(&i->iter),
+ upb_strtable_iter_keylength(&i->iter));
+}
+
+upb_msgval upb_mapiter_value(const upb_mapiter *i) {
+ return upb_msgval_fromval(upb_strtable_iter_value(&i->iter));
+}
+
+void upb_mapiter_setdone(upb_mapiter *i) {
+ upb_strtable_iter_setdone(&i->iter);
+}
+
+bool upb_mapiter_isequal(const upb_mapiter *i1, const upb_mapiter *i2) {
+ return upb_strtable_iter_isequal(&i1->iter, &i2->iter);
+}
+
+
+/** Handlers for upb_msg ******************************************************/
+
+typedef struct {
+ size_t offset;
+ int32_t hasbit;
+} upb_msg_handlerdata;
+
+/* Fallback implementation if the handler is not specialized by the producer. */
+#define MSG_WRITER(type, ctype) \
+ bool upb_msg_set ## type (void *c, const void *hd, ctype val) { \
+ uint8_t *m = c; \
+ const upb_msg_handlerdata *d = hd; \
+ if (d->hasbit > 0) \
+ *(uint8_t*)&m[d->hasbit / 8] |= 1 << (d->hasbit % 8); \
+ *(ctype*)&m[d->offset] = val; \
+ return true; \
+ } \
+
+MSG_WRITER(double, double)
+MSG_WRITER(float, float)
+MSG_WRITER(int32, int32_t)
+MSG_WRITER(int64, int64_t)
+MSG_WRITER(uint32, uint32_t)
+MSG_WRITER(uint64, uint64_t)
+MSG_WRITER(bool, bool)
+
+bool upb_msg_setscalarhandler(upb_handlers *h, const upb_fielddef *f,
+ size_t offset, int32_t hasbit) {
+ upb_handlerattr attr = UPB_HANDLERATTR_INITIALIZER;
+ bool ok;
+
+ upb_msg_handlerdata *d = upb_gmalloc(sizeof(*d));
+ if (!d) return false;
+ d->offset = offset;
+ d->hasbit = hasbit;
+
+ upb_handlerattr_sethandlerdata(&attr, d);
+ upb_handlerattr_setalwaysok(&attr, true);
+ upb_handlers_addcleanup(h, d, upb_gfree);
+
+#define TYPE(u, l) \
+ case UPB_TYPE_##u: \
+ ok = upb_handlers_set##l(h, f, upb_msg_set##l, &attr); break;
+
+ ok = false;
+
+ switch (upb_fielddef_type(f)) {
+ TYPE(INT64, int64);
+ TYPE(INT32, int32);
+ TYPE(ENUM, int32);
+ TYPE(UINT64, uint64);
+ TYPE(UINT32, uint32);
+ TYPE(DOUBLE, double);
+ TYPE(FLOAT, float);
+ TYPE(BOOL, bool);
+ default: UPB_ASSERT(false); break;
+ }
+#undef TYPE
+
+ upb_handlerattr_uninit(&attr);
+ return ok;
+}
+
+bool upb_msg_getscalarhandlerdata(const upb_handlers *h,
+ upb_selector_t s,
+ upb_fieldtype_t *type,
+ size_t *offset,
+ int32_t *hasbit) {
+ const upb_msg_handlerdata *d;
+ upb_func *f = upb_handlers_gethandler(h, s);
+
+ if ((upb_int64_handlerfunc*)f == upb_msg_setint64) {
+ *type = UPB_TYPE_INT64;
+ } else if ((upb_int32_handlerfunc*)f == upb_msg_setint32) {
+ *type = UPB_TYPE_INT32;
+ } else if ((upb_uint64_handlerfunc*)f == upb_msg_setuint64) {
+ *type = UPB_TYPE_UINT64;
+ } else if ((upb_uint32_handlerfunc*)f == upb_msg_setuint32) {
+ *type = UPB_TYPE_UINT32;
+ } else if ((upb_double_handlerfunc*)f == upb_msg_setdouble) {
+ *type = UPB_TYPE_DOUBLE;
+ } else if ((upb_float_handlerfunc*)f == upb_msg_setfloat) {
+ *type = UPB_TYPE_FLOAT;
+ } else if ((upb_bool_handlerfunc*)f == upb_msg_setbool) {
+ *type = UPB_TYPE_BOOL;
+ } else {
+ return false;
+ }
+
+ d = upb_handlers_gethandlerdata(h, s);
+ *offset = d->offset;
+ *hasbit = d->hasbit;
+ return true;
+}
/*
** upb::RefCounted Implementation
**
@@ -2938,7 +4501,7 @@ static trackedref *trackedref_new(bool is_ref2) {
static void track(const upb_refcounted *r, const void *owner, bool ref2) {
upb_value v;
- assert(owner);
+ UPB_ASSERT(owner);
if (owner == UPB_UNTRACKED_REF) return;
upb_lock();
@@ -2949,8 +4512,8 @@ static void track(const upb_refcounted *r, const void *owner, bool ref2) {
* tracking behavior we get with regular refs. Since ref2s only happen
* inside upb, we'll accept this limitation until/unless there is a really
* difficult upb-internal bug that can't be figured out without it. */
- assert(ref2);
- assert(ref->is_ref2);
+ UPB_ASSERT(ref2);
+ UPB_ASSERT(ref->is_ref2);
ref->count++;
} else {
trackedref *ref = trackedref_new(ref2);
@@ -2960,7 +4523,7 @@ static void track(const upb_refcounted *r, const void *owner, bool ref2) {
/* We know this cast is safe when it is a ref2, because it's coming from
* another refcounted object. */
const upb_refcounted *from = owner;
- assert(!upb_inttable_lookupptr(from->ref2s, r, NULL));
+ UPB_ASSERT(!upb_inttable_lookupptr(from->ref2s, r, NULL));
upb_inttable_insertptr2(from->ref2s, r, upb_value_ptr(NULL),
&upb_alloc_debugrefs);
}
@@ -2973,15 +4536,15 @@ static void untrack(const upb_refcounted *r, const void *owner, bool ref2) {
bool found;
trackedref *ref;
- assert(owner);
+ UPB_ASSERT(owner);
if (owner == UPB_UNTRACKED_REF) return;
upb_lock();
found = upb_inttable_lookupptr(r->refs, owner, &v);
/* This assert will fail if an owner attempts to release a ref it didn't have. */
- UPB_ASSERT_VAR(found, found);
+ UPB_ASSERT(found);
ref = upb_value_getptr(v);
- assert(ref->is_ref2 == ref2);
+ UPB_ASSERT(ref->is_ref2 == ref2);
if (--ref->count == 0) {
free(ref);
upb_inttable_removeptr(r->refs, owner, NULL);
@@ -2990,7 +4553,7 @@ static void untrack(const upb_refcounted *r, const void *owner, bool ref2) {
* another refcounted object. */
const upb_refcounted *from = owner;
bool removed = upb_inttable_removeptr(from->ref2s, r, NULL);
- assert(removed);
+ UPB_ASSERT(removed);
}
}
upb_unlock();
@@ -3003,9 +4566,9 @@ static void checkref(const upb_refcounted *r, const void *owner, bool ref2) {
upb_lock();
found = upb_inttable_lookupptr(r->refs, owner, &v);
- UPB_ASSERT_VAR(found, found);
+ UPB_ASSERT(found);
ref = upb_value_getptr(v);
- assert(ref->is_ref2 == ref2);
+ UPB_ASSERT(ref->is_ref2 == ref2);
upb_unlock();
}
@@ -3026,7 +4589,7 @@ static void getref2s(const upb_refcounted *owner, upb_inttable *tab) {
/* To get the count we need to look in the target's table. */
found = upb_inttable_lookupptr(to->refs, owner, &v);
- assert(found);
+ UPB_ASSERT(found);
ref = upb_value_getptr(v);
count = upb_value_int32(ref->count);
@@ -3048,12 +4611,12 @@ static void visit_check(const upb_refcounted *obj, const upb_refcounted *subobj,
bool removed;
int32_t newcount;
- assert(obj == s->obj);
- assert(subobj);
+ UPB_ASSERT(obj == s->obj);
+ UPB_ASSERT(subobj);
removed = upb_inttable_removeptr(ref2, subobj, &v);
/* The following assertion will fail if the visit() function visits a subobj
* that it did not have a ref2 on, or visits the same subobj too many times. */
- assert(removed);
+ UPB_ASSERT(removed);
newcount = upb_value_getint32(v) - 1;
if (newcount > 0) {
upb_inttable_insert2(ref2, (uintptr_t)subobj, upb_value_int32(newcount),
@@ -3075,7 +4638,7 @@ static void visit(const upb_refcounted *r, upb_refcounted_visit *v,
if (r->vtbl->visit) r->vtbl->visit(r, visit_check, &state);
/* This assertion will fail if the visit() function missed any children. */
- assert(upb_inttable_count(&state.ref2) == 0);
+ UPB_ASSERT(upb_inttable_count(&state.ref2) == 0);
upb_inttable_uninit2(&state.ref2, &upb_alloc_debugrefs);
if (r->vtbl->visit) r->vtbl->visit(r, v, closure);
}
@@ -3182,7 +4745,7 @@ static uint64_t trygetattr(const tarjan *t, const upb_refcounted *r) {
static uint64_t getattr(const tarjan *t, const upb_refcounted *r) {
upb_value v;
bool found = upb_inttable_lookupptr(&t->objattr, r, &v);
- UPB_ASSERT_VAR(found, found);
+ UPB_ASSERT(found);
return upb_value_getuint64(v);
}
@@ -3196,13 +4759,13 @@ static color_t color(tarjan *t, const upb_refcounted *r) {
}
static void set_gray(tarjan *t, const upb_refcounted *r) {
- assert(color(t, r) == BLACK);
+ UPB_ASSERT(color(t, r) == BLACK);
setattr(t, r, GRAY);
}
/* Pushes an obj onto the Tarjan stack and sets it to GREEN. */
static void push(tarjan *t, const upb_refcounted *r) {
- assert(color(t, r) == BLACK || color(t, r) == GRAY);
+ UPB_ASSERT(color(t, r) == BLACK || color(t, r) == GRAY);
/* This defines the attr layout for the GREEN state. "index" and "lowlink"
* get 31 bits, which is plenty (limit of 2B objects frozen at a time). */
setattr(t, r, GREEN | (t->index << 2) | (t->index << 33));
@@ -3217,7 +4780,7 @@ static void push(tarjan *t, const upb_refcounted *r) {
* SCC group. */
static upb_refcounted *pop(tarjan *t) {
upb_refcounted *r = upb_value_getptr(upb_inttable_pop(&t->stack));
- assert(color(t, r) == GREEN);
+ UPB_ASSERT(color(t, r) == GREEN);
/* This defines the attr layout for nodes in the WHITE state.
* Top of group stack is [group, NULL]; we point at group. */
setattr(t, r, WHITE | (upb_inttable_count(&t->groups) - 2) << 8);
@@ -3237,7 +4800,7 @@ static void tarjan_newgroup(tarjan *t) {
}
static uint32_t idx(tarjan *t, const upb_refcounted *r) {
- assert(color(t, r) == GREEN);
+ UPB_ASSERT(color(t, r) == GREEN);
return (getattr(t, r) >> 2) & 0x7FFFFFFF;
}
@@ -3250,7 +4813,7 @@ static uint32_t lowlink(tarjan *t, const upb_refcounted *r) {
}
static void set_lowlink(tarjan *t, const upb_refcounted *r, uint32_t lowlink) {
- assert(color(t, r) == GREEN);
+ UPB_ASSERT(color(t, r) == GREEN);
setattr(t, r, ((uint64_t)lowlink << 33) | (getattr(t, r) & 0x1FFFFFFFF));
}
@@ -3259,10 +4822,10 @@ static uint32_t *group(tarjan *t, upb_refcounted *r) {
upb_value v;
bool found;
- assert(color(t, r) == WHITE);
+ UPB_ASSERT(color(t, r) == WHITE);
groupnum = getattr(t, r) >> 8;
found = upb_inttable_lookup(&t->groups, groupnum, &v);
- UPB_ASSERT_VAR(found, found);
+ UPB_ASSERT(found);
return upb_value_getptr(v);
}
@@ -3273,10 +4836,10 @@ static upb_refcounted *groupleader(tarjan *t, upb_refcounted *r) {
upb_value v;
bool found;
- assert(color(t, r) == WHITE);
+ UPB_ASSERT(color(t, r) == WHITE);
leader_slot = (getattr(t, r) >> 8) + 1;
found = upb_inttable_lookup(&t->groups, leader_slot, &v);
- UPB_ASSERT_VAR(found, found);
+ UPB_ASSERT(found);
if (upb_value_getptr(v)) {
return upb_value_getptr(v);
} else {
@@ -3336,7 +4899,7 @@ static void do_tarjan(const upb_refcounted *obj, tarjan *t) {
static void crossref(const upb_refcounted *r, const upb_refcounted *subobj,
void *_t) {
tarjan *t = _t;
- assert(color(t, r) > BLACK);
+ UPB_ASSERT(color(t, r) > BLACK);
if (color(t, subobj) > BLACK && r->group != subobj->group) {
/* Previously this ref was not reflected in subobj->group because they
* were in the same group; now that they are split a ref must be taken. */
@@ -3404,13 +4967,13 @@ static bool freeze(upb_refcounted *const*roots, int n, upb_status *s,
upb_refcounted *move = obj->next;
if (obj == move) {
/* Removing the last object from a group. */
- assert(*obj->group == obj->individual_count);
+ UPB_ASSERT(*obj->group == obj->individual_count);
upb_gfree(obj->group);
} else {
obj->next = move->next;
/* This may decrease to zero; we'll collect GRAY objects (if any) that
* remain in the group in the third pass. */
- assert(*move->group >= move->individual_count);
+ UPB_ASSERT(*move->group >= move->individual_count);
*move->group -= move->individual_count;
}
@@ -3423,7 +4986,7 @@ static bool freeze(upb_refcounted *const*roots, int n, upb_status *s,
*move->group = move->individual_count;
} else {
/* Group already has at least one object in it. */
- assert(leader->group == group(&t, move));
+ UPB_ASSERT(leader->group == group(&t, move));
move->group = group(&t, move);
move->next = leader->next;
leader->next = move;
@@ -3513,7 +5076,7 @@ static void merge(upb_refcounted *r, upb_refcounted *from) {
* TODO(haberman): this linear algorithm can result in an overall O(n^2) bound
* if the user continuously extends a group by one object. Prevent this by
* using one of the techniques in this paper:
- * ftp://www.ncedc.org/outgoing/geomorph/dino/orals/p245-tarjan.pdf */
+ * http://bioinfo.ict.ac.cn/~dbu/AlgorithmCourses/Lectures/Union-Find-Tarjan.pdf */
do { from->group = r->group; } while ((from = from->next) != base);
/* Merge the two circularly linked lists by swapping their next pointers. */
@@ -3530,7 +5093,7 @@ static void release_ref2(const upb_refcounted *obj,
UPB_UNUSED(closure);
untrack(subobj, obj, true);
if (!merged(obj, subobj)) {
- assert(subobj->is_frozen);
+ UPB_ASSERT(subobj->is_frozen);
unref(subobj);
}
}
@@ -3549,7 +5112,7 @@ static void unref(const upb_refcounted *r) {
o = r;
do {
const upb_refcounted *next = o->next;
- assert(o->is_frozen || o->individual_count == 0);
+ UPB_ASSERT(o->is_frozen || o->individual_count == 0);
freeobj((upb_refcounted*)o);
o = next;
} while(o != r);
@@ -3573,9 +5136,9 @@ bool upb_refcounted_init(upb_refcounted *r,
* basically every program using upb. */
const int x = 1;
#ifdef UPB_BIG_ENDIAN
- assert(*(char*)&x != 1);
+ UPB_ASSERT(*(char*)&x != 1);
#else
- assert(*(char*)&x == 1);
+ UPB_ASSERT(*(char*)&x == 1);
#endif
#endif
@@ -3610,7 +5173,7 @@ void upb_refcounted_unref(const upb_refcounted *r, const void *owner) {
}
void upb_refcounted_ref2(const upb_refcounted *r, upb_refcounted *from) {
- assert(!from->is_frozen); /* Non-const pointer implies this. */
+ UPB_ASSERT(!from->is_frozen); /* Non-const pointer implies this. */
track(r, from, true);
if (r->is_frozen) {
refgroup(r->group);
@@ -3620,18 +5183,18 @@ void upb_refcounted_ref2(const upb_refcounted *r, upb_refcounted *from) {
}
void upb_refcounted_unref2(const upb_refcounted *r, upb_refcounted *from) {
- assert(!from->is_frozen); /* Non-const pointer implies this. */
+ UPB_ASSERT(!from->is_frozen); /* Non-const pointer implies this. */
untrack(r, from, true);
if (r->is_frozen) {
unref(r);
} else {
- assert(merged(r, from));
+ UPB_ASSERT(merged(r, from));
}
}
void upb_refcounted_donateref(
const upb_refcounted *r, const void *from, const void *to) {
- assert(from != to);
+ UPB_ASSERT(from != to);
if (to != NULL)
upb_refcounted_ref(r, to);
if (from != NULL)
@@ -3647,587 +5210,99 @@ bool upb_refcounted_freeze(upb_refcounted *const*roots, int n, upb_status *s,
int i;
bool ret;
for (i = 0; i < n; i++) {
- assert(!roots[i]->is_frozen);
+ UPB_ASSERT(!roots[i]->is_frozen);
}
ret = freeze(roots, n, s, maxdepth);
- assert(!s || ret == upb_ok(s));
+ UPB_ASSERT(!s || ret == upb_ok(s));
return ret;
}
-/* Fallback implementation if the shim is not specialized by the JIT. */
-#define SHIM_WRITER(type, ctype) \
- bool upb_shim_set ## type (void *c, const void *hd, ctype val) { \
- uint8_t *m = c; \
- const upb_shim_data *d = hd; \
- if (d->hasbit > 0) \
- *(uint8_t*)&m[d->hasbit / 8] |= 1 << (d->hasbit % 8); \
- *(ctype*)&m[d->offset] = val; \
- return true; \
- } \
-
-SHIM_WRITER(double, double)
-SHIM_WRITER(float, float)
-SHIM_WRITER(int32, int32_t)
-SHIM_WRITER(int64, int64_t)
-SHIM_WRITER(uint32, uint32_t)
-SHIM_WRITER(uint64, uint64_t)
-SHIM_WRITER(bool, bool)
-#undef SHIM_WRITER
-
-bool upb_shim_set(upb_handlers *h, const upb_fielddef *f, size_t offset,
- int32_t hasbit) {
- upb_handlerattr attr = UPB_HANDLERATTR_INITIALIZER;
- bool ok;
-
- upb_shim_data *d = upb_gmalloc(sizeof(*d));
- if (!d) return false;
- d->offset = offset;
- d->hasbit = hasbit;
-
- upb_handlerattr_sethandlerdata(&attr, d);
- upb_handlerattr_setalwaysok(&attr, true);
- upb_handlers_addcleanup(h, d, upb_gfree);
-
-#define TYPE(u, l) \
- case UPB_TYPE_##u: \
- ok = upb_handlers_set##l(h, f, upb_shim_set##l, &attr); break;
-
- ok = false;
-
- switch (upb_fielddef_type(f)) {
- TYPE(INT64, int64);
- TYPE(INT32, int32);
- TYPE(ENUM, int32);
- TYPE(UINT64, uint64);
- TYPE(UINT32, uint32);
- TYPE(DOUBLE, double);
- TYPE(FLOAT, float);
- TYPE(BOOL, bool);
- default: assert(false); break;
- }
-#undef TYPE
-
- upb_handlerattr_uninit(&attr);
- return ok;
-}
-
-const upb_shim_data *upb_shim_getdata(const upb_handlers *h, upb_selector_t s,
- upb_fieldtype_t *type) {
- upb_func *f = upb_handlers_gethandler(h, s);
-
- if ((upb_int64_handlerfunc*)f == upb_shim_setint64) {
- *type = UPB_TYPE_INT64;
- } else if ((upb_int32_handlerfunc*)f == upb_shim_setint32) {
- *type = UPB_TYPE_INT32;
- } else if ((upb_uint64_handlerfunc*)f == upb_shim_setuint64) {
- *type = UPB_TYPE_UINT64;
- } else if ((upb_uint32_handlerfunc*)f == upb_shim_setuint32) {
- *type = UPB_TYPE_UINT32;
- } else if ((upb_double_handlerfunc*)f == upb_shim_setdouble) {
- *type = UPB_TYPE_DOUBLE;
- } else if ((upb_float_handlerfunc*)f == upb_shim_setfloat) {
- *type = UPB_TYPE_FLOAT;
- } else if ((upb_bool_handlerfunc*)f == upb_shim_setbool) {
- *type = UPB_TYPE_BOOL;
- } else {
- return NULL;
- }
-
- return (const upb_shim_data*)upb_handlers_gethandlerdata(h, s);
-}
-
-
-#include <string.h>
-
-static void upb_symtab_free(upb_refcounted *r) {
- upb_symtab *s = (upb_symtab*)r;
- upb_strtable_iter i;
- upb_strtable_begin(&i, &s->symtab);
- for (; !upb_strtable_done(&i); upb_strtable_next(&i)) {
- const upb_def *def = upb_value_getptr(upb_strtable_iter_value(&i));
- upb_def_unref(def, s);
+bool upb_bufsrc_putbuf(const char *buf, size_t len, upb_bytessink *sink) {
+ void *subc;
+ bool ret;
+ upb_bufhandle handle;
+ upb_bufhandle_init(&handle);
+ upb_bufhandle_setbuf(&handle, buf, 0);
+ ret = upb_bytessink_start(sink, len, &subc);
+ if (ret && len != 0) {
+ ret = (upb_bytessink_putbuf(sink, subc, buf, len, &handle) >= len);
}
- upb_strtable_uninit(&s->symtab);
- upb_gfree(s);
-}
-
-upb_symtab *upb_symtab_new(const void *owner) {
- static const struct upb_refcounted_vtbl vtbl = {NULL, &upb_symtab_free};
-
- upb_symtab *s = upb_gmalloc(sizeof(*s));
- if (!s) {
- return NULL;
+ if (ret) {
+ ret = upb_bytessink_end(sink);
}
-
- upb_refcounted_init(upb_symtab_upcast_mutable(s), &vtbl, owner);
- upb_strtable_init(&s->symtab, UPB_CTYPE_PTR);
- return s;
-}
-
-void upb_symtab_freeze(upb_symtab *s) {
- upb_refcounted *r;
- bool ok;
-
- assert(!upb_symtab_isfrozen(s));
- r = upb_symtab_upcast_mutable(s);
- /* The symtab does not take ref2's (see refcounted.h) on the defs, because
- * defs cannot refer back to the table and therefore cannot create cycles. So
- * 0 will suffice for maxdepth here. */
- ok = upb_refcounted_freeze(&r, 1, NULL, 0);
- UPB_ASSERT_VAR(ok, ok);
-}
-
-const upb_def *upb_symtab_lookup(const upb_symtab *s, const char *sym) {
- upb_value v;
- upb_def *ret = upb_strtable_lookup(&s->symtab, sym, &v) ?
- upb_value_getptr(v) : NULL;
+ upb_bufhandle_uninit(&handle);
return ret;
}
-const upb_msgdef *upb_symtab_lookupmsg(const upb_symtab *s, const char *sym) {
- upb_value v;
- upb_def *def = upb_strtable_lookup(&s->symtab, sym, &v) ?
- upb_value_getptr(v) : NULL;
- return def ? upb_dyncast_msgdef(def) : NULL;
-}
-
-const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym) {
- upb_value v;
- upb_def *def = upb_strtable_lookup(&s->symtab, sym, &v) ?
- upb_value_getptr(v) : NULL;
- return def ? upb_dyncast_enumdef(def) : NULL;
-}
-
-/* Given a symbol and the base symbol inside which it is defined, find the
- * symbol's definition in t. */
-static upb_def *upb_resolvename(const upb_strtable *t,
- const char *base, const char *sym) {
- if(strlen(sym) == 0) return NULL;
- if(sym[0] == '.') {
- /* Symbols starting with '.' are absolute, so we do a single lookup.
- * Slice to omit the leading '.' */
- upb_value v;
- return upb_strtable_lookup(t, sym + 1, &v) ? upb_value_getptr(v) : NULL;
- } else {
- /* Remove components from base until we find an entry or run out.
- * TODO: This branch is totally broken, but currently not used. */
- (void)base;
- assert(false);
- return NULL;
- }
-}
-
-const upb_def *upb_symtab_resolve(const upb_symtab *s, const char *base,
- const char *sym) {
- upb_def *ret = upb_resolvename(&s->symtab, base, sym);
- return ret;
-}
-
-/* Starts a depth-first traversal at "def", recursing into any subdefs
- * (ie. submessage types). Adds duplicates of existing defs to addtab
- * wherever necessary, so that the resulting symtab will be consistent once
- * addtab is added.
- *
- * More specifically, if any def D is found in the DFS that:
- *
- * 1. can reach a def that is being replaced by something in addtab, AND
- *
- * 2. is not itself being replaced already (ie. this name doesn't already
- * exist in addtab)
- *
- * ...then a duplicate (new copy) of D will be added to addtab.
- *
- * Returns true if this happened for any def reachable from "def."
- *
- * It is slightly tricky to do this correctly in the presence of cycles. If we
- * detect that our DFS has hit a cycle, we might not yet know if any SCCs on
- * our stack can reach a def in addtab or not. Once we figure this out, that
- * answer needs to apply to *all* defs in these SCCs, even if we visited them
- * already. So a straight up one-pass cycle-detecting DFS won't work.
- *
- * To work around this problem, we traverse each SCC (which we already
- * computed, since these defs are frozen) as a single node. We first compute
- * whether the SCC as a whole can reach any def in addtab, then we dup (or not)
- * the entire SCC. This requires breaking the encapsulation of upb_refcounted,
- * since that is where we get the data about what SCC we are in. */
-static bool upb_resolve_dfs(const upb_def *def, upb_strtable *addtab,
- const void *new_owner, upb_inttable *seen,
- upb_status *s) {
- upb_value v;
- bool need_dup;
- const upb_def *base;
- const void* memoize_key;
-
- /* Memoize results of this function for efficiency (since we're traversing a
- * DAG this is not needed to limit the depth of the search).
- *
- * We memoize by SCC instead of by individual def. */
- memoize_key = def->base.group;
-
- if (upb_inttable_lookupptr(seen, memoize_key, &v))
- return upb_value_getbool(v);
-
- /* Visit submessages for all messages in the SCC. */
- need_dup = false;
- base = def;
- do {
- upb_value v;
- const upb_msgdef *m;
-
- assert(upb_def_isfrozen(def));
- if (def->type == UPB_DEF_FIELD) continue;
- if (upb_strtable_lookup(addtab, upb_def_fullname(def), &v)) {
- need_dup = true;
- }
-
- /* For messages, continue the recursion by visiting all subdefs, but only
- * ones in different SCCs. */
- m = upb_dyncast_msgdef(def);
- if (m) {
- upb_msg_field_iter i;
- for(upb_msg_field_begin(&i, m);
- !upb_msg_field_done(&i);
- upb_msg_field_next(&i)) {
- upb_fielddef *f = upb_msg_iter_field(&i);
- const upb_def *subdef;
-
- if (!upb_fielddef_hassubdef(f)) continue;
- subdef = upb_fielddef_subdef(f);
-
- /* Skip subdefs in this SCC. */
- if (def->base.group == subdef->base.group) continue;
-
- /* |= to avoid short-circuit; we need its side-effects. */
- need_dup |= upb_resolve_dfs(subdef, addtab, new_owner, seen, s);
- if (!upb_ok(s)) return false;
- }
- }
- } while ((def = (upb_def*)def->base.next) != base);
-
- if (need_dup) {
- /* Dup all defs in this SCC that don't already have entries in addtab. */
- def = base;
- do {
- const char *name;
-
- if (def->type == UPB_DEF_FIELD) continue;
- name = upb_def_fullname(def);
- if (!upb_strtable_lookup(addtab, name, NULL)) {
- upb_def *newdef = upb_def_dup(def, new_owner);
- if (!newdef) goto oom;
- newdef->came_from_user = false;
- if (!upb_strtable_insert(addtab, name, upb_value_ptr(newdef)))
- goto oom;
- }
- } while ((def = (upb_def*)def->base.next) != base);
- }
-
- upb_inttable_insertptr(seen, memoize_key, upb_value_bool(need_dup));
- return need_dup;
-
-oom:
- upb_status_seterrmsg(s, "out of memory");
- return false;
-}
-
-/* TODO(haberman): we need a lot more testing of error conditions.
- * The came_from_user stuff in particular is not tested. */
-static bool symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
- void *ref_donor, upb_refcounted *freeze_also,
- upb_status *status) {
- size_t i;
- size_t add_n;
- size_t freeze_n;
- upb_strtable_iter iter;
- upb_refcounted **add_objs = NULL;
- upb_def **add_defs = NULL;
- size_t add_objs_size;
- upb_strtable addtab;
- upb_inttable seen;
-
- if (n == 0 && !freeze_also) {
- return true;
- }
-
- assert(!upb_symtab_isfrozen(s));
- if (!upb_strtable_init(&addtab, UPB_CTYPE_PTR)) {
- upb_status_seterrmsg(status, "out of memory");
- return false;
- }
-
- /* Add new defs to our "add" set. */
- for (i = 0; i < n; i++) {
- upb_def *def = defs[i];
- const char *fullname;
- upb_fielddef *f;
-
- if (upb_def_isfrozen(def)) {
- upb_status_seterrmsg(status, "added defs must be mutable");
- goto err;
- }
- assert(!upb_def_isfrozen(def));
- fullname = upb_def_fullname(def);
- if (!fullname) {
- upb_status_seterrmsg(
- status, "Anonymous defs cannot be added to a symtab");
- goto err;
- }
-
- f = upb_dyncast_fielddef_mutable(def);
-
- if (f) {
- if (!upb_fielddef_containingtypename(f)) {
- upb_status_seterrmsg(status,
- "Standalone fielddefs must have a containing type "
- "(extendee) name set");
- goto err;
- }
- } else {
- if (upb_strtable_lookup(&addtab, fullname, NULL)) {
- upb_status_seterrf(status, "Conflicting defs named '%s'", fullname);
- goto err;
- }
- /* We need this to back out properly, because if there is a failure we
- * need to donate the ref back to the caller. */
- def->came_from_user = true;
- upb_def_donateref(def, ref_donor, s);
- if (!upb_strtable_insert(&addtab, fullname, upb_value_ptr(def)))
- goto oom_err;
- }
- }
-
- /* Add standalone fielddefs (ie. extensions) to the appropriate messages.
- * If the appropriate message only exists in the existing symtab, duplicate
- * it so we have a mutable copy we can add the fields to. */
- for (i = 0; i < n; i++) {
- upb_def *def = defs[i];
- upb_fielddef *f = upb_dyncast_fielddef_mutable(def);
- const char *msgname;
- upb_value v;
- upb_msgdef *m;
-
- if (!f) continue;
- msgname = upb_fielddef_containingtypename(f);
- /* We validated this earlier in this function. */
- assert(msgname);
-
- /* If the extendee name is absolutely qualified, move past the initial ".".
- * TODO(haberman): it is not obvious what it would mean if this was not
- * absolutely qualified. */
- if (msgname[0] == '.') {
- msgname++;
- }
-
- if (upb_strtable_lookup(&addtab, msgname, &v)) {
- /* Extendee is in the set of defs the user asked us to add. */
- m = upb_value_getptr(v);
- } else {
- /* Need to find and dup the extendee from the existing symtab. */
- const upb_msgdef *frozen_m = upb_symtab_lookupmsg(s, msgname);
- if (!frozen_m) {
- upb_status_seterrf(status,
- "Tried to extend message %s that does not exist "
- "in this SymbolTable.",
- msgname);
- goto err;
- }
- m = upb_msgdef_dup(frozen_m, s);
- if (!m) goto oom_err;
- if (!upb_strtable_insert(&addtab, msgname, upb_value_ptr(m))) {
- upb_msgdef_unref(m, s);
- goto oom_err;
- }
- }
-
- if (!upb_msgdef_addfield(m, f, ref_donor, status)) {
- goto err;
- }
- }
-
- /* Add dups of any existing def that can reach a def with the same name as
- * anything in our "add" set. */
- if (!upb_inttable_init(&seen, UPB_CTYPE_BOOL)) goto oom_err;
- upb_strtable_begin(&iter, &s->symtab);
- for (; !upb_strtable_done(&iter); upb_strtable_next(&iter)) {
- upb_def *def = upb_value_getptr(upb_strtable_iter_value(&iter));
- upb_resolve_dfs(def, &addtab, s, &seen, status);
- if (!upb_ok(status)) goto err;
- }
- upb_inttable_uninit(&seen);
-
- /* Now using the table, resolve symbolic references for subdefs. */
- upb_strtable_begin(&iter, &addtab);
- for (; !upb_strtable_done(&iter); upb_strtable_next(&iter)) {
- const char *base;
- upb_def *def = upb_value_getptr(upb_strtable_iter_value(&iter));
- upb_msgdef *m = upb_dyncast_msgdef_mutable(def);
- upb_msg_field_iter j;
-
- if (!m) continue;
- /* Type names are resolved relative to the message in which they appear. */
- base = upb_msgdef_fullname(m);
-
- for(upb_msg_field_begin(&j, m);
- !upb_msg_field_done(&j);
- upb_msg_field_next(&j)) {
- upb_fielddef *f = upb_msg_iter_field(&j);
- const char *name = upb_fielddef_subdefname(f);
- if (name && !upb_fielddef_subdef(f)) {
- /* Try the lookup in the current set of to-be-added defs first. If not
- * there, try existing defs. */
- upb_def *subdef = upb_resolvename(&addtab, base, name);
- if (subdef == NULL) {
- subdef = upb_resolvename(&s->symtab, base, name);
- }
- if (subdef == NULL) {
- upb_status_seterrf(
- status, "couldn't resolve name '%s' in message '%s'", name, base);
- goto err;
- } else if (!upb_fielddef_setsubdef(f, subdef, status)) {
- goto err;
- }
- }
- }
- }
-
- /* We need an array of the defs in addtab, for passing to
- * upb_refcounted_freeze(). */
- add_objs_size = upb_strtable_count(&addtab);
- if (freeze_also) {
- add_objs_size++;
- }
-
- add_defs = upb_gmalloc(sizeof(void*) * add_objs_size);
- if (add_defs == NULL) goto oom_err;
- upb_strtable_begin(&iter, &addtab);
- for (add_n = 0; !upb_strtable_done(&iter); upb_strtable_next(&iter)) {
- add_defs[add_n++] = upb_value_getptr(upb_strtable_iter_value(&iter));
- }
-
- /* Validate defs. */
- if (!_upb_def_validate(add_defs, add_n, status)) {
- goto err;
- }
-
- /* Cheat a little and give the array a new type.
- * This is probably undefined behavior, but this code will be deleted soon. */
- add_objs = (upb_refcounted**)add_defs;
-
- freeze_n = add_n;
- if (freeze_also) {
- add_objs[freeze_n++] = freeze_also;
- }
-
- if (!upb_refcounted_freeze(add_objs, freeze_n, status,
- UPB_MAX_MESSAGE_DEPTH * 2)) {
- goto err;
- }
-
- /* This must be delayed until all errors have been detected, since error
- * recovery code uses this table to cleanup defs. */
- upb_strtable_uninit(&addtab);
-
- /* TODO(haberman) we don't properly handle errors after this point (like
- * OOM in upb_strtable_insert() below). */
- for (i = 0; i < add_n; i++) {
- upb_def *def = (upb_def*)add_objs[i];
- const char *name = upb_def_fullname(def);
- upb_value v;
- bool success;
-
- if (upb_strtable_remove(&s->symtab, name, &v)) {
- const upb_def *def = upb_value_getptr(v);
- upb_def_unref(def, s);
- }
- success = upb_strtable_insert(&s->symtab, name, upb_value_ptr(def));
- UPB_ASSERT_VAR(success, success == true);
- }
- upb_gfree(add_defs);
- return true;
-
-oom_err:
- upb_status_seterrmsg(status, "out of memory");
-err: {
- /* For defs the user passed in, we need to donate the refs back. For defs
- * we dup'd, we need to just unref them. */
- upb_strtable_begin(&iter, &addtab);
- for (; !upb_strtable_done(&iter); upb_strtable_next(&iter)) {
- upb_def *def = upb_value_getptr(upb_strtable_iter_value(&iter));
- bool came_from_user = def->came_from_user;
- def->came_from_user = false;
- if (came_from_user) {
- upb_def_donateref(def, s, ref_donor);
- } else {
- upb_def_unref(def, s);
- }
- }
- }
- upb_strtable_uninit(&addtab);
- upb_gfree(add_defs);
- assert(!upb_ok(status));
- return false;
-}
+struct upb_bufsink {
+ upb_byteshandler handler;
+ upb_bytessink sink;
+ upb_env *env;
+ char *ptr;
+ size_t len, size;
+};
-bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
- void *ref_donor, upb_status *status) {
- return symtab_add(s, defs, n, ref_donor, NULL, status);
+static void *upb_bufsink_start(void *_sink, const void *hd, size_t size_hint) {
+ upb_bufsink *sink = _sink;
+ UPB_UNUSED(hd);
+ UPB_UNUSED(size_hint);
+ sink->len = 0;
+ return sink;
}
-bool upb_symtab_addfile(upb_symtab *s, upb_filedef *file, upb_status *status) {
- size_t n;
- size_t i;
- upb_def **defs;
- bool ret;
+static size_t upb_bufsink_string(void *_sink, const void *hd, const char *ptr,
+ size_t len, const upb_bufhandle *handle) {
+ upb_bufsink *sink = _sink;
+ size_t new_size = sink->size;
- n = upb_filedef_defcount(file);
- defs = upb_gmalloc(sizeof(*defs) * n);
+ UPB_ASSERT(new_size > 0);
+ UPB_UNUSED(hd);
+ UPB_UNUSED(handle);
- if (defs == NULL) {
- upb_status_seterrmsg(status, "Out of memory");
- return false;
+ while (sink->len + len > new_size) {
+ new_size *= 2;
}
- for (i = 0; i < n; i++) {
- defs[i] = upb_filedef_mutabledef(file, i);
+ if (new_size != sink->size) {
+ sink->ptr = upb_env_realloc(sink->env, sink->ptr, sink->size, new_size);
+ sink->size = new_size;
}
- ret = symtab_add(s, defs, n, NULL, upb_filedef_upcast_mutable(file), status);
+ memcpy(sink->ptr + sink->len, ptr, len);
+ sink->len += len;
- upb_gfree(defs);
- return ret;
+ return len;
}
-/* Iteration. */
+upb_bufsink *upb_bufsink_new(upb_env *env) {
+ upb_bufsink *sink = upb_env_malloc(env, sizeof(upb_bufsink));
+ upb_byteshandler_init(&sink->handler);
+ upb_byteshandler_setstartstr(&sink->handler, upb_bufsink_start, NULL);
+ upb_byteshandler_setstring(&sink->handler, upb_bufsink_string, NULL);
-static void advance_to_matching(upb_symtab_iter *iter) {
- if (iter->type == UPB_DEF_ANY)
- return;
+ upb_bytessink_reset(&sink->sink, &sink->handler, sink);
- while (!upb_strtable_done(&iter->iter) &&
- iter->type != upb_symtab_iter_def(iter)->type) {
- upb_strtable_next(&iter->iter);
- }
-}
+ sink->env = env;
+ sink->size = 32;
+ sink->ptr = upb_env_malloc(env, sink->size);
+ sink->len = 0;
-void upb_symtab_begin(upb_symtab_iter *iter, const upb_symtab *s,
- upb_deftype_t type) {
- upb_strtable_begin(&iter->iter, &s->symtab);
- iter->type = type;
- advance_to_matching(iter);
+ return sink;
}
-void upb_symtab_next(upb_symtab_iter *iter) {
- upb_strtable_next(&iter->iter);
- advance_to_matching(iter);
+void upb_bufsink_free(upb_bufsink *sink) {
+ upb_env_free(sink->env, sink->ptr);
+ upb_env_free(sink->env, sink);
}
-bool upb_symtab_done(const upb_symtab_iter *iter) {
- return upb_strtable_done(&iter->iter);
+upb_bytessink *upb_bufsink_sink(upb_bufsink *sink) {
+ return &sink->sink;
}
-const upb_def *upb_symtab_iter_def(const upb_symtab_iter *iter) {
- return upb_value_getptr(upb_strtable_iter_value(&iter->iter));
+const char *upb_bufsink_getdata(const upb_bufsink *sink, size_t *len) {
+ *len = sink->len;
+ return sink->ptr;
}
/*
** upb_table Implementation
@@ -4244,16 +5319,11 @@ const upb_def *upb_symtab_iter_def(const upb_symtab_iter *iter) {
#define ARRAY_SIZE(x) \
((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x])))))
-#ifdef NDEBUG
static void upb_check_alloc(upb_table *t, upb_alloc *a) {
UPB_UNUSED(t);
UPB_UNUSED(a);
+ UPB_ASSERT_DEBUGVAR(t->alloc == a);
}
-#else
-static void upb_check_alloc(upb_table *t, upb_alloc *a) {
- assert(t->alloc == a);
-}
-#endif
static const double MAX_LOAD = 0.85;
@@ -4362,7 +5432,7 @@ static void uninit(upb_table *t, upb_alloc *a) {
static upb_tabent *emptyent(upb_table *t) {
upb_tabent *e = mutable_entries(t) + upb_table_size(t);
- while (1) { if (upb_tabent_isempty(--e)) return e; assert(e > t->entries); }
+ while (1) { if (upb_tabent_isempty(--e)) return e; UPB_ASSERT(e > t->entries); }
}
static upb_tabent *getentry_mutable(upb_table *t, uint32_t hash) {
@@ -4407,10 +5477,8 @@ static void insert(upb_table *t, lookupkey_t key, upb_tabkey tabkey,
upb_tabent *mainpos_e;
upb_tabent *our_e;
- UPB_UNUSED(eql);
- UPB_UNUSED(key);
- assert(findentry(t, key, hash, eql) == NULL);
- assert(val.ctype == t->ctype);
+ UPB_ASSERT(findentry(t, key, hash, eql) == NULL);
+ UPB_ASSERT_DEBUGVAR(val.ctype == t->ctype);
t->count++;
mainpos_e = getentry_mutable(t, hash);
@@ -4437,7 +5505,7 @@ static void insert(upb_table *t, lookupkey_t key, upb_tabkey tabkey,
*new_e = *mainpos_e; /* copies next. */
while (chain->next != mainpos_e) {
chain = (upb_tabent*)chain->next;
- assert(chain);
+ UPB_ASSERT(chain);
}
chain->next = new_e;
our_e = mainpos_e;
@@ -4446,7 +5514,7 @@ static void insert(upb_table *t, lookupkey_t key, upb_tabkey tabkey,
}
our_e->key = tabkey;
our_e->val.val = val.val;
- assert(findentry(t, key, hash, eql) == our_e);
+ UPB_ASSERT(findentry(t, key, hash, eql) == our_e);
}
static bool rm(upb_table *t, lookupkey_t key, upb_value *val,
@@ -4456,38 +5524,33 @@ static bool rm(upb_table *t, lookupkey_t key, upb_value *val,
if (eql(chain->key, key)) {
/* Element to remove is at the head of its chain. */
t->count--;
- if (val) {
- _upb_value_setval(val, chain->val.val, t->ctype);
- }
+ if (val) _upb_value_setval(val, chain->val.val, t->ctype);
+ if (removed) *removed = chain->key;
if (chain->next) {
upb_tabent *move = (upb_tabent*)chain->next;
*chain = *move;
- if (removed) *removed = move->key;
move->key = 0; /* Make the slot empty. */
} else {
- if (removed) *removed = chain->key;
chain->key = 0; /* Make the slot empty. */
}
return true;
} else {
/* Element to remove is either in a non-head position or not in the
* table. */
- while (chain->next && !eql(chain->next->key, key))
+ while (chain->next && !eql(chain->next->key, key)) {
chain = (upb_tabent*)chain->next;
+ }
if (chain->next) {
/* Found element to remove. */
- upb_tabent *rm;
-
- if (val) {
- _upb_value_setval(val, chain->next->val.val, t->ctype);
- }
- rm = (upb_tabent*)chain->next;
+ upb_tabent *rm = (upb_tabent*)chain->next;
+ t->count--;
+ if (val) _upb_value_setval(val, chain->next->val.val, t->ctype);
if (removed) *removed = rm->key;
- rm->key = 0;
+ rm->key = 0; /* Make the slot empty. */
chain->next = rm->next;
- t->count--;
return true;
} else {
+ /* Element to remove is not in the table. */
return false;
}
}
@@ -4596,7 +5659,7 @@ bool upb_strtable_lookup2(const upb_strtable *t, const char *key, size_t len,
bool upb_strtable_remove3(upb_strtable *t, const char *key, size_t len,
upb_value *val, upb_alloc *alloc) {
- uint32_t hash = MurmurHash2(key, strlen(key), 0);
+ uint32_t hash = MurmurHash2(key, len, 0);
upb_tabkey tabkey;
if (rm(&t->t, strkey2(key, len), val, &tabkey, hash, &streql)) {
upb_free(alloc, (void*)tabkey);
@@ -4627,19 +5690,19 @@ bool upb_strtable_done(const upb_strtable_iter *i) {
}
const char *upb_strtable_iter_key(const upb_strtable_iter *i) {
- assert(!upb_strtable_done(i));
+ UPB_ASSERT(!upb_strtable_done(i));
return upb_tabstr(str_tabent(i)->key, NULL);
}
size_t upb_strtable_iter_keylength(const upb_strtable_iter *i) {
uint32_t len;
- assert(!upb_strtable_done(i));
+ UPB_ASSERT(!upb_strtable_done(i));
upb_tabstr(str_tabent(i)->key, &len);
return len;
}
upb_value upb_strtable_iter_value(const upb_strtable_iter *i) {
- assert(!upb_strtable_done(i));
+ UPB_ASSERT(!upb_strtable_done(i));
return _upb_value_val(str_tabent(i)->val.val, i->t->t.ctype);
}
@@ -4698,9 +5761,9 @@ static void check(upb_inttable *t) {
upb_inttable_iter i;
upb_inttable_begin(&i, t);
for(; !upb_inttable_done(&i); upb_inttable_next(&i), count++) {
- assert(upb_inttable_lookup(t, upb_inttable_iter_key(&i), NULL));
+ UPB_ASSERT(upb_inttable_lookup(t, upb_inttable_iter_key(&i), NULL));
}
- assert(count == upb_inttable_count(t));
+ UPB_ASSERT(count == upb_inttable_count(t));
}
#endif
}
@@ -4738,13 +5801,12 @@ bool upb_inttable_insert2(upb_inttable *t, uintptr_t key, upb_value val,
upb_alloc *a) {
upb_tabval tabval;
tabval.val = val.val;
- UPB_UNUSED(tabval);
- assert(upb_arrhas(tabval)); /* This will reject (uint64_t)-1. Fix this. */
+ UPB_ASSERT(upb_arrhas(tabval)); /* This will reject (uint64_t)-1. Fix this. */
upb_check_alloc(&t->t, a);
if (key < t->array_size) {
- assert(!upb_arrhas(t->array[key]));
+ UPB_ASSERT(!upb_arrhas(t->array[key]));
t->array_count++;
mutable_array(t)[key].val = val.val;
} else {
@@ -4767,7 +5829,7 @@ bool upb_inttable_insert2(upb_inttable *t, uintptr_t key, upb_value val,
insert(&new_table, intkey(e->key), e->key, v, hash, &inthash, &inteql);
}
- assert(t->t.count == new_table.count);
+ UPB_ASSERT(t->t.count == new_table.count);
uninit(&t->t, a);
t->t = new_table;
@@ -4807,9 +5869,7 @@ bool upb_inttable_remove(upb_inttable *t, uintptr_t key, upb_value *val) {
success = false;
}
} else {
- upb_tabkey removed;
- uint32_t hash = upb_inthash(key);
- success = rm(&t->t, intkey(key), val, &removed, hash, &inteql);
+ success = rm(&t->t, intkey(key), val, NULL, upb_inthash(key), &inteql);
}
check(t);
return success;
@@ -4823,7 +5883,7 @@ bool upb_inttable_push2(upb_inttable *t, upb_value val, upb_alloc *a) {
upb_value upb_inttable_pop(upb_inttable *t) {
upb_value val;
bool ok = upb_inttable_remove(t, upb_inttable_count(t) - 1, &val);
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
return val;
}
@@ -4879,7 +5939,7 @@ void upb_inttable_compact2(upb_inttable *t, upb_alloc *a) {
arr_count -= counts[size_lg2];
}
- assert(arr_count <= upb_inttable_count(t));
+ UPB_ASSERT(arr_count <= upb_inttable_count(t));
{
/* Insert all elements into new, perfectly-sized table. */
@@ -4894,8 +5954,8 @@ void upb_inttable_compact2(upb_inttable *t, upb_alloc *a) {
uintptr_t k = upb_inttable_iter_key(&i);
upb_inttable_insert2(&new_t, k, upb_inttable_iter_value(&i), a);
}
- assert(new_t.array_size == arr_size);
- assert(new_t.t.size_lg2 == hashsize_lg2);
+ UPB_ASSERT(new_t.array_size == arr_size);
+ UPB_ASSERT(new_t.t.size_lg2 == hashsize_lg2);
}
upb_inttable_uninit2(t, a);
*t = new_t;
@@ -4904,12 +5964,12 @@ void upb_inttable_compact2(upb_inttable *t, upb_alloc *a) {
/* Iteration. */
static const upb_tabent *int_tabent(const upb_inttable_iter *i) {
- assert(!i->array_part);
+ UPB_ASSERT(!i->array_part);
return &i->t->t.entries[i->index];
}
static upb_tabval int_arrent(const upb_inttable_iter *i) {
- assert(i->array_part);
+ UPB_ASSERT(i->array_part);
return i->t->array[i->index];
}
@@ -4946,12 +6006,12 @@ bool upb_inttable_done(const upb_inttable_iter *i) {
}
uintptr_t upb_inttable_iter_key(const upb_inttable_iter *i) {
- assert(!upb_inttable_done(i));
+ UPB_ASSERT(!upb_inttable_done(i));
return i->array_part ? i->index : int_tabent(i)->key;
}
upb_value upb_inttable_iter_value(const upb_inttable_iter *i) {
- assert(!upb_inttable_done(i));
+ UPB_ASSERT(!upb_inttable_done(i));
return _upb_value_val(
i->array_part ? i->t->array[i->index].val : int_tabent(i)->val.val,
i->t->t.ctype);
@@ -5169,7 +6229,7 @@ bool upb_dumptostderr(void *closure, const upb_status* status) {
static void nullz(upb_status *status) {
const char *ellipsis = "...";
size_t len = strlen(ellipsis);
- assert(sizeof(status->msg) > len);
+ UPB_ASSERT(sizeof(status->msg) > len);
memcpy(status->msg + sizeof(status->msg) - len, ellipsis, len);
}
@@ -5252,7 +6312,7 @@ upb_alloc upb_alloc_global = {&upb_global_allocfunc};
/* Be conservative and choose 16 in case anyone is using SSE. */
static const size_t maxalign = 16;
-static size_t align_up(size_t size) {
+static size_t align_up_max(size_t size) {
return ((size + maxalign - 1) / maxalign) * maxalign;
}
@@ -5276,7 +6336,7 @@ static void upb_arena_addblock(upb_arena *a, void *ptr, size_t size,
block->next = a->block_head;
block->size = size;
- block->used = align_up(sizeof(mem_block));
+ block->used = align_up_max(sizeof(mem_block));
block->owned = owned;
a->block_head = block;
@@ -5309,7 +6369,7 @@ static void *upb_arena_doalloc(upb_alloc *alloc, void *ptr, size_t oldsize,
return NULL; /* We are an arena, don't need individual frees. */
}
- size = align_up(size);
+ size = align_up_max(size);
/* TODO(haberman): special-case if this is a realloc of the last alloc? */
@@ -5379,6 +6439,10 @@ void upb_arena_uninit(upb_arena *a) {
block = next;
}
+
+ /* Protect against multiple-uninit. */
+ a->cleanup_head = NULL;
+ a->block_head = NULL;
}
bool upb_arena_addcleanup(upb_arena *a, upb_cleanup_func *func, void *ud) {
@@ -5479,8 +6543,6 @@ size_t upb_env_bytesallocated(const upb_env *e) {
* Do not edit -- your changes will be discarded when the file is
* regenerated. */
-#include <assert.h>
-
static const upb_msgdef msgs[22];
static const upb_fielddef fields[105];
@@ -6416,6 +7478,8 @@ typedef struct {
/* Index of the first def that is under this scope. For msgdefs, the
* msgdef itself is at start-1. */
int start;
+ uint32_t oneof_start;
+ uint32_t oneof_index;
} upb_descreader_frame;
/* The maximum number of nested declarations that are allowed, ie.
@@ -6436,6 +7500,7 @@ struct upb_descreader {
upb_filedef *file; /* The last file in files. */
upb_descreader_frame stack[UPB_MAX_MESSAGE_NESTING];
int stack_len;
+ upb_inttable oneofs;
uint32_t number;
char *name;
@@ -6447,7 +7512,7 @@ struct upb_descreader {
upb_fielddef *f;
};
-static char *upb_strndup(const char *buf, size_t n) {
+static char *upb_gstrndup(const char *buf, size_t n) {
char *ret = upb_gmalloc(n + 1);
if (!ret) return NULL;
memcpy(ret, buf, n);
@@ -6498,9 +7563,9 @@ static bool upb_descreader_qualify(upb_filedef *f, char *str, int32_t start) {
static upb_msgdef *upb_descreader_top(upb_descreader *r) {
int index;
- assert(r->stack_len > 1);
+ UPB_ASSERT(r->stack_len > 1);
index = r->stack[r->stack_len-1].start - 1;
- assert(index >= 0);
+ UPB_ASSERT(index >= 0);
return upb_downcast_msgdef_mutable(upb_filedef_mutabledef(r->file, index));
}
@@ -6513,16 +7578,27 @@ static upb_def *upb_descreader_last(upb_descreader *r) {
void upb_descreader_startcontainer(upb_descreader *r) {
upb_descreader_frame *f = &r->stack[r->stack_len++];
f->start = upb_filedef_defcount(r->file);
+ f->oneof_start = upb_inttable_count(&r->oneofs);
+ f->oneof_index = 0;
f->name = NULL;
}
bool upb_descreader_endcontainer(upb_descreader *r) {
- upb_descreader_frame *f = &r->stack[--r->stack_len];
+ upb_descreader_frame *f = &r->stack[r->stack_len - 1];
+
+ while (upb_inttable_count(&r->oneofs) > f->oneof_start) {
+ upb_oneofdef *o = upb_value_getptr(upb_inttable_pop(&r->oneofs));
+ bool ok = upb_msgdef_addoneof(upb_descreader_top(r), o, &r->oneofs, NULL);
+ UPB_ASSERT(ok);
+ }
+
if (!upb_descreader_qualify(r->file, f->name, f->start)) {
return false;
}
upb_gfree(f->name);
f->name = NULL;
+
+ r->stack_len--;
return true;
}
@@ -6532,6 +7608,26 @@ void upb_descreader_setscopename(upb_descreader *r, char *str) {
f->name = str;
}
+static upb_oneofdef *upb_descreader_getoneof(upb_descreader *r,
+ uint32_t index) {
+ bool found;
+ upb_value val;
+ upb_descreader_frame *f = &r->stack[r->stack_len-1];
+
+ /* DescriptorProto messages can be nested, so we will see the nested messages
+ * between when we see the FieldDescriptorProto and the OneofDescriptorProto.
+ * We need to preserve the oneofs in between these two things. */
+ index += f->oneof_start;
+
+ while (upb_inttable_count(&r->oneofs) <= index) {
+ upb_inttable_push(&r->oneofs, upb_value_ptr(upb_oneofdef_new(&r->oneofs)));
+ }
+
+ found = upb_inttable_lookup(&r->oneofs, index, &val);
+ UPB_ASSERT(found);
+ return upb_value_getptr(val);
+}
+
/** Handlers for google.protobuf.FileDescriptorSet. ***************************/
static void *fileset_startfile(void *closure, const void *hd) {
@@ -6566,11 +7662,11 @@ static size_t file_onname(void *closure, const void *hd, const char *buf,
UPB_UNUSED(hd);
UPB_UNUSED(handle);
- name = upb_strndup(buf, n);
+ name = upb_gstrndup(buf, n);
/* XXX: see comment at the top of the file. */
ok = upb_filedef_setname(r->file, name, NULL);
upb_gfree(name);
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
return n;
}
@@ -6582,11 +7678,11 @@ static size_t file_onpackage(void *closure, const void *hd, const char *buf,
UPB_UNUSED(hd);
UPB_UNUSED(handle);
- package = upb_strndup(buf, n);
+ package = upb_gstrndup(buf, n);
/* XXX: see comment at the top of the file. */
upb_descreader_setscopename(r, package);
ok = upb_filedef_setpackage(r->file, package, NULL);
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
return n;
}
@@ -6605,7 +7701,7 @@ static size_t file_onsyntax(void *closure, const void *hd, const char *buf,
ok = false;
}
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
return n;
}
@@ -6614,7 +7710,7 @@ static void *file_startmsg(void *closure, const void *hd) {
upb_msgdef *m = upb_msgdef_new(&m);
bool ok = upb_filedef_addmsg(r->file, m, &m, NULL);
UPB_UNUSED(hd);
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
return r;
}
@@ -6623,7 +7719,7 @@ static void *file_startenum(void *closure, const void *hd) {
upb_enumdef *e = upb_enumdef_new(&e);
bool ok = upb_filedef_addenum(r->file, e, &e, NULL);
UPB_UNUSED(hd);
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
return r;
}
@@ -6633,7 +7729,7 @@ static void *file_startext(void *closure, const void *hd) {
r->f = upb_fielddef_new(r);
ok = upb_filedef_addext(r->file, r->f, r, NULL);
UPB_UNUSED(hd);
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
return r;
}
@@ -6654,7 +7750,7 @@ static size_t enumval_onname(void *closure, const void *hd, const char *buf,
UPB_UNUSED(handle);
/* XXX: see comment at the top of the file. */
upb_gfree(r->name);
- r->name = upb_strndup(buf, n);
+ r->name = upb_gstrndup(buf, n);
r->saw_name = true;
return n;
}
@@ -6705,7 +7801,7 @@ static bool enum_endmsg(void *closure, const void *hd, upb_status *status) {
static size_t enum_onname(void *closure, const void *hd, const char *buf,
size_t n, const upb_bufhandle *handle) {
upb_descreader *r = closure;
- char *fullname = upb_strndup(buf, n);
+ char *fullname = upb_gstrndup(buf, n);
UPB_UNUSED(hd);
UPB_UNUSED(handle);
/* XXX: see comment at the top of the file. */
@@ -6719,7 +7815,7 @@ static size_t enum_onname(void *closure, const void *hd, const char *buf,
static bool field_startmsg(void *closure, const void *hd) {
upb_descreader *r = closure;
UPB_UNUSED(hd);
- assert(r->f);
+ UPB_ASSERT(r->f);
upb_gfree(r->default_string);
r->default_string = NULL;
@@ -6805,9 +7901,9 @@ static bool field_endmsg(void *closure, const void *hd, upb_status *status) {
UPB_UNUSED(hd);
/* TODO: verify that all required fields were present. */
- assert(upb_fielddef_number(f) != 0);
- assert(upb_fielddef_name(f) != NULL);
- assert((upb_fielddef_subdefname(f) != NULL) == upb_fielddef_hassubdef(f));
+ UPB_ASSERT(upb_fielddef_number(f) != 0);
+ UPB_ASSERT(upb_fielddef_name(f) != NULL);
+ UPB_ASSERT((upb_fielddef_subdefname(f) != NULL) == upb_fielddef_hassubdef(f));
if (r->default_string) {
if (upb_fielddef_issubmsg(f)) {
@@ -6866,14 +7962,14 @@ static bool field_onnumber(void *closure, const void *hd, int32_t val) {
UPB_UNUSED(hd);
ok = upb_fielddef_setnumber(r->f, val, NULL);
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
return true;
}
static size_t field_onname(void *closure, const void *hd, const char *buf,
size_t n, const upb_bufhandle *handle) {
upb_descreader *r = closure;
- char *name = upb_strndup(buf, n);
+ char *name = upb_gstrndup(buf, n);
UPB_UNUSED(hd);
UPB_UNUSED(handle);
@@ -6886,7 +7982,7 @@ static size_t field_onname(void *closure, const void *hd, const char *buf,
static size_t field_ontypename(void *closure, const void *hd, const char *buf,
size_t n, const upb_bufhandle *handle) {
upb_descreader *r = closure;
- char *name = upb_strndup(buf, n);
+ char *name = upb_gstrndup(buf, n);
UPB_UNUSED(hd);
UPB_UNUSED(handle);
@@ -6899,7 +7995,7 @@ static size_t field_ontypename(void *closure, const void *hd, const char *buf,
static size_t field_onextendee(void *closure, const void *hd, const char *buf,
size_t n, const upb_bufhandle *handle) {
upb_descreader *r = closure;
- char *name = upb_strndup(buf, n);
+ char *name = upb_gstrndup(buf, n);
UPB_UNUSED(hd);
UPB_UNUSED(handle);
@@ -6919,7 +8015,34 @@ static size_t field_ondefaultval(void *closure, const void *hd, const char *buf,
* type yet, so we save it as a string until the end of the field.
* XXX: see comment at the top of the file. */
upb_gfree(r->default_string);
- r->default_string = upb_strndup(buf, n);
+ r->default_string = upb_gstrndup(buf, n);
+ return n;
+}
+
+static bool field_ononeofindex(void *closure, const void *hd, int32_t index) {
+ upb_descreader *r = closure;
+ upb_oneofdef *o = upb_descreader_getoneof(r, index);
+ bool ok = upb_oneofdef_addfield(o, r->f, &r->f, NULL);
+ UPB_UNUSED(hd);
+
+ UPB_ASSERT(ok);
+ return true;
+}
+
+/** Handlers for google.protobuf.OneofDescriptorProto. ************************/
+
+static size_t oneof_name(void *closure, const void *hd, const char *buf,
+ size_t n, const upb_bufhandle *handle) {
+ upb_descreader *r = closure;
+ upb_descreader_frame *f = &r->stack[r->stack_len-1];
+ upb_oneofdef *o = upb_descreader_getoneof(r, f->oneof_index++);
+ char *name_null_terminated = upb_gstrndup(buf, n);
+ bool ok = upb_oneofdef_setname(o, name_null_terminated, NULL);
+ UPB_UNUSED(hd);
+ UPB_UNUSED(handle);
+
+ UPB_ASSERT(ok);
+ free(name_null_terminated);
return n;
}
@@ -6950,7 +8073,7 @@ static size_t msg_name(void *closure, const void *hd, const char *buf,
upb_descreader *r = closure;
upb_msgdef *m = upb_descreader_top(r);
/* XXX: see comment at the top of the file. */
- char *name = upb_strndup(buf, n);
+ char *name = upb_gstrndup(buf, n);
UPB_UNUSED(hd);
UPB_UNUSED(handle);
@@ -6964,7 +8087,7 @@ static void *msg_startmsg(void *closure, const void *hd) {
upb_msgdef *m = upb_msgdef_new(&m);
bool ok = upb_filedef_addmsg(r->file, m, &m, NULL);
UPB_UNUSED(hd);
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
return r;
}
@@ -6973,7 +8096,7 @@ static void *msg_startext(void *closure, const void *hd) {
upb_fielddef *f = upb_fielddef_new(&f);
bool ok = upb_filedef_addext(r->file, f, &f, NULL);
UPB_UNUSED(hd);
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
return r;
}
@@ -6989,9 +8112,15 @@ static void *msg_startfield(void *closure, const void *hd) {
static bool msg_endfield(void *closure, const void *hd) {
upb_descreader *r = closure;
upb_msgdef *m = upb_descreader_top(r);
+ bool ok;
UPB_UNUSED(hd);
- upb_msgdef_addfield(m, r->f, &r->f, NULL);
+ /* Oneof fields are added to the msgdef through their oneof, so don't need to
+ * be added here. */
+ if (upb_fielddef_containingoneof(r->f) == NULL) {
+ ok = upb_msgdef_addfield(m, r->f, &r->f, NULL);
+ UPB_ASSERT(ok);
+ }
r->f = NULL;
return true;
}
@@ -7074,6 +8203,10 @@ static void reghandlers(const void *closure, upb_handlers *h) {
&field_onextendee, NULL);
upb_handlers_setstring(h, F(FieldDescriptorProto, default_value),
&field_ondefaultval, NULL);
+ upb_handlers_setint32(h, F(FieldDescriptorProto, oneof_index),
+ &field_ononeofindex, NULL);
+ } else if (upbdefs_google_protobuf_OneofDescriptorProto_is(m)) {
+ upb_handlers_setstring(h, F(OneofDescriptorProto, name), &oneof_name, NULL);
} else if (upbdefs_google_protobuf_FieldOptions_is(m)) {
upb_handlers_setbool(h, F(FieldOptions, lazy), &field_onlazy, NULL);
upb_handlers_setbool(h, F(FieldOptions, packed), &field_onpacked, NULL);
@@ -7081,7 +8214,7 @@ static void reghandlers(const void *closure, upb_handlers *h) {
upb_handlers_setbool(h, F(MessageOptions, map_entry), &msg_onmapentry, NULL);
}
- assert(upb_ok(upb_handlers_status(h)));
+ UPB_ASSERT(upb_ok(upb_handlers_status(h)));
}
#undef F
@@ -7096,6 +8229,7 @@ void descreader_cleanup(void *_r) {
upb_gfree(r->name);
upb_inttable_uninit(&r->files);
+ upb_inttable_uninit(&r->oneofs);
upb_gfree(r->default_string);
while (r->stack_len > 0) {
upb_descreader_frame *f = &r->stack[--r->stack_len];
@@ -7113,6 +8247,7 @@ upb_descreader *upb_descreader_create(upb_env *e, const upb_handlers *h) {
}
upb_inttable_init(&r->files, UPB_CTYPE_PTR);
+ upb_inttable_init(&r->oneofs, UPB_CTYPE_PTR);
upb_sink_reset(upb_descreader_input(r), h, r);
r->stack_len = 0;
r->name = NULL;
@@ -7327,7 +8462,7 @@ bool op_has_longofs(int32_t instruction) {
case OP_TAGN:
return false;
default:
- assert(false);
+ UPB_ASSERT(false);
return false;
}
}
@@ -7346,7 +8481,7 @@ static void setofs(uint32_t *instruction, int32_t ofs) {
} else {
*instruction = (*instruction & ~0xff00) | ((ofs & 0xff) << 8);
}
- assert(getofs(*instruction) == ofs); /* Would fail in cases of overflow. */
+ UPB_ASSERT(getofs(*instruction) == ofs); /* Would fail in cases of overflow. */
}
static uint32_t pcofs(compiler *c) { return c->pc - c->group->bytecode; }
@@ -7358,7 +8493,7 @@ static void label(compiler *c, unsigned int label) {
int val;
uint32_t *codep;
- assert(label < MAXLABEL);
+ UPB_ASSERT(label < MAXLABEL);
val = c->fwd_labels[label];
codep = (val == EMPTYLABEL) ? NULL : c->group->bytecode + val;
while (codep) {
@@ -7379,7 +8514,7 @@ static void label(compiler *c, unsigned int label) {
* The returned value is the offset that should be written into the instruction.
*/
static int32_t labelref(compiler *c, int label) {
- assert(label < MAXLABEL);
+ UPB_ASSERT(label < MAXLABEL);
if (label == LABEL_DISPATCH) {
/* No resolving required. */
return 0;
@@ -7479,7 +8614,7 @@ static void putop(compiler *c, opcode op, ...) {
int label = va_arg(ap, int);
uint64_t tag = va_arg(ap, uint64_t);
uint32_t instruction = op | (tag << 16);
- assert(tag <= 0xffff);
+ UPB_ASSERT(tag <= 0xffff);
setofs(&instruction, labelref(c, label));
put32(c, instruction);
break;
@@ -7616,7 +8751,7 @@ static uint64_t get_encoded_tag(const upb_fielddef *f, int wire_type) {
uint32_t tag = (upb_fielddef_number(f) << 3) | wire_type;
uint64_t encoded_tag = upb_vencode32(tag);
/* No tag should be greater than 5 bytes. */
- assert(encoded_tag <= 0xffffffffff);
+ UPB_ASSERT(encoded_tag <= 0xffffffffff);
return encoded_tag;
}
@@ -7639,7 +8774,7 @@ static void putchecktag(compiler *c, const upb_fielddef *f,
static upb_selector_t getsel(const upb_fielddef *f, upb_handlertype_t type) {
upb_selector_t selector;
bool ok = upb_handlers_getselector(f, type, &selector);
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
return selector;
}
@@ -7651,7 +8786,7 @@ static uint64_t repack(uint64_t dispatch, int new_wt2) {
uint8_t wt1;
uint8_t old_wt2;
upb_pbdecoder_unpackdispatch(dispatch, &ofs, &wt1, &old_wt2);
- assert(old_wt2 == NO_WIRE_TYPE); /* wt2 should not be set yet. */
+ UPB_ASSERT(old_wt2 == NO_WIRE_TYPE); /* wt2 should not be set yet. */
return upb_pbdecoder_packdispatch(ofs, wt1, new_wt2);
}
@@ -7853,7 +8988,7 @@ static void generate_primitivefield(compiler *c, const upb_fielddef *f,
* setting in the fielddef. This will favor (in speed) whichever was
* specified. */
- assert((int)parse_type >= 0 && parse_type <= OP_MAX);
+ UPB_ASSERT((int)parse_type >= 0 && parse_type <= OP_MAX);
sel = getsel(f, upb_handlers_getprimitivehandlertype(f));
wire_type = upb_pb_native_wire_types[upb_fielddef_descriptortype(f)];
if (upb_fielddef_isseq(f)) {
@@ -7895,7 +9030,7 @@ static void compile_method(compiler *c, upb_pbdecodermethod *method) {
upb_msg_field_iter i;
upb_value val;
- assert(method);
+ UPB_ASSERT(method);
/* Clear all entries in the dispatch table. */
upb_inttable_uninit(&method->dispatch);
@@ -8043,7 +9178,7 @@ const mgroup *mgroup_new(const upb_handlers *dest, bool allowjit, bool lazy,
compiler *c;
UPB_UNUSED(allowjit);
- assert(upb_handlers_isfrozen(dest));
+ UPB_ASSERT(upb_handlers_isfrozen(dest));
g = newgroup(owner);
c = newcompiler(g, lazy);
@@ -8064,13 +9199,13 @@ const mgroup *mgroup_new(const upb_handlers *dest, bool allowjit, bool lazy,
#ifdef UPB_DUMP_BYTECODE
{
FILE *f = fopen("/tmp/upb-bytecode", "w");
- assert(f);
+ UPB_ASSERT(f);
dumpbc(g->bytecode, g->bytecode_end, stderr);
dumpbc(g->bytecode, g->bytecode_end, f);
fclose(f);
f = fopen("/tmp/upb-bytecode.bin", "wb");
- assert(f);
+ UPB_ASSERT(f);
fwrite(g->bytecode, 1, g->bytecode_end - g->bytecode, f);
fclose(f);
}
@@ -8120,7 +9255,7 @@ const upb_pbdecodermethod *upb_pbcodecache_getdecodermethod(
upb_inttable_push(&c->groups, upb_value_constptr(g));
ok = upb_inttable_lookupptr(&g->methods, opts->handlers, &v);
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
return upb_value_getptr(v);
}
@@ -8253,7 +9388,7 @@ void upb_pbdecoder_seterr(upb_pbdecoder *d, const char *msg) {
/* How many bytes can be safely read from d->ptr without reading past end-of-buf
* or past the current delimited end. */
static size_t curbufleft(const upb_pbdecoder *d) {
- assert(d->data_end >= d->ptr);
+ UPB_ASSERT(d->data_end >= d->ptr);
return d->data_end - d->ptr;
}
@@ -8274,7 +9409,7 @@ size_t delim_remaining(const upb_pbdecoder *d) {
/* Advances d->ptr. */
static void advance(upb_pbdecoder *d, size_t len) {
- assert(curbufleft(d) >= len);
+ UPB_ASSERT(curbufleft(d) >= len);
d->ptr += len;
}
@@ -8307,7 +9442,7 @@ static void switchtobuf(upb_pbdecoder *d, const char *buf, const char *end) {
}
static void advancetobuf(upb_pbdecoder *d, const char *buf, size_t len) {
- assert(curbufleft(d) == 0);
+ UPB_ASSERT(curbufleft(d) == 0);
d->bufstart_ofs += (d->end - d->buf);
switchtobuf(d, buf, buf + len);
}
@@ -8316,7 +9451,7 @@ static void checkpoint(upb_pbdecoder *d) {
/* The assertion here is in the interests of efficiency, not correctness.
* We are trying to ensure that we don't checkpoint() more often than
* necessary. */
- assert(d->checkpoint != d->ptr);
+ UPB_ASSERT(d->checkpoint != d->ptr);
d->checkpoint = d->ptr;
}
@@ -8327,8 +9462,8 @@ static void checkpoint(upb_pbdecoder *d) {
* won't actually be read.
*/
static int32_t skip(upb_pbdecoder *d, size_t bytes) {
- assert(!in_residual_buf(d, d->ptr) || d->size_param == 0);
- assert(d->skip == 0);
+ UPB_ASSERT(!in_residual_buf(d, d->ptr) || d->size_param == 0);
+ UPB_ASSERT(d->skip == 0);
if (bytes > delim_remaining(d)) {
seterr(d, "Skipped value extended beyond enclosing submessage.");
return upb_pbdecoder_suspend(d);
@@ -8356,7 +9491,7 @@ int32_t upb_pbdecoder_resume(upb_pbdecoder *d, void *p, const char *buf,
/* d->skip and d->residual_end could probably elegantly be represented
* as a single variable, to more easily represent this invariant. */
- assert(!(d->skip && d->residual_end > d->residual));
+ UPB_ASSERT(!(d->skip && d->residual_end > d->residual));
/* We need to remember the original size_param, so that the value we return
* is relative to it, even if we do some skipping first. */
@@ -8389,7 +9524,7 @@ int32_t upb_pbdecoder_resume(upb_pbdecoder *d, void *p, const char *buf,
if (d->residual_end > d->residual) {
/* We have residual bytes from the last buffer. */
- assert(d->ptr == d->residual);
+ UPB_ASSERT(d->ptr == d->residual);
} else {
switchtobuf(d, buf, buf + size);
}
@@ -8423,8 +9558,8 @@ size_t upb_pbdecoder_suspend(upb_pbdecoder *d) {
return 0;
} else {
size_t ret = d->size_param - (d->end - d->checkpoint);
- assert(!in_residual_buf(d, d->checkpoint));
- assert(d->buf == d->buf_param || d->buf == &dummy_char);
+ UPB_ASSERT(!in_residual_buf(d, d->checkpoint));
+ UPB_ASSERT(d->buf == d->buf_param || d->buf == &dummy_char);
d->bufstart_ofs += (d->checkpoint - d->buf);
d->residual_end = d->residual;
@@ -8444,7 +9579,7 @@ static size_t suspend_save(upb_pbdecoder *d) {
if (d->checkpoint == d->residual) {
/* Checkpoint was in residual buf; append user byte(s) to residual buf. */
- assert((d->residual_end - d->residual) + d->size_param <=
+ UPB_ASSERT((d->residual_end - d->residual) + d->size_param <=
sizeof(d->residual));
if (!in_residual_buf(d, d->ptr)) {
d->bufstart_ofs -= (d->residual_end - d->residual);
@@ -8454,11 +9589,11 @@ static size_t suspend_save(upb_pbdecoder *d) {
} else {
/* Checkpoint was in user buf; old residual bytes not needed. */
size_t save;
- assert(!in_residual_buf(d, d->checkpoint));
+ UPB_ASSERT(!in_residual_buf(d, d->checkpoint));
d->ptr = d->checkpoint;
save = curbufleft(d);
- assert(save <= sizeof(d->residual));
+ UPB_ASSERT(save <= sizeof(d->residual));
memcpy(d->residual, d->ptr, save);
d->residual_end = d->residual + save;
d->bufstart_ofs = offset(d);
@@ -8472,7 +9607,7 @@ static size_t suspend_save(upb_pbdecoder *d) {
* Requires that this many bytes are available in the current buffer. */
UPB_FORCEINLINE static void consumebytes(upb_pbdecoder *d, void *buf,
size_t bytes) {
- assert(bytes <= curbufleft(d));
+ UPB_ASSERT(bytes <= curbufleft(d));
memcpy(buf, d->ptr, bytes);
advance(d, bytes);
}
@@ -8485,7 +9620,7 @@ UPB_NOINLINE static int32_t getbytes_slow(upb_pbdecoder *d, void *buf,
const size_t avail = curbufleft(d);
consumebytes(d, buf, avail);
bytes -= avail;
- assert(bytes > 0);
+ UPB_ASSERT(bytes > 0);
if (in_residual_buf(d, d->ptr)) {
advancetobuf(d, d->buf_param, d->size_param);
}
@@ -8668,7 +9803,7 @@ UPB_NOINLINE int32_t upb_pbdecoder_checktag_slow(upb_pbdecoder *d,
if (read == bytes && data == expected) {
/* Advance past matched bytes. */
int32_t ok = getbytes(d, &data, read);
- UPB_ASSERT_VAR(ok, ok < 0);
+ UPB_ASSERT(ok < 0);
return DECODE_OK;
} else if (read < bytes && memcmp(&data, &expected, read) == 0) {
return suspend_save(d);
@@ -8743,7 +9878,7 @@ have_tag:
static void goto_endmsg(upb_pbdecoder *d) {
upb_value v;
bool found = upb_inttable_lookup32(d->top->dispatch, DISPATCH_ENDMSG, &v);
- UPB_ASSERT_VAR(found, found);
+ UPB_ASSERT(found);
d->pc = d->top->base + upb_value_getuint64(v);
}
@@ -8777,7 +9912,7 @@ static int32_t dispatch(upb_pbdecoder *d) {
} else if (wire_type == ((v >> 8) & 0xff)) {
bool found =
upb_inttable_lookup(dispatch, fieldnum + UPB_MAX_FIELDNUMBER, &val);
- UPB_ASSERT_VAR(found, found);
+ UPB_ASSERT(found);
d->pc = d->top->base + upb_value_getuint64(val);
return DECODE_OK;
}
@@ -8789,7 +9924,7 @@ static int32_t dispatch(upb_pbdecoder *d) {
* can re-check the delimited end. */
d->last--; /* Necessary if we get suspended */
d->pc = d->last;
- assert(getop(*d->last) == OP_CHECKDELIM);
+ UPB_ASSERT(getop(*d->last) == OP_CHECKDELIM);
/* Unknown field or ENDGROUP. */
retval = upb_pbdecoder_skipunknown(d, fieldnum, wire_type);
@@ -8807,7 +9942,7 @@ static int32_t dispatch(upb_pbdecoder *d) {
/* Callers know that the stack is more than one deep because the opcodes that
* call this only occur after PUSH operations. */
upb_pbdecoder_frame *outer_frame(upb_pbdecoder *d) {
- assert(d->top != d->stack);
+ UPB_ASSERT(d->top != d->stack);
return d->top - 1;
}
@@ -8839,7 +9974,7 @@ size_t run_decoder_vm(upb_pbdecoder *d, const mgroup *group,
op = getop(instruction);
arg = instruction >> 8;
longofs = arg;
- assert(d->ptr != d->residual_end);
+ UPB_ASSERT(d->ptr != d->residual_end);
UPB_UNUSED(group);
#ifdef UPB_DUMP_BYTECODE
fprintf(stderr, "s_ofs=%d buf_ofs=%d data_rem=%d buf_rem=%d delim_rem=%d "
@@ -8914,7 +10049,7 @@ size_t run_decoder_vm(upb_pbdecoder *d, const mgroup *group,
} else {
int32_t ret = skip(d, n);
/* This shouldn't return DECODE_OK, because n > len. */
- assert(ret >= 0);
+ UPB_ASSERT(ret >= 0);
return ret;
}
}
@@ -8936,7 +10071,7 @@ size_t run_decoder_vm(upb_pbdecoder *d, const mgroup *group,
d->top->groupnum = *d->pc++;
)
VMCASE(OP_POP,
- assert(d->top > d->stack);
+ UPB_ASSERT(d->top > d->stack);
decoder_pop(d);
)
VMCASE(OP_PUSHLENDELIM,
@@ -8952,7 +10087,7 @@ size_t run_decoder_vm(upb_pbdecoder *d, const mgroup *group,
/* We are guaranteed of this assert because we never allow ourselves to
* consume bytes beyond data_end, which covers delim_end when non-NULL.
*/
- assert(!(d->delim_end && d->ptr > d->delim_end));
+ UPB_ASSERT(!(d->delim_end && d->ptr > d->delim_end));
if (d->ptr == d->delim_end)
d->pc += longofs;
)
@@ -8961,7 +10096,7 @@ size_t run_decoder_vm(upb_pbdecoder *d, const mgroup *group,
d->pc += longofs;
)
VMCASE(OP_RET,
- assert(d->call_len > 0);
+ UPB_ASSERT(d->call_len > 0);
d->pc = d->callstack[--d->call_len];
)
VMCASE(OP_BRANCH,
@@ -9088,7 +10223,7 @@ bool upb_pbdecoder_end(void *closure, const void *handler_data) {
if (p != method->code_base.ptr) p--;
if (getop(*p) == OP_CHECKDELIM) {
/* Rewind from OP_TAG* to OP_CHECKDELIM. */
- assert(getop(*d->pc) == OP_TAG1 ||
+ UPB_ASSERT(getop(*d->pc) == OP_TAG1 ||
getop(*d->pc) == OP_TAG2 ||
getop(*d->pc) == OP_TAGN ||
getop(*d->pc) == OP_DISPATCH);
@@ -9152,7 +10287,7 @@ upb_pbdecoder *upb_pbdecoder_create(upb_env *e, const upb_pbdecodermethod *m,
upb_pbdecoder_reset(d);
upb_bytessink_reset(&d->input_, &m->input_handler_, d);
- assert(sink);
+ UPB_ASSERT(sink);
if (d->method_->dest_handlers_) {
if (sink->handlers != d->method_->dest_handlers_)
return NULL;
@@ -9160,7 +10295,8 @@ upb_pbdecoder *upb_pbdecoder_create(upb_env *e, const upb_pbdecodermethod *m,
upb_sink_reset(&d->top->sink, sink->handlers, sink->closure);
/* If this fails, increase the value in decoder.h. */
- assert(upb_env_bytesallocated(e) - size_before <= UPB_PB_DECODER_SIZE);
+ UPB_ASSERT_DEBUGVAR(upb_env_bytesallocated(e) - size_before <=
+ UPB_PB_DECODER_SIZE);
return d;
}
@@ -9181,7 +10317,7 @@ size_t upb_pbdecoder_maxnesting(const upb_pbdecoder *d) {
}
bool upb_pbdecoder_setmaxnesting(upb_pbdecoder *d, size_t max) {
- assert(d->top >= d->stack);
+ UPB_ASSERT(d->top >= d->stack);
if (max < (size_t)(d->top - d->stack)) {
/* Can't set a limit smaller than what we are currently at. */
@@ -9340,7 +10476,7 @@ struct upb_pb_encoder {
/* TODO(haberman): handle pushback */
static void putbuf(upb_pb_encoder *e, const char *buf, size_t len) {
size_t n = upb_bytessink_putbuf(e->output_, e->subc, buf, len, NULL);
- UPB_ASSERT_VAR(n, n == len);
+ UPB_ASSERT(n == len);
}
static upb_pb_encoder_segment *top(upb_pb_encoder *e) {
@@ -9380,7 +10516,7 @@ static bool reserve(upb_pb_encoder *e, size_t bytes) {
/* Call when "bytes" bytes have been writte at e->ptr. The caller *must* have
* previously called reserve() with at least this many bytes. */
static void encoder_advance(upb_pb_encoder *e, size_t bytes) {
- assert((size_t)(e->limit - e->ptr) >= bytes);
+ UPB_ASSERT((size_t)(e->limit - e->ptr) >= bytes);
e->ptr += bytes;
}
@@ -9415,7 +10551,7 @@ static bool encode_bytes(upb_pb_encoder *e, const void *data, size_t len) {
* length. */
static void accumulate(upb_pb_encoder *e) {
size_t run_len;
- assert(e->ptr >= e->runbegin);
+ UPB_ASSERT(e->ptr >= e->runbegin);
run_len = e->ptr - e->runbegin;
e->segptr->seglen += run_len;
top(e)->msglen += run_len;
@@ -9770,7 +10906,8 @@ upb_pb_encoder *upb_pb_encoder_create(upb_env *env, const upb_handlers *h,
e->ptr = e->buf;
/* If this fails, increase the value in encoder.h. */
- assert(upb_env_bytesallocated(env) - size_before <= UPB_PB_ENCODER_SIZE);
+ UPB_ASSERT_DEBUGVAR(upb_env_bytesallocated(env) - size_before <=
+ UPB_PB_ENCODER_SIZE);
return e;
}
@@ -9938,7 +11075,7 @@ bool putf(upb_textprinter *p, const char *fmt, ...) {
if (!str) return false;
written = vsprintf(str, fmt, args);
va_end(args);
- UPB_ASSERT_VAR(written, written == len);
+ UPB_ASSERT(written == len);
ok = upb_bytessink_putbuf(p->output_, p->subc, str, len, NULL);
upb_gfree(str);
@@ -10407,7 +11544,7 @@ static upb_selector_t getsel_for_handlertype(upb_json_parser *p,
upb_handlertype_t type) {
upb_selector_t sel;
bool ok = upb_handlers_getselector(p->top->f, type, &sel);
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
return sel;
}
@@ -10429,7 +11566,7 @@ static bool check_stack(upb_json_parser *p) {
static void set_name_table(upb_json_parser *p, upb_jsonparser_frame *frame) {
upb_value v;
bool ok = upb_inttable_lookupptr(&p->method->name_tables, frame->m, &v);
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
frame->name_table = upb_value_getptr(v);
}
@@ -10552,7 +11689,7 @@ otherchar:
val = b64lookup(ptr[0]) << 18 |
b64lookup(ptr[1]) << 12;
- assert(!(val & 0x80000000));
+ UPB_ASSERT(!(val & 0x80000000));
output = val >> 16;
upb_sink_putstring(&p->top->sink, sel, &output, 1, NULL);
return true;
@@ -10606,9 +11743,8 @@ badpadding:
* the true value in a contiguous buffer. */
static void assert_accumulate_empty(upb_json_parser *p) {
- UPB_UNUSED(p);
- assert(p->accumulated == NULL);
- assert(p->accumulated_len == 0);
+ UPB_ASSERT(p->accumulated == NULL);
+ UPB_ASSERT(p->accumulated_len == 0);
}
static void accumulate_clear(upb_json_parser *p) {
@@ -10674,7 +11810,7 @@ static bool accumulate_append(upb_json_parser *p, const char *buf, size_t len,
* call, and writes the length to *len. This with point either to the input
* buffer or a temporary accumulate buffer. */
static const char *accumulate_getptr(upb_json_parser *p, size_t *len) {
- assert(p->accumulated);
+ UPB_ASSERT(p->accumulated);
*len = p->accumulated_len;
return p->accumulated;
}
@@ -10712,7 +11848,7 @@ enum {
* the end. */
static void multipart_startaccum(upb_json_parser *p) {
assert_accumulate_empty(p);
- assert(p->multipart_state == MULTIPART_INACTIVE);
+ UPB_ASSERT(p->multipart_state == MULTIPART_INACTIVE);
p->multipart_state = MULTIPART_ACCUMULATE;
}
@@ -10720,7 +11856,7 @@ static void multipart_startaccum(upb_json_parser *p) {
* value with the given selector. */
static void multipart_start(upb_json_parser *p, upb_selector_t sel) {
assert_accumulate_empty(p);
- assert(p->multipart_state == MULTIPART_INACTIVE);
+ UPB_ASSERT(p->multipart_state == MULTIPART_INACTIVE);
p->multipart_state = MULTIPART_PUSHEAGERLY;
p->string_selector = sel;
}
@@ -10753,7 +11889,7 @@ static bool multipart_text(upb_json_parser *p, const char *buf, size_t len,
/* Note: this invalidates the accumulate buffer! Call only after reading its
* contents. */
static void multipart_end(upb_json_parser *p) {
- assert(p->multipart_state != MULTIPART_INACTIVE);
+ UPB_ASSERT(p->multipart_state != MULTIPART_INACTIVE);
p->multipart_state = MULTIPART_INACTIVE;
accumulate_clear(p);
}
@@ -10766,13 +11902,13 @@ static void multipart_end(upb_json_parser *p) {
* region. */
static void capture_begin(upb_json_parser *p, const char *ptr) {
- assert(p->multipart_state != MULTIPART_INACTIVE);
- assert(p->capture == NULL);
+ UPB_ASSERT(p->multipart_state != MULTIPART_INACTIVE);
+ UPB_ASSERT(p->capture == NULL);
p->capture = ptr;
}
static bool capture_end(upb_json_parser *p, const char *ptr) {
- assert(p->capture);
+ UPB_ASSERT(p->capture);
if (multipart_text(p, p->capture, ptr - p->capture, true)) {
p->capture = NULL;
return true;
@@ -10805,7 +11941,7 @@ static void capture_suspend(upb_json_parser *p, const char **ptr) {
static void capture_resume(upb_json_parser *p, const char *ptr) {
if (p->capture) {
- assert(p->capture == &suspend_capture);
+ UPB_ASSERT(p->capture == &suspend_capture);
p->capture = ptr;
}
}
@@ -10827,7 +11963,7 @@ static char escape_char(char in) {
case '"': return '"';
case '\\': return '\\';
default:
- assert(0);
+ UPB_ASSERT(0);
return 'x';
}
}
@@ -10851,7 +11987,7 @@ static void hexdigit(upb_json_parser *p, const char *ptr) {
} else if (ch >= 'a' && ch <= 'f') {
p->digit += ((ch - 'a') + 10);
} else {
- assert(ch >= 'A' && ch <= 'F');
+ UPB_ASSERT(ch >= 'A' && ch <= 'F');
p->digit += ((ch - 'A') + 10);
}
}
@@ -10982,7 +12118,7 @@ static bool parse_number(upb_json_parser *p) {
break;
}
default:
- assert(false);
+ UPB_ASSERT(false);
}
multipart_end(p);
@@ -11008,13 +12144,13 @@ static bool parser_putbool(upb_json_parser *p, bool val) {
}
ok = upb_sink_putbool(&p->top->sink, parser_getsel(p), val);
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
return true;
}
static bool start_stringval(upb_json_parser *p) {
- assert(p->top->f);
+ UPB_ASSERT(p->top->f);
if (upb_fielddef_isstring(p->top->f)) {
upb_jsonparser_frame *inner;
@@ -11104,7 +12240,7 @@ static bool end_stringval(upb_json_parser *p) {
}
default:
- assert(false);
+ UPB_ASSERT(false);
upb_status_seterrmsg(&p->status, "Internal error in JSON decoder");
upb_env_reporterror(p->env, &p->status);
ok = false;
@@ -11117,7 +12253,7 @@ static bool end_stringval(upb_json_parser *p) {
}
static void start_member(upb_json_parser *p) {
- assert(!p->top->f);
+ UPB_ASSERT(!p->top->f);
multipart_startaccum(p);
}
@@ -11246,7 +12382,7 @@ static bool handle_mapentry(upb_json_parser *p) {
}
static bool end_membername(upb_json_parser *p) {
- assert(!p->top->f);
+ UPB_ASSERT(!p->top->f);
if (p->top->is_map) {
return handle_mapentry(p);
@@ -11278,7 +12414,7 @@ static void end_member(upb_json_parser *p) {
bool ok;
const upb_fielddef *mapfield;
- assert(p->top > p->stack);
+ UPB_ASSERT(p->top > p->stack);
/* send ENDMSG on submsg. */
upb_sink_endmsg(&p->top->sink, &s);
mapfield = p->top->mapfield;
@@ -11286,7 +12422,7 @@ static void end_member(upb_json_parser *p) {
/* send ENDSUBMSG in repeated-field-of-mapentries frame. */
p->top--;
ok = upb_handlers_getselector(mapfield, UPB_HANDLER_ENDSUBMSG, &sel);
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
upb_sink_endsubmsg(&p->top->sink, sel);
}
@@ -11294,7 +12430,7 @@ static void end_member(upb_json_parser *p) {
}
static bool start_subobject(upb_json_parser *p) {
- assert(p->top->f);
+ UPB_ASSERT(p->top->f);
if (upb_fielddef_ismap(p->top->f)) {
upb_jsonparser_frame *inner;
@@ -11363,7 +12499,7 @@ static bool start_array(upb_json_parser *p) {
upb_jsonparser_frame *inner;
upb_selector_t sel;
- assert(p->top->f);
+ UPB_ASSERT(p->top->f);
if (!upb_fielddef_isseq(p->top->f)) {
upb_status_seterrf(&p->status,
@@ -11391,7 +12527,7 @@ static bool start_array(upb_json_parser *p) {
static void end_array(upb_json_parser *p) {
upb_selector_t sel;
- assert(p->top > p->stack);
+ UPB_ASSERT(p->top > p->stack);
p->top--;
sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSEQ);
@@ -11437,11 +12573,11 @@ static void end_object(upb_json_parser *p) {
* final state once, when the closing '"' is seen. */
-#line 1245 "upb/json/parser.rl"
+#line 1244 "upb/json/parser.rl"
-#line 1157 "upb/json/parser.c"
+#line 1156 "upb/json/parser.c"
static const char _json_actions[] = {
0, 1, 0, 1, 2, 1, 3, 1,
5, 1, 6, 1, 7, 1, 8, 1,
@@ -11590,7 +12726,7 @@ static const int json_en_value_machine = 27;
static const int json_en_main = 1;
-#line 1248 "upb/json/parser.rl"
+#line 1247 "upb/json/parser.rl"
size_t parse(void *closure, const void *hd, const char *buf, size_t size,
const upb_bufhandle *handle) {
@@ -11612,7 +12748,7 @@ size_t parse(void *closure, const void *hd, const char *buf, size_t size,
capture_resume(parser, buf);
-#line 1328 "upb/json/parser.c"
+#line 1327 "upb/json/parser.c"
{
int _klen;
unsigned int _trans;
@@ -11687,118 +12823,118 @@ _match:
switch ( *_acts++ )
{
case 0:
-#line 1160 "upb/json/parser.rl"
+#line 1159 "upb/json/parser.rl"
{ p--; {cs = stack[--top]; goto _again;} }
break;
case 1:
-#line 1161 "upb/json/parser.rl"
+#line 1160 "upb/json/parser.rl"
{ p--; {stack[top++] = cs; cs = 10; goto _again;} }
break;
case 2:
-#line 1165 "upb/json/parser.rl"
+#line 1164 "upb/json/parser.rl"
{ start_text(parser, p); }
break;
case 3:
-#line 1166 "upb/json/parser.rl"
+#line 1165 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_text(parser, p)); }
break;
case 4:
-#line 1172 "upb/json/parser.rl"
+#line 1171 "upb/json/parser.rl"
{ start_hex(parser); }
break;
case 5:
-#line 1173 "upb/json/parser.rl"
+#line 1172 "upb/json/parser.rl"
{ hexdigit(parser, p); }
break;
case 6:
-#line 1174 "upb/json/parser.rl"
+#line 1173 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_hex(parser)); }
break;
case 7:
-#line 1180 "upb/json/parser.rl"
+#line 1179 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(escape(parser, p)); }
break;
case 8:
-#line 1186 "upb/json/parser.rl"
+#line 1185 "upb/json/parser.rl"
{ p--; {cs = stack[--top]; goto _again;} }
break;
case 9:
-#line 1189 "upb/json/parser.rl"
+#line 1188 "upb/json/parser.rl"
{ {stack[top++] = cs; cs = 19; goto _again;} }
break;
case 10:
-#line 1191 "upb/json/parser.rl"
+#line 1190 "upb/json/parser.rl"
{ p--; {stack[top++] = cs; cs = 27; goto _again;} }
break;
case 11:
-#line 1196 "upb/json/parser.rl"
+#line 1195 "upb/json/parser.rl"
{ start_member(parser); }
break;
case 12:
-#line 1197 "upb/json/parser.rl"
+#line 1196 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_membername(parser)); }
break;
case 13:
-#line 1200 "upb/json/parser.rl"
+#line 1199 "upb/json/parser.rl"
{ end_member(parser); }
break;
case 14:
-#line 1206 "upb/json/parser.rl"
+#line 1205 "upb/json/parser.rl"
{ start_object(parser); }
break;
case 15:
-#line 1209 "upb/json/parser.rl"
+#line 1208 "upb/json/parser.rl"
{ end_object(parser); }
break;
case 16:
-#line 1215 "upb/json/parser.rl"
+#line 1214 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(start_array(parser)); }
break;
case 17:
-#line 1219 "upb/json/parser.rl"
+#line 1218 "upb/json/parser.rl"
{ end_array(parser); }
break;
case 18:
-#line 1224 "upb/json/parser.rl"
+#line 1223 "upb/json/parser.rl"
{ start_number(parser, p); }
break;
case 19:
-#line 1225 "upb/json/parser.rl"
+#line 1224 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_number(parser, p)); }
break;
case 20:
-#line 1227 "upb/json/parser.rl"
+#line 1226 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(start_stringval(parser)); }
break;
case 21:
-#line 1228 "upb/json/parser.rl"
+#line 1227 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(end_stringval(parser)); }
break;
case 22:
-#line 1230 "upb/json/parser.rl"
+#line 1229 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(parser_putbool(parser, true)); }
break;
case 23:
-#line 1232 "upb/json/parser.rl"
+#line 1231 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(parser_putbool(parser, false)); }
break;
case 24:
-#line 1234 "upb/json/parser.rl"
+#line 1233 "upb/json/parser.rl"
{ /* null value */ }
break;
case 25:
-#line 1236 "upb/json/parser.rl"
+#line 1235 "upb/json/parser.rl"
{ CHECK_RETURN_TOP(start_subobject(parser)); }
break;
case 26:
-#line 1237 "upb/json/parser.rl"
+#line 1236 "upb/json/parser.rl"
{ end_subobject(parser); }
break;
case 27:
-#line 1242 "upb/json/parser.rl"
+#line 1241 "upb/json/parser.rl"
{ p--; {cs = stack[--top]; goto _again;} }
break;
-#line 1514 "upb/json/parser.c"
+#line 1513 "upb/json/parser.c"
}
}
@@ -11811,7 +12947,7 @@ _again:
_out: {}
}
-#line 1269 "upb/json/parser.rl"
+#line 1268 "upb/json/parser.rl"
if (p != pe) {
upb_status_seterrf(&parser->status, "Parse error at '%.*s'\n", pe - p, p);
@@ -11852,13 +12988,13 @@ static void json_parser_reset(upb_json_parser *p) {
/* Emit Ragel initialization of the parser. */
-#line 1568 "upb/json/parser.c"
+#line 1567 "upb/json/parser.c"
{
cs = json_start;
top = 0;
}
-#line 1309 "upb/json/parser.rl"
+#line 1308 "upb/json/parser.rl"
p->current_state = cs;
p->parser_top = top;
accumulate_clear(p);
@@ -11922,7 +13058,7 @@ static void add_jsonname_table(upb_json_parsermethod *m, const upb_msgdef* md) {
buf = upb_grealloc(buf, 0, field_len);
len = field_len;
len2 = upb_fielddef_getjsonname(f, buf, len);
- UPB_ASSERT_VAR(len2, len == len2);
+ UPB_ASSERT(len == len2);
}
upb_strtable_insert(t, buf, upb_value_constptr(f));
@@ -11966,7 +13102,8 @@ upb_json_parser *upb_json_parser_create(upb_env *env,
/* If this fails, uncomment and increase the value in parser.h. */
/* fprintf(stderr, "%zd\n", upb_env_bytesallocated(env) - size_before); */
- assert(upb_env_bytesallocated(env) - size_before <= UPB_JSON_PARSER_SIZE);
+ UPB_ASSERT_DEBUGVAR(upb_env_bytesallocated(env) - size_before <=
+ UPB_JSON_PARSER_SIZE);
return p;
}
@@ -12054,7 +13191,7 @@ strpc *newstrpc(upb_handlers *h, const upb_fielddef *f,
ret->len = upb_fielddef_getjsonname(f, NULL, 0);
ret->ptr = upb_gmalloc(ret->len);
len = upb_fielddef_getjsonname(f, ret->ptr, ret->len);
- UPB_ASSERT_VAR(len, len == ret->len);
+ UPB_ASSERT(len == ret->len);
ret->len--; /* NULL */
}
@@ -12068,7 +13205,7 @@ static void print_data(
upb_json_printer *p, const char *buf, unsigned int len) {
/* TODO: Will need to change if we support pushback from the sink. */
size_t n = upb_bytessink_putbuf(p->output_, p->subc_, buf, len, NULL);
- UPB_ASSERT_VAR(n, n == len);
+ UPB_ASSERT(n == len);
}
static void print_comma(upb_json_printer *p) {
@@ -12418,7 +13555,7 @@ static size_t putbytes(void *closure, const void *handler_data, const char *str,
while (remaining > 2) {
/* TODO(haberman): handle encoded lengths > sizeof(data) */
- UPB_ASSERT_VAR(limit, (limit - to) >= 4);
+ UPB_ASSERT((limit - to) >= 4);
to[0] = base64[from[0] >> 2];
to[1] = base64[((from[0] & 0x3) << 4) | (from[1] >> 4)];
@@ -12622,7 +13759,7 @@ void printer_sethandlers_mapentry(const void *closure, bool preserve_fieldnames,
upb_handlers_setstring(h, key_field, mapkey_bytes, &empty_attr);
break;
default:
- assert(false);
+ UPB_ASSERT(false);
break;
}
@@ -12796,7 +13933,8 @@ upb_json_printer *upb_json_printer_create(upb_env *e, const upb_handlers *h,
upb_sink_reset(&p->input_, h, p);
/* If this fails, increase the value in printer.h. */
- assert(upb_env_bytesallocated(e) - size_before <= UPB_JSON_PRINTER_SIZE);
+ UPB_ASSERT_DEBUGVAR(upb_env_bytesallocated(e) - size_before <=
+ UPB_JSON_PRINTER_SIZE);
return p;
}
diff --git a/ruby/ext/google/protobuf_c/upb.h b/ruby/ext/google/protobuf_c/upb.h
index e8b683bd..6e1e6c6f 100644
--- a/ruby/ext/google/protobuf_c/upb.h
+++ b/ruby/ext/google/protobuf_c/upb.h
@@ -55,14 +55,13 @@
** store pointers or integers of at least 32 bits (upb isn't really useful on
** systems where sizeof(void*) < 4).
**
-** The table must be homogeneous (all values of the same type). In debug
+** The table must be homogenous (all values of the same type). In debug
** mode, we check this on insert and lookup.
*/
#ifndef UPB_TABLE_H_
#define UPB_TABLE_H_
-#include <assert.h>
#include <stdint.h>
#include <string.h>
/*
@@ -118,20 +117,21 @@ template <int N> class InlinedEnvironment;
#define UPB_NORETURN
#endif
+#if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L
+/* C99/C++11 versions. */
+#include <stdio.h>
+#define _upb_snprintf snprintf
+#define _upb_vsnprintf vsnprintf
+#define _upb_va_copy(a, b) va_copy(a, b)
+#elif defined __GNUC__
/* A few hacky workarounds for functions not in C89.
* For internal use only!
* TODO(haberman): fix these by including our own implementations, or finding
* another workaround.
*/
-#ifdef __GNUC__
#define _upb_snprintf __builtin_snprintf
#define _upb_vsnprintf __builtin_vsnprintf
#define _upb_va_copy(a, b) __va_copy(a, b)
-#elif __STDC_VERSION__ >= 199901L
-/* C99 versions. */
-#define _upb_snprintf snprintf
-#define _upb_vsnprintf vsnprintf
-#define _upb_va_copy(a, b) va_copy(a, b)
#else
#error Need implementations of [v]snprintf and va_copy
#endif
@@ -263,10 +263,23 @@ template <int N> class InlinedEnvironment;
#define UPB_UNUSED(var) (void)var
-/* For asserting something about a variable when the variable is not used for
- * anything else. This prevents "unused variable" warnings when compiling in
- * debug mode. */
-#define UPB_ASSERT_VAR(var, predicate) UPB_UNUSED(var); assert(predicate)
+/* UPB_ASSERT(): in release mode, we use the expression without letting it be
+ * evaluated. This prevents "unused variable" warnings. */
+#ifdef NDEBUG
+#define UPB_ASSERT(expr) do {} while (false && (expr))
+#else
+#define UPB_ASSERT(expr) assert(expr)
+#endif
+
+/* UPB_ASSERT_DEBUGVAR(): assert that uses functions or variables that only
+ * exist in debug mode. This turns into regular assert. */
+#define UPB_ASSERT_DEBUGVAR(expr) assert(expr)
+
+#ifdef __GNUC__
+#define UPB_UNREACHABLE() do { assert(0); __builtin_unreachable(); } while(0)
+#else
+#define UPB_UNREACHABLE() do { assert(0); } while(0)
+#endif
/* Generic function type. */
typedef void upb_func();
@@ -501,17 +514,18 @@ struct upb_alloc {
};
UPB_INLINE void *upb_malloc(upb_alloc *alloc, size_t size) {
- assert(size > 0);
+ UPB_ASSERT(alloc);
return alloc->func(alloc, NULL, 0, size);
}
UPB_INLINE void *upb_realloc(upb_alloc *alloc, void *ptr, size_t oldsize,
size_t size) {
- assert(size > 0);
+ UPB_ASSERT(alloc);
return alloc->func(alloc, ptr, oldsize, size);
}
UPB_INLINE void upb_free(upb_alloc *alloc, void *ptr) {
+ assert(alloc);
alloc->func(alloc, ptr, 0, 0);
}
@@ -560,11 +574,11 @@ UPB_BEGIN_EXTERN_C
void upb_arena_init(upb_arena *a);
void upb_arena_init2(upb_arena *a, void *mem, size_t n, upb_alloc *alloc);
void upb_arena_uninit(upb_arena *a);
-upb_alloc *upb_arena_alloc(upb_arena *a);
bool upb_arena_addcleanup(upb_arena *a, upb_cleanup_func *func, void *ud);
size_t upb_arena_bytesallocated(const upb_arena *a);
void upb_arena_setnextblocksize(upb_arena *a, size_t size);
void upb_arena_setmaxblocksize(upb_arena *a, size_t size);
+UPB_INLINE upb_alloc *upb_arena_alloc(upb_arena *a) { return (upb_alloc*)a; }
UPB_END_EXTERN_C
@@ -795,7 +809,9 @@ typedef enum {
UPB_CTYPE_CSTR = 6,
UPB_CTYPE_PTR = 7,
UPB_CTYPE_CONSTPTR = 8,
- UPB_CTYPE_FPTR = 9
+ UPB_CTYPE_FPTR = 9,
+ UPB_CTYPE_FLOAT = 10,
+ UPB_CTYPE_DOUBLE = 11
} upb_ctype_t;
typedef struct {
@@ -854,7 +870,7 @@ UPB_INLINE upb_value _upb_value_val(uint64_t val, upb_ctype_t ctype) {
return ret; \
} \
UPB_INLINE type_t upb_value_get ## name(upb_value val) { \
- assert(val.ctype == proto_type); \
+ UPB_ASSERT_DEBUGVAR(val.ctype == proto_type); \
return (type_t)(converter)val.val; \
}
@@ -869,6 +885,29 @@ FUNCS(constptr, constptr, const void*, uintptr_t, UPB_CTYPE_CONSTPTR)
FUNCS(fptr, fptr, upb_func*, uintptr_t, UPB_CTYPE_FPTR)
#undef FUNCS
+
+UPB_INLINE void upb_value_setfloat(upb_value *val, float cval) {
+ memcpy(&val->val, &cval, sizeof(cval));
+ SET_TYPE(val->ctype, UPB_CTYPE_FLOAT);
+}
+
+UPB_INLINE void upb_value_setdouble(upb_value *val, double cval) {
+ memcpy(&val->val, &cval, sizeof(cval));
+ SET_TYPE(val->ctype, UPB_CTYPE_DOUBLE);
+}
+
+UPB_INLINE upb_value upb_value_float(float cval) {
+ upb_value ret;
+ upb_value_setfloat(&ret, cval);
+ return ret;
+}
+
+UPB_INLINE upb_value upb_value_double(double cval) {
+ upb_value ret;
+ upb_value_setdouble(&ret, cval);
+ return ret;
+}
+
#undef SET_TYPE
@@ -1111,6 +1150,13 @@ UPB_INLINE size_t upb_strtable_count(const upb_strtable *t) {
return t->t.count;
}
+void upb_inttable_packedsize(const upb_inttable *t, size_t *size);
+void upb_strtable_packedsize(const upb_strtable *t, size_t *size);
+upb_inttable *upb_inttable_pack(const upb_inttable *t, void *p, size_t *ofs,
+ size_t size);
+upb_strtable *upb_strtable_pack(const upb_strtable *t, void *p, size_t *ofs,
+ size_t size);
+
/* Inserts the given key into the hashtable with the given value. The key must
* not already exist in the hash table. For string tables, the key must be
* NULL-terminated, and the table will make an internal copy of the key.
@@ -1556,7 +1602,7 @@ template <class T> class upb::reffed_ptr {
reffed_ptr(U* val, const void* ref_donor = NULL)
: ptr_(upb::upcast(val)) {
if (ref_donor) {
- assert(ptr_);
+ UPB_ASSERT(ptr_);
ptr_->DonateRef(ref_donor, this);
} else if (ptr_) {
ptr_->Ref(this);
@@ -1601,12 +1647,12 @@ template <class T> class upb::reffed_ptr {
}
T& operator*() const {
- assert(ptr_);
+ UPB_ASSERT(ptr_);
return *ptr_;
}
T* operator->() const {
- assert(ptr_);
+ UPB_ASSERT(ptr_);
return ptr_;
}
@@ -1657,6 +1703,7 @@ class FieldDef;
class FileDef;
class MessageDef;
class OneofDef;
+class SymbolTable;
}
#endif
@@ -1665,6 +1712,8 @@ UPB_DECLARE_DERIVED_TYPE(upb::OneofDef, upb::RefCounted, upb_oneofdef,
upb_refcounted)
UPB_DECLARE_DERIVED_TYPE(upb::FileDef, upb::RefCounted, upb_filedef,
upb_refcounted)
+UPB_DECLARE_TYPE(upb::SymbolTable, upb_symtab)
+
/* The maximum message depth that the type graph can have. This is a resource
* limit for the C stack since we sometimes need to recursively traverse the
@@ -1698,8 +1747,6 @@ class upb::Def {
public:
typedef upb_deftype_t Type;
- Def* Dup(const void *owner) const;
-
/* upb::RefCounted methods like Ref()/Unref(). */
UPB_REFCOUNTED_CPPMETHODS
@@ -1745,9 +1792,6 @@ class upb::Def {
UPB_BEGIN_EXTERN_C
-/* Native C API. */
-upb_def *upb_def_dup(const upb_def *def, const void *owner);
-
/* Include upb_refcounted methods like upb_def_ref()/upb_def_unref(). */
UPB_REFCOUNTED_CMETHODS(upb_def, upb_def_upcast)
@@ -1808,7 +1852,7 @@ UPB_END_EXTERN_C
return (upb_##lower *)def; \
} \
UPB_INLINE const upb_##lower *upb_downcast_##lower(const upb_def *def) { \
- assert(upb_def_type(def) == UPB_DEF_##upper); \
+ UPB_ASSERT(upb_def_type(def) == UPB_DEF_##upper); \
return (const upb_##lower *)def; \
} \
UPB_INLINE upb_##lower *upb_dyncast_##lower##_mutable(upb_def *def) { \
@@ -1844,15 +1888,19 @@ UPB_DECLARE_DEF_TYPE(upb::EnumDef, enumdef, ENUM)
* types defined in descriptor.proto, which gives INT32 and SINT32 separate
* types (we distinguish the two with the "integer encoding" enum below). */
typedef enum {
- UPB_TYPE_FLOAT = 1,
- UPB_TYPE_DOUBLE = 2,
- UPB_TYPE_BOOL = 3,
- UPB_TYPE_STRING = 4,
- UPB_TYPE_BYTES = 5,
- UPB_TYPE_MESSAGE = 6,
- UPB_TYPE_ENUM = 7, /* Enum values are int32. */
- UPB_TYPE_INT32 = 8,
- UPB_TYPE_UINT32 = 9,
+ /* Types stored in 1 byte. */
+ UPB_TYPE_BOOL = 1,
+ /* Types stored in 4 bytes. */
+ UPB_TYPE_FLOAT = 2,
+ UPB_TYPE_INT32 = 3,
+ UPB_TYPE_UINT32 = 4,
+ UPB_TYPE_ENUM = 5, /* Enum values are int32. */
+ /* Types stored as pointers (probably 4 or 8 bytes). */
+ UPB_TYPE_STRING = 6,
+ UPB_TYPE_BYTES = 7,
+ UPB_TYPE_MESSAGE = 8,
+ /* Types stored as 8 bytes. */
+ UPB_TYPE_DOUBLE = 9,
UPB_TYPE_INT64 = 10,
UPB_TYPE_UINT64 = 11
} upb_fieldtype_t;
@@ -1933,13 +1981,6 @@ class upb::FieldDef {
/* Returns NULL if memory allocation failed. */
static reffed_ptr<FieldDef> New();
- /* Duplicates the given field, returning NULL if memory allocation failed.
- * When a fielddef is duplicated, the subdef (if any) is made symbolic if it
- * wasn't already. If the subdef is set but has no name (which is possible
- * since msgdefs are not required to have a name) the new fielddef's subdef
- * will be unset. */
- FieldDef* Dup(const void* owner) const;
-
/* upb::RefCounted methods like Ref()/Unref(). */
UPB_REFCOUNTED_CPPMETHODS
@@ -2026,16 +2067,10 @@ class upb::FieldDef {
bool IsPrimitive() const;
bool IsMap() const;
- /* Whether this field must be able to explicitly represent presence:
+ /* Returns whether this field explicitly represents presence.
*
- * * This is always false for repeated fields (an empty repeated field is
- * equivalent to a repeated field with zero entries).
- *
- * * This is always true for submessages.
- *
- * * For other fields, it depends on the message (see
- * MessageDef::SetPrimitivesHavePresence())
- */
+ * For proto2 messages: Returns true for any scalar (non-repeated) field.
+ * For proto3 messages: Returns true for scalar submessage or oneof fields. */
bool HasPresence() const;
/* How integers are encoded. Only meaningful for integer types.
@@ -2194,7 +2229,6 @@ UPB_BEGIN_EXTERN_C
/* Native C API. */
upb_fielddef *upb_fielddef_new(const void *owner);
-upb_fielddef *upb_fielddef_dup(const upb_fielddef *f, const void *owner);
/* Include upb_refcounted methods like upb_fielddef_ref(). */
UPB_REFCOUNTED_CMETHODS(upb_fielddef, upb_fielddef_upcast2)
@@ -2404,16 +2438,6 @@ class upb::MessageDef {
return FindOneofByName(str.c_str(), str.size());
}
- /* Returns a new msgdef that is a copy of the given msgdef (and a copy of all
- * the fields) but with any references to submessages broken and replaced
- * with just the name of the submessage. Returns NULL if memory allocation
- * failed.
- *
- * TODO(haberman): which is more useful, keeping fields resolved or
- * unresolving them? If there's no obvious answer, Should this functionality
- * just be moved into symtab.c? */
- MessageDef* Dup(const void* owner) const;
-
/* Is this message a map entry? */
void setmapentry(bool map_entry);
bool mapentry() const;
@@ -2547,7 +2571,6 @@ UPB_REFCOUNTED_CMETHODS(upb_msgdef, upb_msgdef_upcast2)
bool upb_msgdef_freeze(upb_msgdef *m, upb_status *status);
-upb_msgdef *upb_msgdef_dup(const upb_msgdef *m, const void *owner);
const char *upb_msgdef_fullname(const upb_msgdef *m);
const char *upb_msgdef_name(const upb_msgdef *m);
int upb_msgdef_numoneofs(const upb_msgdef *m);
@@ -2697,10 +2720,6 @@ class upb::EnumDef {
* first one that was added. */
const char* FindValueByNumber(int32_t num) const;
- /* Returns a new EnumDef with all the same values. The new EnumDef will be
- * owned by the given owner. */
- EnumDef* Dup(const void* owner) const;
-
/* Iteration over name/value pairs. The order is undefined.
* Adding an enum val invalidates any iterators.
*
@@ -2728,7 +2747,6 @@ UPB_BEGIN_EXTERN_C
/* Native C API. */
upb_enumdef *upb_enumdef_new(const void *owner);
-upb_enumdef *upb_enumdef_dup(const upb_enumdef *e, const void *owner);
/* Include upb_refcounted methods like upb_enumdef_ref(). */
UPB_REFCOUNTED_CMETHODS(upb_enumdef, upb_enumdef_upcast2)
@@ -2773,6 +2791,7 @@ int32_t upb_enum_iter_number(upb_enum_iter *iter);
UPB_END_EXTERN_C
+
/* upb::OneofDef **************************************************************/
typedef upb_inttable_iter upb_oneof_iter;
@@ -2837,10 +2856,6 @@ class upb::OneofDef {
/* Looks up by tag number. */
const FieldDef* FindFieldByNumber(uint32_t num) const;
- /* Returns a new OneofDef with all the same fields. The OneofDef will be owned
- * by the given owner. */
- OneofDef* Dup(const void* owner) const;
-
/* Iteration over fields. The order is undefined. */
class iterator : public std::iterator<std::forward_iterator_tag, FieldDef*> {
public:
@@ -2886,16 +2901,16 @@ UPB_BEGIN_EXTERN_C
/* Native C API. */
upb_oneofdef *upb_oneofdef_new(const void *owner);
-upb_oneofdef *upb_oneofdef_dup(const upb_oneofdef *o, const void *owner);
/* Include upb_refcounted methods like upb_oneofdef_ref(). */
UPB_REFCOUNTED_CMETHODS(upb_oneofdef, upb_oneofdef_upcast)
const char *upb_oneofdef_name(const upb_oneofdef *o);
-bool upb_oneofdef_setname(upb_oneofdef *o, const char *name, upb_status *s);
-
const upb_msgdef *upb_oneofdef_containingtype(const upb_oneofdef *o);
int upb_oneofdef_numfields(const upb_oneofdef *o);
+uint32_t upb_oneofdef_index(const upb_oneofdef *o);
+
+bool upb_oneofdef_setname(upb_oneofdef *o, const char *name, upb_status *s);
bool upb_oneofdef_addfield(upb_oneofdef *o, upb_fielddef *f,
const void *ref_donor,
upb_status *s);
@@ -3039,19 +3054,163 @@ UPB_INLINE upb_def *upb_filedef_mutabledef(upb_filedef *f, int i) {
UPB_END_EXTERN_C
+typedef struct {
+ UPB_PRIVATE_FOR_CPP
+ upb_strtable_iter iter;
+ upb_deftype_t type;
+} upb_symtab_iter;
+
+#ifdef __cplusplus
+
+/* Non-const methods in upb::SymbolTable are NOT thread-safe. */
+class upb::SymbolTable {
+ public:
+ /* Returns a new symbol table with a single ref owned by "owner."
+ * Returns NULL if memory allocation failed. */
+ static SymbolTable* New();
+ static void Free(upb::SymbolTable* table);
+
+ /* For all lookup functions, the returned pointer is not owned by the
+ * caller; it may be invalidated by any non-const call or unref of the
+ * SymbolTable! To protect against this, take a ref if desired. */
+
+ /* Freezes the symbol table: prevents further modification of it.
+ * After the Freeze() operation is successful, the SymbolTable must only be
+ * accessed via a const pointer.
+ *
+ * Unlike with upb::MessageDef/upb::EnumDef/etc, freezing a SymbolTable is not
+ * a necessary step in using a SymbolTable. If you have no need for it to be
+ * immutable, there is no need to freeze it ever. However sometimes it is
+ * useful, and SymbolTables that are statically compiled into the binary are
+ * always frozen by nature. */
+ void Freeze();
+
+ /* Resolves the given symbol using the rules described in descriptor.proto,
+ * namely:
+ *
+ * If the name starts with a '.', it is fully-qualified. Otherwise,
+ * C++-like scoping rules are used to find the type (i.e. first the nested
+ * types within this message are searched, then within the parent, on up
+ * to the root namespace).
+ *
+ * If not found, returns NULL. */
+ const Def* Resolve(const char* base, const char* sym) const;
+
+ /* Finds an entry in the symbol table with this exact name. If not found,
+ * returns NULL. */
+ const Def* Lookup(const char *sym) const;
+ const MessageDef* LookupMessage(const char *sym) const;
+ const EnumDef* LookupEnum(const char *sym) const;
+
+ /* TODO: introduce a C++ iterator, but make it nice and templated so that if
+ * you ask for an iterator of MessageDef the iterated elements are strongly
+ * typed as MessageDef*. */
+
+ /* Adds the given mutable defs to the symtab, resolving all symbols (including
+ * enum default values) and finalizing the defs. Only one def per name may be
+ * in the list, and the defs may not duplicate any name already in the symtab.
+ * All defs must have a name -- anonymous defs are not allowed. Anonymous
+ * defs can still be frozen by calling upb_def_freeze() directly.
+ *
+ * The entire operation either succeeds or fails. If the operation fails,
+ * the symtab is unchanged, false is returned, and status indicates the
+ * error. The caller passes a ref on all defs to the symtab (even if the
+ * operation fails).
+ *
+ * TODO(haberman): currently failure will leave the symtab unchanged, but may
+ * leave the defs themselves partially resolved. Does this matter? If so we
+ * could do a prepass that ensures that all symbols are resolvable and bail
+ * if not, so we don't mutate anything until we know the operation will
+ * succeed. */
+ bool Add(Def*const* defs, size_t n, void* ref_donor, Status* status);
+
+ bool Add(const std::vector<Def*>& defs, void *owner, Status* status) {
+ return Add((Def*const*)&defs[0], defs.size(), owner, status);
+ }
+
+ /* Resolves all subdefs for messages in this file and attempts to freeze the
+ * file. If this succeeds, adds all the symbols to this SymbolTable
+ * (replacing any existing ones with the same names). */
+ bool AddFile(FileDef* file, Status* s);
+
+ private:
+ UPB_DISALLOW_POD_OPS(SymbolTable, upb::SymbolTable)
+};
+
+#endif /* __cplusplus */
+
+UPB_BEGIN_EXTERN_C
+
+/* Native C API. */
+
+upb_symtab *upb_symtab_new();
+void upb_symtab_free(upb_symtab* s);
+const upb_def *upb_symtab_resolve(const upb_symtab *s, const char *base,
+ const char *sym);
+const upb_def *upb_symtab_lookup(const upb_symtab *s, const char *sym);
+const upb_msgdef *upb_symtab_lookupmsg(const upb_symtab *s, const char *sym);
+const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym);
+bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
+ void *ref_donor, upb_status *status);
+bool upb_symtab_addfile(upb_symtab *s, upb_filedef *file, upb_status* status);
+
+/* upb_symtab_iter i;
+ * for(upb_symtab_begin(&i, s, type); !upb_symtab_done(&i);
+ * upb_symtab_next(&i)) {
+ * const upb_def *def = upb_symtab_iter_def(&i);
+ * // ...
+ * }
+ *
+ * For C we don't have separate iterators for const and non-const.
+ * It is the caller's responsibility to cast the upb_fielddef* to
+ * const if the upb_msgdef* is const. */
+void upb_symtab_begin(upb_symtab_iter *iter, const upb_symtab *s,
+ upb_deftype_t type);
+void upb_symtab_next(upb_symtab_iter *iter);
+bool upb_symtab_done(const upb_symtab_iter *iter);
+const upb_def *upb_symtab_iter_def(const upb_symtab_iter *iter);
+
+UPB_END_EXTERN_C
+
+#ifdef __cplusplus
+/* C++ inline wrappers. */
+namespace upb {
+inline SymbolTable* SymbolTable::New() {
+ return upb_symtab_new();
+}
+inline void SymbolTable::Free(SymbolTable* s) {
+ upb_symtab_free(s);
+}
+inline const Def *SymbolTable::Resolve(const char *base,
+ const char *sym) const {
+ return upb_symtab_resolve(this, base, sym);
+}
+inline const Def* SymbolTable::Lookup(const char *sym) const {
+ return upb_symtab_lookup(this, sym);
+}
+inline const MessageDef *SymbolTable::LookupMessage(const char *sym) const {
+ return upb_symtab_lookupmsg(this, sym);
+}
+inline bool SymbolTable::Add(
+ Def*const* defs, size_t n, void* ref_donor, Status* status) {
+ return upb_symtab_add(this, (upb_def*const*)defs, n, ref_donor, status);
+}
+inline bool SymbolTable::AddFile(FileDef* file, Status* s) {
+ return upb_symtab_addfile(this, file, s);
+}
+} /* namespace upb */
+#endif
+
#ifdef __cplusplus
UPB_INLINE const char* upb_safecstr(const std::string& str) {
- assert(str.size() == std::strlen(str.c_str()));
+ UPB_ASSERT(str.size() == std::strlen(str.c_str()));
return str.c_str();
}
/* Inline C++ wrappers. */
namespace upb {
-inline Def* Def::Dup(const void* owner) const {
- return upb_def_dup(this, owner);
-}
inline Def::Type Def::def_type() const { return upb_def_type(this); }
inline const char* Def::full_name() const { return upb_def_fullname(this); }
inline const char* Def::name() const { return upb_def_name(this); }
@@ -3081,19 +3240,19 @@ inline bool FieldDef::CheckIntegerFormat(int32_t val) {
return upb_fielddef_checkintfmt(val);
}
inline FieldDef::Type FieldDef::ConvertType(int32_t val) {
- assert(CheckType(val));
+ UPB_ASSERT(CheckType(val));
return static_cast<FieldDef::Type>(val);
}
inline FieldDef::Label FieldDef::ConvertLabel(int32_t val) {
- assert(CheckLabel(val));
+ UPB_ASSERT(CheckLabel(val));
return static_cast<FieldDef::Label>(val);
}
inline FieldDef::DescriptorType FieldDef::ConvertDescriptorType(int32_t val) {
- assert(CheckDescriptorType(val));
+ UPB_ASSERT(CheckDescriptorType(val));
return static_cast<FieldDef::DescriptorType>(val);
}
inline FieldDef::IntegerFormat FieldDef::ConvertIntegerFormat(int32_t val) {
- assert(CheckIntegerFormat(val));
+ UPB_ASSERT(CheckIntegerFormat(val));
return static_cast<FieldDef::IntegerFormat>(val);
}
@@ -3101,9 +3260,6 @@ inline reffed_ptr<FieldDef> FieldDef::New() {
upb_fielddef *f = upb_fielddef_new(&f);
return reffed_ptr<FieldDef>(f, &f);
}
-inline FieldDef* FieldDef::Dup(const void* owner) const {
- return upb_fielddef_dup(this, owner);
-}
inline const char* FieldDef::full_name() const {
return upb_fielddef_fullname(this);
}
@@ -3343,9 +3499,6 @@ inline const OneofDef* MessageDef::FindOneofByName(const char* name,
size_t len) const {
return upb_msgdef_ntoo(this, name, len);
}
-inline MessageDef* MessageDef::Dup(const void *owner) const {
- return upb_msgdef_dup(this, owner);
-}
inline void MessageDef::setmapentry(bool map_entry) {
upb_msgdef_setmapentry(this, map_entry);
}
@@ -3515,9 +3668,6 @@ inline bool EnumDef::FindValueByName(const char* name, int32_t *num) const {
inline const char* EnumDef::FindValueByNumber(int32_t num) const {
return upb_enumdef_iton(this, num);
}
-inline EnumDef* EnumDef::Dup(const void* owner) const {
- return upb_enumdef_dup(this, owner);
-}
inline EnumDef::Iterator::Iterator(const EnumDef* e) {
upb_enum_begin(&iter_, e);
@@ -3824,6 +3974,7 @@ extern const struct upb_refcounted_vtbl upb_enumdef_vtbl;
struct upb_oneofdef {
upb_refcounted base;
+ uint32_t index; /* Index within oneofs. */
const char *name;
upb_strtable ntof;
upb_inttable itof;
@@ -3833,7 +3984,7 @@ struct upb_oneofdef {
extern const struct upb_refcounted_vtbl upb_oneofdef_vtbl;
#define UPB_ONEOFDEF_INIT(name, ntof, itof, refs, ref2s) \
- { UPB_REFCOUNT_INIT(&upb_oneofdef_vtbl, refs, ref2s), name, ntof, itof }
+ { UPB_REFCOUNT_INIT(&upb_oneofdef_vtbl, refs, ref2s), 0, name, ntof, itof }
/* upb_symtab *****************************************************************/
@@ -4469,7 +4620,7 @@ template <class T> class Handler {
void AddCleanup(Handlers* h) const {
if (cleanup_func_) {
bool ok = h->AddCleanup(cleanup_data_, cleanup_func_);
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
}
}
@@ -5489,7 +5640,7 @@ struct ConvertParams<BoundFunc5<R, P1, P2, P3, P4, P5, F, I>, T> {
inline bool Handlers::SetValueHandler<vtype>( \
const FieldDef *f, \
const Handlers::utype ## Handler& handler) { \
- assert(!handler.registered_); \
+ UPB_ASSERT(!handler.registered_); \
handler.AddCleanup(this); \
handler.registered_ = true; \
return upb_handlers_set##ltype(this, f, handler.handler_, &handler.attr_); \
@@ -5601,7 +5752,7 @@ inline Handler<T>::Handler(F func)
template <class T>
inline Handler<T>::~Handler() {
- assert(registered_);
+ UPB_ASSERT(registered_);
}
inline HandlerAttributes::HandlerAttributes() { upb_handlerattr_init(this); }
@@ -5687,63 +5838,63 @@ inline bool Handlers::AddCleanup(void *p, upb_handlerfree *func) {
}
inline bool Handlers::SetStartMessageHandler(
const Handlers::StartMessageHandler &handler) {
- assert(!handler.registered_);
+ UPB_ASSERT(!handler.registered_);
handler.registered_ = true;
handler.AddCleanup(this);
return upb_handlers_setstartmsg(this, handler.handler_, &handler.attr_);
}
inline bool Handlers::SetEndMessageHandler(
const Handlers::EndMessageHandler &handler) {
- assert(!handler.registered_);
+ UPB_ASSERT(!handler.registered_);
handler.registered_ = true;
handler.AddCleanup(this);
return upb_handlers_setendmsg(this, handler.handler_, &handler.attr_);
}
inline bool Handlers::SetStartStringHandler(const FieldDef *f,
const StartStringHandler &handler) {
- assert(!handler.registered_);
+ UPB_ASSERT(!handler.registered_);
handler.registered_ = true;
handler.AddCleanup(this);
return upb_handlers_setstartstr(this, f, handler.handler_, &handler.attr_);
}
inline bool Handlers::SetEndStringHandler(const FieldDef *f,
const EndFieldHandler &handler) {
- assert(!handler.registered_);
+ UPB_ASSERT(!handler.registered_);
handler.registered_ = true;
handler.AddCleanup(this);
return upb_handlers_setendstr(this, f, handler.handler_, &handler.attr_);
}
inline bool Handlers::SetStringHandler(const FieldDef *f,
const StringHandler& handler) {
- assert(!handler.registered_);
+ UPB_ASSERT(!handler.registered_);
handler.registered_ = true;
handler.AddCleanup(this);
return upb_handlers_setstring(this, f, handler.handler_, &handler.attr_);
}
inline bool Handlers::SetStartSequenceHandler(
const FieldDef *f, const StartFieldHandler &handler) {
- assert(!handler.registered_);
+ UPB_ASSERT(!handler.registered_);
handler.registered_ = true;
handler.AddCleanup(this);
return upb_handlers_setstartseq(this, f, handler.handler_, &handler.attr_);
}
inline bool Handlers::SetStartSubMessageHandler(
const FieldDef *f, const StartFieldHandler &handler) {
- assert(!handler.registered_);
+ UPB_ASSERT(!handler.registered_);
handler.registered_ = true;
handler.AddCleanup(this);
return upb_handlers_setstartsubmsg(this, f, handler.handler_, &handler.attr_);
}
inline bool Handlers::SetEndSubMessageHandler(const FieldDef *f,
const EndFieldHandler &handler) {
- assert(!handler.registered_);
+ UPB_ASSERT(!handler.registered_);
handler.registered_ = true;
handler.AddCleanup(this);
return upb_handlers_setendsubmsg(this, f, handler.handler_, &handler.attr_);
}
inline bool Handlers::SetEndSequenceHandler(const FieldDef *f,
const EndFieldHandler &handler) {
- assert(!handler.registered_);
+ UPB_ASSERT(!handler.registered_);
handler.registered_ = true;
handler.AddCleanup(this);
return upb_handlers_setendseq(this, f, handler.handler_, &handler.attr_);
@@ -5820,12 +5971,14 @@ inline BytesHandler::~BytesHandler() {}
#ifdef __cplusplus
namespace upb {
+class BufferSink;
class BufferSource;
class BytesSink;
class Sink;
}
#endif
+UPB_DECLARE_TYPE(upb::BufferSink, upb_bufsink)
UPB_DECLARE_TYPE(upb::BufferSource, upb_bufsrc)
UPB_DECLARE_TYPE(upb::BytesSink, upb_bytessink)
UPB_DECLARE_TYPE(upb::Sink, upb_sink)
@@ -6012,6 +6165,13 @@ struct upb_bufsrc {
UPB_BEGIN_EXTERN_C
+/* A class for accumulating output string data in a flat buffer. */
+
+upb_bufsink *upb_bufsink_new(upb_env *env);
+void upb_bufsink_free(upb_bufsink *sink);
+upb_bytessink *upb_bufsink_sink(upb_bufsink *sink);
+const char *upb_bufsink_getdata(const upb_bufsink *sink, size_t *len);
+
/* Inline definitions. */
UPB_INLINE void upb_bytessink_reset(upb_bytessink *s, const upb_byteshandler *h,
@@ -6061,23 +6221,7 @@ UPB_INLINE bool upb_bytessink_end(upb_bytessink *s) {
&s->handler->table[UPB_ENDSTR_SELECTOR].attr));
}
-UPB_INLINE bool upb_bufsrc_putbuf(const char *buf, size_t len,
- upb_bytessink *sink) {
- void *subc;
- bool ret;
- upb_bufhandle handle;
- upb_bufhandle_init(&handle);
- upb_bufhandle_setbuf(&handle, buf, 0);
- ret = upb_bytessink_start(sink, len, &subc);
- if (ret && len != 0) {
- ret = (upb_bytessink_putbuf(sink, subc, buf, len, &handle) >= len);
- }
- if (ret) {
- ret = upb_bytessink_end(sink);
- }
- upb_bufhandle_uninit(&handle);
- return ret;
-}
+bool upb_bufsrc_putbuf(const char *buf, size_t len, upb_bytessink *sink);
#define PUTVAL(type, ctype) \
UPB_INLINE bool upb_sink_put##type(upb_sink *s, upb_selector_t sel, \
@@ -6325,267 +6469,407 @@ inline bool BufferSource::PutBuffer(const char *buf, size_t len,
#endif
/*
-** For handlers that do very tiny, very simple operations, the function call
-** overhead of calling a handler can be significant. This file allows the
-** user to define handlers that do something very simple like store the value
-** to memory and/or set a hasbit. JIT compilers can then special-case these
-** handlers and emit specialized code for them instead of actually calling the
-** handler.
+** upb::Message is a representation for protobuf messages.
**
-** The functionality is very simple/limited right now but may expand to be able
-** to call another function.
-*/
-
-#ifndef UPB_SHIM_H
-#define UPB_SHIM_H
+** However it differs from other common representations like
+** google::protobuf::Message in one key way: it does not prescribe any
+** ownership between messages and submessages, and it relies on the
+** client to delete each message/submessage/array/map at the appropriate
+** time.
+**
+** A client can access a upb::Message without knowing anything about
+** ownership semantics, but to create or mutate a message a user needs
+** to implement the memory management themselves.
+**
+** Currently all messages, arrays, and maps store a upb_alloc* internally.
+** Mutating operations use this when they require dynamically-allocated
+** memory. We could potentially eliminate this size overhead later by
+** letting the user flip a bit on the factory that prevents this from
+** being stored. The user would then need to use separate functions where
+** the upb_alloc* is passed explicitly. However for handlers to populate
+** such structures, they would need a place to store this upb_alloc* during
+** parsing; upb_handlers don't currently have a good way to accommodate this.
+**
+** TODO: UTF-8 checking?
+**/
+#ifndef UPB_MSG_H_
+#define UPB_MSG_H_
-typedef struct {
- size_t offset;
- int32_t hasbit;
-} upb_shim_data;
#ifdef __cplusplus
namespace upb {
+class Array;
+class Map;
+class MapIterator;
+class MessageFactory;
+class MessageLayout;
+class Visitor;
+class VisitorPlan;
+}
-struct Shim {
- typedef upb_shim_data Data;
+#endif
- /* Sets a handler for the given field that writes the value to the given
- * offset and, if hasbit >= 0, sets a bit at the given bit offset. Returns
- * true if the handler was set successfully. */
- static bool Set(Handlers *h, const FieldDef *f, size_t ofs, int32_t hasbit);
+UPB_DECLARE_TYPE(upb::MessageFactory, upb_msgfactory)
+UPB_DECLARE_TYPE(upb::MessageLayout, upb_msglayout)
+UPB_DECLARE_TYPE(upb::Array, upb_array)
+UPB_DECLARE_TYPE(upb::Map, upb_map)
+UPB_DECLARE_TYPE(upb::MapIterator, upb_mapiter)
+UPB_DECLARE_TYPE(upb::Visitor, upb_visitor)
+UPB_DECLARE_TYPE(upb::VisitorPlan, upb_visitorplan)
- /* If this handler is a shim, returns the corresponding upb::Shim::Data and
- * stores the type in "type". Otherwise returns NULL. */
- static const Data* GetData(const Handlers* h, Handlers::Selector s,
- FieldDef::Type* type);
-};
+/* TODO(haberman): C++ accessors */
-} /* namespace upb */
+UPB_BEGIN_EXTERN_C
-#endif
+typedef void upb_msg;
-UPB_BEGIN_EXTERN_C
-/* C API. */
-bool upb_shim_set(upb_handlers *h, const upb_fielddef *f, size_t offset,
- int32_t hasbit);
-const upb_shim_data *upb_shim_getdata(const upb_handlers *h, upb_selector_t s,
- upb_fieldtype_t *type);
+/** upb_msglayout *************************************************************/
-UPB_END_EXTERN_C
+/* upb_msglayout represents the memory layout of a given upb_msgdef. You get
+ * instances of this from a upb_msgfactory, and the factory always owns the
+ * msglayout. */
-#ifdef __cplusplus
-/* C++ Wrappers. */
-namespace upb {
-inline bool Shim::Set(Handlers* h, const FieldDef* f, size_t ofs,
- int32_t hasbit) {
- return upb_shim_set(h, f, ofs, hasbit);
-}
-inline const Shim::Data* Shim::GetData(const Handlers* h, Handlers::Selector s,
- FieldDef::Type* type) {
- return upb_shim_getdata(h, s, type);
-}
-} /* namespace upb */
-#endif
+/* Gets the factory for this layout */
+upb_msgfactory *upb_msglayout_factory(const upb_msglayout *l);
-#endif /* UPB_SHIM_H */
-/*
-** upb::SymbolTable (upb_symtab)
-**
-** A symtab (symbol table) stores a name->def map of upb_defs. Clients could
-** always create such tables themselves, but upb_symtab has logic for resolving
-** symbolic references, and in particular, for keeping a whole set of consistent
-** defs when replacing some subset of those defs. This logic is nontrivial.
-**
-** This is a mixed C/C++ interface that offers a full API to both languages.
-** See the top-level README for more information.
-*/
+/* Get the msglayout for a submessage. This requires that this field is a
+ * submessage, ie. upb_fielddef_issubmsg(upb_msglayout_msgdef(l)) == true.
+ *
+ * Since map entry messages don't have layouts, if upb_fielddef_ismap(f) == true
+ * then this function will return the layout for the map's value. It requires
+ * that the value type of the map field is a submessage. */
+const upb_msglayout *upb_msglayout_sublayout(const upb_msglayout *l,
+ const upb_fielddef *f);
-#ifndef UPB_SYMTAB_H_
-#define UPB_SYMTAB_H_
+/* Returns the msgdef for this msglayout. */
+const upb_msgdef *upb_msglayout_msgdef(const upb_msglayout *l);
-#ifdef __cplusplus
-#include <vector>
-namespace upb { class SymbolTable; }
-#endif
+/** upb_visitor ***************************************************************/
-UPB_DECLARE_DERIVED_TYPE(upb::SymbolTable, upb::RefCounted,
- upb_symtab, upb_refcounted)
+/* upb_visitor will visit all the fields of a message and its submessages. It
+ * uses a upb_visitorplan which you can obtain from a upb_msgfactory. */
-typedef struct {
- UPB_PRIVATE_FOR_CPP
- upb_strtable_iter iter;
- upb_deftype_t type;
-} upb_symtab_iter;
+upb_visitor *upb_visitor_create(upb_env *e, const upb_visitorplan *vp,
+ upb_sink *output);
+bool upb_visitor_visitmsg(upb_visitor *v, const upb_msg *msg);
-#ifdef __cplusplus
-/* Non-const methods in upb::SymbolTable are NOT thread-safe. */
-class upb::SymbolTable {
- public:
- /* Returns a new symbol table with a single ref owned by "owner."
- * Returns NULL if memory allocation failed. */
- static reffed_ptr<SymbolTable> New();
+/** upb_msgfactory ************************************************************/
- /* Include RefCounted base methods. */
- UPB_REFCOUNTED_CPPMETHODS
+/* A upb_msgfactory contains a cache of upb_msglayout, upb_handlers, and
+ * upb_visitorplan objects. These are the objects necessary to represent,
+ * populate, and and visit upb_msg objects.
+ *
+ * These caches are all populated by upb_msgdef, and lazily created on demand.
+ */
- /* For all lookup functions, the returned pointer is not owned by the
- * caller; it may be invalidated by any non-const call or unref of the
- * SymbolTable! To protect against this, take a ref if desired. */
+/* Creates and destroys a msgfactory, respectively. The messages for this
+ * msgfactory must come from |symtab| (which should outlive the msgfactory). */
+upb_msgfactory *upb_msgfactory_new(const upb_symtab *symtab);
+void upb_msgfactory_free(upb_msgfactory *f);
- /* Freezes the symbol table: prevents further modification of it.
- * After the Freeze() operation is successful, the SymbolTable must only be
- * accessed via a const pointer.
- *
- * Unlike with upb::MessageDef/upb::EnumDef/etc, freezing a SymbolTable is not
- * a necessary step in using a SymbolTable. If you have no need for it to be
- * immutable, there is no need to freeze it ever. However sometimes it is
- * useful, and SymbolTables that are statically compiled into the binary are
- * always frozen by nature. */
- void Freeze();
+const upb_symtab *upb_msgfactory_symtab(const upb_msgfactory *f);
- /* Resolves the given symbol using the rules described in descriptor.proto,
- * namely:
- *
- * If the name starts with a '.', it is fully-qualified. Otherwise,
- * C++-like scoping rules are used to find the type (i.e. first the nested
- * types within this message are searched, then within the parent, on up
- * to the root namespace).
- *
- * If not found, returns NULL. */
- const Def* Resolve(const char* base, const char* sym) const;
+/* The functions to get cached objects, lazily creating them on demand. These
+ * all require:
+ *
+ * - m is in upb_msgfactory_symtab(f)
+ * - upb_msgdef_mapentry(m) == false (since map messages can't have layouts).
+ *
+ * The returned objects will live for as long as the msgfactory does.
+ *
+ * TODO(haberman): consider making this thread-safe and take a const
+ * upb_msgfactory. */
+const upb_msglayout *upb_msgfactory_getlayout(upb_msgfactory *f,
+ const upb_msgdef *m);
+const upb_handlers *upb_msgfactory_getmergehandlers(upb_msgfactory *f,
+ const upb_msgdef *m);
+const upb_visitorplan *upb_msgfactory_getvisitorplan(upb_msgfactory *f,
+ const upb_handlers *h);
- /* Finds an entry in the symbol table with this exact name. If not found,
- * returns NULL. */
- const Def* Lookup(const char *sym) const;
- const MessageDef* LookupMessage(const char *sym) const;
- const EnumDef* LookupEnum(const char *sym) const;
- /* TODO: introduce a C++ iterator, but make it nice and templated so that if
- * you ask for an iterator of MessageDef the iterated elements are strongly
- * typed as MessageDef*. */
+/** upb_msgval ****************************************************************/
- /* Adds the given mutable defs to the symtab, resolving all symbols
- * (including enum default values) and finalizing the defs. Only one def per
- * name may be in the list, but defs can replace existing defs in the symtab.
- * All defs must have a name -- anonymous defs are not allowed. Anonymous
- * defs can still be frozen by calling upb_def_freeze() directly.
- *
- * Any existing defs that can reach defs that are being replaced will
- * themselves be replaced also, so that the resulting set of defs is fully
- * consistent.
- *
- * This logic implemented in this method is a convenience; ultimately it
- * calls some combination of upb_fielddef_setsubdef(), upb_def_dup(), and
- * upb_freeze(), any of which the client could call themself. However, since
- * the logic for doing so is nontrivial, we provide it here.
- *
- * The entire operation either succeeds or fails. If the operation fails,
- * the symtab is unchanged, false is returned, and status indicates the
- * error. The caller passes a ref on all defs to the symtab (even if the
- * operation fails).
- *
- * TODO(haberman): currently failure will leave the symtab unchanged, but may
- * leave the defs themselves partially resolved. Does this matter? If so we
- * could do a prepass that ensures that all symbols are resolvable and bail
- * if not, so we don't mutate anything until we know the operation will
- * succeed.
- *
- * TODO(haberman): since the defs must be mutable, refining a frozen def
- * requires making mutable copies of the entire tree. This is wasteful if
- * only a few messages are changing. We may want to add a way of adding a
- * tree of frozen defs to the symtab (perhaps an alternate constructor where
- * you pass the root of the tree?) */
- bool Add(Def*const* defs, size_t n, void* ref_donor, Status* status);
+/* A union representing all possible protobuf values. Used for generic get/set
+ * operations. */
- bool Add(const std::vector<Def*>& defs, void *owner, Status* status) {
- return Add((Def*const*)&defs[0], defs.size(), owner, status);
+typedef union {
+ bool b;
+ float flt;
+ double dbl;
+ int32_t i32;
+ int64_t i64;
+ uint32_t u32;
+ uint64_t u64;
+ const upb_map* map;
+ const upb_msg* msg;
+ const upb_array* arr;
+ const void* ptr;
+ struct {
+ const char *ptr;
+ size_t len;
+ } str;
+} upb_msgval;
+
+#define ACCESSORS(name, membername, ctype) \
+ UPB_INLINE ctype upb_msgval_get ## name(upb_msgval v) { \
+ return v.membername; \
+ } \
+ UPB_INLINE void upb_msgval_set ## name(upb_msgval *v, ctype cval) { \
+ v->membername = cval; \
+ } \
+ UPB_INLINE upb_msgval upb_msgval_ ## name(ctype v) { \
+ upb_msgval ret; \
+ ret.membername = v; \
+ return ret; \
}
- /* Resolves all subdefs for messages in this file and attempts to freeze the
- * file. If this succeeds, adds all the symbols to this SymbolTable
- * (replacing any existing ones with the same names). */
- bool AddFile(FileDef* file, Status* s);
+ACCESSORS(bool, b, bool)
+ACCESSORS(float, flt, float)
+ACCESSORS(double, dbl, double)
+ACCESSORS(int32, i32, int32_t)
+ACCESSORS(int64, i64, int64_t)
+ACCESSORS(uint32, u32, uint32_t)
+ACCESSORS(uint64, u64, uint64_t)
+ACCESSORS(map, map, const upb_map*)
+ACCESSORS(msg, msg, const upb_msg*)
+ACCESSORS(ptr, ptr, const void*)
+ACCESSORS(arr, arr, const upb_array*)
+
+#undef ACCESSORS
+
+UPB_INLINE upb_msgval upb_msgval_str(const char *ptr, size_t len) {
+ upb_msgval ret;
+ ret.str.ptr = ptr;
+ ret.str.len = len;
+ return ret;
+}
- private:
- UPB_DISALLOW_POD_OPS(SymbolTable, upb::SymbolTable)
-};
+UPB_INLINE const char* upb_msgval_getstr(upb_msgval val) {
+ return val.str.ptr;
+}
-#endif /* __cplusplus */
+UPB_INLINE size_t upb_msgval_getstrlen(upb_msgval val) {
+ return val.str.len;
+}
-UPB_BEGIN_EXTERN_C
-/* Native C API. */
+/** upb_msg *******************************************************************/
-/* Include refcounted methods like upb_symtab_ref(). */
-UPB_REFCOUNTED_CMETHODS(upb_symtab, upb_symtab_upcast)
+/* A upb_msg represents a protobuf message. It always corresponds to a specific
+ * upb_msglayout, which describes how it is laid out in memory.
+ *
+ * The message will have a fixed size, as returned by upb_msg_sizeof(), which
+ * will be used to store fixed-length fields. The upb_msg may also allocate
+ * dynamic memory internally to store data such as:
+ *
+ * - extensions
+ * - unknown fields
+ */
-upb_symtab *upb_symtab_new(const void *owner);
-void upb_symtab_freeze(upb_symtab *s);
-const upb_def *upb_symtab_resolve(const upb_symtab *s, const char *base,
- const char *sym);
-const upb_def *upb_symtab_lookup(const upb_symtab *s, const char *sym);
-const upb_msgdef *upb_symtab_lookupmsg(const upb_symtab *s, const char *sym);
-const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym);
-bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
- void *ref_donor, upb_status *status);
-bool upb_symtab_addfile(upb_symtab *s, upb_filedef *file, upb_status* status);
+/* Returns the size of a message given this layout. */
+size_t upb_msg_sizeof(const upb_msglayout *l);
-/* upb_symtab_iter i;
- * for(upb_symtab_begin(&i, s, type); !upb_symtab_done(&i);
- * upb_symtab_next(&i)) {
- * const upb_def *def = upb_symtab_iter_def(&i);
- * // ...
- * }
+/* upb_msg_init() / upb_msg_uninit() allow the user to use a pre-allocated
+ * block of memory as a message. The block's size should be upb_msg_sizeof().
+ * upb_msg_uninit() must be called to release internally-allocated memory
+ * unless the allocator is an arena that does not require freeing.
*
- * For C we don't have separate iterators for const and non-const.
- * It is the caller's responsibility to cast the upb_fielddef* to
- * const if the upb_msgdef* is const. */
-void upb_symtab_begin(upb_symtab_iter *iter, const upb_symtab *s,
- upb_deftype_t type);
-void upb_symtab_next(upb_symtab_iter *iter);
-bool upb_symtab_done(const upb_symtab_iter *iter);
-const upb_def *upb_symtab_iter_def(const upb_symtab_iter *iter);
+ * Please note that upb_msg_uninit() does *not* free any submessages, maps,
+ * or arrays referred to by this message's fields. You must free them manually
+ * yourself. */
+void upb_msg_init(upb_msg *msg, const upb_msglayout *l, upb_alloc *a);
+void upb_msg_uninit(upb_msg *msg, const upb_msglayout *l);
+
+/* Like upb_msg_init() / upb_msg_uninit(), except the message's memory is
+ * allocated / freed from the given upb_alloc. */
+upb_msg *upb_msg_new(const upb_msglayout *l, upb_alloc *a);
+void upb_msg_free(upb_msg *msg, const upb_msglayout *l);
+
+/* Returns the upb_alloc for the given message. */
+upb_alloc *upb_msg_alloc(const upb_msg *msg, const upb_msglayout *l);
+
+/* Packs the tree of messages rooted at "msg" into a single hunk of memory,
+ * allocated from the given allocator. */
+void *upb_msg_pack(const upb_msg *msg, const upb_msglayout *l,
+ void *p, size_t *ofs, size_t size);
+
+/* Read-only message API. Can be safely called by anyone. */
+
+/* Returns the value associated with this field:
+ * - for scalar fields (including strings), the value directly.
+ * - return upb_msg*, or upb_map* for msg/map.
+ * If the field is unset for these field types, returns NULL.
+ *
+ * TODO(haberman): should we let users store cached array/map/msg
+ * pointers here for fields that are unset? Could be useful for the
+ * strongly-owned submessage model (ie. generated C API that doesn't use
+ * arenas).
+ */
+upb_msgval upb_msg_get(const upb_msg *msg,
+ const upb_fielddef *f,
+ const upb_msglayout *l);
-UPB_END_EXTERN_C
+/* May only be called for fields where upb_fielddef_haspresence(f) == true. */
+bool upb_msg_has(const upb_msg *msg,
+ const upb_fielddef *f,
+ const upb_msglayout *l);
-#ifdef __cplusplus
-/* C++ inline wrappers. */
-namespace upb {
-inline reffed_ptr<SymbolTable> SymbolTable::New() {
- upb_symtab *s = upb_symtab_new(&s);
- return reffed_ptr<SymbolTable>(s, &s);
-}
+/* Returns NULL if no field in the oneof is set. */
+const upb_fielddef *upb_msg_getoneofcase(const upb_msg *msg,
+ const upb_oneofdef *o,
+ const upb_msglayout *l);
-inline void SymbolTable::Freeze() {
- return upb_symtab_freeze(this);
-}
-inline const Def *SymbolTable::Resolve(const char *base,
- const char *sym) const {
- return upb_symtab_resolve(this, base, sym);
-}
-inline const Def* SymbolTable::Lookup(const char *sym) const {
- return upb_symtab_lookup(this, sym);
-}
-inline const MessageDef *SymbolTable::LookupMessage(const char *sym) const {
- return upb_symtab_lookupmsg(this, sym);
-}
-inline bool SymbolTable::Add(
- Def*const* defs, size_t n, void* ref_donor, Status* status) {
- return upb_symtab_add(this, (upb_def*const*)defs, n, ref_donor, status);
-}
-inline bool SymbolTable::AddFile(FileDef* file, Status* s) {
- return upb_symtab_addfile(this, file, s);
-}
-} /* namespace upb */
-#endif
+/* Returns true if any field in the oneof is set. */
+bool upb_msg_hasoneof(const upb_msg *msg,
+ const upb_oneofdef *o,
+ const upb_msglayout *l);
+
+
+/* Mutable message API. May only be called by the owner of the message who
+ * knows its ownership scheme and how to keep it consistent. */
+
+/* Sets the given field to the given value. Does not perform any memory
+ * management: if you overwrite a pointer to a msg/array/map/string without
+ * cleaning it up (or using an arena) it will leak.
+ */
+bool upb_msg_set(upb_msg *msg,
+ const upb_fielddef *f,
+ upb_msgval val,
+ const upb_msglayout *l);
+
+/* For a primitive field, set it back to its default. For repeated, string, and
+ * submessage fields set it back to NULL. This could involve releasing some
+ * internal memory (for example, from an extension dictionary), but it is not
+ * recursive in any way and will not recover any memory that may be used by
+ * arrays/maps/strings/msgs that this field may have pointed to.
+ */
+bool upb_msg_clearfield(upb_msg *msg,
+ const upb_fielddef *f,
+ const upb_msglayout *l);
+
+/* Clears all fields in the oneof such that none of them are set. */
+bool upb_msg_clearoneof(upb_msg *msg,
+ const upb_oneofdef *o,
+ const upb_msglayout *l);
+
+/* TODO(haberman): copyfrom()/mergefrom()? */
+
+
+/** upb_array *****************************************************************/
+
+/* A upb_array stores data for a repeated field. The memory management
+ * semantics are the same as upb_msg. A upb_array allocates dynamic
+ * memory internally for the array elements. */
+
+size_t upb_array_sizeof(upb_fieldtype_t type);
+void upb_array_init(upb_array *arr, upb_fieldtype_t type, upb_alloc *a);
+void upb_array_uninit(upb_array *arr);
+upb_array *upb_array_new(upb_fieldtype_t type, upb_alloc *a);
+void upb_array_free(upb_array *arr);
+
+/* Read-only interface. Safe for anyone to call. */
+
+size_t upb_array_size(const upb_array *arr);
+upb_fieldtype_t upb_array_type(const upb_array *arr);
+upb_msgval upb_array_get(const upb_array *arr, size_t i);
+
+/* Write interface. May only be called by the message's owner who can enforce
+ * its memory management invariants. */
+
+bool upb_array_set(upb_array *arr, size_t i, upb_msgval val);
+
+
+/** upb_map *******************************************************************/
+
+/* A upb_map stores data for a map field. The memory management semantics are
+ * the same as upb_msg, with one notable exception. upb_map will internally
+ * store a copy of all string keys, but *not* any string values or submessages.
+ * So you must ensure that any string or message values outlive the map, and you
+ * must delete them manually when they are no longer required. */
+
+size_t upb_map_sizeof(upb_fieldtype_t ktype, upb_fieldtype_t vtype);
+bool upb_map_init(upb_map *map, upb_fieldtype_t ktype, upb_fieldtype_t vtype,
+ upb_alloc *a);
+void upb_map_uninit(upb_map *map);
+upb_map *upb_map_new(upb_fieldtype_t ktype, upb_fieldtype_t vtype, upb_alloc *a);
+void upb_map_free(upb_map *map);
+
+/* Read-only interface. Safe for anyone to call. */
+
+size_t upb_map_size(const upb_map *map);
+upb_fieldtype_t upb_map_keytype(const upb_map *map);
+upb_fieldtype_t upb_map_valuetype(const upb_map *map);
+bool upb_map_get(const upb_map *map, upb_msgval key, upb_msgval *val);
+
+/* Write interface. May only be called by the message's owner who can enforce
+ * its memory management invariants. */
+
+/* Sets or overwrites an entry in the map. Return value indicates whether
+ * the operation succeeded or failed with OOM, and also whether an existing
+ * key was replaced or not. */
+bool upb_map_set(upb_map *map,
+ upb_msgval key, upb_msgval val,
+ upb_msgval *valremoved);
+
+/* Deletes an entry in the map. Returns true if the key was present. */
+bool upb_map_del(upb_map *map, upb_msgval key);
+
+
+/** upb_mapiter ***************************************************************/
+
+/* For iterating over a map. Map iterators are invalidated by mutations to the
+ * map, but an invalidated iterator will never return junk or crash the process.
+ * An invalidated iterator may return entries that were already returned though,
+ * and if you keep invalidating the iterator during iteration, the program may
+ * enter an infinite loop. */
+
+size_t upb_mapiter_sizeof();
+
+void upb_mapiter_begin(upb_mapiter *i, const upb_map *t);
+upb_mapiter *upb_mapiter_new(const upb_map *t, upb_alloc *a);
+void upb_mapiter_free(upb_mapiter *i, upb_alloc *a);
+void upb_mapiter_next(upb_mapiter *i);
+bool upb_mapiter_done(const upb_mapiter *i);
+
+upb_msgval upb_mapiter_key(const upb_mapiter *i);
+upb_msgval upb_mapiter_value(const upb_mapiter *i);
+void upb_mapiter_setdone(upb_mapiter *i);
+bool upb_mapiter_isequal(const upb_mapiter *i1, const upb_mapiter *i2);
+
+
+/** Handlers ******************************************************************/
+
+/* These are the handlers used internally by upb_msgfactory_getmergehandlers().
+ * They write scalar data to a known offset from the message pointer.
+ *
+ * These would be trivial for anyone to implement themselves, but it's better
+ * to use these because some JITs will recognize and specialize these instead
+ * of actually calling the function. */
+
+/* Sets a handler for the given primitive field that will write the data at the
+ * given offset. If hasbit > 0, also sets a hasbit at the given bit offset
+ * (addressing each byte low to high). */
+bool upb_msg_setscalarhandler(upb_handlers *h,
+ const upb_fielddef *f,
+ size_t offset,
+ int32_t hasbit);
+
+/* If the given handler is a msghandlers_primitive field, returns true and sets
+ * *type, *offset and *hasbit. Otherwise returns false. */
+bool upb_msg_getscalarhandlerdata(const upb_handlers *h,
+ upb_selector_t s,
+ upb_fieldtype_t *type,
+ size_t *offset,
+ int32_t *hasbit);
+
+UPB_END_EXTERN_C
-#endif /* UPB_SYMTAB_H_ */
+#endif /* UPB_MSG_H_ */
/*
** upb::descriptor::Reader (upb_descreader)
**
@@ -6853,111 +7137,111 @@ UPB_INLINE bool upbdefs_google_protobuf_FileOptions_OptimizeMode_is(const upb_en
/* Functions to get a fielddef from a msgdef reference. */
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_f_end(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_f_start(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_f_end(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_f_start(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_enum_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_extension(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_extension_range(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_field(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_nested_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_oneof_decl(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 8); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 7); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_reserved_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 10); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_reserved_range(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 9); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_allow_alias(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 999); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_number(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueOptions_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueOptions_is(m)); return upb_msgdef_itof(m, 999); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_default_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 7); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_extendee(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_json_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 10); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_label(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_number(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_oneof_index(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 9); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 8); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_type_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_ctype(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_jstype(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 6); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_lazy(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 5); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_packed(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 999); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_weak(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 10); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_dependency(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_enum_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_extension(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 7); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_message_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 8); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_package(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_public_dependency(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 10); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_service(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_source_code_info(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 9); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_syntax(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 12); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_weak_dependency(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 11); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorSet_f_file(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorSet_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_cc_enable_arenas(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 31); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_cc_generic_services(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 16); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_csharp_namespace(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 37); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 23); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_go_package(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 11); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_generate_equals_and_hash(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 20); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_generic_services(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 17); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_multiple_files(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 10); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_outer_classname(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 8); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_package(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_string_check_utf8(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 27); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_javanano_use_deprecated_package(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 38); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_objc_class_prefix(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 36); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_optimize_for(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 9); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_py_generic_services(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 18); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 999); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_map_entry(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 7); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_message_set_wire_format(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_no_standard_descriptor_accessor(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 999); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_client_streaming(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_input_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_output_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_server_streaming(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodOptions_is(m)); return upb_msgdef_itof(m, 33); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodOptions_is(m)); return upb_msgdef_itof(m, 999); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_OneofDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_OneofDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_method(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceOptions_is(m)); return upb_msgdef_itof(m, 33); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceOptions_is(m)); return upb_msgdef_itof(m, 999); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_leading_comments(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_leading_detached_comments(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 6); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_path(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_span(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_trailing_comments(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 4); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_f_location(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NamePart_f_is_extension(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NamePart_f_name_part(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m)); return upb_msgdef_itof(m, 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_aggregate_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 8); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_double_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 6); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_identifier_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_negative_int_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 5); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_positive_int_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 4); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_string_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 7); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_f_end(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_f_start(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_f_end(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_f_start(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_enum_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_extension(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_extension_range(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_field(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_nested_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_oneof_decl(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 8); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 7); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_reserved_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 10); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_reserved_range(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 9); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_allow_alias(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 999); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_number(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueOptions_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueOptions_is(m)); return upb_msgdef_itof(m, 999); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_default_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 7); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_extendee(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_json_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 10); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_label(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_number(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_oneof_index(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 9); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 8); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_type_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_ctype(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_jstype(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 6); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_lazy(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 5); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_packed(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 999); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_weak(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 10); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_dependency(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_enum_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_extension(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 7); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_message_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 8); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_package(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_public_dependency(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 10); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_service(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_source_code_info(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 9); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_syntax(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 12); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_weak_dependency(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 11); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorSet_f_file(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorSet_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_cc_enable_arenas(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 31); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_cc_generic_services(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 16); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_csharp_namespace(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 37); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 23); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_go_package(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 11); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_generate_equals_and_hash(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 20); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_generic_services(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 17); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_multiple_files(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 10); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_outer_classname(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 8); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_package(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_string_check_utf8(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 27); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_javanano_use_deprecated_package(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 38); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_objc_class_prefix(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 36); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_optimize_for(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 9); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_py_generic_services(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 18); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 999); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_map_entry(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 7); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_message_set_wire_format(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_no_standard_descriptor_accessor(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 999); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_client_streaming(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_input_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_output_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_server_streaming(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodOptions_is(m)); return upb_msgdef_itof(m, 33); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodOptions_is(m)); return upb_msgdef_itof(m, 999); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_OneofDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_OneofDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_method(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceOptions_is(m)); return upb_msgdef_itof(m, 33); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceOptions_is(m)); return upb_msgdef_itof(m, 999); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_leading_comments(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_leading_detached_comments(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 6); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_path(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_span(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_trailing_comments(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 4); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_f_location(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NamePart_f_is_extension(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NamePart_f_name_part(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_aggregate_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 8); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_double_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 6); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_identifier_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_negative_int_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 5); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_positive_int_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 4); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_string_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 7); }
UPB_END_EXTERN_C
@@ -6971,7 +7255,7 @@ class DescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public:
DescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) {
- assert(upbdefs_google_protobuf_DescriptorProto_is(m));
+ UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m));
}
static DescriptorProto get() {
@@ -6983,7 +7267,7 @@ class DescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public:
ExtensionRange(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) {
- assert(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m));
+ UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m));
}
static ExtensionRange get() {
@@ -6996,7 +7280,7 @@ class DescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public:
ReservedRange(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) {
- assert(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m));
+ UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m));
}
static ReservedRange get() {
@@ -7010,7 +7294,7 @@ class EnumDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public:
EnumDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) {
- assert(upbdefs_google_protobuf_EnumDescriptorProto_is(m));
+ UPB_ASSERT(upbdefs_google_protobuf_EnumDescriptorProto_is(m));
}
static EnumDescriptorProto get() {
@@ -7023,7 +7307,7 @@ class EnumOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public:
EnumOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) {
- assert(upbdefs_google_protobuf_EnumOptions_is(m));
+ UPB_ASSERT(upbdefs_google_protobuf_EnumOptions_is(m));
}
static EnumOptions get() {
@@ -7036,7 +7320,7 @@ class EnumValueDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDe
public:
EnumValueDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) {
- assert(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m));
+ UPB_ASSERT(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m));
}
static EnumValueDescriptorProto get() {
@@ -7049,7 +7333,7 @@ class EnumValueOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public:
EnumValueOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) {
- assert(upbdefs_google_protobuf_EnumValueOptions_is(m));
+ UPB_ASSERT(upbdefs_google_protobuf_EnumValueOptions_is(m));
}
static EnumValueOptions get() {
@@ -7062,7 +7346,7 @@ class FieldDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public:
FieldDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) {
- assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m));
+ UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m));
}
static FieldDescriptorProto get() {
@@ -7074,7 +7358,7 @@ class FieldDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public:
Label(const ::upb::EnumDef* e, const void *ref_donor = NULL)
: reffed_ptr(e, ref_donor) {
- assert(upbdefs_google_protobuf_FieldDescriptorProto_Label_is(e));
+ UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_Label_is(e));
}
static Label get() {
const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldDescriptorProto_Label_get(&e);
@@ -7086,7 +7370,7 @@ class FieldDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public:
Type(const ::upb::EnumDef* e, const void *ref_donor = NULL)
: reffed_ptr(e, ref_donor) {
- assert(upbdefs_google_protobuf_FieldDescriptorProto_Type_is(e));
+ UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_Type_is(e));
}
static Type get() {
const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldDescriptorProto_Type_get(&e);
@@ -7099,7 +7383,7 @@ class FieldOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public:
FieldOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) {
- assert(upbdefs_google_protobuf_FieldOptions_is(m));
+ UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m));
}
static FieldOptions get() {
@@ -7111,7 +7395,7 @@ class FieldOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public:
CType(const ::upb::EnumDef* e, const void *ref_donor = NULL)
: reffed_ptr(e, ref_donor) {
- assert(upbdefs_google_protobuf_FieldOptions_CType_is(e));
+ UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_CType_is(e));
}
static CType get() {
const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldOptions_CType_get(&e);
@@ -7123,7 +7407,7 @@ class FieldOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public:
JSType(const ::upb::EnumDef* e, const void *ref_donor = NULL)
: reffed_ptr(e, ref_donor) {
- assert(upbdefs_google_protobuf_FieldOptions_JSType_is(e));
+ UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_JSType_is(e));
}
static JSType get() {
const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldOptions_JSType_get(&e);
@@ -7136,7 +7420,7 @@ class FileDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public:
FileDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) {
- assert(upbdefs_google_protobuf_FileDescriptorProto_is(m));
+ UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m));
}
static FileDescriptorProto get() {
@@ -7149,7 +7433,7 @@ class FileDescriptorSet : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public:
FileDescriptorSet(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) {
- assert(upbdefs_google_protobuf_FileDescriptorSet_is(m));
+ UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorSet_is(m));
}
static FileDescriptorSet get() {
@@ -7162,7 +7446,7 @@ class FileOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public:
FileOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) {
- assert(upbdefs_google_protobuf_FileOptions_is(m));
+ UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m));
}
static FileOptions get() {
@@ -7174,7 +7458,7 @@ class FileOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public:
OptimizeMode(const ::upb::EnumDef* e, const void *ref_donor = NULL)
: reffed_ptr(e, ref_donor) {
- assert(upbdefs_google_protobuf_FileOptions_OptimizeMode_is(e));
+ UPB_ASSERT(upbdefs_google_protobuf_FileOptions_OptimizeMode_is(e));
}
static OptimizeMode get() {
const ::upb::EnumDef* e = upbdefs_google_protobuf_FileOptions_OptimizeMode_get(&e);
@@ -7187,7 +7471,7 @@ class MessageOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public:
MessageOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) {
- assert(upbdefs_google_protobuf_MessageOptions_is(m));
+ UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m));
}
static MessageOptions get() {
@@ -7200,7 +7484,7 @@ class MethodDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef>
public:
MethodDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) {
- assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m));
+ UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m));
}
static MethodDescriptorProto get() {
@@ -7213,7 +7497,7 @@ class MethodOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public:
MethodOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) {
- assert(upbdefs_google_protobuf_MethodOptions_is(m));
+ UPB_ASSERT(upbdefs_google_protobuf_MethodOptions_is(m));
}
static MethodOptions get() {
@@ -7226,7 +7510,7 @@ class OneofDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public:
OneofDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) {
- assert(upbdefs_google_protobuf_OneofDescriptorProto_is(m));
+ UPB_ASSERT(upbdefs_google_protobuf_OneofDescriptorProto_is(m));
}
static OneofDescriptorProto get() {
@@ -7239,7 +7523,7 @@ class ServiceDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef>
public:
ServiceDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) {
- assert(upbdefs_google_protobuf_ServiceDescriptorProto_is(m));
+ UPB_ASSERT(upbdefs_google_protobuf_ServiceDescriptorProto_is(m));
}
static ServiceDescriptorProto get() {
@@ -7252,7 +7536,7 @@ class ServiceOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public:
ServiceOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) {
- assert(upbdefs_google_protobuf_ServiceOptions_is(m));
+ UPB_ASSERT(upbdefs_google_protobuf_ServiceOptions_is(m));
}
static ServiceOptions get() {
@@ -7265,7 +7549,7 @@ class SourceCodeInfo : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public:
SourceCodeInfo(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) {
- assert(upbdefs_google_protobuf_SourceCodeInfo_is(m));
+ UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_is(m));
}
static SourceCodeInfo get() {
@@ -7277,7 +7561,7 @@ class SourceCodeInfo : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public:
Location(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) {
- assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m));
+ UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m));
}
static Location get() {
@@ -7291,7 +7575,7 @@ class UninterpretedOption : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public:
UninterpretedOption(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) {
- assert(upbdefs_google_protobuf_UninterpretedOption_is(m));
+ UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m));
}
static UninterpretedOption get() {
@@ -7303,7 +7587,7 @@ class UninterpretedOption : public ::upb::reffed_ptr<const ::upb::MessageDef> {
public:
NamePart(const ::upb::MessageDef* m, const void *ref_donor = NULL)
: reffed_ptr(m, ref_donor) {
- assert(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m));
+ UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m));
}
static NamePart get() {
@@ -8112,9 +8396,9 @@ UPB_INLINE uint64_t upb_vencode32(uint32_t val) {
char buf[UPB_PB_VARINT_MAX_LEN];
size_t bytes = upb_vencode64(val, buf);
uint64_t ret = 0;
- assert(bytes <= 5);
+ UPB_ASSERT(bytes <= 5);
memcpy(&ret, buf, bytes);
- assert(ret <= 0xffffffffffU);
+ UPB_ASSERT(ret <= 0xffffffffffU);
return ret;
}
diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec
index 19be14e5..97bf9970 100644
--- a/ruby/google-protobuf.gemspec
+++ b/ruby/google-protobuf.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "google-protobuf"
- s.version = "3.1.0"
+ s.version = "3.2.0"
s.licenses = ["BSD"]
s.summary = "Protocol Buffers"
s.description = "Protocol Buffers are Google's data interchange format."
diff --git a/ruby/lib/google/protobuf/repeated_field.rb b/ruby/lib/google/protobuf/repeated_field.rb
index 831e0320..11d6c2eb 100644
--- a/ruby/lib/google/protobuf/repeated_field.rb
+++ b/ruby/lib/google/protobuf/repeated_field.rb
@@ -74,7 +74,7 @@ module Google
:include?, :index, :inspect, :join,
:pack, :permutation, :product, :pretty_print, :pretty_print_cycle,
:rassoc, :repeated_combination, :repeated_permutation, :reverse,
- :rindex, :rotate, :sample, :shuffle, :shelljoin, :slice,
+ :rindex, :rotate, :sample, :shuffle, :shelljoin,
:to_s, :transpose, :uniq, :|
diff --git a/ruby/tests/basic.rb b/ruby/tests/basic.rb
index 989a047e..ca81e3a5 100644
--- a/ruby/tests/basic.rb
+++ b/ruby/tests/basic.rb
@@ -667,6 +667,13 @@ module BasicTest
end
end
+ def test_map_corruption
+ # This pattern led to a crash in a previous version of upb/protobuf.
+ m = MapMessage.new(map_string_int32: { "aaa" => 1 })
+ m.map_string_int32['podid'] = 2
+ m.map_string_int32['aaa'] = 3
+ end
+
def test_map_encode_decode
m = MapMessage.new(
:map_string_int32 => {"a" => 1, "b" => 2},
@@ -1181,5 +1188,17 @@ module BasicTest
m2 = MapMessage.decode_json(MapMessage.encode_json(m))
assert m == m2
end
+
+ def test_comparison_with_arbitrary_object
+ assert MapMessage.new != nil
+ end
+
+ def test_respond_to
+ # This test fails with JRuby 1.7.23, likely because of an old JRuby bug.
+ return if RUBY_PLATFORM == "java"
+ msg = MapMessage.new
+ assert msg.respond_to?(:map_string_int32)
+ assert !msg.respond_to?(:bacon)
+ end
end
end
diff --git a/src/Makefile.am b/src/Makefile.am
index 8d9e07ab..ab9eb31b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -56,7 +56,9 @@ clean-local:
CLEANFILES = $(protoc_outputs) unittest_proto_middleman \
testzip.jar testzip.list testzip.proto testzip.zip \
- no_warning_test.cc
+ no_warning_test.cc \
+ google/protobuf/compiler/js/well_known_types_embed.cc \
+ js_embed$(EXEEXT)
MAINTAINERCLEANFILES = \
Makefile.in
@@ -72,7 +74,6 @@ nobase_include_HEADERS = \
google/protobuf/stubs/atomicops_internals_atomicword_compat.h \
google/protobuf/stubs/atomicops_internals_generic_c11_atomic.h \
google/protobuf/stubs/atomicops_internals_generic_gcc.h \
- google/protobuf/stubs/atomicops_internals_macosx.h \
google/protobuf/stubs/atomicops_internals_mips_gcc.h \
google/protobuf/stubs/atomicops_internals_solaris.h \
google/protobuf/stubs/atomicops_internals_tsan.h \
@@ -161,6 +162,7 @@ nobase_include_HEADERS = \
google/protobuf/compiler/java/java_names.h \
google/protobuf/compiler/javanano/javanano_generator.h \
google/protobuf/compiler/js/js_generator.h \
+ google/protobuf/compiler/js/well_known_types_embed.h \
google/protobuf/compiler/objectivec/objectivec_generator.h \
google/protobuf/compiler/objectivec/objectivec_helpers.h \
google/protobuf/compiler/php/php_generator.h \
@@ -177,7 +179,7 @@ nobase_include_HEADERS = \
lib_LTLIBRARIES = libprotobuf-lite.la libprotobuf.la libprotoc.la
libprotobuf_lite_la_LIBADD = $(PTHREAD_LIBS)
-libprotobuf_lite_la_LDFLAGS = -version-info 11:0:0 -export-dynamic -no-undefined
+libprotobuf_lite_la_LDFLAGS = -version-info 12:0:0 -export-dynamic -no-undefined
libprotobuf_lite_la_SOURCES = \
google/protobuf/stubs/atomicops_internals_x86_gcc.cc \
google/protobuf/stubs/atomicops_internals_x86_msvc.cc \
@@ -218,7 +220,7 @@ libprotobuf_lite_la_SOURCES = \
google/protobuf/io/zero_copy_stream_impl_lite.cc
libprotobuf_la_LIBADD = $(PTHREAD_LIBS)
-libprotobuf_la_LDFLAGS = -version-info 11:0:0 -export-dynamic -no-undefined
+libprotobuf_la_LDFLAGS = -version-info 12:0:0 -export-dynamic -no-undefined
libprotobuf_la_SOURCES = \
$(libprotobuf_lite_la_SOURCES) \
google/protobuf/any.pb.cc \
@@ -302,7 +304,7 @@ libprotobuf_la_SOURCES = \
nodist_libprotobuf_la_SOURCES = $(nodist_libprotobuf_lite_la_SOURCES)
libprotoc_la_LIBADD = $(PTHREAD_LIBS) libprotobuf.la
-libprotoc_la_LDFLAGS = -version-info 11:0:0 -export-dynamic -no-undefined
+libprotoc_la_LDFLAGS = -version-info 12:0:0 -export-dynamic -no-undefined
libprotoc_la_SOURCES = \
google/protobuf/compiler/code_generator.cc \
google/protobuf/compiler/command_line_interface.cc \
@@ -399,6 +401,7 @@ libprotoc_la_SOURCES = \
google/protobuf/compiler/java/java_doc_comment.cc \
google/protobuf/compiler/java/java_doc_comment.h \
google/protobuf/compiler/js/js_generator.cc \
+ google/protobuf/compiler/js/well_known_types_embed.cc \
google/protobuf/compiler/javanano/javanano_enum.cc \
google/protobuf/compiler/javanano/javanano_enum.h \
google/protobuf/compiler/javanano/javanano_enum_field.cc \
@@ -485,6 +488,21 @@ bin_PROGRAMS = protoc
protoc_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la
protoc_SOURCES = google/protobuf/compiler/main.cc
+# The special JS code for the well-known types is linked into the compiler via
+# well_known_types_embed.cc, which is generated from .js source files. We have
+# to build the js_embed binary using $(CXX_FOR_BUILD) so that it is executable
+# on the build machine in a cross-compilation setup.
+js_embed$(EXEEXT): $(srcdir)/google/protobuf/compiler/js/embed.cc
+ $(CXX_FOR_BUILD) -o $@ $<
+js_well_known_types_sources = \
+ google/protobuf/compiler/js/well_known_types/any.js \
+ google/protobuf/compiler/js/well_known_types/struct.js \
+ google/protobuf/compiler/js/well_known_types/timestamp.js
+# We have to cd to $(srcdir) so that out-of-tree builds work properly.
+google/protobuf/compiler/js/well_known_types_embed.cc: js_embed$(EXEEXT) $(js_well_known_types_sources)
+ oldpwd=`pwd` && cd $(srcdir) && \
+ $$oldpwd/js_embed$(EXEEXT) $(js_well_known_types_sources) > $$oldpwd/$@
+
# Tests ==============================================================
protoc_inputs = \
@@ -537,6 +555,7 @@ protoc_inputs = \
EXTRA_DIST = \
$(protoc_inputs) \
+ $(js_well_known_types_sources) \
solaris/libstdc++.la \
google/protobuf/io/gzip_stream.h \
google/protobuf/io/gzip_stream_unittest.sh \
@@ -556,6 +575,7 @@ EXTRA_DIST = \
google/protobuf/package_info.h \
google/protobuf/io/package_info.h \
google/protobuf/util/package_info.h \
+ google/protobuf/compiler/js/embed.cc \
google/protobuf/compiler/ruby/ruby_generated_code.proto \
google/protobuf/compiler/ruby/ruby_generated_code_pb.rb \
google/protobuf/compiler/package_info.h \
@@ -659,7 +679,7 @@ protoc_outputs = \
google/protobuf/util/message_differencer_unittest.pb.cc \
google/protobuf/util/message_differencer_unittest.pb.h
-BUILT_SOURCES = $(protoc_outputs)
+BUILT_SOURCES = $(protoc_outputs) google/protobuf/compiler/js/well_known_types_embed.cc
if USE_EXTERNAL_PROTOC
diff --git a/src/google/protobuf/any.cc b/src/google/protobuf/any.cc
index f7b1d310..83edba57 100644
--- a/src/google/protobuf/any.cc
+++ b/src/google/protobuf/any.cc
@@ -30,6 +30,8 @@
#include <google/protobuf/any.h>
+#include <google/protobuf/generated_message_util.h>
+
namespace google {
namespace protobuf {
namespace internal {
@@ -70,13 +72,11 @@ bool AnyMetadata::UnpackTo(Message* message) const {
if (!InternalIs(message->GetDescriptor())) {
return false;
}
- return message->ParseFromString(
- value_->GetNoArena(&::google::protobuf::internal::GetEmptyString()));
+ return message->ParseFromString(value_->GetNoArena());
}
bool AnyMetadata::InternalIs(const Descriptor* descriptor) const {
- const string type_url = type_url_->GetNoArena(
- &::google::protobuf::internal::GetEmptyString());
+ const string type_url = type_url_->GetNoArena();
string full_name;
if (!ParseAnyTypeUrl(type_url, &full_name)) {
return false;
diff --git a/src/google/protobuf/any.pb.cc b/src/google/protobuf/any.pb.cc
index 0df8d168..407dc0ad 100644
--- a/src/google/protobuf/any.pb.cc
+++ b/src/google/protobuf/any.pb.cc
@@ -19,111 +19,103 @@
namespace google {
namespace protobuf {
+class AnyDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Any> {
+} _Any_default_instance_;
+
+namespace protobuf_google_2fprotobuf_2fany_2eproto {
+
namespace {
-const ::google::protobuf::Descriptor* Any_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- Any_reflection_ = NULL;
+::google::protobuf::Metadata file_level_metadata[1];
} // namespace
+const ::google::protobuf::uint32 TableStruct::offsets[] = {
+ ~0u, // no _has_bits_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, type_url_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, value_),
+};
-void protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto() GOOGLE_ATTRIBUTE_COLD;
-void protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto() {
- protobuf_AddDesc_google_2fprotobuf_2fany_2eproto();
- const ::google::protobuf::FileDescriptor* file =
- ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
- "google/protobuf/any.proto");
- GOOGLE_CHECK(file != NULL);
- Any_descriptor_ = file->message_type(0);
- static const int Any_offsets_[2] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, type_url_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, value_),
- };
- Any_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- Any_descriptor_,
- Any::internal_default_instance(),
- Any_offsets_,
- -1,
- -1,
- -1,
- sizeof(Any),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, _internal_metadata_));
-}
+static const ::google::protobuf::internal::MigrationSchema schemas[] = {
+ { 0, -1, sizeof(Any)},
+};
+
+static ::google::protobuf::Message const * const file_default_instances[] = {
+ reinterpret_cast<const ::google::protobuf::Message*>(&_Any_default_instance_),
+};
namespace {
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
+void protobuf_AssignDescriptors() {
+ AddDescriptors();
+ ::google::protobuf::MessageFactory* factory = NULL;
+ AssignDescriptors(
+ "google/protobuf/any.proto", schemas, file_default_instances, TableStruct::offsets, factory,
+ file_level_metadata, NULL, NULL);
+}
+
void protobuf_AssignDescriptorsOnce() {
- ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
- &protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto);
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);
}
void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;
void protobuf_RegisterTypes(const ::std::string&) {
protobuf_AssignDescriptorsOnce();
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- Any_descriptor_, Any::internal_default_instance());
+ ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1);
}
} // namespace
-void protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto() {
- Any_default_instance_.Shutdown();
- delete Any_reflection_;
+void TableStruct::Shutdown() {
+ _Any_default_instance_.Shutdown();
+ delete file_level_metadata[0].reflection;
}
-void protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_impl() {
+void TableStruct::InitDefaultsImpl() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
- ::google::protobuf::internal::GetEmptyString();
- Any_default_instance_.DefaultConstruct();
- Any_default_instance_.get_mutable()->InitAsDefaultInstance();
+ ::google::protobuf::internal::InitProtobufDefaults();
+ _Any_default_instance_.DefaultConstruct();
}
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_once_);
-void protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto() {
- ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_once_,
- &protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_impl);
+void InitDefaults() {
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);
}
-void protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_impl() {
- GOOGLE_PROTOBUF_VERIFY_VERSION;
-
- protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto();
+void AddDescriptorsImpl() {
+ InitDefaults();
+ static const char descriptor[] = {
+ "\n\031google/protobuf/any.proto\022\017google.prot"
+ "obuf\"&\n\003Any\022\020\n\010type_url\030\001 \001(\t\022\r\n\005value\030\002"
+ " \001(\014Bo\n\023com.google.protobufB\010AnyProtoP\001Z"
+ "%github.com/golang/protobuf/ptypes/any\242\002"
+ "\003GPB\252\002\036Google.Protobuf.WellKnownTypesb\006p"
+ "roto3"
+ };
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
- "\n\031google/protobuf/any.proto\022\017google.prot"
- "obuf\"&\n\003Any\022\020\n\010type_url\030\001 \001(\t\022\r\n\005value\030\002"
- " \001(\014Bo\n\023com.google.protobufB\010AnyProtoP\001Z"
- "%github.com/golang/protobuf/ptypes/any\242\002"
- "\003GPB\252\002\036Google.Protobuf.WellKnownTypesb\006p"
- "roto3", 205);
+ descriptor, 205);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"google/protobuf/any.proto", &protobuf_RegisterTypes);
- ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto);
+ ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);
}
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_once_);
-void protobuf_AddDesc_google_2fprotobuf_2fany_2eproto() {
- ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_once_,
- &protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_impl);
+void AddDescriptors() {
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
}
// Force AddDescriptors() to be called at static initialization time.
-struct StaticDescriptorInitializer_google_2fprotobuf_2fany_2eproto {
- StaticDescriptorInitializer_google_2fprotobuf_2fany_2eproto() {
- protobuf_AddDesc_google_2fprotobuf_2fany_2eproto();
+struct StaticDescriptorInitializer {
+ StaticDescriptorInitializer() {
+ AddDescriptors();
}
-} static_descriptor_initializer_google_2fprotobuf_2fany_2eproto_;
+} static_descriptor_initializer;
-namespace {
-
-static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN;
-static void MergeFromFail(int line) {
- ::google::protobuf::internal::MergeFromFail(__FILE__, line);
-}
-
-} // namespace
+} // namespace protobuf_google_2fprotobuf_2fany_2eproto
// ===================================================================
@@ -148,20 +140,26 @@ const int Any::kValueFieldNumber;
Any::Any()
: ::google::protobuf::Message(), _internal_metadata_(NULL), _any_metadata_(&type_url_, &value_) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fany_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.Any)
}
-
-void Any::InitAsDefaultInstance() {
-}
-
Any::Any(const Any& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL),
- _any_metadata_(&type_url_, &value_) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _cached_size_(0),
+ _any_metadata_(&type_url_, &value_) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.type_url().size() > 0) {
+ type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_url_);
+ }
+ value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.value().size() > 0) {
+ value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.value_);
+ }
// @@protoc_insertion_point(copy_constructor:google.protobuf.Any)
}
@@ -187,17 +185,15 @@ void Any::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* Any::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return Any_descriptor_;
+ protobuf_google_2fprotobuf_2fany_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fany_2eproto::file_level_metadata[0].descriptor;
}
const Any& Any::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto();
+ protobuf_google_2fprotobuf_2fany_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<Any> Any_default_instance_;
-
Any* Any::New(::google::protobuf::Arena* arena) const {
Any* n = new Any;
if (arena != NULL) {
@@ -218,13 +214,14 @@ bool Any::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Any)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional string type_url = 1;
+ // string type_url = 1;
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_type_url()));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
@@ -234,20 +231,18 @@ bool Any::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(18)) goto parse_value;
break;
}
- // optional bytes value = 2;
+ // bytes value = 2;
case 2: {
- if (tag == 18) {
- parse_value:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(18u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
input, this->mutable_value()));
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -275,7 +270,7 @@ failure:
void Any::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.Any)
- // optional string type_url = 1;
+ // string type_url = 1;
if (this->type_url().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->type_url().data(), this->type_url().length(),
@@ -285,7 +280,7 @@ void Any::SerializeWithCachedSizes(
1, this->type_url(), output);
}
- // optional bytes value = 2;
+ // bytes value = 2;
if (this->value().size() > 0) {
::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(
2, this->value(), output);
@@ -296,9 +291,9 @@ void Any::SerializeWithCachedSizes(
::google::protobuf::uint8* Any::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Any)
- // optional string type_url = 1;
+ // string type_url = 1;
if (this->type_url().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->type_url().data(), this->type_url().length(),
@@ -309,7 +304,7 @@ void Any::SerializeWithCachedSizes(
1, this->type_url(), target);
}
- // optional bytes value = 2;
+ // bytes value = 2;
if (this->value().size() > 0) {
target =
::google::protobuf::internal::WireFormatLite::WriteBytesToArray(
@@ -324,14 +319,14 @@ size_t Any::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Any)
size_t total_size = 0;
- // optional string type_url = 1;
+ // string type_url = 1;
if (this->type_url().size() > 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->type_url());
}
- // optional bytes value = 2;
+ // bytes value = 2;
if (this->value().size() > 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::BytesSize(
@@ -347,7 +342,7 @@ size_t Any::ByteSizeLong() const {
void Any::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Any)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const Any* source =
::google::protobuf::internal::DynamicCastToGenerated<const Any>(
&from);
@@ -356,21 +351,14 @@ void Any::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Any)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void Any::MergeFrom(const Any& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Any)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void Any::UnsafeMergeFrom(const Any& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
if (from.type_url().size() > 0) {
type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_url_);
@@ -392,11 +380,10 @@ void Any::CopyFrom(const Any& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Any)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool Any::IsInitialized() const {
-
return true;
}
@@ -407,34 +394,38 @@ void Any::Swap(Any* other) {
void Any::InternalSwap(Any* other) {
type_url_.Swap(&other->type_url_);
value_.Swap(&other->value_);
- _internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata Any::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = Any_descriptor_;
- metadata.reflection = Any_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fany_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fany_2eproto::file_level_metadata[0];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// Any
-// optional string type_url = 1;
+// string type_url = 1;
void Any::clear_type_url() {
type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
const ::std::string& Any::type_url() const {
// @@protoc_insertion_point(field_get:google.protobuf.Any.type_url)
- return type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return type_url_.GetNoArena();
}
void Any::set_type_url(const ::std::string& value) {
type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.Any.type_url)
}
+#if LANG_CXX11
+void Any::set_type_url(::std::string&& value) {
+
+ type_url_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Any.type_url)
+}
+#endif
void Any::set_type_url(const char* value) {
type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -466,19 +457,27 @@ void Any::set_allocated_type_url(::std::string* type_url) {
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.type_url)
}
-// optional bytes value = 2;
+// bytes value = 2;
void Any::clear_value() {
value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
const ::std::string& Any::value() const {
// @@protoc_insertion_point(field_get:google.protobuf.Any.value)
- return value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return value_.GetNoArena();
}
void Any::set_value(const ::std::string& value) {
value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.Any.value)
}
+#if LANG_CXX11
+void Any::set_value(::std::string&& value) {
+
+ value_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Any.value)
+}
+#endif
void Any::set_value(const char* value) {
value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -510,9 +509,6 @@ void Any::set_allocated_value(::std::string* value) {
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.value)
}
-inline const Any* Any::internal_default_instance() {
- return &Any_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// @@protoc_insertion_point(namespace_scope)
diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h
index 0641e244..1a61d5af 100644
--- a/src/google/protobuf/any.pb.h
+++ b/src/google/protobuf/any.pb.h
@@ -8,38 +8,49 @@
#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3001000
+#if GOOGLE_PROTOBUF_VERSION < 3002000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
#endif
+#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata.h>
#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/extension_set.h>
+#include <google/protobuf/repeated_field.h> // IWYU pragma: export
+#include <google/protobuf/extension_set.h> // IWYU pragma: export
#include <google/protobuf/unknown_field_set.h>
#include <google/protobuf/any.h>
// @@protoc_insertion_point(includes)
+namespace google {
+namespace protobuf {
+class Any;
+class AnyDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern AnyDefaultTypeInternal _Any_default_instance_;
+} // namespace protobuf
+} // namespace google
namespace google {
namespace protobuf {
+namespace protobuf_google_2fprotobuf_2fany_2eproto {
// Internal implementation detail -- do not call these.
-void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fany_2eproto();
-void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto();
-void protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto();
-void protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto();
-
-class Any;
+struct LIBPROTOBUF_EXPORT TableStruct {
+ static const ::google::protobuf::uint32 offsets[];
+ static void InitDefaultsImpl();
+ static void Shutdown();
+};
+void LIBPROTOBUF_EXPORT AddDescriptors();
+void LIBPROTOBUF_EXPORT InitDefaults();
+} // namespace protobuf_google_2fprotobuf_2fany_2eproto
// ===================================================================
@@ -58,7 +69,10 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in
static const ::google::protobuf::Descriptor* descriptor();
static const Any& default_instance();
- static const Any* internal_default_instance();
+ static inline const Any* internal_default_instance() {
+ return reinterpret_cast<const Any*>(
+ &_Any_default_instance_);
+ }
// implements Any -----------------------------------------------
@@ -74,64 +88,71 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in
// implements Message ----------------------------------------------
- inline Any* New() const { return New(NULL); }
+ inline Any* New() const PROTOBUF_FINAL { return New(NULL); }
- Any* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ Any* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Any& from);
void MergeFrom(const Any& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(Any* other);
- void UnsafeMergeFrom(const Any& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
- // optional string type_url = 1;
+ // string type_url = 1;
void clear_type_url();
static const int kTypeUrlFieldNumber = 1;
const ::std::string& type_url() const;
void set_type_url(const ::std::string& value);
+ #if LANG_CXX11
+ void set_type_url(::std::string&& value);
+ #endif
void set_type_url(const char* value);
void set_type_url(const char* value, size_t size);
::std::string* mutable_type_url();
::std::string* release_type_url();
void set_allocated_type_url(::std::string* type_url);
- // optional bytes value = 2;
+ // bytes value = 2;
void clear_value();
static const int kValueFieldNumber = 2;
const ::std::string& value() const;
void set_value(const ::std::string& value);
+ #if LANG_CXX11
+ void set_value(::std::string&& value);
+ #endif
void set_value(const char* value);
void set_value(const void* value, size_t size);
::std::string* mutable_value();
@@ -146,15 +167,8 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in
::google::protobuf::internal::ArenaStringPtr value_;
mutable int _cached_size_;
::google::protobuf::internal::AnyMetadata _any_metadata_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fany_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<Any> Any_default_instance_;
-
// ===================================================================
@@ -163,19 +177,27 @@ extern ::google::protobuf::internal::ExplicitlyConstructed<Any> Any_default_inst
#if !PROTOBUF_INLINE_NOT_IN_HEADERS
// Any
-// optional string type_url = 1;
+// string type_url = 1;
inline void Any::clear_type_url() {
type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline const ::std::string& Any::type_url() const {
// @@protoc_insertion_point(field_get:google.protobuf.Any.type_url)
- return type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return type_url_.GetNoArena();
}
inline void Any::set_type_url(const ::std::string& value) {
type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.Any.type_url)
}
+#if LANG_CXX11
+inline void Any::set_type_url(::std::string&& value) {
+
+ type_url_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Any.type_url)
+}
+#endif
inline void Any::set_type_url(const char* value) {
type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -207,19 +229,27 @@ inline void Any::set_allocated_type_url(::std::string* type_url) {
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.type_url)
}
-// optional bytes value = 2;
+// bytes value = 2;
inline void Any::clear_value() {
value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline const ::std::string& Any::value() const {
// @@protoc_insertion_point(field_get:google.protobuf.Any.value)
- return value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return value_.GetNoArena();
}
inline void Any::set_value(const ::std::string& value) {
value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.Any.value)
}
+#if LANG_CXX11
+inline void Any::set_value(::std::string&& value) {
+
+ value_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Any.value)
+}
+#endif
inline void Any::set_value(const char* value) {
value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -251,13 +281,11 @@ inline void Any::set_allocated_value(::std::string* value) {
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.value)
}
-inline const Any* Any::internal_default_instance() {
- return &Any_default_instance_.get();
-}
#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS
// @@protoc_insertion_point(namespace_scope)
+
} // namespace protobuf
} // namespace google
diff --git a/src/google/protobuf/api.pb.cc b/src/google/protobuf/api.pb.cc
index 35139faf..7965d1ce 100644
--- a/src/google/protobuf/api.pb.cc
+++ b/src/google/protobuf/api.pb.cc
@@ -19,187 +19,158 @@
namespace google {
namespace protobuf {
+class ApiDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Api> {
+} _Api_default_instance_;
+class MethodDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Method> {
+} _Method_default_instance_;
+class MixinDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Mixin> {
+} _Mixin_default_instance_;
+
+namespace protobuf_google_2fprotobuf_2fapi_2eproto {
+
namespace {
-const ::google::protobuf::Descriptor* Api_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- Api_reflection_ = NULL;
-const ::google::protobuf::Descriptor* Method_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- Method_reflection_ = NULL;
-const ::google::protobuf::Descriptor* Mixin_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- Mixin_reflection_ = NULL;
+::google::protobuf::Metadata file_level_metadata[3];
} // namespace
-
-void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto() GOOGLE_ATTRIBUTE_COLD;
-void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto() {
- protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto();
- const ::google::protobuf::FileDescriptor* file =
- ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
- "google/protobuf/api.proto");
- GOOGLE_CHECK(file != NULL);
- Api_descriptor_ = file->message_type(0);
- static const int Api_offsets_[7] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, methods_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, options_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, version_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, source_context_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, mixins_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, syntax_),
- };
- Api_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- Api_descriptor_,
- Api::internal_default_instance(),
- Api_offsets_,
- -1,
- -1,
- -1,
- sizeof(Api),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, _internal_metadata_));
- Method_descriptor_ = file->message_type(1);
- static const int Method_offsets_[7] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, request_type_url_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, request_streaming_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, response_type_url_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, response_streaming_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, options_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, syntax_),
- };
- Method_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- Method_descriptor_,
- Method::internal_default_instance(),
- Method_offsets_,
- -1,
- -1,
- -1,
- sizeof(Method),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, _internal_metadata_));
- Mixin_descriptor_ = file->message_type(2);
- static const int Mixin_offsets_[2] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, root_),
- };
- Mixin_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- Mixin_descriptor_,
- Mixin::internal_default_instance(),
- Mixin_offsets_,
- -1,
- -1,
- -1,
- sizeof(Mixin),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, _internal_metadata_));
-}
+const ::google::protobuf::uint32 TableStruct::offsets[] = {
+ ~0u, // no _has_bits_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, methods_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, options_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, version_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, source_context_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, mixins_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, syntax_),
+ ~0u, // no _has_bits_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, request_type_url_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, request_streaming_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, response_type_url_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, response_streaming_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, options_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, syntax_),
+ ~0u, // no _has_bits_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, root_),
+};
+
+static const ::google::protobuf::internal::MigrationSchema schemas[] = {
+ { 0, -1, sizeof(Api)},
+ { 11, -1, sizeof(Method)},
+ { 22, -1, sizeof(Mixin)},
+};
+
+static ::google::protobuf::Message const * const file_default_instances[] = {
+ reinterpret_cast<const ::google::protobuf::Message*>(&_Api_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_Method_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_Mixin_default_instance_),
+};
namespace {
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
+void protobuf_AssignDescriptors() {
+ AddDescriptors();
+ ::google::protobuf::MessageFactory* factory = NULL;
+ AssignDescriptors(
+ "google/protobuf/api.proto", schemas, file_default_instances, TableStruct::offsets, factory,
+ file_level_metadata, NULL, NULL);
+}
+
void protobuf_AssignDescriptorsOnce() {
- ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
- &protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto);
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);
}
void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;
void protobuf_RegisterTypes(const ::std::string&) {
protobuf_AssignDescriptorsOnce();
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- Api_descriptor_, Api::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- Method_descriptor_, Method::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- Mixin_descriptor_, Mixin::internal_default_instance());
+ ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 3);
}
} // namespace
-void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto() {
- Api_default_instance_.Shutdown();
- delete Api_reflection_;
- Method_default_instance_.Shutdown();
- delete Method_reflection_;
- Mixin_default_instance_.Shutdown();
- delete Mixin_reflection_;
+void TableStruct::Shutdown() {
+ _Api_default_instance_.Shutdown();
+ delete file_level_metadata[0].reflection;
+ _Method_default_instance_.Shutdown();
+ delete file_level_metadata[1].reflection;
+ _Mixin_default_instance_.Shutdown();
+ delete file_level_metadata[2].reflection;
}
-void protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl() {
+void TableStruct::InitDefaultsImpl() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
- ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto();
- ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
- ::google::protobuf::internal::GetEmptyString();
- Api_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- Method_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- Mixin_default_instance_.DefaultConstruct();
- Api_default_instance_.get_mutable()->InitAsDefaultInstance();
- Method_default_instance_.get_mutable()->InitAsDefaultInstance();
- Mixin_default_instance_.get_mutable()->InitAsDefaultInstance();
-}
-
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_once_);
-void protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto() {
- ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_once_,
- &protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl);
-}
-void protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl() {
- GOOGLE_PROTOBUF_VERIFY_VERSION;
+ ::google::protobuf::internal::InitProtobufDefaults();
+ ::google::protobuf::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::InitDefaults();
+ ::google::protobuf::protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
+ _Api_default_instance_.DefaultConstruct();
+ _Method_default_instance_.DefaultConstruct();
+ _Mixin_default_instance_.DefaultConstruct();
+ _Api_default_instance_.get_mutable()->source_context_ = const_cast< ::google::protobuf::SourceContext*>(
+ ::google::protobuf::SourceContext::internal_default_instance());
+}
- protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto();
+void InitDefaults() {
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);
+}
+void AddDescriptorsImpl() {
+ InitDefaults();
+ static const char descriptor[] = {
+ "\n\031google/protobuf/api.proto\022\017google.prot"
+ "obuf\032$google/protobuf/source_context.pro"
+ "to\032\032google/protobuf/type.proto\"\201\002\n\003Api\022\014"
+ "\n\004name\030\001 \001(\t\022(\n\007methods\030\002 \003(\0132\027.google.p"
+ "rotobuf.Method\022(\n\007options\030\003 \003(\0132\027.google"
+ ".protobuf.Option\022\017\n\007version\030\004 \001(\t\0226\n\016sou"
+ "rce_context\030\005 \001(\0132\036.google.protobuf.Sour"
+ "ceContext\022&\n\006mixins\030\006 \003(\0132\026.google.proto"
+ "buf.Mixin\022\'\n\006syntax\030\007 \001(\0162\027.google.proto"
+ "buf.Syntax\"\325\001\n\006Method\022\014\n\004name\030\001 \001(\t\022\030\n\020r"
+ "equest_type_url\030\002 \001(\t\022\031\n\021request_streami"
+ "ng\030\003 \001(\010\022\031\n\021response_type_url\030\004 \001(\t\022\032\n\022r"
+ "esponse_streaming\030\005 \001(\010\022(\n\007options\030\006 \003(\013"
+ "2\027.google.protobuf.Option\022\'\n\006syntax\030\007 \001("
+ "\0162\027.google.protobuf.Syntax\"#\n\005Mixin\022\014\n\004n"
+ "ame\030\001 \001(\t\022\014\n\004root\030\002 \001(\tBu\n\023com.google.pr"
+ "otobufB\010ApiProtoP\001Z+google.golang.org/ge"
+ "nproto/protobuf/api;api\242\002\003GPB\252\002\036Google.P"
+ "rotobuf.WellKnownTypesb\006proto3"
+ };
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
- "\n\031google/protobuf/api.proto\022\017google.prot"
- "obuf\032$google/protobuf/source_context.pro"
- "to\032\032google/protobuf/type.proto\"\201\002\n\003Api\022\014"
- "\n\004name\030\001 \001(\t\022(\n\007methods\030\002 \003(\0132\027.google.p"
- "rotobuf.Method\022(\n\007options\030\003 \003(\0132\027.google"
- ".protobuf.Option\022\017\n\007version\030\004 \001(\t\0226\n\016sou"
- "rce_context\030\005 \001(\0132\036.google.protobuf.Sour"
- "ceContext\022&\n\006mixins\030\006 \003(\0132\026.google.proto"
- "buf.Mixin\022\'\n\006syntax\030\007 \001(\0162\027.google.proto"
- "buf.Syntax\"\325\001\n\006Method\022\014\n\004name\030\001 \001(\t\022\030\n\020r"
- "equest_type_url\030\002 \001(\t\022\031\n\021request_streami"
- "ng\030\003 \001(\010\022\031\n\021response_type_url\030\004 \001(\t\022\032\n\022r"
- "esponse_streaming\030\005 \001(\010\022(\n\007options\030\006 \003(\013"
- "2\027.google.protobuf.Option\022\'\n\006syntax\030\007 \001("
- "\0162\027.google.protobuf.Syntax\"#\n\005Mixin\022\014\n\004n"
- "ame\030\001 \001(\t\022\014\n\004root\030\002 \001(\tBH\n\023com.google.pr"
- "otobufB\010ApiProtoP\001\242\002\003GPB\252\002\036Google.Protob"
- "uf.WellKnownTypesb\006proto3", 705);
+ descriptor, 750);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"google/protobuf/api.proto", &protobuf_RegisterTypes);
- ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto();
- ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto();
- ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto);
+ ::google::protobuf::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::AddDescriptors();
+ ::google::protobuf::protobuf_google_2fprotobuf_2ftype_2eproto::AddDescriptors();
+ ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);
}
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_once_);
-void protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto() {
- ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_once_,
- &protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl);
+void AddDescriptors() {
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
}
// Force AddDescriptors() to be called at static initialization time.
-struct StaticDescriptorInitializer_google_2fprotobuf_2fapi_2eproto {
- StaticDescriptorInitializer_google_2fprotobuf_2fapi_2eproto() {
- protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto();
+struct StaticDescriptorInitializer {
+ StaticDescriptorInitializer() {
+ AddDescriptors();
}
-} static_descriptor_initializer_google_2fprotobuf_2fapi_2eproto_;
+} static_descriptor_initializer;
-namespace {
-
-static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN;
-static void MergeFromFail(int line) {
- ::google::protobuf::internal::MergeFromFail(__FILE__, line);
-}
-
-} // namespace
+} // namespace protobuf_google_2fprotobuf_2fapi_2eproto
// ===================================================================
@@ -216,29 +187,42 @@ const int Api::kSyntaxFieldNumber;
Api::Api()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.Api)
}
-
-void Api::InitAsDefaultInstance() {
- source_context_ = const_cast< ::google::protobuf::SourceContext*>(
- ::google::protobuf::SourceContext::internal_default_instance());
-}
-
Api::Api(const Api& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ methods_(from.methods_),
+ options_(from.options_),
+ mixins_(from.mixins_),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.name().size() > 0) {
+ name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
+ }
+ version_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.version().size() > 0) {
+ version_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.version_);
+ }
+ if (from.has_source_context()) {
+ source_context_ = new ::google::protobuf::SourceContext(*from.source_context_);
+ } else {
+ source_context_ = NULL;
+ }
+ syntax_ = from.syntax_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.Api)
}
void Api::SharedCtor() {
name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
version_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- source_context_ = NULL;
- syntax_ = 0;
+ ::memset(&source_context_, 0, reinterpret_cast<char*>(&syntax_) -
+ reinterpret_cast<char*>(&source_context_) + sizeof(syntax_));
_cached_size_ = 0;
}
@@ -250,7 +234,7 @@ Api::~Api() {
void Api::SharedDtor() {
name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
version_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- if (this != &Api_default_instance_.get()) {
+ if (this != internal_default_instance()) {
delete source_context_;
}
}
@@ -261,17 +245,15 @@ void Api::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* Api::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return Api_descriptor_;
+ protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[0].descriptor;
}
const Api& Api::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto();
+ protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<Api> Api_default_instance_;
-
Api* Api::New(::google::protobuf::Arena* arena) const {
Api* n = new Api;
if (arena != NULL) {
@@ -282,14 +264,16 @@ Api* Api::New(::google::protobuf::Arena* arena) const {
void Api::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Api)
+ methods_.Clear();
+ options_.Clear();
+ mixins_.Clear();
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
version_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_;
+ if (GetArenaNoVirtual() == NULL && source_context_ != NULL) {
+ delete source_context_;
+ }
source_context_ = NULL;
syntax_ = 0;
- methods_.Clear();
- options_.Clear();
- mixins_.Clear();
}
bool Api::MergePartialFromCodedStream(
@@ -298,13 +282,14 @@ bool Api::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Api)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional string name = 1;
+ // string name = 1;
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name()));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
@@ -314,47 +299,41 @@ bool Api::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(18)) goto parse_methods;
break;
}
// repeated .google.protobuf.Method methods = 2;
case 2: {
- if (tag == 18) {
- parse_methods:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(18u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_methods:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_methods()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(18)) goto parse_loop_methods;
- if (input->ExpectTag(26)) goto parse_loop_options;
input->UnsafeDecrementRecursionDepth();
break;
}
// repeated .google.protobuf.Option options = 3;
case 3: {
- if (tag == 26) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(26u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_options:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_options()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(26)) goto parse_loop_options;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectTag(34)) goto parse_version;
break;
}
- // optional string version = 4;
+ // string version = 4;
case 4: {
- if (tag == 34) {
- parse_version:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(34u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_version()));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
@@ -364,44 +343,39 @@ bool Api::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(42)) goto parse_source_context;
break;
}
- // optional .google.protobuf.SourceContext source_context = 5;
+ // .google.protobuf.SourceContext source_context = 5;
case 5: {
- if (tag == 42) {
- parse_source_context:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(42u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_source_context()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(50)) goto parse_mixins;
break;
}
// repeated .google.protobuf.Mixin mixins = 6;
case 6: {
- if (tag == 50) {
- parse_mixins:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(50u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_mixins:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_mixins()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(50)) goto parse_loop_mixins;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectTag(56)) goto parse_syntax;
break;
}
- // optional .google.protobuf.Syntax syntax = 7;
+ // .google.protobuf.Syntax syntax = 7;
case 7: {
- if (tag == 56) {
- parse_syntax:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(56u)) {
int value;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
@@ -410,7 +384,6 @@ bool Api::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -438,7 +411,7 @@ failure:
void Api::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.Api)
- // optional string name = 1;
+ // string name = 1;
if (this->name().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->name().data(), this->name().length(),
@@ -460,7 +433,7 @@ void Api::SerializeWithCachedSizes(
3, this->options(i), output);
}
- // optional string version = 4;
+ // string version = 4;
if (this->version().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->version().data(), this->version().length(),
@@ -470,7 +443,7 @@ void Api::SerializeWithCachedSizes(
4, this->version(), output);
}
- // optional .google.protobuf.SourceContext source_context = 5;
+ // .google.protobuf.SourceContext source_context = 5;
if (this->has_source_context()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
5, *this->source_context_, output);
@@ -482,7 +455,7 @@ void Api::SerializeWithCachedSizes(
6, this->mixins(i), output);
}
- // optional .google.protobuf.Syntax syntax = 7;
+ // .google.protobuf.Syntax syntax = 7;
if (this->syntax() != 0) {
::google::protobuf::internal::WireFormatLite::WriteEnum(
7, this->syntax(), output);
@@ -493,9 +466,9 @@ void Api::SerializeWithCachedSizes(
::google::protobuf::uint8* Api::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Api)
- // optional string name = 1;
+ // string name = 1;
if (this->name().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->name().data(), this->name().length(),
@@ -520,7 +493,7 @@ void Api::SerializeWithCachedSizes(
3, this->options(i), false, target);
}
- // optional string version = 4;
+ // string version = 4;
if (this->version().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->version().data(), this->version().length(),
@@ -531,7 +504,7 @@ void Api::SerializeWithCachedSizes(
4, this->version(), target);
}
- // optional .google.protobuf.SourceContext source_context = 5;
+ // .google.protobuf.SourceContext source_context = 5;
if (this->has_source_context()) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
@@ -545,7 +518,7 @@ void Api::SerializeWithCachedSizes(
6, this->mixins(i), false, target);
}
- // optional .google.protobuf.Syntax syntax = 7;
+ // .google.protobuf.Syntax syntax = 7;
if (this->syntax() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
7, this->syntax(), target);
@@ -559,33 +532,6 @@ size_t Api::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Api)
size_t total_size = 0;
- // optional string name = 1;
- if (this->name().size() > 0) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->name());
- }
-
- // optional string version = 4;
- if (this->version().size() > 0) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->version());
- }
-
- // optional .google.protobuf.SourceContext source_context = 5;
- if (this->has_source_context()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->source_context_);
- }
-
- // optional .google.protobuf.Syntax syntax = 7;
- if (this->syntax() != 0) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->syntax());
- }
-
// repeated .google.protobuf.Method methods = 2;
{
unsigned int count = this->methods_size();
@@ -619,6 +565,33 @@ size_t Api::ByteSizeLong() const {
}
}
+ // string name = 1;
+ if (this->name().size() > 0) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->name());
+ }
+
+ // string version = 4;
+ if (this->version().size() > 0) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->version());
+ }
+
+ // .google.protobuf.SourceContext source_context = 5;
+ if (this->has_source_context()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->source_context_);
+ }
+
+ // .google.protobuf.Syntax syntax = 7;
+ if (this->syntax() != 0) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->syntax());
+ }
+
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
@@ -628,7 +601,7 @@ size_t Api::ByteSizeLong() const {
void Api::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Api)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const Api* source =
::google::protobuf::internal::DynamicCastToGenerated<const Api>(
&from);
@@ -637,21 +610,14 @@ void Api::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Api)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void Api::MergeFrom(const Api& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Api)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void Api::UnsafeMergeFrom(const Api& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
methods_.MergeFrom(from.methods_);
options_.MergeFrom(from.options_);
mixins_.MergeFrom(from.mixins_);
@@ -682,11 +648,10 @@ void Api::CopyFrom(const Api& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Api)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool Api::IsInitialized() const {
-
return true;
}
@@ -695,41 +660,45 @@ void Api::Swap(Api* other) {
InternalSwap(other);
}
void Api::InternalSwap(Api* other) {
- name_.Swap(&other->name_);
methods_.UnsafeArenaSwap(&other->methods_);
options_.UnsafeArenaSwap(&other->options_);
+ mixins_.UnsafeArenaSwap(&other->mixins_);
+ name_.Swap(&other->name_);
version_.Swap(&other->version_);
std::swap(source_context_, other->source_context_);
- mixins_.UnsafeArenaSwap(&other->mixins_);
std::swap(syntax_, other->syntax_);
- _internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata Api::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = Api_descriptor_;
- metadata.reflection = Api_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[0];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// Api
-// optional string name = 1;
+// string name = 1;
void Api::clear_name() {
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
const ::std::string& Api::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.Api.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.GetNoArena();
}
void Api::set_name(const ::std::string& value) {
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.Api.name)
}
+#if LANG_CXX11
+void Api::set_name(::std::string&& value) {
+
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Api.name)
+}
+#endif
void Api::set_name(const char* value) {
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -821,19 +790,27 @@ Api::options() const {
return options_;
}
-// optional string version = 4;
+// string version = 4;
void Api::clear_version() {
version_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
const ::std::string& Api::version() const {
// @@protoc_insertion_point(field_get:google.protobuf.Api.version)
- return version_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return version_.GetNoArena();
}
void Api::set_version(const ::std::string& value) {
version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.Api.version)
}
+#if LANG_CXX11
+void Api::set_version(::std::string&& value) {
+
+ version_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Api.version)
+}
+#endif
void Api::set_version(const char* value) {
version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -865,7 +842,7 @@ void Api::set_allocated_version(::std::string* version) {
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.version)
}
-// optional .google.protobuf.SourceContext source_context = 5;
+// .google.protobuf.SourceContext source_context = 5;
bool Api::has_source_context() const {
return this != internal_default_instance() && source_context_ != NULL;
}
@@ -934,7 +911,7 @@ Api::mixins() const {
return mixins_;
}
-// optional .google.protobuf.Syntax syntax = 7;
+// .google.protobuf.Syntax syntax = 7;
void Api::clear_syntax() {
syntax_ = 0;
}
@@ -948,9 +925,6 @@ void Api::set_syntax(::google::protobuf::Syntax value) {
// @@protoc_insertion_point(field_set:google.protobuf.Api.syntax)
}
-inline const Api* Api::internal_default_instance() {
- return &Api_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -967,19 +941,33 @@ const int Method::kSyntaxFieldNumber;
Method::Method()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.Method)
}
-
-void Method::InitAsDefaultInstance() {
-}
-
Method::Method(const Method& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ options_(from.options_),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.name().size() > 0) {
+ name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
+ }
+ request_type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.request_type_url().size() > 0) {
+ request_type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.request_type_url_);
+ }
+ response_type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.response_type_url().size() > 0) {
+ response_type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.response_type_url_);
+ }
+ ::memcpy(&request_streaming_, &from.request_streaming_,
+ reinterpret_cast<char*>(&syntax_) -
+ reinterpret_cast<char*>(&request_streaming_) + sizeof(syntax_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.Method)
}
@@ -1009,17 +997,15 @@ void Method::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* Method::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return Method_descriptor_;
+ protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[1].descriptor;
}
const Method& Method::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto();
+ protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<Method> Method_default_instance_;
-
Method* Method::New(::google::protobuf::Arena* arena) const {
Method* n = new Method;
if (arena != NULL) {
@@ -1030,31 +1016,12 @@ Method* Method::New(::google::protobuf::Arena* arena) const {
void Method::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Method)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(Method, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<Method*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- ZR_(request_streaming_, syntax_);
+ options_.Clear();
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
request_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
response_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-
-#undef ZR_HELPER_
-#undef ZR_
-
- options_.Clear();
+ ::memset(&request_streaming_, 0, reinterpret_cast<char*>(&syntax_) -
+ reinterpret_cast<char*>(&request_streaming_) + sizeof(syntax_));
}
bool Method::MergePartialFromCodedStream(
@@ -1063,13 +1030,14 @@ bool Method::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Method)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional string name = 1;
+ // string name = 1;
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name()));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
@@ -1079,14 +1047,13 @@ bool Method::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(18)) goto parse_request_type_url;
break;
}
- // optional string request_type_url = 2;
+ // string request_type_url = 2;
case 2: {
- if (tag == 18) {
- parse_request_type_url:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(18u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_request_type_url()));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
@@ -1096,14 +1063,13 @@ bool Method::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(24)) goto parse_request_streaming;
break;
}
- // optional bool request_streaming = 3;
+ // bool request_streaming = 3;
case 3: {
- if (tag == 24) {
- parse_request_streaming:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(24u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -1111,14 +1077,13 @@ bool Method::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(34)) goto parse_response_type_url;
break;
}
- // optional string response_type_url = 4;
+ // string response_type_url = 4;
case 4: {
- if (tag == 34) {
- parse_response_type_url:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(34u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_response_type_url()));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
@@ -1128,14 +1093,13 @@ bool Method::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(40)) goto parse_response_streaming;
break;
}
- // optional bool response_streaming = 5;
+ // bool response_streaming = 5;
case 5: {
- if (tag == 40) {
- parse_response_streaming:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(40u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -1143,31 +1107,27 @@ bool Method::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(50)) goto parse_options;
break;
}
// repeated .google.protobuf.Option options = 6;
case 6: {
- if (tag == 50) {
- parse_options:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(50u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_options:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_options()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(50)) goto parse_loop_options;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectTag(56)) goto parse_syntax;
break;
}
- // optional .google.protobuf.Syntax syntax = 7;
+ // .google.protobuf.Syntax syntax = 7;
case 7: {
- if (tag == 56) {
- parse_syntax:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(56u)) {
int value;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
@@ -1176,7 +1136,6 @@ bool Method::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -1204,7 +1163,7 @@ failure:
void Method::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.Method)
- // optional string name = 1;
+ // string name = 1;
if (this->name().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->name().data(), this->name().length(),
@@ -1214,7 +1173,7 @@ void Method::SerializeWithCachedSizes(
1, this->name(), output);
}
- // optional string request_type_url = 2;
+ // string request_type_url = 2;
if (this->request_type_url().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->request_type_url().data(), this->request_type_url().length(),
@@ -1224,12 +1183,12 @@ void Method::SerializeWithCachedSizes(
2, this->request_type_url(), output);
}
- // optional bool request_streaming = 3;
+ // bool request_streaming = 3;
if (this->request_streaming() != 0) {
::google::protobuf::internal::WireFormatLite::WriteBool(3, this->request_streaming(), output);
}
- // optional string response_type_url = 4;
+ // string response_type_url = 4;
if (this->response_type_url().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->response_type_url().data(), this->response_type_url().length(),
@@ -1239,7 +1198,7 @@ void Method::SerializeWithCachedSizes(
4, this->response_type_url(), output);
}
- // optional bool response_streaming = 5;
+ // bool response_streaming = 5;
if (this->response_streaming() != 0) {
::google::protobuf::internal::WireFormatLite::WriteBool(5, this->response_streaming(), output);
}
@@ -1250,7 +1209,7 @@ void Method::SerializeWithCachedSizes(
6, this->options(i), output);
}
- // optional .google.protobuf.Syntax syntax = 7;
+ // .google.protobuf.Syntax syntax = 7;
if (this->syntax() != 0) {
::google::protobuf::internal::WireFormatLite::WriteEnum(
7, this->syntax(), output);
@@ -1261,9 +1220,9 @@ void Method::SerializeWithCachedSizes(
::google::protobuf::uint8* Method::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Method)
- // optional string name = 1;
+ // string name = 1;
if (this->name().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->name().data(), this->name().length(),
@@ -1274,7 +1233,7 @@ void Method::SerializeWithCachedSizes(
1, this->name(), target);
}
- // optional string request_type_url = 2;
+ // string request_type_url = 2;
if (this->request_type_url().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->request_type_url().data(), this->request_type_url().length(),
@@ -1285,12 +1244,12 @@ void Method::SerializeWithCachedSizes(
2, this->request_type_url(), target);
}
- // optional bool request_streaming = 3;
+ // bool request_streaming = 3;
if (this->request_streaming() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(3, this->request_streaming(), target);
}
- // optional string response_type_url = 4;
+ // string response_type_url = 4;
if (this->response_type_url().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->response_type_url().data(), this->response_type_url().length(),
@@ -1301,7 +1260,7 @@ void Method::SerializeWithCachedSizes(
4, this->response_type_url(), target);
}
- // optional bool response_streaming = 5;
+ // bool response_streaming = 5;
if (this->response_streaming() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(5, this->response_streaming(), target);
}
@@ -1313,7 +1272,7 @@ void Method::SerializeWithCachedSizes(
6, this->options(i), false, target);
}
- // optional .google.protobuf.Syntax syntax = 7;
+ // .google.protobuf.Syntax syntax = 7;
if (this->syntax() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
7, this->syntax(), target);
@@ -1327,54 +1286,54 @@ size_t Method::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Method)
size_t total_size = 0;
- // optional string name = 1;
+ // repeated .google.protobuf.Option options = 6;
+ {
+ unsigned int count = this->options_size();
+ total_size += 1UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->options(i));
+ }
+ }
+
+ // string name = 1;
if (this->name().size() > 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->name());
}
- // optional string request_type_url = 2;
+ // string request_type_url = 2;
if (this->request_type_url().size() > 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->request_type_url());
}
- // optional bool request_streaming = 3;
- if (this->request_streaming() != 0) {
- total_size += 1 + 1;
- }
-
- // optional string response_type_url = 4;
+ // string response_type_url = 4;
if (this->response_type_url().size() > 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->response_type_url());
}
- // optional bool response_streaming = 5;
+ // bool request_streaming = 3;
+ if (this->request_streaming() != 0) {
+ total_size += 1 + 1;
+ }
+
+ // bool response_streaming = 5;
if (this->response_streaming() != 0) {
total_size += 1 + 1;
}
- // optional .google.protobuf.Syntax syntax = 7;
+ // .google.protobuf.Syntax syntax = 7;
if (this->syntax() != 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::EnumSize(this->syntax());
}
- // repeated .google.protobuf.Option options = 6;
- {
- unsigned int count = this->options_size();
- total_size += 1UL * count;
- for (unsigned int i = 0; i < count; i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->options(i));
- }
- }
-
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
@@ -1384,7 +1343,7 @@ size_t Method::ByteSizeLong() const {
void Method::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Method)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const Method* source =
::google::protobuf::internal::DynamicCastToGenerated<const Method>(
&from);
@@ -1393,21 +1352,14 @@ void Method::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Method)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void Method::MergeFrom(const Method& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Method)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void Method::UnsafeMergeFrom(const Method& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
options_.MergeFrom(from.options_);
if (from.name().size() > 0) {
@@ -1417,13 +1369,13 @@ void Method::UnsafeMergeFrom(const Method& from) {
request_type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.request_type_url_);
}
- if (from.request_streaming() != 0) {
- set_request_streaming(from.request_streaming());
- }
if (from.response_type_url().size() > 0) {
response_type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.response_type_url_);
}
+ if (from.request_streaming() != 0) {
+ set_request_streaming(from.request_streaming());
+ }
if (from.response_streaming() != 0) {
set_response_streaming(from.response_streaming());
}
@@ -1443,11 +1395,10 @@ void Method::CopyFrom(const Method& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Method)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool Method::IsInitialized() const {
-
return true;
}
@@ -1456,41 +1407,45 @@ void Method::Swap(Method* other) {
InternalSwap(other);
}
void Method::InternalSwap(Method* other) {
+ options_.UnsafeArenaSwap(&other->options_);
name_.Swap(&other->name_);
request_type_url_.Swap(&other->request_type_url_);
- std::swap(request_streaming_, other->request_streaming_);
response_type_url_.Swap(&other->response_type_url_);
+ std::swap(request_streaming_, other->request_streaming_);
std::swap(response_streaming_, other->response_streaming_);
- options_.UnsafeArenaSwap(&other->options_);
std::swap(syntax_, other->syntax_);
- _internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata Method::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = Method_descriptor_;
- metadata.reflection = Method_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[1];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// Method
-// optional string name = 1;
+// string name = 1;
void Method::clear_name() {
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
const ::std::string& Method::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.Method.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.GetNoArena();
}
void Method::set_name(const ::std::string& value) {
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.Method.name)
}
+#if LANG_CXX11
+void Method::set_name(::std::string&& value) {
+
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.name)
+}
+#endif
void Method::set_name(const char* value) {
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -1522,19 +1477,27 @@ void Method::set_allocated_name(::std::string* name) {
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.name)
}
-// optional string request_type_url = 2;
+// string request_type_url = 2;
void Method::clear_request_type_url() {
request_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
const ::std::string& Method::request_type_url() const {
// @@protoc_insertion_point(field_get:google.protobuf.Method.request_type_url)
- return request_type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return request_type_url_.GetNoArena();
}
void Method::set_request_type_url(const ::std::string& value) {
request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.Method.request_type_url)
}
+#if LANG_CXX11
+void Method::set_request_type_url(::std::string&& value) {
+
+ request_type_url_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.request_type_url)
+}
+#endif
void Method::set_request_type_url(const char* value) {
request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -1566,7 +1529,7 @@ void Method::set_allocated_request_type_url(::std::string* request_type_url) {
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.request_type_url)
}
-// optional bool request_streaming = 3;
+// bool request_streaming = 3;
void Method::clear_request_streaming() {
request_streaming_ = false;
}
@@ -1580,19 +1543,27 @@ void Method::set_request_streaming(bool value) {
// @@protoc_insertion_point(field_set:google.protobuf.Method.request_streaming)
}
-// optional string response_type_url = 4;
+// string response_type_url = 4;
void Method::clear_response_type_url() {
response_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
const ::std::string& Method::response_type_url() const {
// @@protoc_insertion_point(field_get:google.protobuf.Method.response_type_url)
- return response_type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return response_type_url_.GetNoArena();
}
void Method::set_response_type_url(const ::std::string& value) {
response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.Method.response_type_url)
}
+#if LANG_CXX11
+void Method::set_response_type_url(::std::string&& value) {
+
+ response_type_url_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.response_type_url)
+}
+#endif
void Method::set_response_type_url(const char* value) {
response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -1624,7 +1595,7 @@ void Method::set_allocated_response_type_url(::std::string* response_type_url) {
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.response_type_url)
}
-// optional bool response_streaming = 5;
+// bool response_streaming = 5;
void Method::clear_response_streaming() {
response_streaming_ = false;
}
@@ -1668,7 +1639,7 @@ Method::options() const {
return options_;
}
-// optional .google.protobuf.Syntax syntax = 7;
+// .google.protobuf.Syntax syntax = 7;
void Method::clear_syntax() {
syntax_ = 0;
}
@@ -1682,9 +1653,6 @@ void Method::set_syntax(::google::protobuf::Syntax value) {
// @@protoc_insertion_point(field_set:google.protobuf.Method.syntax)
}
-inline const Method* Method::internal_default_instance() {
- return &Method_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -1696,19 +1664,25 @@ const int Mixin::kRootFieldNumber;
Mixin::Mixin()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.Mixin)
}
-
-void Mixin::InitAsDefaultInstance() {
-}
-
Mixin::Mixin(const Mixin& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.name().size() > 0) {
+ name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
+ }
+ root_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.root().size() > 0) {
+ root_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.root_);
+ }
// @@protoc_insertion_point(copy_constructor:google.protobuf.Mixin)
}
@@ -1734,17 +1708,15 @@ void Mixin::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* Mixin::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return Mixin_descriptor_;
+ protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[2].descriptor;
}
const Mixin& Mixin::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto();
+ protobuf_google_2fprotobuf_2fapi_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<Mixin> Mixin_default_instance_;
-
Mixin* Mixin::New(::google::protobuf::Arena* arena) const {
Mixin* n = new Mixin;
if (arena != NULL) {
@@ -1765,13 +1737,14 @@ bool Mixin::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Mixin)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional string name = 1;
+ // string name = 1;
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name()));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
@@ -1781,14 +1754,13 @@ bool Mixin::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(18)) goto parse_root;
break;
}
- // optional string root = 2;
+ // string root = 2;
case 2: {
- if (tag == 18) {
- parse_root:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(18u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_root()));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
@@ -1798,7 +1770,6 @@ bool Mixin::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -1826,7 +1797,7 @@ failure:
void Mixin::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.Mixin)
- // optional string name = 1;
+ // string name = 1;
if (this->name().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->name().data(), this->name().length(),
@@ -1836,7 +1807,7 @@ void Mixin::SerializeWithCachedSizes(
1, this->name(), output);
}
- // optional string root = 2;
+ // string root = 2;
if (this->root().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->root().data(), this->root().length(),
@@ -1851,9 +1822,9 @@ void Mixin::SerializeWithCachedSizes(
::google::protobuf::uint8* Mixin::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Mixin)
- // optional string name = 1;
+ // string name = 1;
if (this->name().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->name().data(), this->name().length(),
@@ -1864,7 +1835,7 @@ void Mixin::SerializeWithCachedSizes(
1, this->name(), target);
}
- // optional string root = 2;
+ // string root = 2;
if (this->root().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->root().data(), this->root().length(),
@@ -1883,14 +1854,14 @@ size_t Mixin::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Mixin)
size_t total_size = 0;
- // optional string name = 1;
+ // string name = 1;
if (this->name().size() > 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->name());
}
- // optional string root = 2;
+ // string root = 2;
if (this->root().size() > 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
@@ -1906,7 +1877,7 @@ size_t Mixin::ByteSizeLong() const {
void Mixin::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Mixin)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const Mixin* source =
::google::protobuf::internal::DynamicCastToGenerated<const Mixin>(
&from);
@@ -1915,21 +1886,14 @@ void Mixin::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Mixin)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void Mixin::MergeFrom(const Mixin& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Mixin)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void Mixin::UnsafeMergeFrom(const Mixin& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
if (from.name().size() > 0) {
name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
@@ -1951,11 +1915,10 @@ void Mixin::CopyFrom(const Mixin& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Mixin)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool Mixin::IsInitialized() const {
-
return true;
}
@@ -1966,34 +1929,38 @@ void Mixin::Swap(Mixin* other) {
void Mixin::InternalSwap(Mixin* other) {
name_.Swap(&other->name_);
root_.Swap(&other->root_);
- _internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata Mixin::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = Mixin_descriptor_;
- metadata.reflection = Mixin_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fapi_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fapi_2eproto::file_level_metadata[2];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// Mixin
-// optional string name = 1;
+// string name = 1;
void Mixin::clear_name() {
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
const ::std::string& Mixin::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.Mixin.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.GetNoArena();
}
void Mixin::set_name(const ::std::string& value) {
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.Mixin.name)
}
+#if LANG_CXX11
+void Mixin::set_name(::std::string&& value) {
+
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Mixin.name)
+}
+#endif
void Mixin::set_name(const char* value) {
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -2025,19 +1992,27 @@ void Mixin::set_allocated_name(::std::string* name) {
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.name)
}
-// optional string root = 2;
+// string root = 2;
void Mixin::clear_root() {
root_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
const ::std::string& Mixin::root() const {
// @@protoc_insertion_point(field_get:google.protobuf.Mixin.root)
- return root_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return root_.GetNoArena();
}
void Mixin::set_root(const ::std::string& value) {
root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.Mixin.root)
}
+#if LANG_CXX11
+void Mixin::set_root(::std::string&& value) {
+
+ root_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Mixin.root)
+}
+#endif
void Mixin::set_root(const char* value) {
root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -2069,9 +2044,6 @@ void Mixin::set_allocated_root(::std::string* root) {
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.root)
}
-inline const Mixin* Mixin::internal_default_instance() {
- return &Mixin_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// @@protoc_insertion_point(namespace_scope)
diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h
index 94102863..2eb571e6 100644
--- a/src/google/protobuf/api.pb.h
+++ b/src/google/protobuf/api.pb.h
@@ -8,41 +8,74 @@
#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3001000
+#if GOOGLE_PROTOBUF_VERSION < 3002000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
#endif
+#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata.h>
#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/extension_set.h>
+#include <google/protobuf/repeated_field.h> // IWYU pragma: export
+#include <google/protobuf/extension_set.h> // IWYU pragma: export
#include <google/protobuf/unknown_field_set.h>
#include <google/protobuf/source_context.pb.h>
#include <google/protobuf/type.pb.h>
// @@protoc_insertion_point(includes)
-
namespace google {
namespace protobuf {
-
-// Internal implementation detail -- do not call these.
-void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto();
-void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto();
-void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto();
-void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto();
-
class Api;
+class ApiDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern ApiDefaultTypeInternal _Api_default_instance_;
+class Enum;
+class EnumDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern EnumDefaultTypeInternal _Enum_default_instance_;
+class EnumValue;
+class EnumValueDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern EnumValueDefaultTypeInternal _EnumValue_default_instance_;
+class Field;
+class FieldDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern FieldDefaultTypeInternal _Field_default_instance_;
class Method;
+class MethodDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern MethodDefaultTypeInternal _Method_default_instance_;
class Mixin;
+class MixinDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern MixinDefaultTypeInternal _Mixin_default_instance_;
+class Option;
+class OptionDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern OptionDefaultTypeInternal _Option_default_instance_;
+class SourceContext;
+class SourceContextDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern SourceContextDefaultTypeInternal _SourceContext_default_instance_;
+class Type;
+class TypeDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern TypeDefaultTypeInternal _Type_default_instance_;
+} // namespace protobuf
+} // namespace google
+
+namespace google {
+namespace protobuf {
+
+namespace protobuf_google_2fprotobuf_2fapi_2eproto {
+// Internal implementation detail -- do not call these.
+struct LIBPROTOBUF_EXPORT TableStruct {
+ static const ::google::protobuf::uint32 offsets[];
+ static void InitDefaultsImpl();
+ static void Shutdown();
+};
+void LIBPROTOBUF_EXPORT AddDescriptors();
+void LIBPROTOBUF_EXPORT InitDefaults();
+} // namespace protobuf_google_2fprotobuf_2fapi_2eproto
// ===================================================================
@@ -61,65 +94,58 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in
static const ::google::protobuf::Descriptor* descriptor();
static const Api& default_instance();
- static const Api* internal_default_instance();
+ static inline const Api* internal_default_instance() {
+ return reinterpret_cast<const Api*>(
+ &_Api_default_instance_);
+ }
void Swap(Api* other);
// implements Message ----------------------------------------------
- inline Api* New() const { return New(NULL); }
+ inline Api* New() const PROTOBUF_FINAL { return New(NULL); }
- Api* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ Api* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Api& from);
void MergeFrom(const Api& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(Api* other);
- void UnsafeMergeFrom(const Api& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
- // optional string name = 1;
- void clear_name();
- static const int kNameFieldNumber = 1;
- const ::std::string& name() const;
- void set_name(const ::std::string& value);
- void set_name(const char* value);
- void set_name(const char* value, size_t size);
- ::std::string* mutable_name();
- ::std::string* release_name();
- void set_allocated_name(::std::string* name);
-
// repeated .google.protobuf.Method methods = 2;
int methods_size() const;
void clear_methods();
@@ -144,18 +170,47 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
options() const;
- // optional string version = 4;
+ // repeated .google.protobuf.Mixin mixins = 6;
+ int mixins_size() const;
+ void clear_mixins();
+ static const int kMixinsFieldNumber = 6;
+ const ::google::protobuf::Mixin& mixins(int index) const;
+ ::google::protobuf::Mixin* mutable_mixins(int index);
+ ::google::protobuf::Mixin* add_mixins();
+ ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >*
+ mutable_mixins();
+ const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >&
+ mixins() const;
+
+ // string name = 1;
+ void clear_name();
+ static const int kNameFieldNumber = 1;
+ const ::std::string& name() const;
+ void set_name(const ::std::string& value);
+ #if LANG_CXX11
+ void set_name(::std::string&& value);
+ #endif
+ void set_name(const char* value);
+ void set_name(const char* value, size_t size);
+ ::std::string* mutable_name();
+ ::std::string* release_name();
+ void set_allocated_name(::std::string* name);
+
+ // string version = 4;
void clear_version();
static const int kVersionFieldNumber = 4;
const ::std::string& version() const;
void set_version(const ::std::string& value);
+ #if LANG_CXX11
+ void set_version(::std::string&& value);
+ #endif
void set_version(const char* value);
void set_version(const char* value, size_t size);
::std::string* mutable_version();
::std::string* release_version();
void set_allocated_version(::std::string* version);
- // optional .google.protobuf.SourceContext source_context = 5;
+ // .google.protobuf.SourceContext source_context = 5;
bool has_source_context() const;
void clear_source_context();
static const int kSourceContextFieldNumber = 5;
@@ -164,19 +219,7 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in
::google::protobuf::SourceContext* release_source_context();
void set_allocated_source_context(::google::protobuf::SourceContext* source_context);
- // repeated .google.protobuf.Mixin mixins = 6;
- int mixins_size() const;
- void clear_mixins();
- static const int kMixinsFieldNumber = 6;
- const ::google::protobuf::Mixin& mixins(int index) const;
- ::google::protobuf::Mixin* mutable_mixins(int index);
- ::google::protobuf::Mixin* add_mixins();
- ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >*
- mutable_mixins();
- const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >&
- mixins() const;
-
- // optional .google.protobuf.Syntax syntax = 7;
+ // .google.protobuf.Syntax syntax = 7;
void clear_syntax();
static const int kSyntaxFieldNumber = 7;
::google::protobuf::Syntax syntax() const;
@@ -194,15 +237,8 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in
::google::protobuf::SourceContext* source_context_;
int syntax_;
mutable int _cached_size_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fapi_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<Api> Api_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Method) */ {
@@ -220,112 +256,125 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc
static const ::google::protobuf::Descriptor* descriptor();
static const Method& default_instance();
- static const Method* internal_default_instance();
+ static inline const Method* internal_default_instance() {
+ return reinterpret_cast<const Method*>(
+ &_Method_default_instance_);
+ }
void Swap(Method* other);
// implements Message ----------------------------------------------
- inline Method* New() const { return New(NULL); }
+ inline Method* New() const PROTOBUF_FINAL { return New(NULL); }
- Method* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ Method* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Method& from);
void MergeFrom(const Method& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(Method* other);
- void UnsafeMergeFrom(const Method& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
- // optional string name = 1;
+ // repeated .google.protobuf.Option options = 6;
+ int options_size() const;
+ void clear_options();
+ static const int kOptionsFieldNumber = 6;
+ const ::google::protobuf::Option& options(int index) const;
+ ::google::protobuf::Option* mutable_options(int index);
+ ::google::protobuf::Option* add_options();
+ ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*
+ mutable_options();
+ const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
+ options() const;
+
+ // string name = 1;
void clear_name();
static const int kNameFieldNumber = 1;
const ::std::string& name() const;
void set_name(const ::std::string& value);
+ #if LANG_CXX11
+ void set_name(::std::string&& value);
+ #endif
void set_name(const char* value);
void set_name(const char* value, size_t size);
::std::string* mutable_name();
::std::string* release_name();
void set_allocated_name(::std::string* name);
- // optional string request_type_url = 2;
+ // string request_type_url = 2;
void clear_request_type_url();
static const int kRequestTypeUrlFieldNumber = 2;
const ::std::string& request_type_url() const;
void set_request_type_url(const ::std::string& value);
+ #if LANG_CXX11
+ void set_request_type_url(::std::string&& value);
+ #endif
void set_request_type_url(const char* value);
void set_request_type_url(const char* value, size_t size);
::std::string* mutable_request_type_url();
::std::string* release_request_type_url();
void set_allocated_request_type_url(::std::string* request_type_url);
- // optional bool request_streaming = 3;
- void clear_request_streaming();
- static const int kRequestStreamingFieldNumber = 3;
- bool request_streaming() const;
- void set_request_streaming(bool value);
-
- // optional string response_type_url = 4;
+ // string response_type_url = 4;
void clear_response_type_url();
static const int kResponseTypeUrlFieldNumber = 4;
const ::std::string& response_type_url() const;
void set_response_type_url(const ::std::string& value);
+ #if LANG_CXX11
+ void set_response_type_url(::std::string&& value);
+ #endif
void set_response_type_url(const char* value);
void set_response_type_url(const char* value, size_t size);
::std::string* mutable_response_type_url();
::std::string* release_response_type_url();
void set_allocated_response_type_url(::std::string* response_type_url);
- // optional bool response_streaming = 5;
+ // bool request_streaming = 3;
+ void clear_request_streaming();
+ static const int kRequestStreamingFieldNumber = 3;
+ bool request_streaming() const;
+ void set_request_streaming(bool value);
+
+ // bool response_streaming = 5;
void clear_response_streaming();
static const int kResponseStreamingFieldNumber = 5;
bool response_streaming() const;
void set_response_streaming(bool value);
- // repeated .google.protobuf.Option options = 6;
- int options_size() const;
- void clear_options();
- static const int kOptionsFieldNumber = 6;
- const ::google::protobuf::Option& options(int index) const;
- ::google::protobuf::Option* mutable_options(int index);
- ::google::protobuf::Option* add_options();
- ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*
- mutable_options();
- const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
- options() const;
-
- // optional .google.protobuf.Syntax syntax = 7;
+ // .google.protobuf.Syntax syntax = 7;
void clear_syntax();
static const int kSyntaxFieldNumber = 7;
::google::protobuf::Syntax syntax() const;
@@ -343,15 +392,8 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc
bool response_streaming_;
int syntax_;
mutable int _cached_size_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fapi_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<Method> Method_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Mixin) */ {
@@ -369,70 +411,80 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_
static const ::google::protobuf::Descriptor* descriptor();
static const Mixin& default_instance();
- static const Mixin* internal_default_instance();
+ static inline const Mixin* internal_default_instance() {
+ return reinterpret_cast<const Mixin*>(
+ &_Mixin_default_instance_);
+ }
void Swap(Mixin* other);
// implements Message ----------------------------------------------
- inline Mixin* New() const { return New(NULL); }
+ inline Mixin* New() const PROTOBUF_FINAL { return New(NULL); }
- Mixin* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ Mixin* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Mixin& from);
void MergeFrom(const Mixin& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(Mixin* other);
- void UnsafeMergeFrom(const Mixin& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
- // optional string name = 1;
+ // string name = 1;
void clear_name();
static const int kNameFieldNumber = 1;
const ::std::string& name() const;
void set_name(const ::std::string& value);
+ #if LANG_CXX11
+ void set_name(::std::string&& value);
+ #endif
void set_name(const char* value);
void set_name(const char* value, size_t size);
::std::string* mutable_name();
::std::string* release_name();
void set_allocated_name(::std::string* name);
- // optional string root = 2;
+ // string root = 2;
void clear_root();
static const int kRootFieldNumber = 2;
const ::std::string& root() const;
void set_root(const ::std::string& value);
+ #if LANG_CXX11
+ void set_root(::std::string&& value);
+ #endif
void set_root(const char* value);
void set_root(const char* value, size_t size);
::std::string* mutable_root();
@@ -446,15 +498,8 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_
::google::protobuf::internal::ArenaStringPtr name_;
::google::protobuf::internal::ArenaStringPtr root_;
mutable int _cached_size_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fapi_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<Mixin> Mixin_default_instance_;
-
// ===================================================================
@@ -463,19 +508,27 @@ extern ::google::protobuf::internal::ExplicitlyConstructed<Mixin> Mixin_default_
#if !PROTOBUF_INLINE_NOT_IN_HEADERS
// Api
-// optional string name = 1;
+// string name = 1;
inline void Api::clear_name() {
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline const ::std::string& Api::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.Api.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.GetNoArena();
}
inline void Api::set_name(const ::std::string& value) {
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.Api.name)
}
+#if LANG_CXX11
+inline void Api::set_name(::std::string&& value) {
+
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Api.name)
+}
+#endif
inline void Api::set_name(const char* value) {
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -567,19 +620,27 @@ Api::options() const {
return options_;
}
-// optional string version = 4;
+// string version = 4;
inline void Api::clear_version() {
version_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline const ::std::string& Api::version() const {
// @@protoc_insertion_point(field_get:google.protobuf.Api.version)
- return version_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return version_.GetNoArena();
}
inline void Api::set_version(const ::std::string& value) {
version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.Api.version)
}
+#if LANG_CXX11
+inline void Api::set_version(::std::string&& value) {
+
+ version_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Api.version)
+}
+#endif
inline void Api::set_version(const char* value) {
version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -611,7 +672,7 @@ inline void Api::set_allocated_version(::std::string* version) {
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.version)
}
-// optional .google.protobuf.SourceContext source_context = 5;
+// .google.protobuf.SourceContext source_context = 5;
inline bool Api::has_source_context() const {
return this != internal_default_instance() && source_context_ != NULL;
}
@@ -680,7 +741,7 @@ Api::mixins() const {
return mixins_;
}
-// optional .google.protobuf.Syntax syntax = 7;
+// .google.protobuf.Syntax syntax = 7;
inline void Api::clear_syntax() {
syntax_ = 0;
}
@@ -694,26 +755,31 @@ inline void Api::set_syntax(::google::protobuf::Syntax value) {
// @@protoc_insertion_point(field_set:google.protobuf.Api.syntax)
}
-inline const Api* Api::internal_default_instance() {
- return &Api_default_instance_.get();
-}
// -------------------------------------------------------------------
// Method
-// optional string name = 1;
+// string name = 1;
inline void Method::clear_name() {
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline const ::std::string& Method::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.Method.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.GetNoArena();
}
inline void Method::set_name(const ::std::string& value) {
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.Method.name)
}
+#if LANG_CXX11
+inline void Method::set_name(::std::string&& value) {
+
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.name)
+}
+#endif
inline void Method::set_name(const char* value) {
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -745,19 +811,27 @@ inline void Method::set_allocated_name(::std::string* name) {
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.name)
}
-// optional string request_type_url = 2;
+// string request_type_url = 2;
inline void Method::clear_request_type_url() {
request_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline const ::std::string& Method::request_type_url() const {
// @@protoc_insertion_point(field_get:google.protobuf.Method.request_type_url)
- return request_type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return request_type_url_.GetNoArena();
}
inline void Method::set_request_type_url(const ::std::string& value) {
request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.Method.request_type_url)
}
+#if LANG_CXX11
+inline void Method::set_request_type_url(::std::string&& value) {
+
+ request_type_url_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.request_type_url)
+}
+#endif
inline void Method::set_request_type_url(const char* value) {
request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -789,7 +863,7 @@ inline void Method::set_allocated_request_type_url(::std::string* request_type_u
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.request_type_url)
}
-// optional bool request_streaming = 3;
+// bool request_streaming = 3;
inline void Method::clear_request_streaming() {
request_streaming_ = false;
}
@@ -803,19 +877,27 @@ inline void Method::set_request_streaming(bool value) {
// @@protoc_insertion_point(field_set:google.protobuf.Method.request_streaming)
}
-// optional string response_type_url = 4;
+// string response_type_url = 4;
inline void Method::clear_response_type_url() {
response_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline const ::std::string& Method::response_type_url() const {
// @@protoc_insertion_point(field_get:google.protobuf.Method.response_type_url)
- return response_type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return response_type_url_.GetNoArena();
}
inline void Method::set_response_type_url(const ::std::string& value) {
response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.Method.response_type_url)
}
+#if LANG_CXX11
+inline void Method::set_response_type_url(::std::string&& value) {
+
+ response_type_url_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Method.response_type_url)
+}
+#endif
inline void Method::set_response_type_url(const char* value) {
response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -847,7 +929,7 @@ inline void Method::set_allocated_response_type_url(::std::string* response_type
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.response_type_url)
}
-// optional bool response_streaming = 5;
+// bool response_streaming = 5;
inline void Method::clear_response_streaming() {
response_streaming_ = false;
}
@@ -891,7 +973,7 @@ Method::options() const {
return options_;
}
-// optional .google.protobuf.Syntax syntax = 7;
+// .google.protobuf.Syntax syntax = 7;
inline void Method::clear_syntax() {
syntax_ = 0;
}
@@ -905,26 +987,31 @@ inline void Method::set_syntax(::google::protobuf::Syntax value) {
// @@protoc_insertion_point(field_set:google.protobuf.Method.syntax)
}
-inline const Method* Method::internal_default_instance() {
- return &Method_default_instance_.get();
-}
// -------------------------------------------------------------------
// Mixin
-// optional string name = 1;
+// string name = 1;
inline void Mixin::clear_name() {
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline const ::std::string& Mixin::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.Mixin.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.GetNoArena();
}
inline void Mixin::set_name(const ::std::string& value) {
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.Mixin.name)
}
+#if LANG_CXX11
+inline void Mixin::set_name(::std::string&& value) {
+
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Mixin.name)
+}
+#endif
inline void Mixin::set_name(const char* value) {
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -956,19 +1043,27 @@ inline void Mixin::set_allocated_name(::std::string* name) {
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.name)
}
-// optional string root = 2;
+// string root = 2;
inline void Mixin::clear_root() {
root_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline const ::std::string& Mixin::root() const {
// @@protoc_insertion_point(field_get:google.protobuf.Mixin.root)
- return root_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return root_.GetNoArena();
}
inline void Mixin::set_root(const ::std::string& value) {
root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.Mixin.root)
}
+#if LANG_CXX11
+inline void Mixin::set_root(::std::string&& value) {
+
+ root_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.Mixin.root)
+}
+#endif
inline void Mixin::set_root(const char* value) {
root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -1000,9 +1095,6 @@ inline void Mixin::set_allocated_root(::std::string* root) {
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.root)
}
-inline const Mixin* Mixin::internal_default_instance() {
- return &Mixin_default_instance_.get();
-}
#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS
// -------------------------------------------------------------------
@@ -1011,6 +1103,7 @@ inline const Mixin* Mixin::internal_default_instance() {
// @@protoc_insertion_point(namespace_scope)
+
} // namespace protobuf
} // namespace google
diff --git a/src/google/protobuf/api.proto b/src/google/protobuf/api.proto
index bbbe9833..7c30e8b7 100644
--- a/src/google/protobuf/api.proto
+++ b/src/google/protobuf/api.proto
@@ -40,6 +40,7 @@ option java_package = "com.google.protobuf";
option java_outer_classname = "ApiProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
+option go_package = "google.golang.org/genproto/protobuf/api;api";
// Api is a light-weight descriptor for a protocol buffer service.
message Api {
diff --git a/src/google/protobuf/arena.cc b/src/google/protobuf/arena.cc
index aa4e587c..16cf8951 100755
--- a/src/google/protobuf/arena.cc
+++ b/src/google/protobuf/arena.cc
@@ -36,7 +36,7 @@
#ifdef ADDRESS_SANITIZER
#include <sanitizer/asan_interface.h>
-#endif
+#endif // ADDRESS_SANITIZER
namespace google {
namespace protobuf {
@@ -62,6 +62,7 @@ void Arena::Init() {
lifecycle_id_ = lifecycle_id_generator_.GetNext();
blocks_ = 0;
hint_ = 0;
+ space_allocated_ = 0;
owns_first_block_ = true;
cleanup_list_ = 0;
@@ -141,7 +142,7 @@ Arena::Block* Arena::NewBlock(void* me, Block* my_last_block, size_t n,
// malloc but it's not yet usable until we return it as part of an allocation.
ASAN_POISON_MEMORY_REGION(
reinterpret_cast<char*>(b) + b->pos, b->size - b->pos);
-#endif
+#endif // ADDRESS_SANITIZER
return b;
}
@@ -157,6 +158,7 @@ void Arena::AddBlockInternal(Block* b) {
// Direct future allocations to this block.
google::protobuf::internal::Release_Store(&hint_, reinterpret_cast<google::protobuf::internal::AtomicWord>(b));
}
+ space_allocated_ += b->size;
}
void Arena::AddListNode(void* elem, void (*cleanup)(void*)) {
@@ -205,7 +207,7 @@ void* Arena::AllocFromBlock(Block* b, size_t n) {
b->pos = p + n;
#ifdef ADDRESS_SANITIZER
ASAN_UNPOISON_MEMORY_REGION(reinterpret_cast<char*>(b) + p, n);
-#endif
+#endif // ADDRESS_SANITIZER
return reinterpret_cast<char*>(b) + p;
}
@@ -225,13 +227,8 @@ void* Arena::SlowAlloc(size_t n) {
}
uint64 Arena::SpaceAllocated() const {
- uint64 space_allocated = 0;
- Block* b = reinterpret_cast<Block*>(google::protobuf::internal::NoBarrier_Load(&blocks_));
- while (b != NULL) {
- space_allocated += (b->size);
- b = b->next;
- }
- return space_allocated;
+ MutexLock l(&blocks_lock_);
+ return space_allocated_;
}
uint64 Arena::SpaceUsed() const {
@@ -244,17 +241,8 @@ uint64 Arena::SpaceUsed() const {
return space_used;
}
-pair<uint64, uint64> Arena::SpaceAllocatedAndUsed() const {
- uint64 allocated = 0;
- uint64 used = 0;
-
- Block* b = reinterpret_cast<Block*>(google::protobuf::internal::NoBarrier_Load(&blocks_));
- while (b != NULL) {
- allocated += b->size;
- used += (b->pos - kHeaderSize);
- b = b->next;
- }
- return std::make_pair(allocated, used);
+std::pair<uint64, uint64> Arena::SpaceAllocatedAndUsed() const {
+ return std::make_pair(SpaceAllocated(), SpaceUsed());
}
uint64 Arena::FreeBlocks() {
@@ -265,9 +253,19 @@ uint64 Arena::FreeBlocks() {
space_allocated += (b->size);
Block* next = b->next;
if (next != NULL) {
+#ifdef ADDRESS_SANITIZER
+ // This memory was provided by the underlying allocator as unpoisoned, so
+ // return it in an unpoisoned state.
+ ASAN_UNPOISON_MEMORY_REGION(reinterpret_cast<char*>(b), b->size);
+#endif // ADDRESS_SANITIZER
options_.block_dealloc(b, b->size);
} else {
if (owns_first_block_) {
+#ifdef ADDRESS_SANITIZER
+ // This memory was provided by the underlying allocator as unpoisoned,
+ // so return it in an unpoisoned state.
+ ASAN_UNPOISON_MEMORY_REGION(reinterpret_cast<char*>(b), b->size);
+#endif // ADDRESS_SANITIZER
options_.block_dealloc(b, b->size);
} else {
// User passed in the first block, skip free'ing the memory.
@@ -278,6 +276,7 @@ uint64 Arena::FreeBlocks() {
}
blocks_ = 0;
hint_ = 0;
+ space_allocated_ = 0;
if (!owns_first_block_) {
// Make the first block that was passed in through ArenaOptions
// available for reuse.
diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h
index 87066507..05e05ebc 100644
--- a/src/google/protobuf/arena.h
+++ b/src/google/protobuf/arena.h
@@ -322,6 +322,17 @@ class LIBPROTOBUF_EXPORT Arena {
arg);
}
}
+#if LANG_CXX11
+ template <typename T, typename Arg> GOOGLE_ATTRIBUTE_ALWAYS_INLINE
+ static T* Create(::google::protobuf::Arena* arena, Arg&& arg) {
+ if (arena == NULL) {
+ return new T(std::move(arg));
+ } else {
+ return arena->CreateInternal<T>(google::protobuf::internal::has_trivial_destructor<T>::value,
+ std::move(arg));
+ }
+ }
+#endif
// Version of the above with two constructor arguments for the created object.
template <typename T, typename Arg1, typename Arg2> GOOGLE_ATTRIBUTE_ALWAYS_INLINE
@@ -449,14 +460,17 @@ class LIBPROTOBUF_EXPORT Arena {
}
}
- // Returns the total space used by the arena, which is the sums of the sizes
- // of the underlying blocks. The total space used may not include the new
- // blocks that are allocated by this arena from other threads concurrently
- // with the call to this method.
- GOOGLE_ATTRIBUTE_NOINLINE uint64 SpaceAllocated() const;
- // As above, but does not include any free space in underlying blocks.
+ // Returns the total space allocated by the arena, which is the sum of the
+ // sizes of the underlying blocks. This method is relatively fast; a counter
+ // is kept as blocks are allocated.
+ uint64 SpaceAllocated() const;
+ // Returns the total space used by the arena. Similar to SpaceAllocated but
+ // does not include free space and block overhead. The total space returned
+ // may not include space used by other threads executing concurrently with
+ // the call to this method.
GOOGLE_ATTRIBUTE_NOINLINE uint64 SpaceUsed() const;
-
+ // DEPRECATED. Please use SpaceAllocated() and SpaceUsed().
+ //
// Combines SpaceAllocated and SpaceUsed. Returns a pair of
// <space_allocated, space_used>.
GOOGLE_ATTRIBUTE_NOINLINE std::pair<uint64, uint64> SpaceAllocatedAndUsed() const;
@@ -659,6 +673,18 @@ class LIBPROTOBUF_EXPORT Arena {
return t;
}
+#if LANG_CXX11
+ template <typename T, typename Arg> GOOGLE_ATTRIBUTE_ALWAYS_INLINE
+ T* CreateInternal(bool skip_explicit_ownership, Arg&& arg) {
+ T* t = new (AllocateAligned(RTTI_TYPE_ID(T), sizeof(T))) T(
+ std::move(arg));
+ if (!skip_explicit_ownership) {
+ AddListNode(t, &internal::arena_destruct_object<T>);
+ }
+ return t;
+ }
+#endif
+
template <typename T, typename Arg1, typename Arg2> GOOGLE_ATTRIBUTE_ALWAYS_INLINE
T* CreateInternal(
bool skip_explicit_ownership, const Arg1& arg1, const Arg2& arg2) {
@@ -884,8 +910,9 @@ class LIBPROTOBUF_EXPORT Arena {
int64 lifecycle_id_; // Unique for each arena. Changes on Reset().
- google::protobuf::internal::AtomicWord blocks_; // Head of linked list of all allocated blocks
- google::protobuf::internal::AtomicWord hint_; // Fast thread-local block access
+ google::protobuf::internal::AtomicWord blocks_; // Head of linked list of all allocated blocks
+ google::protobuf::internal::AtomicWord hint_; // Fast thread-local block access
+ uint64 space_allocated_; // Sum of sizes of all allocated blocks.
// Node contains the ptr of the object to be cleaned up and the associated
// cleanup function ptr.
@@ -899,7 +926,7 @@ class LIBPROTOBUF_EXPORT Arena {
// ptrs and cleanup methods.
bool owns_first_block_; // Indicates that arena owns the first block
- Mutex blocks_lock_;
+ mutable Mutex blocks_lock_;
void AddBlock(Block* b);
// Access must be synchronized, either by blocks_lock_ or by being called from
diff --git a/src/google/protobuf/arena_test_util.h b/src/google/protobuf/arena_test_util.h
index 690cc706..8c9f7698 100644
--- a/src/google/protobuf/arena_test_util.h
+++ b/src/google/protobuf/arena_test_util.h
@@ -31,9 +31,40 @@
#ifndef GOOGLE_PROTOBUF_ARENA_TEST_UTIL_H__
#define GOOGLE_PROTOBUF_ARENA_TEST_UTIL_H__
+#include <google/protobuf/stubs/logging.h>
+#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/arena.h>
namespace google {
namespace protobuf {
+
+template <typename T, bool use_arena>
+void TestParseCorruptedString(const T& message) {
+ int success_count = 0;
+ string s = message.SerializeAsString();
+ const int kMaxIters = 900;
+ const int stride = s.size() <= kMaxIters ? 1 : s.size() / kMaxIters;
+ const int start = stride == 1 || use_arena ? 0 : (stride + 1) / 2;
+ for (int i = start; i < s.size(); i += stride) {
+ for (int c = 1 + (i % 17); c < 256; c += 2 * c + (i & 3)) {
+ s[i] ^= c;
+ google::protobuf::Arena arena;
+ T* message =
+ google::protobuf::Arena::CreateMessage<T>(use_arena ? &arena : NULL);
+ if (message->ParseFromString(s)) {
+ ++success_count;
+ }
+ if (!use_arena) {
+ delete message;
+ }
+ s[i] ^= c; // Restore s to its original state.
+ }
+ }
+ // This next line is a low bar. But getting through the test without crashing
+ // due to use-after-free or other bugs is a big part of what we're checking.
+ GOOGLE_CHECK_GT(success_count, 0);
+}
+
namespace internal {
class NoHeapChecker {
diff --git a/src/google/protobuf/arena_unittest.cc b/src/google/protobuf/arena_unittest.cc
index 35d00463..4f9571db 100644
--- a/src/google/protobuf/arena_unittest.cc
+++ b/src/google/protobuf/arena_unittest.cc
@@ -249,7 +249,7 @@ TEST(ArenaTest, Parsing) {
arena_message->ParseFromString(original.SerializeAsString());
TestUtil::ExpectAllFieldsSet(*arena_message);
- // Test that string fields have null terminator bytes (earlier bug).
+ // Test that string fields have nul terminator bytes (earlier bug).
EXPECT_EQ(strlen(original.optional_string().c_str()),
strlen(arena_message->optional_string().c_str()));
}
@@ -1154,6 +1154,13 @@ TEST(ArenaTest, NoHeapAllocationsTest) {
arena.Reset();
}
+TEST(ArenaTest, ParseCorruptedString) {
+ TestAllTypes message;
+ TestUtil::SetAllFields(&message);
+ TestParseCorruptedString<TestAllTypes, true>(message);
+ TestParseCorruptedString<TestAllTypes, false>(message);
+}
+
#ifndef GOOGLE_PROTOBUF_NO_RTTI
// Test construction on an arena via generic MessageLite interface. We should be
// able to successfully deserialize on the arena without incurring heap
diff --git a/src/google/protobuf/arenastring.cc b/src/google/protobuf/arenastring.cc
index cce61d74..f10732c0 100644
--- a/src/google/protobuf/arenastring.cc
+++ b/src/google/protobuf/arenastring.cc
@@ -44,7 +44,7 @@ void ArenaStringPtr::AssignWithDefault(const ::std::string* default_value,
const ::std::string* other = *value.UnsafeRawStringPointer();
// If the pointers are the same then do nothing.
if (me != other) {
- SetNoArena(default_value, value.GetNoArena(default_value));
+ SetNoArena(default_value, value.GetNoArena());
}
}
diff --git a/src/google/protobuf/arenastring.h b/src/google/protobuf/arenastring.h
index 590ffce9..a7efb752 100755
--- a/src/google/protobuf/arenastring.h
+++ b/src/google/protobuf/arenastring.h
@@ -37,7 +37,6 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/fastmem.h>
#include <google/protobuf/arena.h>
-#include <google/protobuf/generated_message_util.h>
@@ -64,9 +63,7 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr {
}
// Basic accessors.
- inline const ::std::string& Get(const ::std::string* /* default_value */) const {
- return *ptr_;
- }
+ inline const ::std::string& Get() const { return *ptr_; }
inline ::std::string* Mutable(const ::std::string* default_value,
::google::protobuf::Arena* arena) {
@@ -150,13 +147,12 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr {
std::swap(ptr_, other->ptr_);
}
- // Frees storage (if not on an arena) and sets field to default value.
+ // Frees storage (if not on an arena).
inline void Destroy(const ::std::string* default_value,
::google::protobuf::Arena* arena) {
if (arena == NULL && ptr_ != default_value) {
delete ptr_;
}
- ptr_ = const_cast< ::std::string* >(default_value);
}
// Clears content, but keeps allocated string if arena != NULL, to avoid the
@@ -214,11 +210,19 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr {
}
}
+#if LANG_CXX11
+ void SetNoArena(const ::std::string* default_value, ::std::string&& value) {
+ if (IsDefault(default_value)) {
+ ptr_ = new ::std::string(std::move(value));
+ } else {
+ *ptr_ = std::move(value);
+ }
+ }
+#endif
+
void AssignWithDefault(const ::std::string* default_value, ArenaStringPtr value);
- inline const ::std::string& GetNoArena(const ::std::string* /* default_value */) const {
- return *ptr_;
- }
+ inline const ::std::string& GetNoArena() const { return *ptr_; }
inline ::std::string* MutableNoArena(const ::std::string* default_value) {
if (ptr_ == default_value) {
@@ -253,7 +257,6 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr {
if (ptr_ != default_value) {
delete ptr_;
}
- ptr_ = NULL;
}
inline void ClearToEmptyNoArena(const ::std::string* default_value) {
@@ -281,27 +284,24 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr {
return &ptr_;
}
+ inline bool IsDefault(const ::std::string* default_value) const {
+ return ptr_ == default_value;
+ }
+
private:
::std::string* ptr_;
GOOGLE_ATTRIBUTE_NOINLINE void CreateInstance(::google::protobuf::Arena* arena,
const ::std::string* initial_value) {
- // Assumes ptr_ is not NULL.
- if (initial_value != NULL) {
- ptr_ = new ::std::string(*initial_value);
- } else {
- ptr_ = new ::std::string();
- }
+ GOOGLE_DCHECK(initial_value != NULL);
+ ptr_ = new ::std::string(*initial_value);
if (arena != NULL) {
arena->Own(ptr_);
}
}
GOOGLE_ATTRIBUTE_NOINLINE void CreateInstanceNoArena(const ::std::string* initial_value) {
- if (initial_value != NULL) {
- ptr_ = new ::std::string(*initial_value);
- } else {
- ptr_ = new ::std::string();
- }
+ GOOGLE_DCHECK(initial_value != NULL);
+ ptr_ = new ::std::string(*initial_value);
}
};
diff --git a/src/google/protobuf/arenastring_unittest.cc b/src/google/protobuf/arenastring_unittest.cc
index ea405d7d..e5afe42d 100644
--- a/src/google/protobuf/arenastring_unittest.cc
+++ b/src/google/protobuf/arenastring_unittest.cc
@@ -59,11 +59,11 @@ TEST(ArenaStringPtrTest, ArenaStringPtrOnHeap) {
ArenaStringPtr field;
::std::string default_value = "default";
field.UnsafeSetDefault(&default_value);
- EXPECT_EQ(string("default"), field.Get(&default_value));
+ EXPECT_EQ(string("default"), field.Get());
field.Set(&default_value, WrapString("Test short"), NULL);
- EXPECT_EQ(string("Test short"), field.Get(&default_value));
+ EXPECT_EQ(string("Test short"), field.Get());
field.Set(&default_value, WrapString("Test long long long long value"), NULL);
- EXPECT_EQ(string("Test long long long long value"), field.Get(&default_value));
+ EXPECT_EQ(string("Test long long long long value"), field.Get());
field.Set(&default_value, string(""), NULL);
field.Destroy(&default_value, NULL);
@@ -71,11 +71,11 @@ TEST(ArenaStringPtrTest, ArenaStringPtrOnHeap) {
field2.UnsafeSetDefault(&default_value);
::std::string* mut = field2.Mutable(&default_value, NULL);
EXPECT_EQ(mut, field2.Mutable(&default_value, NULL));
- EXPECT_EQ(mut, &field2.Get(&default_value));
+ EXPECT_EQ(mut, &field2.Get());
EXPECT_NE(&default_value, mut);
EXPECT_EQ(string("default"), *mut);
*mut = "Test long long long long value"; // ensure string allocates storage
- EXPECT_EQ(string("Test long long long long value"), field2.Get(&default_value));
+ EXPECT_EQ(string("Test long long long long value"), field2.Get());
field2.Destroy(&default_value, NULL);
}
@@ -84,12 +84,11 @@ TEST(ArenaStringPtrTest, ArenaStringPtrOnArena) {
ArenaStringPtr field;
::std::string default_value = "default";
field.UnsafeSetDefault(&default_value);
- EXPECT_EQ(string("default"), field.Get(&default_value));
+ EXPECT_EQ(string("default"), field.Get());
field.Set(&default_value, WrapString("Test short"), &arena);
- EXPECT_EQ(string("Test short"), field.Get(&default_value));
+ EXPECT_EQ(string("Test short"), field.Get());
field.Set(&default_value, WrapString("Test long long long long value"), &arena);
- EXPECT_EQ(string("Test long long long long value"),
- field.Get(&default_value));
+ EXPECT_EQ(string("Test long long long long value"), field.Get());
field.Set(&default_value, string(""), &arena);
field.Destroy(&default_value, &arena);
@@ -97,12 +96,11 @@ TEST(ArenaStringPtrTest, ArenaStringPtrOnArena) {
field2.UnsafeSetDefault(&default_value);
::std::string* mut = field2.Mutable(&default_value, &arena);
EXPECT_EQ(mut, field2.Mutable(&default_value, &arena));
- EXPECT_EQ(mut, &field2.Get(&default_value));
+ EXPECT_EQ(mut, &field2.Get());
EXPECT_NE(&default_value, mut);
EXPECT_EQ(string("default"), *mut);
*mut = "Test long long long long value"; // ensure string allocates storage
- EXPECT_EQ(string("Test long long long long value"),
- field2.Get(&default_value));
+ EXPECT_EQ(string("Test long long long long value"), field2.Get());
field2.Destroy(&default_value, &arena);
}
diff --git a/src/google/protobuf/compiler/code_generator.cc b/src/google/protobuf/compiler/code_generator.cc
index f6ff1e5d..11d0f334 100644
--- a/src/google/protobuf/compiler/code_generator.cc
+++ b/src/google/protobuf/compiler/code_generator.cc
@@ -34,6 +34,7 @@
#include <google/protobuf/compiler/code_generator.h>
+#include <google/protobuf/compiler/plugin.pb.h>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/descriptor.h>
@@ -46,7 +47,7 @@ namespace compiler {
CodeGenerator::~CodeGenerator() {}
bool CodeGenerator::GenerateAll(
- const vector<const FileDescriptor*>& files,
+ const std::vector<const FileDescriptor*>& files,
const string& parameter,
GeneratorContext* generator_context,
string* error) const {
@@ -85,18 +86,25 @@ io::ZeroCopyOutputStream* GeneratorContext::OpenForInsert(
}
void GeneratorContext::ListParsedFiles(
- vector<const FileDescriptor*>* output) {
+ std::vector<const FileDescriptor*>* output) {
GOOGLE_LOG(FATAL) << "This GeneratorContext does not support ListParsedFiles";
}
+void GeneratorContext::GetCompilerVersion(Version* version) const {
+ version->set_major(GOOGLE_PROTOBUF_VERSION / 1000000);
+ version->set_minor(GOOGLE_PROTOBUF_VERSION / 1000 % 1000);
+ version->set_patch(GOOGLE_PROTOBUF_VERSION % 1000);
+ version->set_suffix(GOOGLE_PROTOBUF_VERSION_SUFFIX);
+}
+
// Parses a set of comma-delimited name/value pairs.
void ParseGeneratorParameter(const string& text,
- vector<pair<string, string> >* output) {
- vector<string> parts = Split(text, ",", true);
+ std::vector<std::pair<string, string> >* output) {
+ std::vector<string> parts = Split(text, ",", true);
for (int i = 0; i < parts.size(); i++) {
string::size_type equals_pos = parts[i].find_first_of('=');
- pair<string, string> value;
+ std::pair<string, string> value;
if (equals_pos == string::npos) {
value.first = parts[i];
value.second = "";
diff --git a/src/google/protobuf/compiler/code_generator.h b/src/google/protobuf/compiler/code_generator.h
index 642bbfad..e2b2a661 100644
--- a/src/google/protobuf/compiler/code_generator.h
+++ b/src/google/protobuf/compiler/code_generator.h
@@ -50,6 +50,7 @@ namespace io { class ZeroCopyOutputStream; }
class FileDescriptor;
namespace compiler {
+class Version;
// Defined in this file.
class CodeGenerator;
@@ -90,7 +91,7 @@ class LIBPROTOC_EXPORT CodeGenerator {
//
// Returns true if successful. Otherwise, sets *error to a description of
// the problem (e.g. "invalid parameter") and returns false.
- virtual bool GenerateAll(const vector<const FileDescriptor*>& files,
+ virtual bool GenerateAll(const std::vector<const FileDescriptor*>& files,
const string& parameter,
GeneratorContext* generator_context,
string* error) const;
@@ -141,7 +142,11 @@ class LIBPROTOC_EXPORT GeneratorContext {
// Returns a vector of FileDescriptors for all the files being compiled
// in this run. Useful for languages, such as Go, that treat files
// differently when compiled as a set rather than individually.
- virtual void ListParsedFiles(vector<const FileDescriptor*>* output);
+ virtual void ListParsedFiles(std::vector<const FileDescriptor*>* output);
+
+ // Retrieves the version number of the protocol compiler associated with
+ // this GeneratorContext.
+ virtual void GetCompilerVersion(Version* version) const;
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GeneratorContext);
@@ -157,8 +162,8 @@ typedef GeneratorContext OutputDirectory;
// "foo=bar,baz,qux=corge"
// parses to the pairs:
// ("foo", "bar"), ("baz", ""), ("qux", "corge")
-extern void ParseGeneratorParameter(const string&,
- vector<pair<string, string> >*);
+extern void LIBPROTOC_EXPORT ParseGeneratorParameter(const string&,
+ std::vector<std::pair<string, string> >*);
} // namespace compiler
} // namespace protobuf
diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc
index 8ab69d02..0c9b1fb5 100644
--- a/src/google/protobuf/compiler/command_line_interface.cc
+++ b/src/google/protobuf/compiler/command_line_interface.cc
@@ -116,6 +116,9 @@ static const char* kPathSeparator = ";";
static const char* kPathSeparator = ":";
#endif
+static const char* kDefaultDirectDependenciesViolationMsg =
+ "File is imported but not declared in --direct_dependencies: %s";
+
// Returns true if the text looks like a Windows-style absolute path, starting
// with a drive letter. Example: "C:\foo". TODO(kenton): Share this with
// copy in importer.cc?
@@ -173,7 +176,8 @@ bool VerifyDirectoryExists(const string& path) {
// directories listed in |filename|.
bool TryCreateParentDirectory(const string& prefix, const string& filename) {
// Recursively create parent directories to the output file.
- vector<string> parts = Split(filename, "/", true);
+ std::vector<string> parts =
+ Split(filename, "/", true);
string path_so_far = prefix;
for (int i = 0; i < parts.size() - 1; i++) {
path_so_far += parts[i];
@@ -275,12 +279,13 @@ class CommandLineInterface::ErrorPrinter : public MultiFileErrorCollector,
public io::ErrorCollector {
public:
ErrorPrinter(ErrorFormat format, DiskSourceTree *tree = NULL)
- : format_(format), tree_(tree) {}
+ : format_(format), tree_(tree), found_errors_(false) {}
~ErrorPrinter() {}
// implements MultiFileErrorCollector ------------------------------
void AddError(const string& filename, int line, int column,
const string& message) {
+ found_errors_ = true;
AddErrorOrWarning(filename, line, column, message, "error", std::cerr);
}
@@ -298,10 +303,12 @@ class CommandLineInterface::ErrorPrinter : public MultiFileErrorCollector,
AddErrorOrWarning("input", line, column, message, "warning", std::clog);
}
+ bool FoundErrors() const { return found_errors_; }
+
private:
- void AddErrorOrWarning(
- const string& filename, int line, int column,
- const string& message, const string& type, ostream& out) {
+ void AddErrorOrWarning(const string& filename, int line, int column,
+ const string& message, const string& type,
+ std::ostream& out) {
// Print full path when running under MSVS
string dfile;
if (format_ == CommandLineInterface::ERROR_FORMAT_MSVS &&
@@ -336,6 +343,7 @@ class CommandLineInterface::ErrorPrinter : public MultiFileErrorCollector,
const ErrorFormat format_;
DiskSourceTree *tree_;
+ bool found_errors_;
};
// -------------------------------------------------------------------
@@ -344,7 +352,7 @@ class CommandLineInterface::ErrorPrinter : public MultiFileErrorCollector,
// them all to disk on demand.
class CommandLineInterface::GeneratorContextImpl : public GeneratorContext {
public:
- GeneratorContextImpl(const vector<const FileDescriptor*>& parsed_files);
+ GeneratorContextImpl(const std::vector<const FileDescriptor*>& parsed_files);
~GeneratorContextImpl();
// Write all files in the directory to disk at the given output location,
@@ -360,14 +368,14 @@ class CommandLineInterface::GeneratorContextImpl : public GeneratorContext {
void AddJarManifest();
// Get name of all output files.
- void GetOutputFilenames(vector<string>* output_filenames);
+ void GetOutputFilenames(std::vector<string>* output_filenames);
// implements GeneratorContext --------------------------------------
io::ZeroCopyOutputStream* Open(const string& filename);
io::ZeroCopyOutputStream* OpenForAppend(const string& filename);
io::ZeroCopyOutputStream* OpenForInsert(
const string& filename, const string& insertion_point);
- void ListParsedFiles(vector<const FileDescriptor*>* output) {
+ void ListParsedFiles(std::vector<const FileDescriptor*>* output) {
*output = parsed_files_;
}
@@ -376,8 +384,8 @@ class CommandLineInterface::GeneratorContextImpl : public GeneratorContext {
// map instead of hash_map so that files are written in order (good when
// writing zips).
- map<string, string*> files_;
- const vector<const FileDescriptor*>& parsed_files_;
+ std::map<string, string*> files_;
+ const std::vector<const FileDescriptor*>& parsed_files_;
bool had_error_;
};
@@ -414,7 +422,7 @@ class CommandLineInterface::MemoryOutputStream
// -------------------------------------------------------------------
CommandLineInterface::GeneratorContextImpl::GeneratorContextImpl(
- const vector<const FileDescriptor*>& parsed_files)
+ const std::vector<const FileDescriptor*>& parsed_files)
: parsed_files_(parsed_files),
had_error_(false) {
}
@@ -433,7 +441,7 @@ bool CommandLineInterface::GeneratorContextImpl::WriteAllToDisk(
return false;
}
- for (map<string, string*>::const_iterator iter = files_.begin();
+ for (std::map<string, string*>::const_iterator iter = files_.begin();
iter != files_.end(); ++iter) {
const string& relative_filename = iter->first;
const char* data = iter->second->data();
@@ -521,7 +529,7 @@ bool CommandLineInterface::GeneratorContextImpl::WriteAllToZip(
io::FileOutputStream stream(file_descriptor);
ZipWriter zip_writer(&stream);
- for (map<string, string*>::const_iterator iter = files_.begin();
+ for (std::map<string, string*>::const_iterator iter = files_.begin();
iter != files_.end(); ++iter) {
zip_writer.Write(iter->first, *iter->second);
}
@@ -550,8 +558,8 @@ void CommandLineInterface::GeneratorContextImpl::AddJarManifest() {
}
void CommandLineInterface::GeneratorContextImpl::GetOutputFilenames(
- vector<string>* output_filenames) {
- for (map<string, string*>::iterator iter = files_.begin();
+ std::vector<string>* output_filenames) {
+ for (std::map<string, string*>::iterator iter = files_.begin();
iter != files_.end(); ++iter) {
output_filenames->push_back(iter->first);
}
@@ -707,14 +715,17 @@ CommandLineInterface::MemoryOutputStream::~MemoryOutputStream() {
// ===================================================================
CommandLineInterface::CommandLineInterface()
- : mode_(MODE_COMPILE),
- print_mode_(PRINT_NONE),
- error_format_(ERROR_FORMAT_GCC),
- direct_dependencies_explicitly_set_(false),
- imports_in_descriptor_set_(false),
- source_info_in_descriptor_set_(false),
- disallow_services_(false),
- inputs_are_proto_path_relative_(false) {}
+ : mode_(MODE_COMPILE),
+ print_mode_(PRINT_NONE),
+ error_format_(ERROR_FORMAT_GCC),
+ direct_dependencies_explicitly_set_(false),
+ direct_dependencies_violation_msg_(
+ kDefaultDirectDependenciesViolationMsg),
+ imports_in_descriptor_set_(false),
+ source_info_in_descriptor_set_(false),
+ disallow_services_(false),
+ inputs_are_proto_path_relative_(false) {
+}
CommandLineInterface::~CommandLineInterface() {}
void CommandLineInterface::RegisterGenerator(const string& flag_name,
@@ -774,7 +785,7 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
ErrorPrinter error_collector(error_format_, &source_tree);
Importer importer(&source_tree, &error_collector);
- vector<const FileDescriptor*> parsed_files;
+ std::vector<const FileDescriptor*> parsed_files;
// Parse each file.
for (int i = 0; i < input_files_.size(); i++) {
@@ -799,10 +810,11 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
if (direct_dependencies_.find(parsed_file->dependency(i)->name()) ==
direct_dependencies_.end()) {
indirect_imports = true;
- cerr << parsed_file->name()
- << ": File is imported but not declared in "
- << "--direct_dependencies: "
- << parsed_file->dependency(i)->name() << std::endl;
+ cerr << parsed_file->name() << ": "
+ << StringReplace(direct_dependencies_violation_msg_, "%s",
+ parsed_file->dependency(i)->name(),
+ true /* replace_all */)
+ << std::endl;
}
}
if (indirect_imports) {
@@ -894,6 +906,10 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
}
}
+ if (error_collector.FoundErrors()) {
+ return 1;
+ }
+
if (mode_ == MODE_PRINT) {
switch (print_mode_) {
case PRINT_FREE_FIELDS:
@@ -923,6 +939,7 @@ void CommandLineInterface::Clear() {
proto_path_.clear();
input_files_.clear();
direct_dependencies_.clear();
+ direct_dependencies_violation_msg_ = kDefaultDirectDependenciesViolationMsg;
output_directives_.clear();
codec_type_.clear();
descriptor_set_name_.clear();
@@ -984,7 +1001,7 @@ CommandLineInterface::ParseArgumentStatus
CommandLineInterface::ParseArguments(int argc, const char* const argv[]) {
executable_name_ = argv[0];
- vector<string> arguments;
+ std::vector<string> arguments;
for (int i = 1; i < argc; ++i) {
arguments.push_back(argv[i]);
}
@@ -1014,23 +1031,41 @@ CommandLineInterface::ParseArguments(int argc, const char* const argv[]) {
}
// Make sure each plugin option has a matching plugin output.
+ bool foundUnknownPluginOption = false;
for (map<string, string>::const_iterator i = plugin_parameters_.begin();
i != plugin_parameters_.end(); ++i) {
- if (plugins_.find(i->first) == plugins_.end()) {
+ if (plugins_.find(i->first) != plugins_.end()) {
+ continue;
+ }
+ bool foundImplicitPlugin = false;
+ for (std::vector<OutputDirective>::const_iterator j = output_directives_.cbegin();
+ j != output_directives_.cend(); ++j) {
+ if (j->generator == NULL) {
+ string plugin_name = PluginName(plugin_prefix_ , j->name);
+ if (plugin_name == i->first) {
+ foundImplicitPlugin = true;
+ break;
+ }
+ }
+ }
+ if (!foundImplicitPlugin) {
std::cerr << "Unknown flag: "
// strip prefix + "gen-" and add back "_opt"
<< "--" + i->first.substr(plugin_prefix_.size() + 4) + "_opt"
<< std::endl;
- return PARSE_ARGUMENT_FAIL;
+ foundUnknownPluginOption = true;
}
}
+ if (foundUnknownPluginOption) {
+ return PARSE_ARGUMENT_FAIL;
+ }
// If no --proto_path was given, use the current working directory.
if (proto_path_.empty()) {
// Don't use make_pair as the old/default standard library on Solaris
// doesn't support it without explicit template parameters, which are
// incompatible with C++0x's make_pair.
- proto_path_.push_back(pair<string, string>("", "."));
+ proto_path_.push_back(std::pair<string, string>("", "."));
}
// Check some errror cases.
@@ -1153,7 +1188,7 @@ CommandLineInterface::InterpretArgument(const string& name,
// Java's -classpath (and some other languages) delimits path components
// with colons. Let's accept that syntax too just to make things more
// intuitive.
- vector<string> parts = Split(
+ std::vector<string> parts = Split(
value, kPathSeparator, true);
for (int i = 0; i < parts.size(); i++) {
@@ -1190,22 +1225,27 @@ CommandLineInterface::InterpretArgument(const string& name,
// Don't use make_pair as the old/default standard library on Solaris
// doesn't support it without explicit template parameters, which are
// incompatible with C++0x's make_pair.
- proto_path_.push_back(pair<string, string>(virtual_path, disk_path));
+ proto_path_.push_back(std::pair<string, string>(virtual_path, disk_path));
}
} else if (name == "--direct_dependencies") {
if (direct_dependencies_explicitly_set_) {
std::cerr << name << " may only be passed once. To specify multiple "
"direct dependencies, pass them all as a single "
- "parameter separated by ':'." << std::endl;
+ "parameter separated by ':'."
+ << std::endl;
return PARSE_ARGUMENT_FAIL;
}
direct_dependencies_explicitly_set_ = true;
- vector<string> direct = Split(value, ":", true);
+ std::vector<string> direct = Split(
+ value, ":", true);
GOOGLE_DCHECK(direct_dependencies_.empty());
direct_dependencies_.insert(direct.begin(), direct.end());
+ } else if (name == "--direct_dependencies_violation_msg") {
+ direct_dependencies_violation_msg_ = value;
+
} else if (name == "-o" || name == "--descriptor_set_out") {
if (!descriptor_set_name_.empty()) {
std::cerr << name << " may only be passed once." << std::endl;
@@ -1476,7 +1516,7 @@ void CommandLineInterface::PrintHelpText() {
}
bool CommandLineInterface::GenerateOutput(
- const vector<const FileDescriptor*>& parsed_files,
+ const std::vector<const FileDescriptor*>& parsed_files,
const OutputDirective& output_directive,
GeneratorContext* generator_context) {
// Call the generator.
@@ -1522,12 +1562,12 @@ bool CommandLineInterface::GenerateOutput(
}
bool CommandLineInterface::GenerateDependencyManifestFile(
- const vector<const FileDescriptor*>& parsed_files,
+ const std::vector<const FileDescriptor*>& parsed_files,
const GeneratorContextMap& output_directories,
DiskSourceTree* source_tree) {
FileDescriptorSet file_set;
- set<const FileDescriptor*> already_seen;
+ std::set<const FileDescriptor*> already_seen;
for (int i = 0; i < parsed_files.size(); i++) {
GetTransitiveDependencies(parsed_files[i],
false,
@@ -1536,12 +1576,12 @@ bool CommandLineInterface::GenerateDependencyManifestFile(
file_set.mutable_file());
}
- vector<string> output_filenames;
+ std::vector<string> output_filenames;
for (GeneratorContextMap::const_iterator iter = output_directories.begin();
iter != output_directories.end(); ++iter) {
const string& location = iter->first;
GeneratorContextImpl* directory = iter->second;
- vector<string> relative_output_filenames;
+ std::vector<string> relative_output_filenames;
directory->GetOutputFilenames(&relative_output_filenames);
for (int i = 0; i < relative_output_filenames.size(); i++) {
string output_filename = location + relative_output_filenames[i];
@@ -1594,7 +1634,7 @@ bool CommandLineInterface::GenerateDependencyManifestFile(
}
bool CommandLineInterface::GeneratePluginOutput(
- const vector<const FileDescriptor*>& parsed_files,
+ const std::vector<const FileDescriptor*>& parsed_files,
const string& plugin_name,
const string& parameter,
GeneratorContext* generator_context,
@@ -1607,7 +1647,7 @@ bool CommandLineInterface::GeneratePluginOutput(
request.set_parameter(parameter);
}
- set<const FileDescriptor*> already_seen;
+ std::set<const FileDescriptor*> already_seen;
for (int i = 0; i < parsed_files.size(); i++) {
request.add_file_to_generate(parsed_files[i]->name());
GetTransitiveDependencies(parsed_files[i],
@@ -1616,6 +1656,13 @@ bool CommandLineInterface::GeneratePluginOutput(
&already_seen, request.mutable_proto_file());
}
+ google::protobuf::compiler::Version* version =
+ request.mutable_compiler_version();
+ version->set_major(GOOGLE_PROTOBUF_VERSION / 1000000);
+ version->set_minor(GOOGLE_PROTOBUF_VERSION / 1000 % 1000);
+ version->set_patch(GOOGLE_PROTOBUF_VERSION % 1000);
+ version->set_suffix(GOOGLE_PROTOBUF_VERSION_SUFFIX);
+
// Invoke the plugin.
Subprocess subprocess;
@@ -1737,11 +1784,11 @@ bool CommandLineInterface::EncodeOrDecode(const DescriptorPool* pool) {
}
bool CommandLineInterface::WriteDescriptorSet(
- const vector<const FileDescriptor*> parsed_files) {
+ const std::vector<const FileDescriptor*> parsed_files) {
FileDescriptorSet file_set;
if (imports_in_descriptor_set_) {
- set<const FileDescriptor*> already_seen;
+ std::set<const FileDescriptor*> already_seen;
for (int i = 0; i < parsed_files.size(); i++) {
GetTransitiveDependencies(parsed_files[i],
true, // Include json_name
@@ -1749,7 +1796,7 @@ bool CommandLineInterface::WriteDescriptorSet(
&already_seen, file_set.mutable_file());
}
} else {
- set<const FileDescriptor*> already_seen;
+ std::set<const FileDescriptor*> already_seen;
for (int i = 0; i < parsed_files.size(); i++) {
if (!already_seen.insert(parsed_files[i]).second) {
continue;
@@ -1794,7 +1841,7 @@ void CommandLineInterface::GetTransitiveDependencies(
const FileDescriptor* file,
bool include_json_name,
bool include_source_code_info,
- set<const FileDescriptor*>* already_seen,
+ std::set<const FileDescriptor*>* already_seen,
RepeatedPtrField<FileDescriptorProto>* output) {
if (!already_seen->insert(file).second) {
// Already saw this file. Skip.
@@ -1853,11 +1900,11 @@ namespace {
// parameter will contain the direct children (when groups are ignored in the
// tree) of the given descriptor for the caller to traverse. The declaration
// order of the nested messages is also preserved.
-typedef pair<int, int> FieldRange;
-void GatherOccupiedFieldRanges(const Descriptor* descriptor,
- set<FieldRange>* ranges,
- vector<const Descriptor*>* nested_messages) {
- set<const Descriptor*> groups;
+typedef std::pair<int, int> FieldRange;
+void GatherOccupiedFieldRanges(
+ const Descriptor* descriptor, std::set<FieldRange>* ranges,
+ std::vector<const Descriptor*>* nested_messages) {
+ std::set<const Descriptor*> groups;
for (int i = 0; i < descriptor->field_count(); ++i) {
const FieldDescriptor* fd = descriptor->field(i);
ranges->insert(FieldRange(fd->number(), fd->number() + 1));
@@ -1889,11 +1936,11 @@ void GatherOccupiedFieldRanges(const Descriptor* descriptor,
// Actually prints the formatted free field numbers for given message name and
// occupied ranges.
void FormatFreeFieldNumbers(const string& name,
- const set<FieldRange>& ranges) {
+ const std::set<FieldRange>& ranges) {
string output;
StringAppendF(&output, "%-35s free:", name.c_str());
int next_free_number = 1;
- for (set<FieldRange>::const_iterator i = ranges.begin();
+ for (std::set<FieldRange>::const_iterator i = ranges.begin();
i != ranges.end(); ++i) {
// This happens when groups re-use parent field numbers, in which
// case we skip the FieldRange entirely.
@@ -1920,8 +1967,8 @@ void FormatFreeFieldNumbers(const string& name,
void CommandLineInterface::PrintFreeFieldNumbers(
const Descriptor* descriptor) {
- set<FieldRange> ranges;
- vector<const Descriptor*> nested_messages;
+ std::set<FieldRange> ranges;
+ std::vector<const Descriptor*> nested_messages;
GatherOccupiedFieldRanges(descriptor, &ranges, &nested_messages);
for (int i = 0; i < nested_messages.size(); ++i) {
diff --git a/src/google/protobuf/compiler/command_line_interface.h b/src/google/protobuf/compiler/command_line_interface.h
index d779fc87..8f8c2682 100644
--- a/src/google/protobuf/compiler/command_line_interface.h
+++ b/src/google/protobuf/compiler/command_line_interface.h
@@ -56,9 +56,7 @@ class FileDescriptorProto; // descriptor.pb.h
template<typename T> class RepeatedPtrField; // repeated_field.h
} // namespace protobuf
-} // namespace google
-namespace google {
namespace protobuf {
namespace compiler {
@@ -247,24 +245,24 @@ class LIBPROTOC_EXPORT CommandLineInterface {
// Generate the given output file from the given input.
struct OutputDirective; // see below
- bool GenerateOutput(const vector<const FileDescriptor*>& parsed_files,
+ bool GenerateOutput(const std::vector<const FileDescriptor*>& parsed_files,
const OutputDirective& output_directive,
GeneratorContext* generator_context);
- bool GeneratePluginOutput(const vector<const FileDescriptor*>& parsed_files,
- const string& plugin_name,
- const string& parameter,
- GeneratorContext* generator_context,
- string* error);
+ bool GeneratePluginOutput(
+ const std::vector<const FileDescriptor*>& parsed_files,
+ const string& plugin_name, const string& parameter,
+ GeneratorContext* generator_context, string* error);
// Implements --encode and --decode.
bool EncodeOrDecode(const DescriptorPool* pool);
// Implements the --descriptor_set_out option.
- bool WriteDescriptorSet(const vector<const FileDescriptor*> parsed_files);
+ bool WriteDescriptorSet(
+ const std::vector<const FileDescriptor*> parsed_files);
// Implements the --dependency_out option
bool GenerateDependencyManifestFile(
- const vector<const FileDescriptor*>& parsed_files,
+ const std::vector<const FileDescriptor*>& parsed_files,
const GeneratorContextMap& output_directories,
DiskSourceTree* source_tree);
@@ -281,7 +279,7 @@ class LIBPROTOC_EXPORT CommandLineInterface {
const FileDescriptor* file,
bool include_json_name,
bool include_source_code_info,
- set<const FileDescriptor*>* already_seen,
+ std::set<const FileDescriptor*>* already_seen,
RepeatedPtrField<FileDescriptorProto>* output);
// Implements the --print_free_field_numbers. This function prints free field
@@ -315,16 +313,16 @@ class LIBPROTOC_EXPORT CommandLineInterface {
CodeGenerator* generator;
string help_text;
};
- typedef map<string, GeneratorInfo> GeneratorMap;
+ typedef std::map<string, GeneratorInfo> GeneratorMap;
GeneratorMap generators_by_flag_name_;
GeneratorMap generators_by_option_name_;
// A map from generator names to the parameters specified using the option
// flag. For example, if the user invokes the compiler with:
// protoc --foo_out=outputdir --foo_opt=enable_bar ...
// Then there will be an entry ("--foo_out", "enable_bar") in this map.
- map<string, string> generator_parameters_;
+ std::map<string, string> generator_parameters_;
// Similar to generator_parameters_, but stores the parameters for plugins.
- map<string, string> plugin_parameters_;
+ std::map<string, string> plugin_parameters_;
// See AllowPlugins(). If this is empty, plugins aren't allowed.
string plugin_prefix_;
@@ -332,7 +330,7 @@ class LIBPROTOC_EXPORT CommandLineInterface {
// Maps specific plugin names to files. When executing a plugin, this map
// is searched first to find the plugin executable. If not found here, the
// PATH (or other OS-specific search strategy) is searched.
- map<string, string> plugins_;
+ std::map<string, string> plugins_;
// Stuff parsed from command line.
enum Mode {
@@ -358,14 +356,19 @@ class LIBPROTOC_EXPORT CommandLineInterface {
ErrorFormat error_format_;
- vector<pair<string, string> > proto_path_; // Search path for proto files.
- vector<string> input_files_; // Names of the input proto files.
+ std::vector<std::pair<string, string> >
+ proto_path_; // Search path for proto files.
+ std::vector<string> input_files_; // Names of the input proto files.
// Names of proto files which are allowed to be imported. Used by build
// systems to enforce depend-on-what-you-import.
- set<string> direct_dependencies_;
+ std::set<string> direct_dependencies_;
bool direct_dependencies_explicitly_set_;
+ // If there's a violation of depend-on-what-you-import, this string will be
+ // presented to the user. "%s" will be replaced with the violating import.
+ string direct_dependencies_violation_msg_;
+
// output_directives_ lists all the files we are supposed to output and what
// generator to use for each.
struct OutputDirective {
@@ -374,7 +377,7 @@ class LIBPROTOC_EXPORT CommandLineInterface {
string parameter;
string output_location;
};
- vector<OutputDirective> output_directives_;
+ std::vector<OutputDirective> output_directives_;
// When using --encode or --decode, this names the type we are encoding or
// decoding. (Empty string indicates --decode_raw.)
diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc
index dfbaa45a..cce1018a 100644
--- a/src/google/protobuf/compiler/command_line_interface_unittest.cc
+++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc
@@ -57,6 +57,7 @@
#include <google/protobuf/io/printer.h>
#include <google/protobuf/unittest.pb.h>
#include <google/protobuf/testing/file.h>
+#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/substitute.h>
@@ -100,6 +101,7 @@ class CommandLineInterfaceTest : public testing::Test {
// command is automatically split on spaces, and the string "$tmpdir"
// is replaced with TestTempDir().
void Run(const string& command);
+ void RunWithArgs(vector<string> args);
// -----------------------------------------------------------------
// Methods to set up the test (called before Run()).
@@ -217,7 +219,7 @@ class CommandLineInterfaceTest : public testing::Test {
string captured_stdout_;
// Pointers which need to be deleted later.
- vector<CodeGenerator*> mock_generators_to_delete_;
+ std::vector<CodeGenerator*> mock_generators_to_delete_;
NullCodeGenerator* null_generator_;
};
@@ -291,8 +293,10 @@ void CommandLineInterfaceTest::TearDown() {
}
void CommandLineInterfaceTest::Run(const string& command) {
- vector<string> args = Split(command, " ", true);
+ RunWithArgs(Split(command, " ", true));
+}
+void CommandLineInterfaceTest::RunWithArgs(vector<string> args) {
if (!disallow_plugins_) {
cli_.AllowPlugins("prefix-");
#ifndef GOOGLE_THIRD_PARTY_PROTOBUF
@@ -685,10 +689,36 @@ TEST_F(CommandLineInterfaceTest, UnrecognizedExtraParameters) {
"message Foo {}\n");
Run("protocol_compiler --plug_out=TestParameter:$tmpdir "
+ "--unknown_plug_a_opt=Foo "
+ "--unknown_plug_b_opt=Bar "
+ "--proto_path=$tmpdir foo.proto");
+
+ ExpectErrorSubstring("Unknown flag: --unknown_plug_a_opt");
+ ExpectErrorSubstring("Unknown flag: --unknown_plug_b_opt");
+}
+
+TEST_F(CommandLineInterfaceTest, ExtraPluginParametersForOutParameters) {
+ // This doesn't rely on the plugin having been registred and instead that
+ // the existence of --[name]_out is enough to make the --[name]_opt valid.
+ // However, running out of process plugins found via the search path (i.e. -
+ // not pre registered with --plugin) isn't support in this test suite, so we
+ // list the options pre/post the _out directive, and then include _opt that
+ // will be unknown, and confirm the failure output is about the expected
+ // unknown directive, which means the other were accepted.
+ // NOTE: UnrecognizedExtraParameters confirms that if two unknown _opt
+ // directives appear, they both are reported.
+
+ CreateTempFile("foo.proto",
+ "syntax = \"proto2\";\n"
+ "message Foo {}\n");
+
+ Run("protocol_compiler --plug_out=TestParameter:$tmpdir "
+ "--xyz_opt=foo=bar --xyz_out=$tmpdir "
+ "--abc_out=$tmpdir --abc_opt=foo=bar "
"--unknown_plug_opt=Foo "
"--proto_path=$tmpdir foo.proto");
- ExpectErrorSubstring("Unknown flag: --unknown_plug_opt");
+ ExpectErrorText("Unknown flag: --unknown_plug_opt\n");
}
TEST_F(CommandLineInterfaceTest, Insert) {
@@ -759,7 +789,7 @@ TEST_F(CommandLineInterfaceTest, TrailingBackslash) {
TEST_F(CommandLineInterfaceTest, Win32ErrorMessage) {
EXPECT_EQ("The system cannot find the file specified.\r\n",
- Subprocess::Win32ErrorMessage(ERROR_FILE_NOT_FOUND));
+ Subprocess::Win32ErrorMessage(ERROR_FILE_NOT_FOUND));
}
#endif // defined(_WIN32) || defined(__CYGWIN__)
@@ -995,6 +1025,27 @@ TEST_F(CommandLineInterfaceTest, DirectDependencies_ProvidedMultipleTimes) {
"':'.\n");
}
+TEST_F(CommandLineInterfaceTest, DirectDependencies_CustomErrorMessage) {
+ CreateTempFile("foo.proto",
+ "syntax = \"proto2\";\n"
+ "import \"bar.proto\";\n"
+ "message Foo { optional Bar bar = 1; }");
+ CreateTempFile("bar.proto",
+ "syntax = \"proto2\";\n"
+ "message Bar { optional string text = 1; }");
+
+ vector<string> commands;
+ commands.push_back("protocol_compiler");
+ commands.push_back("--test_out=$tmpdir");
+ commands.push_back("--proto_path=$tmpdir");
+ commands.push_back("--direct_dependencies=");
+ commands.push_back("--direct_dependencies_violation_msg=Bla \"%s\" Bla");
+ commands.push_back("foo.proto");
+ RunWithArgs(commands);
+
+ ExpectErrorText("foo.proto: Bla \"bar.proto\" Bla\n");
+}
+
TEST_F(CommandLineInterfaceTest, CwdRelativeInputs) {
// Test that we can accept working-directory-relative input files.
@@ -1282,6 +1333,19 @@ TEST_F(CommandLineInterfaceTest, ParseErrorsMultipleFiles) {
"foo.proto: Import \"baz.proto\" was not found or had errors.\n");
}
+TEST_F(CommandLineInterfaceTest, RecursiveImportFails) {
+ // Create a proto file that imports itself.
+ CreateTempFile("foo.proto",
+ "syntax = \"proto2\";\n"
+ "import \"foo.proto\";\n");
+
+ Run("protocol_compiler --test_out=$tmpdir "
+ "--proto_path=$tmpdir foo.proto");
+
+ ExpectErrorSubstring(
+ "foo.proto: File recursively imports itself: foo.proto -> foo.proto\n");
+}
+
TEST_F(CommandLineInterfaceTest, InputNotFoundError) {
// Test what happens if the input file is not found.
@@ -1582,6 +1646,21 @@ TEST_F(CommandLineInterfaceTest, PluginReceivesJsonName) {
ExpectErrorSubstring("Saw json_name: 1");
}
+TEST_F(CommandLineInterfaceTest, PluginReceivesCompilerVersion) {
+ CreateTempFile("foo.proto",
+ "syntax = \"proto2\";\n"
+ "message MockCodeGenerator_ShowVersionNumber {\n"
+ " optional int32 value = 1;\n"
+ "}\n");
+
+ Run("protocol_compiler --plug_out=$tmpdir --proto_path=$tmpdir foo.proto");
+
+ ExpectErrorSubstring(
+ StringPrintf("Saw compiler_version: %d %s",
+ GOOGLE_PROTOBUF_VERSION,
+ GOOGLE_PROTOBUF_VERSION_SUFFIX));
+}
+
TEST_F(CommandLineInterfaceTest, GeneratorPluginNotFound) {
// Test what happens if the plugin isn't found.
@@ -1856,7 +1935,7 @@ class EncodeDecodeTest : public testing::Test {
enum ReturnCode { SUCCESS, ERROR };
bool Run(const string& command) {
- vector<string> args;
+ std::vector<string> args;
args.push_back("protoc");
SplitStringUsing(command, " ", &args);
args.push_back("--proto_path=" + TestSourceDir());
diff --git a/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc b/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc
index deef290b..bf4e5831 100644
--- a/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc
@@ -114,7 +114,7 @@ class MockGeneratorContext : public GeneratorContext {
}
private:
- map<string, string*> files_;
+ std::map<string, string*> files_;
};
TEST(BootstrapTest, GeneratedDescriptorMatches) {
diff --git a/src/google/protobuf/compiler/cpp/cpp_enum.cc b/src/google/protobuf/compiler/cpp/cpp_enum.cc
index 6ced26bc..6a8a83d1 100644
--- a/src/google/protobuf/compiler/cpp/cpp_enum.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_enum.cc
@@ -70,7 +70,7 @@ EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor,
EnumGenerator::~EnumGenerator() {}
void EnumGenerator::FillForwardDeclaration(
- map<string, const EnumDescriptor*>* enum_names) {
+ std::map<string, const EnumDescriptor*>* enum_names) {
if (!options_.proto_h) {
return;
}
@@ -78,7 +78,7 @@ void EnumGenerator::FillForwardDeclaration(
}
void EnumGenerator::GenerateDefinition(io::Printer* printer) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars["classname"] = classname_;
vars["short_name"] = descriptor_->name();
vars["enumbase"] = classname_ + (options_.proto_h ? " : int" : "");
@@ -180,7 +180,7 @@ GenerateGetEnumDescriptorSpecializations(io::Printer* printer) {
}
void EnumGenerator::GenerateSymbolImports(io::Printer* printer) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars["nested_name"] = descriptor_->name();
vars["classname"] = classname_;
vars["constexpr"] = options_.proto_h ? "constexpr " : "";
@@ -229,33 +229,38 @@ void EnumGenerator::GenerateSymbolImports(io::Printer* printer) {
}
}
-void EnumGenerator::GenerateDescriptorInitializer(
- io::Printer* printer, int index) {
- map<string, string> vars;
- vars["classname"] = classname_;
- vars["index"] = SimpleItoa(index);
+void EnumGenerator::GenerateDescriptorInitializer(io::Printer* printer) {
+ std::map<string, string> vars;
+ vars["index"] = SimpleItoa(descriptor_->index());
+ vars["index_in_metadata"] = SimpleItoa(index_in_metadata_);
if (descriptor_->containing_type() == NULL) {
printer->Print(vars,
- "$classname$_descriptor_ = file->enum_type($index$);\n");
+ "file_level_enum_descriptors[$index_in_metadata$] = "
+ "file->enum_type($index$);\n");
} else {
vars["parent"] = ClassName(descriptor_->containing_type(), false);
printer->Print(vars,
- "$classname$_descriptor_ = $parent$_descriptor_->enum_type($index$);\n");
+ "file_level_enum_descriptors[$index_in_metadata$] = "
+ "$parent$_descriptor->enum_type($index$);\n");
}
}
void EnumGenerator::GenerateMethods(io::Printer* printer) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars["classname"] = classname_;
+ vars["index_in_metadata"] = SimpleItoa(index_in_metadata_);
vars["constexpr"] = options_.proto_h ? "constexpr " : "";
+ vars["file_namespace"] = FileLevelNamespace(descriptor_->file()->name());
if (HasDescriptorMethods(descriptor_->file(), options_)) {
- printer->Print(vars,
- "const ::google::protobuf::EnumDescriptor* $classname$_descriptor() {\n"
- " protobuf_AssignDescriptorsOnce();\n"
- " return $classname$_descriptor_;\n"
- "}\n");
+ printer->Print(
+ vars,
+ "const ::google::protobuf::EnumDescriptor* $classname$_descriptor() {\n"
+ " $file_namespace$::protobuf_AssignDescriptorsOnce();\n"
+ " return "
+ "$file_namespace$::file_level_enum_descriptors[$index_in_metadata$];\n"
+ "}\n");
}
printer->Print(vars,
@@ -266,13 +271,13 @@ void EnumGenerator::GenerateMethods(io::Printer* printer) {
// each number once by first constructing a set containing all valid
// numbers, then printing a case statement for each element.
- set<int> numbers;
+ std::set<int> numbers;
for (int j = 0; j < descriptor_->value_count(); j++) {
const EnumValueDescriptor* value = descriptor_->value(j);
numbers.insert(value->number());
}
- for (set<int>::iterator iter = numbers.begin();
+ for (std::set<int>::iterator iter = numbers.begin();
iter != numbers.end(); ++iter) {
printer->Print(
" case $number$:\n",
diff --git a/src/google/protobuf/compiler/cpp/cpp_enum.h b/src/google/protobuf/compiler/cpp/cpp_enum.h
index 90edf001..0b568c57 100644
--- a/src/google/protobuf/compiler/cpp/cpp_enum.h
+++ b/src/google/protobuf/compiler/cpp/cpp_enum.h
@@ -66,7 +66,8 @@ class EnumGenerator {
// enums. A given key in enum_names will map from an enum class name to the
// EnumDescriptor that was responsible for its inclusion in the map. This can
// be used to associate the descriptor with the code generated for it.
- void FillForwardDeclaration(map<string, const EnumDescriptor*>* enum_names);
+ void FillForwardDeclaration(
+ std::map<string, const EnumDescriptor*>* enum_names);
// Generate header code defining the enum. This code should be placed
// within the enum's package namespace, but NOT within any class, even for
@@ -87,7 +88,7 @@ class EnumGenerator {
// Generate code that initializes the global variable storing the enum's
// descriptor.
- void GenerateDescriptorInitializer(io::Printer* printer, int index);
+ void GenerateDescriptorInitializer(io::Printer* printer);
// Generate non-inline methods related to the enum, such as IsValidValue().
// Goes in the .cc file.
@@ -100,6 +101,9 @@ class EnumGenerator {
// whether to generate the *_ARRAYSIZE constant.
const bool generate_array_size_;
+ int index_in_metadata_;
+
+ friend class FileGenerator;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator);
};
diff --git a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
index c3dfa817..e4b17a98 100644
--- a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
@@ -46,7 +46,7 @@ namespace cpp {
namespace {
void SetEnumVariables(const FieldDescriptor* descriptor,
- map<string, string>* variables,
+ std::map<string, string>* variables,
const Options& options) {
SetCommonFieldVariables(descriptor, variables, options);
const EnumValueDescriptor* default_value = descriptor->default_value_enum();
@@ -82,7 +82,7 @@ GenerateAccessorDeclarations(io::Printer* printer) const {
void EnumFieldGenerator::
GenerateInlineAccessorDefinitions(io::Printer* printer,
bool is_inline) const {
- map<string, string> variables(variables_);
+ std::map<string, string> variables(variables_);
variables["inline"] = is_inline ? "inline " : "";
printer->Print(variables,
"$inline$$type$ $classname$::$name$() const {\n"
@@ -122,6 +122,11 @@ GenerateConstructorCode(io::Printer* printer) const {
}
void EnumFieldGenerator::
+GenerateCopyConstructorCode(io::Printer* printer) const {
+ printer->Print(variables_, "$name$_ = from.$name$_;\n");
+}
+
+void EnumFieldGenerator::
GenerateMergeFromCodedStream(io::Printer* printer) const {
printer->Print(variables_,
"int value;\n"
@@ -142,7 +147,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
} else {
printer->Print(
"} else {\n"
- " unknown_fields_stream.WriteVarint32($tag$);\n"
+ " unknown_fields_stream.WriteVarint32($tag$u);\n"
" unknown_fields_stream.WriteVarint32(value);\n",
"tag", SimpleItoa(internal::WireFormat::MakeTag(descriptor_)));
}
@@ -186,7 +191,7 @@ EnumOneofFieldGenerator::~EnumOneofFieldGenerator() {}
void EnumOneofFieldGenerator::
GenerateInlineAccessorDefinitions(io::Printer* printer,
bool is_inline) const {
- map<string, string> variables(variables_);
+ std::map<string, string> variables(variables_);
variables["inline"] = is_inline ? "inline " : "";
printer->Print(variables,
"$inline$$type$ $classname$::$name$() const {\n"
@@ -223,8 +228,9 @@ GenerateSwappingCode(io::Printer* printer) const {
void EnumOneofFieldGenerator::
GenerateConstructorCode(io::Printer* printer) const {
- printer->Print(variables_,
- " $classname$_default_oneof_instance_->$name$_ = $default$;\n");
+ printer->Print(
+ variables_,
+ "_$classname$_default_instance_.$name$_ = $default$;\n");
}
// ===================================================================
@@ -262,7 +268,7 @@ GenerateAccessorDeclarations(io::Printer* printer) const {
void RepeatedEnumFieldGenerator::
GenerateInlineAccessorDefinitions(io::Printer* printer,
bool is_inline) const {
- map<string, string> variables(variables_);
+ std::map<string, string> variables(variables_);
variables["inline"] = is_inline ? "inline " : "";
printer->Print(variables,
"$inline$$type$ $classname$::$name$(int index) const {\n"
@@ -311,11 +317,6 @@ GenerateMergingCode(io::Printer* printer) const {
}
void RepeatedEnumFieldGenerator::
-GenerateUnsafeMergingCode(io::Printer* printer) const {
- printer->Print(variables_, "$name$_.UnsafeMergeFrom(from.$name$_);\n");
-}
-
-void RepeatedEnumFieldGenerator::
GenerateSwappingCode(io::Printer* printer) const {
printer->Print(variables_, "$name$_.UnsafeArenaSwap(&other->$name$_);\n");
}
@@ -435,7 +436,7 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const {
"}\n");
}
printer->Print(variables_,
- "for (int i = 0; i < this->$name$_size(); i++) {\n");
+ "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n");
if (descriptor_->is_packed()) {
printer->Print(variables_,
" ::google::protobuf::internal::WireFormatLite::WriteEnumNoTag(\n"
@@ -463,7 +464,7 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
"}\n");
}
printer->Print(variables_,
- "for (int i = 0; i < this->$name$_size(); i++) {\n");
+ "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n");
if (descriptor_->is_packed()) {
printer->Print(variables_,
" target = ::google::protobuf::internal::WireFormatLite::WriteEnumNoTagToArray(\n"
diff --git a/src/google/protobuf/compiler/cpp/cpp_enum_field.h b/src/google/protobuf/compiler/cpp/cpp_enum_field.h
index 57ffeec5..3ecd7ba8 100644
--- a/src/google/protobuf/compiler/cpp/cpp_enum_field.h
+++ b/src/google/protobuf/compiler/cpp/cpp_enum_field.h
@@ -58,6 +58,7 @@ class EnumFieldGenerator : public FieldGenerator {
void GenerateMergingCode(io::Printer* printer) const;
void GenerateSwappingCode(io::Printer* printer) const;
void GenerateConstructorCode(io::Printer* printer) const;
+ void GenerateCopyConstructorCode(io::Printer* printer) const;
void GenerateMergeFromCodedStream(io::Printer* printer) const;
void GenerateSerializeWithCachedSizes(io::Printer* printer) const;
void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
@@ -65,7 +66,7 @@ class EnumFieldGenerator : public FieldGenerator {
protected:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumFieldGenerator);
@@ -101,9 +102,9 @@ class RepeatedEnumFieldGenerator : public FieldGenerator {
bool is_inline) const;
void GenerateClearingCode(io::Printer* printer) const;
void GenerateMergingCode(io::Printer* printer) const;
- void GenerateUnsafeMergingCode(io::Printer* printer) const;
void GenerateSwappingCode(io::Printer* printer) const;
void GenerateConstructorCode(io::Printer* printer) const;
+ void GenerateCopyConstructorCode(io::Printer* printer) const {}
void GenerateMergeFromCodedStream(io::Printer* printer) const;
void GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const;
void GenerateSerializeWithCachedSizes(io::Printer* printer) const;
@@ -112,7 +113,7 @@ class RepeatedEnumFieldGenerator : public FieldGenerator {
private:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedEnumFieldGenerator);
};
diff --git a/src/google/protobuf/compiler/cpp/cpp_extension.cc b/src/google/protobuf/compiler/cpp/cpp_extension.cc
index 4554c72c..e4fce461 100644
--- a/src/google/protobuf/compiler/cpp/cpp_extension.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_extension.cc
@@ -92,7 +92,7 @@ ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor,
ExtensionGenerator::~ExtensionGenerator() {}
void ExtensionGenerator::GenerateDeclaration(io::Printer* printer) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars["extendee" ] = ExtendeeClassName(descriptor_);
vars["number" ] = SimpleItoa(descriptor_->number());
vars["type_traits" ] = type_traits_;
@@ -128,7 +128,7 @@ void ExtensionGenerator::GenerateDefinition(io::Printer* printer) {
ClassName(descriptor_->extension_scope(), false) + "::";
string name = scope + descriptor_->name();
- map<string, string> vars;
+ std::map<string, string> vars;
vars["extendee" ] = ExtendeeClassName(descriptor_);
vars["type_traits" ] = type_traits_;
vars["name" ] = name;
@@ -167,7 +167,7 @@ void ExtensionGenerator::GenerateDefinition(io::Printer* printer) {
}
void ExtensionGenerator::GenerateRegistration(io::Printer* printer) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars["extendee" ] = ExtendeeClassName(descriptor_);
vars["number" ] = SimpleItoa(descriptor_->number());
vars["field_type" ] = SimpleItoa(static_cast<int>(descriptor_->type()));
diff --git a/src/google/protobuf/compiler/cpp/cpp_field.cc b/src/google/protobuf/compiler/cpp/cpp_field.cc
index e2033c1a..4480a9d2 100644
--- a/src/google/protobuf/compiler/cpp/cpp_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_field.cc
@@ -59,7 +59,7 @@ namespace cpp {
using internal::WireFormat;
void SetCommonFieldVariables(const FieldDescriptor* descriptor,
- map<string, string>* variables,
+ std::map<string, string>* variables,
const Options& options) {
(*variables)["name"] = FieldName(descriptor);
(*variables)["index"] = SimpleItoa(descriptor->index());
@@ -98,7 +98,7 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
}
void SetCommonOneofFieldVariables(const FieldDescriptor* descriptor,
- map<string, string>* variables) {
+ std::map<string, string>* variables) {
const string prefix = descriptor->containing_oneof()->name() + "_.";
(*variables)["oneof_prefix"] = prefix;
(*variables)["oneof_name"] = descriptor->containing_oneof()->name();
diff --git a/src/google/protobuf/compiler/cpp/cpp_field.h b/src/google/protobuf/compiler/cpp/cpp_field.h
index fdd338a6..00dc25d4 100644
--- a/src/google/protobuf/compiler/cpp/cpp_field.h
+++ b/src/google/protobuf/compiler/cpp/cpp_field.h
@@ -61,11 +61,11 @@ namespace cpp {
// ['name', 'index', 'number', 'classname', 'declared_type', 'tag_size',
// 'deprecation'].
void SetCommonFieldVariables(const FieldDescriptor* descriptor,
- map<string, string>* variables,
+ std::map<string, string>* variables,
const Options& options);
void SetCommonOneofFieldVariables(const FieldDescriptor* descriptor,
- map<string, string>* variables);
+ std::map<string, string>* variables);
class FieldGenerator {
public:
@@ -124,10 +124,20 @@ class FieldGenerator {
io::Printer* /*printer*/) const {}
// Generate lines of code (statements, not declarations) which clear the
- // field. This is used to define the clear_$name$() method as well as
- // the Clear() method for the whole message.
+ // field. This is used to define the clear_$name$() method
virtual void GenerateClearingCode(io::Printer* printer) const = 0;
+ // Generate lines of code (statements, not declarations) which clear the field
+ // as part of the Clear() method for the whole message. For message types
+ // which have field presence bits, MessageGenerator::GenerateClear will have
+ // already checked the presence bits.
+ //
+ // Since most field types can re-use GenerateClearingCode, this method is not
+ // pure virtual.
+ virtual void GenerateMessageClearingCode(io::Printer* printer) const {
+ GenerateClearingCode(printer);
+ }
+
// Generate lines of code (statements, not declarations) which merges the
// contents of the field from the current message to the target message,
// which is stored in the generated code variable "from".
@@ -136,12 +146,8 @@ class FieldGenerator {
// GenerateMergeFrom method.
virtual void GenerateMergingCode(io::Printer* printer) const = 0;
- // The same, but the generated code may or may not check the possibility that
- // the two objects being merged have the same address. To be safe, callers
- // should avoid calling this unless they know the objects are different.
- virtual void GenerateUnsafeMergingCode(io::Printer* printer) const {
- GenerateMergingCode(printer);
- }
+ // Generates a copy constructor
+ virtual void GenerateCopyConstructorCode(io::Printer* printer) const = 0;
// Generate lines of code (statements, not declarations) which swaps
// this field and the corresponding field of another message, which
diff --git a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc
index 369497ce..0e5e2f18 100644
--- a/src/google/protobuf/compiler/cpp/cpp_file.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_file.cc
@@ -60,33 +60,42 @@ namespace cpp {
FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options)
: file_(file),
options_(options),
- message_generators_(
- new google::protobuf::scoped_ptr<MessageGenerator>[file->message_type_count()]),
- enum_generators_(
- new google::protobuf::scoped_ptr<EnumGenerator>[file->enum_type_count()]),
- service_generators_(
- new google::protobuf::scoped_ptr<ServiceGenerator>[file->service_count()]),
- extension_generators_(
- new google::protobuf::scoped_ptr<ExtensionGenerator>[file->extension_count()]) {
+ message_generators_owner_(
+ new google::protobuf::scoped_ptr<MessageGenerator>[ file->message_type_count() ]),
+ enum_generators_owner_(
+ new google::protobuf::scoped_ptr<EnumGenerator>[ file->enum_type_count() ]),
+ service_generators_owner_(
+ new google::protobuf::scoped_ptr<ServiceGenerator>[ file->service_count() ]),
+ extension_generators_owner_(
+ new google::protobuf::scoped_ptr<ExtensionGenerator>[ file->extension_count() ]) {
for (int i = 0; i < file->message_type_count(); i++) {
- message_generators_[i].reset(
- new MessageGenerator(file->message_type(i), options));
+ message_generators_owner_[i].reset(
+ new MessageGenerator(file->message_type(i), options));
+ message_generators_owner_[i]->Flatten(&message_generators_);
+ }
+
+ for (int i = 0; i < message_generators_.size(); i++) {
+ message_generators_[i]->AddGenerators(&enum_generators_,
+ &extension_generators_);
}
for (int i = 0; i < file->enum_type_count(); i++) {
- enum_generators_[i].reset(
- new EnumGenerator(file->enum_type(i), options));
+ enum_generators_owner_[i].reset(
+ new EnumGenerator(file->enum_type(i), options));
+ enum_generators_.push_back(enum_generators_owner_[i].get());
}
for (int i = 0; i < file->service_count(); i++) {
- service_generators_[i].reset(
- new ServiceGenerator(file->service(i), options));
+ service_generators_owner_[i].reset(
+ new ServiceGenerator(file->service(i), options));
+ service_generators_.push_back(service_generators_owner_[i].get());
}
for (int i = 0; i < file->extension_count(); i++) {
- extension_generators_[i].reset(
- new ExtensionGenerator(file->extension(i), options));
+ extension_generators_owner_[i].reset(
+ new ExtensionGenerator(file->extension(i), options));
+ extension_generators_.push_back(extension_generators_owner_[i].get());
}
package_parts_ = Split(file_->package(), ".", true);
@@ -94,29 +103,7 @@ FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options)
FileGenerator::~FileGenerator() {}
-void FileGenerator::GenerateProtoHeader(io::Printer* printer,
- const string& info_path) {
- if (!options_.proto_h) {
- return;
- }
-
- string filename_identifier = FilenameIdentifier(file_->name());
- GenerateTopHeaderGuard(printer, filename_identifier);
-
-
- GenerateLibraryIncludes(printer);
-
- for (int i = 0; i < file_->public_dependency_count(); i++) {
- const FileDescriptor* dep = file_->public_dependency(i);
- const char* extension = ".proto.h";
- string dependency = StripProto(dep->name()) + extension;
- printer->Print(
- "#include \"$dependency$\" // IWYU pragma: export\n",
- "dependency", dependency);
- }
-
- GenerateMetadataPragma(printer, info_path);
-
+void FileGenerator::GenerateHeader(io::Printer* printer) {
printer->Print(
"// @@protoc_insertion_point(includes)\n");
@@ -166,6 +153,32 @@ void FileGenerator::GenerateProtoHeader(io::Printer* printer,
"\n"
"// @@protoc_insertion_point(global_scope)\n"
"\n");
+}
+
+void FileGenerator::GenerateProtoHeader(io::Printer* printer,
+ const string& info_path) {
+ if (!options_.proto_h) {
+ return;
+ }
+
+ string filename_identifier = FilenameIdentifier(file_->name());
+ GenerateTopHeaderGuard(printer, filename_identifier);
+
+
+ GenerateLibraryIncludes(printer);
+
+ for (int i = 0; i < file_->public_dependency_count(); i++) {
+ const FileDescriptor* dep = file_->public_dependency(i);
+ const char* extension = ".proto.h";
+ string dependency = StripProto(dep->name()) + extension;
+ printer->Print(
+ "#include \"$dependency$\" // IWYU pragma: export\n",
+ "dependency", dependency);
+ }
+
+ GenerateMetadataPragma(printer, info_path);
+
+ GenerateHeader(printer);
GenerateBottomHeaderGuard(printer, filename_identifier);
}
@@ -185,59 +198,29 @@ void FileGenerator::GeneratePBHeader(io::Printer* printer,
GenerateDependencyIncludes(printer);
GenerateMetadataPragma(printer, info_path);
- printer->Print(
- "// @@protoc_insertion_point(includes)\n");
-
-
-
- // Open namespace.
- GenerateNamespaceOpeners(printer);
-
if (!options_.proto_h) {
- GenerateGlobalStateFunctionDeclarations(printer);
- GenerateMessageForwardDeclarations(printer);
-
- printer->Print("\n");
-
- GenerateEnumDefinitions(printer);
-
- printer->Print(kThickSeparator);
- printer->Print("\n");
-
- GenerateMessageDefinitions(printer);
-
- printer->Print("\n");
- printer->Print(kThickSeparator);
- printer->Print("\n");
-
- GenerateServiceDefinitions(printer);
-
- GenerateExtensionIdentifiers(printer);
-
- printer->Print("\n");
- printer->Print(kThickSeparator);
- printer->Print("\n");
-
- GenerateInlineFunctionDefinitions(printer);
- }
-
- printer->Print(
- "\n"
- "// @@protoc_insertion_point(namespace_scope)\n");
+ GenerateHeader(printer);
+ } else {
+ // This is unfortunately necessary for some plugins. I don't see why we
+ // need two of the same insertion points.
+ // TODO(gerbens) remove this.
+ printer->Print(
+ "// @@protoc_insertion_point(includes)\n");
- // Close up namespace.
- GenerateNamespaceClosers(printer);
+ // Open namespace.
+ GenerateNamespaceOpeners(printer);
+ printer->Print(
+ "\n"
+ "// @@protoc_insertion_point(namespace_scope)\n");
+ // Close up namespace.
+ GenerateNamespaceClosers(printer);
- if (!options_.proto_h) {
- // We need to specialize some templates in the ::google::protobuf namespace:
- GenerateProto2NamespaceEnumSpecializations(printer);
+ printer->Print(
+ "\n"
+ "// @@protoc_insertion_point(global_scope)\n"
+ "\n");
}
- printer->Print(
- "\n"
- "// @@protoc_insertion_point(global_scope)\n"
- "\n");
-
GenerateBottomHeaderGuard(printer, filename_identifier);
}
@@ -267,7 +250,7 @@ void FileGenerator::GenerateSource(io::Printer* printer) {
"right", use_system_include ? ">" : "\"");
// Unknown fields implementation in lite mode uses StringOutputStream
- if (!UseUnknownFieldSet(file_, options_) && file_->message_type_count() > 0) {
+ if (!UseUnknownFieldSet(file_, options_) && !message_generators_.empty()) {
printer->Print(
"#include <google/protobuf/io/zero_copy_stream_impl_lite.h>\n");
}
@@ -297,26 +280,59 @@ void FileGenerator::GenerateSource(io::Printer* printer) {
GenerateNamespaceOpeners(printer);
+ for (int i = 0; i < message_generators_.size(); i++) {
+ if (IsMapEntryMessage(message_generators_[i]->descriptor_)) continue;
+ printer->Print(
+ "class $classname$DefaultTypeInternal : "
+ "public ::google::protobuf::internal::ExplicitlyConstructed<$classname$> {\n",
+ "classname", message_generators_[i]->classname_);
+ printer->Indent();
+ message_generators_[i]->GenerateExtraDefaultFields(printer);
+ printer->Outdent();
+ printer->Print(
+ "} _$classname$_default_instance_;\n",
+ "classname", message_generators_[i]->classname_);
+ }
+
+ for (int i = 0; i < message_generators_.size(); i++) {
+ message_generators_[i]->index_in_metadata_ = i;
+ }
+ for (int i = 0; i < enum_generators_.size(); i++) {
+ enum_generators_[i]->index_in_metadata_ = i;
+ }
+ if (HasGenericServices(file_, options_)) {
+ for (int i = 0; i < service_generators_.size(); i++) {
+ service_generators_[i]->index_in_metadata_ = i;
+ }
+ }
+
+ printer->Print(
+ "\n"
+ "namespace $file_namespace$ {\n"
+ "\n",
+ "file_namespace", FileLevelNamespace(file_->name()));
+
if (HasDescriptorMethods(file_, options_)) {
printer->Print(
"\n"
"namespace {\n"
"\n");
- for (int i = 0; i < file_->message_type_count(); i++) {
- message_generators_[i]->GenerateDescriptorDeclarations(printer);
+
+ if (!message_generators_.empty()) {
+ printer->Print("::google::protobuf::Metadata file_level_metadata[$size$];\n",
+ "size", SimpleItoa(message_generators_.size()));
}
- for (int i = 0; i < file_->enum_type_count(); i++) {
+ if (!enum_generators_.empty()) {
printer->Print(
- "const ::google::protobuf::EnumDescriptor* $name$_descriptor_ = NULL;\n",
- "name", ClassName(file_->enum_type(i), false));
+ "const ::google::protobuf::EnumDescriptor* "
+ "file_level_enum_descriptors[$size$];\n",
+ "size", SimpleItoa(enum_generators_.size()));
}
-
- if (HasGenericServices(file_, options_)) {
- for (int i = 0; i < file_->service_count(); i++) {
- printer->Print(
- "const ::google::protobuf::ServiceDescriptor* $name$_descriptor_ = NULL;\n",
- "name", file_->service(i)->name());
- }
+ if (HasGenericServices(file_, options_) && file_->service_count() > 0) {
+ printer->Print(
+ "const ::google::protobuf::ServiceDescriptor* "
+ "file_level_service_descriptors[$size$];\n",
+ "size", SimpleItoa(file_->service_count()));
}
printer->Print(
@@ -329,27 +345,19 @@ void FileGenerator::GenerateSource(io::Printer* printer) {
// library, all this does is initialize default instances.)
GenerateBuildDescriptors(printer);
+ printer->Print(
+ "\n"
+ "} // namespace $file_namespace$\n"
+ "\n",
+ "file_namespace", FileLevelNamespace(file_->name()));
+
// Generate enums.
- for (int i = 0; i < file_->enum_type_count(); i++) {
+ for (int i = 0; i < enum_generators_.size(); i++) {
enum_generators_[i]->GenerateMethods(printer);
}
// Generate classes.
- for (int i = 0; i < file_->message_type_count(); i++) {
- if (i == 0 && HasGeneratedMethods(file_, options_)) {
- printer->Print(
- "\n"
- "namespace {\n"
- "\n"
- "static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD"
- " GOOGLE_ATTRIBUTE_NORETURN;\n"
- "static void MergeFromFail(int line) {\n"
- " ::google::protobuf::internal::MergeFromFail(__FILE__, line);\n"
- "}\n"
- "\n"
- "} // namespace\n"
- "\n");
- }
+ for (int i = 0; i < message_generators_.size(); i++) {
printer->Print("\n");
printer->Print(kThickSeparator);
printer->Print("\n");
@@ -364,7 +372,7 @@ void FileGenerator::GenerateSource(io::Printer* printer) {
if (HasGenericServices(file_, options_)) {
// Generate services.
- for (int i = 0; i < file_->service_count(); i++) {
+ for (int i = 0; i < service_generators_.size(); i++) {
if (i == 0) printer->Print("\n");
printer->Print(kThickSeparator);
printer->Print("\n");
@@ -373,7 +381,7 @@ void FileGenerator::GenerateSource(io::Printer* printer) {
}
// Define extensions.
- for (int i = 0; i < file_->extension_count(); i++) {
+ for (int i = 0; i < extension_generators_.size(); i++) {
extension_generators_[i]->GenerateDefinition(printer);
}
@@ -391,8 +399,9 @@ void FileGenerator::GenerateSource(io::Printer* printer) {
class FileGenerator::ForwardDeclarations {
public:
~ForwardDeclarations() {
- for (map<string, ForwardDeclarations *>::iterator it = namespaces_.begin(),
- end = namespaces_.end();
+ for (std::map<string, ForwardDeclarations*>::iterator
+ it = namespaces_.begin(),
+ end = namespaces_.end();
it != end; ++it) {
delete it->second;
}
@@ -407,11 +416,11 @@ class FileGenerator::ForwardDeclarations {
return ns;
}
- map<string, const Descriptor*>& classes() { return classes_; }
- map<string, const EnumDescriptor*>& enums() { return enums_; }
+ std::map<string, const Descriptor*>& classes() { return classes_; }
+ std::map<string, const EnumDescriptor*>& enums() { return enums_; }
- void Print(io::Printer* printer) const {
- for (map<string, const EnumDescriptor *>::const_iterator
+ void Print(io::Printer* printer, const Options& options) const {
+ for (std::map<string, const EnumDescriptor *>::const_iterator
it = enums_.begin(),
end = enums_.end();
it != end; ++it) {
@@ -420,19 +429,30 @@ class FileGenerator::ForwardDeclarations {
printer->Print("bool $enumname$_IsValid(int value);\n", "enumname",
it->first);
}
- for (map<string, const Descriptor *>::const_iterator it = classes_.begin(),
- end = classes_.end();
+ for (std::map<string, const Descriptor*>::const_iterator
+ it = classes_.begin(),
+ end = classes_.end();
it != end; ++it) {
printer->Print("class $classname$;\n", "classname", it->first);
printer->Annotate("classname", it->second);
+
+ printer->Print(
+ "class $classname$DefaultTypeInternal;\n"
+ "$dllexport_decl$"
+ "extern $classname$DefaultTypeInternal "
+ "_$classname$_default_instance_;\n", // NOLINT
+ "dllexport_decl",
+ options.dllexport_decl.empty() ? "" : options.dllexport_decl + " ",
+ "classname",
+ it->first);
}
- for (map<string, ForwardDeclarations *>::const_iterator
+ for (std::map<string, ForwardDeclarations *>::const_iterator
it = namespaces_.begin(),
end = namespaces_.end();
it != end; ++it) {
printer->Print("namespace $nsname$ {\n",
"nsname", it->first);
- it->second->Print(printer);
+ it->second->Print(printer, options);
printer->Print("} // namespace $nsname$\n",
"nsname", it->first);
}
@@ -440,9 +460,9 @@ class FileGenerator::ForwardDeclarations {
private:
- map<string, ForwardDeclarations*> namespaces_;
- map<string, const Descriptor*> classes_;
- map<string, const EnumDescriptor*> enums_;
+ std::map<string, ForwardDeclarations*> namespaces_;
+ std::map<string, const Descriptor*> classes_;
+ std::map<string, const EnumDescriptor*> enums_;
};
void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) {
@@ -465,75 +485,112 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) {
// and we only use AddDescriptors() to allocate default instances.
if (HasDescriptorMethods(file_, options_)) {
- printer->Print(
- "\n"
- "void $assigndescriptorsname$() GOOGLE_ATTRIBUTE_COLD;\n"
- "void $assigndescriptorsname$() {\n",
- "assigndescriptorsname", GlobalAssignDescriptorsName(file_->name()));
- printer->Indent();
-
- // Make sure the file has found its way into the pool. If a descriptor
- // is requested *during* static init then AddDescriptors() may not have
- // been called yet, so we call it manually. Note that it's fine if
- // AddDescriptors() is called multiple times.
- printer->Print(
- "$adddescriptorsname$();\n",
- "adddescriptorsname", GlobalAddDescriptorsName(file_->name()));
-
- // Get the file's descriptor from the pool.
- printer->Print(
- "const ::google::protobuf::FileDescriptor* file =\n"
- " ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(\n"
- " \"$filename$\");\n"
- // Note that this GOOGLE_CHECK is necessary to prevent a warning about "file"
- // being unused when compiling an empty .proto file.
- "GOOGLE_CHECK(file != NULL);\n",
- "filename", file_->name());
+ if (!message_generators_.empty()) {
+ printer->Print("const ::google::protobuf::uint32 TableStruct::offsets[] = {\n");
+ printer->Indent();
+ std::vector<std::pair<size_t, size_t> > pairs;
+ for (int i = 0; i < message_generators_.size(); i++) {
+ pairs.push_back(message_generators_[i]->GenerateOffsets(printer));
+ }
+ printer->Outdent();
+ printer->Print(
+ "};\n"
+ "\n"
+ "static const ::google::protobuf::internal::MigrationSchema schemas[] = {\n");
+ printer->Indent();
+ {
+ int offset = 0;
+ for (int i = 0; i < message_generators_.size(); i++) {
+ message_generators_[i]->GenerateSchema(printer, offset,
+ pairs[i].second);
+ offset += pairs[i].first;
+ }
+ }
+ printer->Outdent();
+ printer->Print(
+ "};\n"
+ "\nstatic "
+ "::google::protobuf::Message const * const file_default_instances[] = {\n");
+ printer->Indent();
+ for (int i = 0; i < message_generators_.size(); i++) {
+ const Descriptor* descriptor = message_generators_[i]->descriptor_;
+ if (IsMapEntryMessage(descriptor)) continue;
- // Go through all the stuff defined in this file and generated code to
- // assign the global descriptor pointers based on the file descriptor.
- for (int i = 0; i < file_->message_type_count(); i++) {
- message_generators_[i]->GenerateDescriptorInitializer(printer, i);
- }
- for (int i = 0; i < file_->enum_type_count(); i++) {
- enum_generators_[i]->GenerateDescriptorInitializer(printer, i);
- }
- if (HasGenericServices(file_, options_)) {
- for (int i = 0; i < file_->service_count(); i++) {
- service_generators_[i]->GenerateDescriptorInitializer(printer, i);
+ printer->Print(
+ "reinterpret_cast<const "
+ "::google::protobuf::Message*>(&_$classname$_default_instance_),\n",
+ "classname", ClassName(descriptor, false));
}
+ printer->Outdent();
+ printer->Print(
+ "};\n"
+ "\n");
+ } else {
+ // we still need these symbols to exist
+ printer->Print(
+ // MSVC doesn't like empty arrays, so we add a dummy.
+ "const ::google::protobuf::uint32 TableStruct::offsets[] = { ~0u };\n"
+ "static const ::google::protobuf::internal::MigrationSchema* schemas = NULL;\n"
+ "static const ::google::protobuf::Message* const* "
+ "file_default_instances = NULL;\n");
}
- printer->Outdent();
- printer->Print(
- "}\n"
- "\n");
-
// ---------------------------------------------------------------
// protobuf_AssignDescriptorsOnce(): The first time it is called, calls
// AssignDescriptors(). All later times, waits for the first call to
// complete and then returns.
+ string message_factory = "NULL";
printer->Print(
"namespace {\n"
"\n"
- "GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);\n"
+ "void protobuf_AssignDescriptors() {\n"
+ // Make sure the file has found its way into the pool. If a descriptor
+ // is requested *during* static init then AddDescriptors() may not have
+ // been called yet, so we call it manually. Note that it's fine if
+ // AddDescriptors() is called multiple times.
+ " AddDescriptors();\n"
+ " ::google::protobuf::MessageFactory* factory = $factory$;\n"
+ " AssignDescriptors(\n"
+ " \"$filename$\", schemas, file_default_instances, "
+ "TableStruct::offsets, factory,\n"
+ " $metadata$, $enum_descriptors$, $service_descriptors$);\n"
+ "}\n"
+ "\n"
"void protobuf_AssignDescriptorsOnce() {\n"
- " ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,\n"
- " &$assigndescriptorsname$);\n"
+ " static GOOGLE_PROTOBUF_DECLARE_ONCE(once);\n"
+ " ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);\n"
"}\n"
"\n",
- "assigndescriptorsname", GlobalAssignDescriptorsName(file_->name()));
-
- // protobuf_RegisterTypes(): Calls
- // MessageFactory::InternalRegisterGeneratedType() for each message type.
+ "filename", file_->name(), "metadata",
+ !message_generators_.empty() ? "file_level_metadata" : "NULL",
+ "enum_descriptors",
+ !enum_generators_.empty() ? "file_level_enum_descriptors" : "NULL",
+ "service_descriptors",
+ HasGenericServices(file_, options_) && file_->service_count() > 0
+ ? "file_level_service_descriptors"
+ : "NULL",
+ "factory", message_factory);
+
+ // Only here because of useless string reference that we don't want in
+ // protobuf_AssignDescriptorsOnce, because that is called from all the
+ // GetMetadata member methods.
printer->Print(
"void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;\n"
"void protobuf_RegisterTypes(const ::std::string&) {\n"
" protobuf_AssignDescriptorsOnce();\n");
printer->Indent();
- for (int i = 0; i < file_->message_type_count(); i++) {
+ // All normal messages can be done generically
+ if (!message_generators_.empty()) {
+ printer->Print(
+ "::google::protobuf::internal::RegisterAllTypes(file_level_metadata, $size$);\n",
+ "size", SimpleItoa(message_generators_.size()));
+ }
+
+ // Map types are treated special
+ // TODO(gerbens) find a way to treat maps more like normal messages.
+ for (int i = 0; i < message_generators_.size(); i++) {
message_generators_[i]->GenerateTypeRegistrations(printer);
}
@@ -549,11 +606,10 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) {
// ShutdownFile(): Deletes descriptors, default instances, etc. on shutdown.
printer->Print(
"\n"
- "void $shutdownfilename$() {\n",
- "shutdownfilename", GlobalShutdownFileName(file_->name()));
+ "void TableStruct::Shutdown() {\n");
printer->Indent();
- for (int i = 0; i < file_->message_type_count(); i++) {
+ for (int i = 0; i < message_generators_.size(); i++) {
message_generators_[i]->GenerateShutdownCode(printer);
}
@@ -563,13 +619,12 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) {
// -----------------------------------------------------------------
- // Now generate the InitDefaults() function.
+ // Now generate the InitDefaultsImpl() function.
printer->Print(
- "void $initdefaultsname$_impl() {\n"
- " GOOGLE_PROTOBUF_VERIFY_VERSION;\n"
- "\n",
- // Vars.
- "initdefaultsname", GlobalInitDefaultsName(file_->name()));
+ "void TableStruct::InitDefaultsImpl() {\n"
+ " GOOGLE_PROTOBUF_VERIFY_VERSION;\n\n"
+ // Force initialization of primitive values we depend on.
+ " ::google::protobuf::internal::InitProtobufDefaults();\n");
printer->Indent();
@@ -578,48 +633,40 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) {
for (int i = 0; i < file_->dependency_count(); i++) {
const FileDescriptor* dependency = file_->dependency(i);
// Print the namespace prefix for the dependency.
- string add_desc_name = QualifiedFileLevelSymbol(
- dependency->package(), GlobalInitDefaultsName(dependency->name()));
+ string file_namespace = QualifiedFileLevelSymbol(
+ dependency->package(), FileLevelNamespace(dependency->name()));
// Call its AddDescriptors function.
- printer->Print(
- "$name$();\n",
- "name", add_desc_name);
+ printer->Print("$file_namespace$::InitDefaults();\n", "file_namespace",
+ file_namespace);
}
// Allocate and initialize default instances. This can't be done lazily
// since default instances are returned by simple accessors and are used with
// extensions. Speaking of which, we also register extensions at this time.
- for (int i = 0; i < file_->message_type_count(); i++) {
+ for (int i = 0; i < message_generators_.size(); i++) {
message_generators_[i]->GenerateDefaultInstanceAllocator(printer);
}
- for (int i = 0; i < file_->extension_count(); i++) {
+ for (int i = 0; i < extension_generators_.size(); i++) {
extension_generators_[i]->GenerateRegistration(printer);
}
- for (int i = 0; i < file_->message_type_count(); i++) {
+ for (int i = 0; i < message_generators_.size(); i++) {
message_generators_[i]->GenerateDefaultInstanceInitializer(printer);
}
printer->Outdent();
printer->Print(
"}\n"
"\n"
- "GOOGLE_PROTOBUF_DECLARE_ONCE($initdefaultsname$_once_);\n"
- "void $initdefaultsname$() {\n"
- " ::google::protobuf::GoogleOnceInit(&$initdefaultsname$_once_,\n"
- " &$initdefaultsname$_impl);\n"
- "}\n",
- "initdefaultsname", GlobalInitDefaultsName(file_->name()));
+ "void InitDefaults() {\n"
+ " static GOOGLE_PROTOBUF_DECLARE_ONCE(once);\n"
+ " ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);\n"
+ "}\n");
// -----------------------------------------------------------------
// Now generate the AddDescriptors() function.
printer->Print(
- "void $adddescriptorsname$_impl() {\n"
- " GOOGLE_PROTOBUF_VERIFY_VERSION;\n"
- "\n"
- " $initdefaultsname$();\n",
- // Vars.
- "adddescriptorsname", GlobalAddDescriptorsName(file_->name()),
- "initdefaultsname", GlobalInitDefaultsName(file_->name()));
+ "void AddDescriptorsImpl() {\n"
+ " InitDefaults();\n");
printer->Indent();
if (HasDescriptorMethods(file_, options_)) {
@@ -632,60 +679,37 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) {
string file_data;
file_proto.SerializeToString(&file_data);
-#ifdef _MSC_VER
- bool breakdown_large_file = true;
-#else
- bool breakdown_large_file = false;
-#endif
- // Workaround for MSVC: "Error C1091: compiler limit: string exceeds 65535
- // bytes in length". Declare a static array of characters rather than use a
- // string literal.
- if (breakdown_large_file && file_data.size() > 65535) {
- // This has to be explicitly marked as a signed char because the generated
- // code puts negative values in the array, and sometimes plain char is
- // unsigned. That implicit narrowing conversion is not allowed in C++11.
- // <http://stackoverflow.com/questions/4434140/narrowing-conversions-in-c0x-is-it-just-me-or-does-this-sound-like-a-breakin>
- // has details on why.
- printer->Print(
- "static const signed char descriptor[] = {\n");
- printer->Indent();
+ printer->Print("static const char descriptor[] = {\n");
+ printer->Indent();
- // Only write 25 bytes per line.
+ if (file_data.size() > 66535) {
+ // Workaround for MSVC: "Error C1091: compiler limit: string exceeds 65535
+ // bytes in length". Declare a static array of characters rather than use
+ // a string literal. Only write 25 bytes per line.
static const int kBytesPerLine = 25;
for (int i = 0; i < file_data.size();) {
- for (int j = 0; j < kBytesPerLine && i < file_data.size(); ++i, ++j) {
- printer->Print(
- "$char$, ",
- "char", SimpleItoa(file_data[i]));
- }
- printer->Print(
- "\n");
+ for (int j = 0; j < kBytesPerLine && i < file_data.size(); ++i, ++j) {
+ printer->Print("'$char$', ", "char",
+ CEscape(file_data.substr(i, 1)));
+ }
+ printer->Print("\n");
}
-
- printer->Outdent();
- printer->Print(
- "};\n");
-
- printer->Print(
- "::google::protobuf::DescriptorPool::InternalAddGeneratedFile(descriptor, $size$);\n",
- "size", SimpleItoa(file_data.size()));
-
} else {
- printer->Print(
- "::google::protobuf::DescriptorPool::InternalAddGeneratedFile(");
-
// Only write 40 bytes per line.
static const int kBytesPerLine = 40;
for (int i = 0; i < file_data.size(); i += kBytesPerLine) {
- printer->Print("\n \"$data$\"",
- "data",
- EscapeTrigraphs(
- CEscape(file_data.substr(i, kBytesPerLine))));
+ printer->Print(" \"$data$\"\n", "data",
+ EscapeTrigraphs(CEscape(
+ file_data.substr(i, kBytesPerLine))));
+ }
}
+
+ printer->Outdent();
+ printer->Print("};\n");
printer->Print(
- ", $size$);\n",
+ "::google::protobuf::DescriptorPool::InternalAddGeneratedFile(\n"
+ " descriptor, $size$);\n",
"size", SimpleItoa(file_data.size()));
- }
// Call MessageFactory::InternalRegisterGeneratedFile().
printer->Print(
@@ -699,27 +723,24 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) {
for (int i = 0; i < file_->dependency_count(); i++) {
const FileDescriptor* dependency = file_->dependency(i);
// Print the namespace prefix for the dependency.
- string add_desc_name = QualifiedFileLevelSymbol(
- dependency->package(), GlobalAddDescriptorsName(dependency->name()));
+ string file_namespace = QualifiedFileLevelSymbol(
+ dependency->package(), FileLevelNamespace(dependency->name()));
// Call its AddDescriptors function.
- printer->Print("$adddescriptorsname$();\n", "adddescriptorsname",
- add_desc_name);
+ printer->Print("$file_namespace$::AddDescriptors();\n", "file_namespace",
+ file_namespace);
}
printer->Print(
- "::google::protobuf::internal::OnShutdown(&$shutdownfilename$);\n",
- "shutdownfilename", GlobalShutdownFileName(file_->name()));
+ "::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);\n");
printer->Outdent();
printer->Print(
"}\n"
"\n"
- "GOOGLE_PROTOBUF_DECLARE_ONCE($adddescriptorsname$_once_);\n"
- "void $adddescriptorsname$() {\n"
- " ::google::protobuf::GoogleOnceInit(&$adddescriptorsname$_once_,\n"
- " &$adddescriptorsname$_impl);\n"
- "}\n",
- "adddescriptorsname", GlobalAddDescriptorsName(file_->name()));
+ "void AddDescriptors() {\n"
+ " static GOOGLE_PROTOBUF_DECLARE_ONCE(once);\n"
+ " ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);\n"
+ "}\n");
if (!StaticInitializersForced(file_, options_)) {
printer->Print("#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n");
@@ -727,14 +748,11 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) {
printer->Print(
// With static initializers.
"// Force AddDescriptors() to be called at static initialization time.\n"
- "struct StaticDescriptorInitializer_$filename$ {\n"
- " StaticDescriptorInitializer_$filename$() {\n"
- " $adddescriptorsname$();\n"
+ "struct StaticDescriptorInitializer {\n"
+ " StaticDescriptorInitializer() {\n"
+ " AddDescriptors();\n"
" }\n"
- "} static_descriptor_initializer_$filename$_;\n",
- // Vars.
- "adddescriptorsname", GlobalAddDescriptorsName(file_->name()), "filename",
- FilenameIdentifier(file_->name()));
+ "} static_descriptor_initializer;\n");
if (!StaticInitializersForced(file_, options_)) {
printer->Print("#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n");
}
@@ -765,7 +783,7 @@ void FileGenerator::GenerateForwardDeclarations(io::Printer* printer) {
dependency.FillForwardDeclarations(&decls);
}
FillForwardDeclarations(&decls);
- decls.Print(printer);
+ decls.Print(printer, options_);
}
void FileGenerator::FillForwardDeclarations(ForwardDeclarations* decls) {
@@ -777,14 +795,11 @@ void FileGenerator::FillForwardDeclarations(ForwardDeclarations* decls) {
decls = decls->AddOrGetNamespace(package_parts_[i]);
}
// Generate enum definitions.
- for (int i = 0; i < file_->message_type_count(); i++) {
- message_generators_[i]->FillEnumForwardDeclarations(&decls->enums());
- }
- for (int i = 0; i < file_->enum_type_count(); i++) {
+ for (int i = 0; i < enum_generators_.size(); i++) {
enum_generators_[i]->FillForwardDeclaration(&decls->enums());
}
// Generate forward declarations of classes.
- for (int i = 0; i < file_->message_type_count(); i++) {
+ for (int i = 0; i < message_generators_.size(); i++) {
message_generators_[i]->FillMessageForwardDeclarations(
&decls->classes());
}
@@ -838,14 +853,13 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) {
// OK, it's now safe to #include other files.
printer->Print(
- "#include <google/protobuf/arena.h>\n"
- "#include <google/protobuf/arenastring.h>\n"
- "#include <google/protobuf/generated_message_util.h>\n");
- if (UseUnknownFieldSet(file_, options_)) {
- printer->Print(
+ "#include <google/protobuf/io/coded_stream.h>\n"
+ "#include <google/protobuf/arena.h>\n"
+ "#include <google/protobuf/arenastring.h>\n"
+ "#include <google/protobuf/generated_message_util.h>\n"
"#include <google/protobuf/metadata.h>\n");
- }
- if (file_->message_type_count() > 0) {
+
+ if (!message_generators_.empty()) {
if (HasDescriptorMethods(file_, options_)) {
printer->Print(
"#include <google/protobuf/message.h>\n");
@@ -855,8 +869,10 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) {
}
}
printer->Print(
- "#include <google/protobuf/repeated_field.h>\n"
- "#include <google/protobuf/extension_set.h>\n");
+ "#include <google/protobuf/repeated_field.h>"
+ " // IWYU pragma: export\n"
+ "#include <google/protobuf/extension_set.h>"
+ " // IWYU pragma: export\n");
if (HasMapFields(file_)) {
printer->Print(
"#include <google/protobuf/map.h>\n");
@@ -884,7 +900,7 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) {
"#include <google/protobuf/service.h>\n");
}
- if (UseUnknownFieldSet(file_, options_) && file_->message_type_count() > 0) {
+ if (UseUnknownFieldSet(file_, options_) && !message_generators_.empty()) {
printer->Print(
"#include <google/protobuf/unknown_field_set.h>\n");
}
@@ -910,7 +926,7 @@ void FileGenerator::GenerateMetadataPragma(io::Printer* printer,
}
void FileGenerator::GenerateDependencyIncludes(io::Printer* printer) {
- set<string> public_import_names;
+ std::set<string> public_import_names;
for (int i = 0; i < file_->public_dependency_count(); i++) {
public_import_names.insert(file_->public_dependency(i)->name());
}
@@ -936,40 +952,27 @@ void FileGenerator::GenerateGlobalStateFunctionDeclarations(
// functions, so that we can declare them to be friends of each class.
printer->Print(
"\n"
+ "namespace $file_namespace$ {\n"
"// Internal implementation detail -- do not call these.\n"
- "void $dllexport_decl$$adddescriptorsname$();\n"
- "void $dllexport_decl$$initdefaultsname$();\n",
- "initdefaultsname", GlobalInitDefaultsName(file_->name()),
- "adddescriptorsname", GlobalAddDescriptorsName(file_->name()),
- "dllexport_decl",
+ "struct $dllexport_decl$TableStruct {\n"
+ " static const ::google::protobuf::uint32 offsets[];\n"
+ // The following function(s) need to be able to access private members of
+ // the messages defined in the file. So we make them static members.
+ // This is the internal implementation of InitDefaults. It should only
+ // be called by InitDefaults which makes sure it will be called only once.
+ " static void InitDefaultsImpl();\n"
+ " static void Shutdown();\n"
+ "};\n"
+ "void $dllexport_decl$AddDescriptors();\n"
+ "void $dllexport_decl$InitDefaults();\n"
+ "} // namespace $file_namespace$\n",
+ "file_namespace", FileLevelNamespace(file_->name()), "dllexport_decl",
options_.dllexport_decl.empty() ? "" : options_.dllexport_decl + " ");
-
- printer->Print(
- // Note that we don't put dllexport_decl on these because they are only
- // called by the .pb.cc file in which they are defined.
- "void $assigndescriptorsname$();\n"
- "void $shutdownfilename$();\n"
- "\n",
- "assigndescriptorsname", GlobalAssignDescriptorsName(file_->name()),
- "shutdownfilename", GlobalShutdownFileName(file_->name()));
-}
-
-void FileGenerator::GenerateMessageForwardDeclarations(io::Printer* printer) {
- map<string, const Descriptor*> classes;
- for (int i = 0; i < file_->message_type_count(); i++) {
- message_generators_[i]->FillMessageForwardDeclarations(&classes);
- }
- for (map<string, const Descriptor *>::const_iterator it = classes.begin(),
- end = classes.end();
- it != end; ++it) {
- printer->Print("class $classname$;\n", "classname", it->first);
- printer->Annotate("classname", it->second);
- }
}
void FileGenerator::GenerateMessageDefinitions(io::Printer* printer) {
// Generate class definitions.
- for (int i = 0; i < file_->message_type_count(); i++) {
+ for (int i = 0; i < message_generators_.size(); i++) {
if (i > 0) {
printer->Print("\n");
printer->Print(kThinSeparator);
@@ -981,10 +984,7 @@ void FileGenerator::GenerateMessageDefinitions(io::Printer* printer) {
void FileGenerator::GenerateEnumDefinitions(io::Printer* printer) {
// Generate enum definitions.
- for (int i = 0; i < file_->message_type_count(); i++) {
- message_generators_[i]->GenerateEnumDefinitions(printer);
- }
- for (int i = 0; i < file_->enum_type_count(); i++) {
+ for (int i = 0; i < enum_generators_.size(); i++) {
enum_generators_[i]->GenerateDefinition(printer);
}
}
@@ -992,7 +992,7 @@ void FileGenerator::GenerateEnumDefinitions(io::Printer* printer) {
void FileGenerator::GenerateServiceDefinitions(io::Printer* printer) {
if (HasGenericServices(file_, options_)) {
// Generate service definitions.
- for (int i = 0; i < file_->service_count(); i++) {
+ for (int i = 0; i < service_generators_.size(); i++) {
if (i > 0) {
printer->Print("\n");
printer->Print(kThinSeparator);
@@ -1008,9 +1008,10 @@ void FileGenerator::GenerateServiceDefinitions(io::Printer* printer) {
}
void FileGenerator::GenerateExtensionIdentifiers(io::Printer* printer) {
- // Declare extension identifiers.
+ // Declare extension identifiers. These are in global scope and so only
+ // the global scope extensions.
for (int i = 0; i < file_->extension_count(); i++) {
- extension_generators_[i]->GenerateDeclaration(printer);
+ extension_generators_owner_[i]->GenerateDeclaration(printer);
}
}
@@ -1051,7 +1052,7 @@ void FileGenerator::GenerateInlineFunctionDefinitions(io::Printer* printer) {
printer->Print("#if !PROTOBUF_INLINE_NOT_IN_HEADERS\n");
// Generate class inline methods.
- for (int i = 0; i < file_->message_type_count(); i++) {
+ for (int i = 0; i < message_generators_.size(); i++) {
if (i > 0) {
printer->Print(kThinSeparator);
printer->Print("\n");
@@ -1061,7 +1062,7 @@ void FileGenerator::GenerateInlineFunctionDefinitions(io::Printer* printer) {
}
printer->Print("#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS\n");
- for (int i = 0; i < file_->message_type_count(); i++) {
+ for (int i = 0; i < message_generators_.size(); i++) {
if (i > 0) {
printer->Print(kThinSeparator);
printer->Print("\n");
@@ -1084,10 +1085,7 @@ void FileGenerator::GenerateProto2NamespaceEnumSpecializations(
"#ifndef SWIG\n"
"namespace google {\nnamespace protobuf {\n"
"\n");
- for (int i = 0; i < file_->message_type_count(); i++) {
- message_generators_[i]->GenerateGetEnumDescriptorSpecializations(printer);
- }
- for (int i = 0; i < file_->enum_type_count(); i++) {
+ for (int i = 0; i < enum_generators_.size(); i++) {
enum_generators_[i]->GenerateGetEnumDescriptorSpecializations(printer);
}
printer->Print(
diff --git a/src/google/protobuf/compiler/cpp/cpp_file.h b/src/google/protobuf/compiler/cpp/cpp_file.h
index 5dcf692b..25d6eabf 100644
--- a/src/google/protobuf/compiler/cpp/cpp_file.h
+++ b/src/google/protobuf/compiler/cpp/cpp_file.h
@@ -68,6 +68,9 @@ class FileGenerator {
FileGenerator(const FileDescriptor* file, const Options& options);
~FileGenerator();
+ // Shared code between the two header generators below.
+ void GenerateHeader(io::Printer* printer);
+
// info_path, if non-empty, should be the path (relative to printer's output)
// to the metadata file describing this proto header.
void GenerateProtoHeader(io::Printer* printer,
@@ -117,18 +120,6 @@ class FileGenerator {
// Generates types for classes.
void GenerateMessageDefinitions(io::Printer* printer);
- // Generates forward-declarations for just this file's classes. This is
- // used for .pb.h headers, but not in proto_h mode.
- void GenerateMessageForwardDeclarations(io::Printer* printer);
-
- // Fills in types for forward declarations. This is used internally, and
- // also by other FileGenerators to determine imports' declarations.
- void FillMessageForwardDeclarations(ForwardDeclarations* decls);
- void FillMessageDefinitions(ForwardDeclarations* decls);
-
- // Generates enum definitions.
- void GenerateEnumForwardDeclarations(io::Printer* printer);
- void FillEnumForwardDeclarations(ForwardDeclarations* decls);
void GenerateEnumDefinitions(io::Printer* printer);
// Generates generic service definitions.
@@ -145,13 +136,25 @@ class FileGenerator {
const FileDescriptor* file_;
const Options options_;
- google::protobuf::scoped_array<google::protobuf::scoped_ptr<MessageGenerator> > message_generators_;
- google::protobuf::scoped_array<google::protobuf::scoped_ptr<EnumGenerator> > enum_generators_;
- google::protobuf::scoped_array<google::protobuf::scoped_ptr<ServiceGenerator> > service_generators_;
- google::protobuf::scoped_array<google::protobuf::scoped_ptr<ExtensionGenerator> > extension_generators_;
+ // Contains the post-order walk of all the messages (and child messages) in
+ // this file. If you need a pre-order walk just reverse iterate.
+ std::vector<MessageGenerator*> message_generators_;
+ std::vector<EnumGenerator*> enum_generators_;
+ std::vector<ServiceGenerator*> service_generators_;
+ std::vector<ExtensionGenerator*> extension_generators_;
+
+ // These members are just for owning (and thus proper deleting). Some of the
+ // message_ and enum_generators above are owned by child messages.
+ google::protobuf::scoped_array<google::protobuf::scoped_ptr<MessageGenerator> >
+ message_generators_owner_;
+ google::protobuf::scoped_array<google::protobuf::scoped_ptr<EnumGenerator> > enum_generators_owner_;
+ google::protobuf::scoped_array<google::protobuf::scoped_ptr<ServiceGenerator> >
+ service_generators_owner_;
+ google::protobuf::scoped_array<google::protobuf::scoped_ptr<ExtensionGenerator> >
+ extension_generators_owner_;
// E.g. if the package is foo.bar, package_parts_ is {"foo", "bar"}.
- vector<string> package_parts_;
+ std::vector<string> package_parts_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator);
};
diff --git a/src/google/protobuf/compiler/cpp/cpp_generator.cc b/src/google/protobuf/compiler/cpp/cpp_generator.cc
index 31d189c2..648ab28a 100644
--- a/src/google/protobuf/compiler/cpp/cpp_generator.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_generator.cc
@@ -59,7 +59,7 @@ bool CppGenerator::Generate(const FileDescriptor* file,
const string& parameter,
GeneratorContext* generator_context,
string* error) const {
- vector<pair<string, string> > options;
+ std::vector<std::pair<string, string> > options;
ParseGeneratorParameter(parameter, &options);
// -----------------------------------------------------------------
diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/src/google/protobuf/compiler/cpp/cpp_helpers.cc
index 6d844cc2..3c4dddc5 100644
--- a/src/google/protobuf/compiler/cpp/cpp_helpers.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_helpers.cc
@@ -371,9 +371,9 @@ string DefaultValue(const FieldDescriptor* field) {
return "GOOGLE_ULONGLONG(" + SimpleItoa(field->default_value_uint64())+ ")";
case FieldDescriptor::CPPTYPE_DOUBLE: {
double value = field->default_value_double();
- if (value == numeric_limits<double>::infinity()) {
+ if (value == std::numeric_limits<double>::infinity()) {
return "::google::protobuf::internal::Infinity()";
- } else if (value == -numeric_limits<double>::infinity()) {
+ } else if (value == -std::numeric_limits<double>::infinity()) {
return "-::google::protobuf::internal::Infinity()";
} else if (value != value) {
return "::google::protobuf::internal::NaN()";
@@ -384,9 +384,9 @@ string DefaultValue(const FieldDescriptor* field) {
case FieldDescriptor::CPPTYPE_FLOAT:
{
float value = field->default_value_float();
- if (value == numeric_limits<float>::infinity()) {
+ if (value == std::numeric_limits<float>::infinity()) {
return "static_cast<float>(::google::protobuf::internal::Infinity())";
- } else if (value == -numeric_limits<float>::infinity()) {
+ } else if (value == -std::numeric_limits<float>::infinity()) {
return "static_cast<float>(-::google::protobuf::internal::Infinity())";
} else if (value != value) {
return "static_cast<float>(::google::protobuf::internal::NaN())";
@@ -440,23 +440,8 @@ string FilenameIdentifier(const string& filename) {
return result;
}
-// Return the name of the AddDescriptors() function for a given file.
-string GlobalAddDescriptorsName(const string& filename) {
- return "protobuf_AddDesc_" + FilenameIdentifier(filename);
-}
-
-string GlobalInitDefaultsName(const string& filename) {
- return "protobuf_InitDefaults_" + FilenameIdentifier(filename);
-}
-
-// Return the name of the AssignDescriptors() function for a given file.
-string GlobalAssignDescriptorsName(const string& filename) {
- return "protobuf_AssignDesc_" + FilenameIdentifier(filename);
-}
-
-// Return the name of the ShutdownFile() function for a given file.
-string GlobalShutdownFileName(const string& filename) {
- return "protobuf_ShutdownFile_" + FilenameIdentifier(filename);
+string FileLevelNamespace(const string& filename) {
+ return "protobuf_" + FilenameIdentifier(filename);
}
// Return the qualified C++ name for a file level symbol.
@@ -602,7 +587,7 @@ static Utf8CheckMode GetUtf8CheckMode(const FieldDescriptor* field,
static void GenerateUtf8CheckCode(const FieldDescriptor* field,
const Options& options, bool for_parse,
- const map<string, string>& variables,
+ const std::map<string, string>& variables,
const char* parameters,
const char* strict_function,
const char* verify_function,
@@ -652,7 +637,7 @@ static void GenerateUtf8CheckCode(const FieldDescriptor* field,
void GenerateUtf8CheckCodeForString(const FieldDescriptor* field,
const Options& options, bool for_parse,
- const map<string, string>& variables,
+ const std::map<string, string>& variables,
const char* parameters,
io::Printer* printer) {
GenerateUtf8CheckCode(field, options, for_parse, variables, parameters,
@@ -662,7 +647,7 @@ void GenerateUtf8CheckCodeForString(const FieldDescriptor* field,
void GenerateUtf8CheckCodeForCord(const FieldDescriptor* field,
const Options& options, bool for_parse,
- const map<string, string>& variables,
+ const std::map<string, string>& variables,
const char* parameters,
io::Printer* printer) {
GenerateUtf8CheckCode(field, options, for_parse, variables, parameters,
diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.h b/src/google/protobuf/compiler/cpp/cpp_helpers.h
index 3a0c0388..0f297ec8 100644
--- a/src/google/protobuf/compiler/cpp/cpp_helpers.h
+++ b/src/google/protobuf/compiler/cpp/cpp_helpers.h
@@ -144,21 +144,13 @@ string DefaultValue(const FieldDescriptor* field);
// Convert a file name into a valid identifier.
string FilenameIdentifier(const string& filename);
-// Return the name of the AddDescriptors() function for a given file.
-string GlobalAddDescriptorsName(const string& filename);
-
-// Return the name of the InitDefaults() function for a given file.
-string GlobalInitDefaultsName(const string& filename);
-
-// Return the name of the AssignDescriptors() function for a given file.
-string GlobalAssignDescriptorsName(const string& filename);
+// For each .proto file generates a unique namespace. In this namespace global
+// definitions are put to prevent collisions.
+string FileLevelNamespace(const string& filename);
// Return the qualified C++ name for a file level symbol.
string QualifiedFileLevelSymbol(const string& package, const string& name);
-// Return the name of the ShutdownFile() function for a given file.
-string GlobalShutdownFileName(const string& filename);
-
// Escape C++ trigraphs by escaping question marks to \?
string EscapeTrigraphs(const string& to_escape);
@@ -269,13 +261,13 @@ bool IsWellKnownMessage(const FileDescriptor* descriptor);
void GenerateUtf8CheckCodeForString(const FieldDescriptor* field,
const Options& options, bool for_parse,
- const map<string, string>& variables,
+ const std::map<string, string>& variables,
const char* parameters,
io::Printer* printer);
void GenerateUtf8CheckCodeForCord(const FieldDescriptor* field,
const Options& options, bool for_parse,
- const map<string, string>& variables,
+ const std::map<string, string>& variables,
const char* parameters, io::Printer* printer);
inline ::google::protobuf::FileOptions_OptimizeMode GetOptimizeFor(
diff --git a/src/google/protobuf/compiler/cpp/cpp_map_field.cc b/src/google/protobuf/compiler/cpp/cpp_map_field.cc
index 31ac9ca7..b4eaf485 100644
--- a/src/google/protobuf/compiler/cpp/cpp_map_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_map_field.cc
@@ -45,10 +45,12 @@ bool IsProto3Field(const FieldDescriptor* field_descriptor) {
}
void SetMessageVariables(const FieldDescriptor* descriptor,
- map<string, string>* variables,
+ std::map<string, string>* variables,
const Options& options) {
SetCommonFieldVariables(descriptor, variables, options);
- (*variables)["type"] = FieldMessageTypeName(descriptor);
+ (*variables)["type"] = ClassName(descriptor->message_type(), false);
+ (*variables)["file_namespace"] =
+ FileLevelNamespace(descriptor->file()->name());
(*variables)["stream_writer"] =
(*variables)["declared_type"] +
(HasFastArraySerialization(descriptor->message_type()->file(), options)
@@ -137,7 +139,7 @@ GenerateAccessorDeclarations(io::Printer* printer) const {
void MapFieldGenerator::
GenerateInlineAccessorDefinitions(io::Printer* printer,
bool is_inline) const {
- map<string, string> variables(variables_);
+ std::map<string, string> variables(variables_);
variables["inline"] = is_inline ? "inline" : "";
printer->Print(variables,
"$inline$ const ::google::protobuf::Map< $key_cpp$, $val_cpp$ >&\n"
@@ -154,7 +156,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer,
void MapFieldGenerator::
GenerateClearingCode(io::Printer* printer) const {
- map<string, string> variables(variables_);
+ std::map<string, string> variables(variables_);
variables["this_message"] = dependent_field_ ? DependentBaseDownCast() : "";
printer->Print(variables, "$this_message$$name$_.Clear();\n");
}
@@ -173,14 +175,20 @@ void MapFieldGenerator::
GenerateConstructorCode(io::Printer* printer) const {
if (HasDescriptorMethods(descriptor_->file(), options_)) {
printer->Print(variables_,
- "$name$_.SetAssignDescriptorCallback(\n"
- " protobuf_AssignDescriptorsOnce);\n"
- "$name$_.SetEntryDescriptor(\n"
- " &$type$_descriptor_);\n");
+ "$name$_.SetAssignDescriptorCallback(\n"
+ " $file_namespace$::protobuf_AssignDescriptorsOnce);\n"
+ "$name$_.SetEntryDescriptor(\n"
+ " &$type$_descriptor);\n");
}
}
void MapFieldGenerator::
+GenerateCopyConstructorCode(io::Printer* printer) const {
+ GenerateConstructorCode(printer);
+ GenerateMergingCode(printer);
+}
+
+void MapFieldGenerator::
GenerateMergeFromCodedStream(io::Printer* printer) const {
const FieldDescriptor* key_field =
descriptor_->message_type()->FindFieldByName("key");
@@ -224,7 +232,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
"->AddLengthDelimited($number$, data);\n");
} else {
printer->Print(variables_,
- " unknown_fields_stream.WriteVarint32($tag$);\n"
+ " unknown_fields_stream.WriteVarint32($tag$u);\n"
" unknown_fields_stream.WriteVarint32(data.size());\n"
" unknown_fields_stream.WriteString(data);\n");
}
@@ -252,7 +260,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
}
static void GenerateSerializationLoop(io::Printer* printer,
- const map<string, string>& variables,
+ const std::map<string, string>& variables,
bool supports_arenas,
const string& utf8_check,
const string& loop_header,
@@ -291,17 +299,17 @@ static void GenerateSerializationLoop(io::Printer* printer,
void MapFieldGenerator::
GenerateSerializeWithCachedSizes(io::Printer* printer) const {
- map<string, string> variables(variables_);
+ std::map<string, string> variables(variables_);
variables["write_entry"] = "::google::protobuf::internal::WireFormatLite::Write" +
variables["stream_writer"] + "(\n " +
variables["number"] + ", *entry, output)";
- variables["deterministic"] = "output->IsSerializationDeterminstic()";
+ variables["deterministic"] = "output->IsSerializationDeterministic()";
GenerateSerializeWithCachedSizes(printer, variables);
}
void MapFieldGenerator::
GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
- map<string, string> variables(variables_);
+ std::map<string, string> variables(variables_);
variables["write_entry"] =
"target = ::google::protobuf::internal::WireFormatLite::\n"
" InternalWrite" + variables["declared_type"] +
@@ -312,7 +320,7 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
}
void MapFieldGenerator::GenerateSerializeWithCachedSizes(
- io::Printer* printer, const map<string, string>& variables) const {
+ io::Printer* printer, const std::map<string, string>& variables) const {
printer->Print(variables,
"if (!this->$name$().empty()) {\n");
printer->Indent();
diff --git a/src/google/protobuf/compiler/cpp/cpp_map_field.h b/src/google/protobuf/compiler/cpp/cpp_map_field.h
index 2930fe59..816687b3 100644
--- a/src/google/protobuf/compiler/cpp/cpp_map_field.h
+++ b/src/google/protobuf/compiler/cpp/cpp_map_field.h
@@ -55,6 +55,7 @@ class MapFieldGenerator : public FieldGenerator {
void GenerateMergingCode(io::Printer* printer) const;
void GenerateSwappingCode(io::Printer* printer) const;
void GenerateConstructorCode(io::Printer* printer) const;
+ void GenerateCopyConstructorCode(io::Printer* printer) const;
void GenerateMergeFromCodedStream(io::Printer* printer) const;
void GenerateSerializeWithCachedSizes(io::Printer* printer) const;
void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
@@ -63,11 +64,11 @@ class MapFieldGenerator : public FieldGenerator {
private:
// A helper for GenerateSerializeWithCachedSizes{,ToArray}.
void GenerateSerializeWithCachedSizes(
- io::Printer* printer, const map<string, string>& variables) const;
+ io::Printer* printer, const std::map<string, string>& variables) const;
const FieldDescriptor* descriptor_;
const bool dependent_field_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapFieldGenerator);
};
diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc
index efc56ddc..b4f1adfd 100644
--- a/src/google/protobuf/compiler/cpp/cpp_message.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_message.cc
@@ -207,7 +207,7 @@ class FieldGroup {
}
void SetPreferredLocation(float location) { preferred_location_ = location; }
- const vector<const FieldDescriptor*>& fields() const { return fields_; }
+ const std::vector<const FieldDescriptor*>& fields() const { return fields_; }
// FieldGroup objects sort by their preferred location.
bool operator<(const FieldGroup& other) const {
@@ -221,7 +221,7 @@ class FieldGroup {
// approximate, but should put this group close to where its member fields
// originally went.
float preferred_location_;
- vector<const FieldDescriptor*> fields_;
+ std::vector<const FieldDescriptor*> fields_;
// We rely on the default copy constructor and operator= so this type can be
// used in a vector.
};
@@ -251,6 +251,39 @@ bool CanInitializeByZeroing(const FieldDescriptor* field) {
}
}
+bool IsPOD(const FieldDescriptor* field) {
+ if (field->is_repeated() || field->is_extension()) return false;
+ switch (field->cpp_type()) {
+ case internal::WireFormatLite::CPPTYPE_ENUM:
+ case internal::WireFormatLite::CPPTYPE_INT32:
+ case internal::WireFormatLite::CPPTYPE_INT64:
+ case internal::WireFormatLite::CPPTYPE_UINT32:
+ case internal::WireFormatLite::CPPTYPE_UINT64:
+ case internal::WireFormatLite::CPPTYPE_FLOAT:
+ case internal::WireFormatLite::CPPTYPE_DOUBLE:
+ case internal::WireFormatLite::CPPTYPE_BOOL:
+ return true;
+ case internal::WireFormatLite::CPPTYPE_STRING:
+ return false;
+ default:
+ return false;
+ }
+}
+
+// Helper for the code that emits the SharedCtor() method.
+bool CanConstructByZeroing(const FieldDescriptor* field,
+ const Options& options) {
+ bool ret = CanInitializeByZeroing(field);
+
+ // Non-repeated, non-lazy message fields are simply raw pointers, so we can
+ // use memset to initialize these in SharedCtor. We cannot use this in
+ // Clear, as we need to potentially delete the existing value.
+ ret = ret ||
+ (!field->is_repeated() &&
+ field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE);
+ return ret;
+}
+
// Reorder 'fields' so that if the fields are output into a c++ class in the new
// order, fields of similiar family (see below) are together and within each
// family, alignment padding is minimized.
@@ -260,9 +293,6 @@ bool CanInitializeByZeroing(const FieldDescriptor* field) {
// locality much for function that access each field in order. This is also the
// only (weak) signal we have for author intent concerning field layout.
//
-// TODO(ckennelly): Update these functions to use the optimized layout order
-// for their access patterns.
-//
// TODO(ckennelly): If/when we have profiles available for the compiler, use
// those rather than respect declaration order.
//
@@ -275,30 +305,32 @@ bool CanInitializeByZeroing(const FieldDescriptor* field) {
// STRING is grouped next, as our Clear/SharedCtor/SharedDtor walks it and
// calls ArenaStringPtr::Destroy on each.
//
+//
// MESSAGE is grouped next, as our Clear/SharedDtor code walks it and calls
// delete on each. We initialize these fields with a NULL pointer (see
-// MessageFieldGenerator::GenerateConstructorCode).
-// TODO(ckennelly): memset these in SharedCtor.
+// MessageFieldGenerator::GenerateConstructorCode), which allows them to be
+// memset.
//
// ZERO_INITIALIZABLE is memset in Clear/SharedCtor
//
// OTHER these fields are initialized one-by-one.
-void OptimizePadding(vector<const FieldDescriptor*>* fields) {
+void OptimizePadding(std::vector<const FieldDescriptor*>* fields,
+ const Options& options) {
// The sorted numeric order of Family determines the declaration order in the
// memory layout.
enum Family {
REPEATED = 0,
STRING = 1,
MESSAGE = 2,
- ZERO_INITIALIZABLE = 3,
- OTHER = 4,
+ ZERO_INITIALIZABLE = 4,
+ OTHER = 5,
kMaxFamily
};
// First divide fields into those that align to 1 byte, 4 bytes or 8 bytes.
- vector<FieldGroup> aligned_to_1[kMaxFamily];
- vector<FieldGroup> aligned_to_4[kMaxFamily];
- vector<FieldGroup> aligned_to_8[kMaxFamily];
+ std::vector<FieldGroup> aligned_to_1[kMaxFamily];
+ std::vector<FieldGroup> aligned_to_4[kMaxFamily];
+ std::vector<FieldGroup> aligned_to_8[kMaxFamily];
for (int i = 0; i < fields->size(); ++i) {
const FieldDescriptor* field = (*fields)[i];
@@ -309,6 +341,7 @@ void OptimizePadding(vector<const FieldDescriptor*>* fields) {
f = STRING;
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
f = MESSAGE;
+
} else if (CanInitializeByZeroing(field)) {
f = ZERO_INITIALIZABLE;
}
@@ -427,23 +460,9 @@ bool HasHasMethod(const FieldDescriptor* field) {
return field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE;
}
-size_t HasBitsSize(const Descriptor* descriptor) {
- // TODO(jieluo) - Optimize _has_bits_ for repeated and oneof fields.
- size_t sizeof_has_bits = (descriptor->field_count() + 31) / 32 * 4;
- if (descriptor->field_count() == 0) {
- // Zero-size arrays aren't technically allowed, and MSVC in particular
- // doesn't like them. We still need to declare these arrays to make
- // other code compile. Since this is an uncommon case, we'll just declare
- // them with size 1 and waste some space. Oh well.
- sizeof_has_bits = 4;
- }
-
- return sizeof_has_bits;
-}
-
// Collects map entry message type information.
void CollectMapInfo(const Descriptor* descriptor,
- map<string, string>* variables) {
+ std::map<string, string>* variables) {
GOOGLE_CHECK(IsMapEntryMessage(descriptor));
const FieldDescriptor* key = descriptor->FindFieldByName("key");
const FieldDescriptor* val = descriptor->FindFieldByName("value");
@@ -475,6 +494,7 @@ bool HasPrivateHasMethod(const FieldDescriptor* field) {
field->containing_oneof() != NULL);
}
+
} // anonymous namespace
// ===================================================================
@@ -485,6 +505,7 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor,
classname_(ClassName(descriptor, false)),
options_(options),
field_generators_(descriptor, options),
+ max_has_bit_index_(0),
nested_generators_(new google::protobuf::scoped_ptr<
MessageGenerator>[descriptor->nested_type_count()]),
enum_generators_(
@@ -500,7 +521,21 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor,
optimized_order_.push_back(descriptor_->field(i));
}
}
- OptimizePadding(&optimized_order_);
+ OptimizePadding(&optimized_order_, options_);
+
+ if (HasFieldPresence(descriptor_->file())) {
+ // We use -1 as a sentinel.
+ has_bit_indices_.resize(descriptor_->field_count(), -1);
+ for (int i = 0; i < optimized_order_.size(); i++) {
+ const FieldDescriptor* field = optimized_order_[i];
+ // Skip fields that do not have has bits.
+ if (field->is_repeated()) {
+ continue;
+ }
+
+ has_bit_indices_[field->index()] = max_has_bit_index_++;
+ }
+ }
for (int i = 0; i < descriptor->nested_type_count(); i++) {
nested_generators_[i].reset(
@@ -534,48 +569,41 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor,
MessageGenerator::~MessageGenerator() {}
-void MessageGenerator::
-FillMessageForwardDeclarations(map<string, const Descriptor*>* class_names) {
- (*class_names)[classname_] = descriptor_;
-
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- // map entry message doesn't need forward declaration. Since map entry
- // message cannot be a top level class, we just need to avoid calling
- // GenerateForwardDeclaration here.
- if (IsMapEntryMessage(descriptor_->nested_type(i))) continue;
- nested_generators_[i]->FillMessageForwardDeclarations(class_names);
+size_t MessageGenerator::HasBitsSize() const {
+ size_t sizeof_has_bits = (max_has_bit_index_ + 31) / 32 * 4;
+ if (sizeof_has_bits == 0) {
+ // Zero-size arrays aren't technically allowed, and MSVC in particular
+ // doesn't like them. We still need to declare these arrays to make
+ // other code compile. Since this is an uncommon case, we'll just declare
+ // them with size 1 and waste some space. Oh well.
+ sizeof_has_bits = 4;
}
-}
-void MessageGenerator::
-FillEnumForwardDeclarations(map<string, const EnumDescriptor*>* enum_names) {
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- nested_generators_[i]->FillEnumForwardDeclarations(enum_names);
- }
- for (int i = 0; i < descriptor_->enum_type_count(); i++) {
- enum_generators_[i]->FillForwardDeclaration(enum_names);
- }
+ return sizeof_has_bits;
}
-void MessageGenerator::
-GenerateEnumDefinitions(io::Printer* printer) {
+void MessageGenerator::Flatten(std::vector<MessageGenerator*>* list) {
for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- nested_generators_[i]->GenerateEnumDefinitions(printer);
+ nested_generators_[i]->Flatten(list);
}
+ list->push_back(this);
+}
+void MessageGenerator::AddGenerators(
+ std::vector<EnumGenerator*>* enum_generators,
+ std::vector<ExtensionGenerator*>* extension_generators) {
for (int i = 0; i < descriptor_->enum_type_count(); i++) {
- enum_generators_[i]->GenerateDefinition(printer);
+ enum_generators->push_back(enum_generators_[i].get());
+ }
+ for (int i = 0; i < descriptor_->extension_count(); i++) {
+ extension_generators->push_back(extension_generators_[i].get());
}
}
-void MessageGenerator::
-GenerateGetEnumDescriptorSpecializations(io::Printer* printer) {
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- nested_generators_[i]->GenerateGetEnumDescriptorSpecializations(printer);
- }
- for (int i = 0; i < descriptor_->enum_type_count(); i++) {
- enum_generators_[i]->GenerateGetEnumDescriptorSpecializations(printer);
- }
+void MessageGenerator::FillMessageForwardDeclarations(
+ std::map<string, const Descriptor*>* class_names) {
+ if (IsMapEntryMessage(descriptor_)) return;
+ (*class_names)[classname_] = descriptor_;
}
void MessageGenerator::
@@ -585,7 +613,7 @@ GenerateDependentFieldAccessorDeclarations(io::Printer* printer) {
PrintFieldComment(printer, field);
- map<string, string> vars;
+ std::map<string, string> vars;
SetCommonFieldVariables(field, &vars, options_);
if (use_dependent_base_ && IsFieldDependent(field)) {
@@ -602,12 +630,32 @@ GenerateDependentFieldAccessorDeclarations(io::Printer* printer) {
void MessageGenerator::
GenerateFieldAccessorDeclarations(io::Printer* printer) {
+ // optimized_fields_ does not contain fields where
+ // field->containing_oneof() != NULL
+ // so we need to iterate over those as well.
+ //
+ // We place the non-oneof fields in optimized_order_, as that controls the
+ // order of the _has_bits_ entries and we want GDB's pretty printers to be
+ // able to infer these indices from the k[FIELDNAME]FieldNumber order.
+ std::vector<const FieldDescriptor*> ordered_fields;
+ ordered_fields.reserve(descriptor_->field_count());
+
+ ordered_fields.insert(
+ ordered_fields.begin(), optimized_order_.begin(), optimized_order_.end());
for (int i = 0; i < descriptor_->field_count(); i++) {
const FieldDescriptor* field = descriptor_->field(i);
+ if (field->containing_oneof() == NULL) {
+ continue;
+ }
+ ordered_fields.push_back(field);
+ }
+
+ for (int i = 0; i < ordered_fields.size(); i++) {
+ const FieldDescriptor* field = ordered_fields[i];
PrintFieldComment(printer, field);
- map<string, string> vars;
+ std::map<string, string> vars;
SetCommonFieldVariables(field, &vars, options_);
vars["constant_name"] = FieldConstantName(field);
@@ -679,6 +727,8 @@ GenerateDependentFieldAccessorDefinitions(io::Printer* printer) {
for (int i = 0; i < descriptor_->field_count(); i++) {
const FieldDescriptor* field = descriptor_->field(i);
+ if (field->options().weak()) continue;
+
PrintFieldComment(printer, field);
// These functions are not really dependent: they are part of the
@@ -688,7 +738,7 @@ GenerateDependentFieldAccessorDefinitions(io::Printer* printer) {
// See the comment in FileGenerator::GenerateInlineFunctionDefinitions
// for a more complete explanation.
if (use_dependent_base_ && IsFieldDependent(field)) {
- map<string, string> vars;
+ std::map<string, string> vars;
SetCommonFieldVariables(field, &vars, options_);
vars["inline"] = "inline ";
if (field->containing_oneof()) {
@@ -725,13 +775,16 @@ GenerateDependentFieldAccessorDefinitions(io::Printer* printer) {
void MessageGenerator::
GenerateSingularFieldHasBits(const FieldDescriptor* field,
- map<string, string> vars,
+ std::map<string, string> vars,
io::Printer* printer) {
if (HasFieldPresence(descriptor_->file())) {
// N.B.: without field presence, we do not use has-bits or generate
// has_$name$() methods.
- vars["has_array_index"] = SimpleItoa(field->index() / 32);
- vars["has_mask"] = StrCat(strings::Hex(1u << (field->index() % 32),
+ int has_bit_index = has_bit_indices_[field->index()];
+ GOOGLE_CHECK_GE(has_bit_index, 0);
+
+ vars["has_array_index"] = SimpleItoa(has_bit_index / 32);
+ vars["has_mask"] = StrCat(strings::Hex(1u << (has_bit_index % 32),
strings::ZERO_PAD_8));
printer->Print(vars,
"$inline$"
@@ -771,7 +824,7 @@ GenerateSingularFieldHasBits(const FieldDescriptor* field,
void MessageGenerator::
GenerateOneofHasBits(io::Printer* printer, bool is_inline) {
for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars["oneof_name"] = descriptor_->oneof_decl(i)->name();
vars["oneof_index"] = SimpleItoa(descriptor_->oneof_decl(i)->index());
vars["cap_oneof_name"] =
@@ -793,7 +846,7 @@ GenerateOneofHasBits(io::Printer* printer, bool is_inline) {
void MessageGenerator::
GenerateOneofMemberHasBits(const FieldDescriptor* field,
- const map<string, string>& vars,
+ const std::map<string, string>& vars,
io::Printer* printer) {
// Singular field in a oneof
// N.B.: Without field presence, we do not use has-bits or generate
@@ -815,7 +868,7 @@ GenerateOneofMemberHasBits(const FieldDescriptor* field,
void MessageGenerator::
GenerateFieldClear(const FieldDescriptor* field,
- const map<string, string>& vars,
+ const std::map<string, string>& vars,
io::Printer* printer) {
// Generate clear_$name$() (See GenerateFieldAccessorDeclarations and
// GenerateDependentFieldAccessorDeclarations, $dependent_classname$ is
@@ -863,7 +916,7 @@ GenerateFieldAccessorDefinitions(io::Printer* printer, bool is_inline) {
PrintFieldComment(printer, field);
- map<string, string> vars;
+ std::map<string, string> vars;
SetCommonFieldVariables(field, &vars, options_);
vars["inline"] = is_inline ? "inline " : "";
if (use_dependent_base_ && IsFieldDependent(field)) {
@@ -925,7 +978,7 @@ GenerateDependentBaseClassDefinition(io::Printer* printer) {
return;
}
- map<string, string> vars;
+ std::map<string, string> vars;
vars["classname"] = DependentBaseClassTemplateName(descriptor_);
vars["full_name"] = descriptor_->full_name();
vars["superclass"] = SuperClassName(descriptor_, options_);
@@ -951,23 +1004,13 @@ GenerateDependentBaseClassDefinition(io::Printer* printer) {
void MessageGenerator::
GenerateClassDefinition(io::Printer* printer) {
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- // map entry message doesn't need class definition. Since map entry message
- // cannot be a top level class, we just need to avoid calling
- // GenerateClassDefinition here.
- if (IsMapEntryMessage(descriptor_->nested_type(i))) continue;
- nested_generators_[i]->GenerateClassDefinition(printer);
- printer->Print("\n");
- printer->Print(kThinSeparator);
- printer->Print("\n");
- }
-
+ if (IsMapEntryMessage(descriptor_)) return;
if (use_dependent_base_) {
GenerateDependentBaseClassDefinition(printer);
printer->Print("\n");
}
- map<string, string> vars;
+ std::map<string, string> vars;
vars["classname"] = classname_;
vars["full_name"] = descriptor_->full_name();
vars["field_count"] = SimpleItoa(descriptor_->field_count());
@@ -1007,44 +1050,19 @@ GenerateClassDefinition(io::Printer* printer) {
"\n");
if (PreserveUnknownFields(descriptor_)) {
- if (UseUnknownFieldSet(descriptor_->file(), options_)) {
- printer->Print(
- "inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n"
- " return _internal_metadata_.unknown_fields();\n"
- "}\n"
- "\n"
- "inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n"
- " return _internal_metadata_.mutable_unknown_fields();\n"
- "}\n"
- "\n");
- } else {
- if (SupportsArenas(descriptor_)) {
- printer->Print(
- "inline const ::std::string& unknown_fields() const {\n"
- " return _unknown_fields_.Get(\n"
- " &::google::protobuf::internal::GetEmptyStringAlreadyInited());\n"
- "}\n"
- "\n"
- "inline ::std::string* mutable_unknown_fields() {\n"
- " return _unknown_fields_.Mutable(\n"
- " &::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n"
- " GetArenaNoVirtual());\n"
- "}\n"
- "\n");
- } else {
- printer->Print(
- "inline const ::std::string& unknown_fields() const {\n"
- " return _unknown_fields_.GetNoArena(\n"
- " &::google::protobuf::internal::GetEmptyStringAlreadyInited());\n"
- "}\n"
- "\n"
- "inline ::std::string* mutable_unknown_fields() {\n"
- " return _unknown_fields_.MutableNoArena(\n"
- " &::google::protobuf::internal::GetEmptyStringAlreadyInited());\n"
- "}\n"
- "\n");
- }
- }
+ string type = UseUnknownFieldSet(descriptor_->file(), options_)
+ ? "::google::protobuf::UnknownFieldSet"
+ : "::std::string";
+ printer->Print(
+ "inline const $type$& unknown_fields() const {\n"
+ " return _internal_metadata_.unknown_fields();\n"
+ "}\n"
+ "\n"
+ "inline $type$* mutable_unknown_fields() {\n"
+ " return _internal_metadata_.mutable_unknown_fields();\n"
+ "}\n"
+ "\n",
+ "type", type );
}
// N.B.: We exclude GetArena() when arena support is disabled, falling back on
@@ -1054,8 +1072,10 @@ GenerateClassDefinition(io::Printer* printer) {
// virtual method version of GetArenaNoVirtual(), required for generic dispatch given a
// MessageLite* (e.g., in RepeatedField::AddAllocated()).
printer->Print(
- "inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }\n"
- "inline void* GetMaybeArenaPointer() const {\n"
+ "inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {\n"
+ " return GetArenaNoVirtual();\n"
+ "}\n"
+ "inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {\n"
" return MaybeArenaPtr();\n"
"}\n");
}
@@ -1101,7 +1121,10 @@ GenerateClassDefinition(io::Printer* printer) {
// TODO(gerbens) make this private, while still granting other protos access.
printer->Print(
vars,
- "static const $classname$* internal_default_instance();\n"
+ "static inline const $classname$* internal_default_instance() {\n"
+ " return reinterpret_cast<const $classname$*>(\n"
+ " &_$classname$_default_instance_);\n"
+ "}\n"
"\n");
@@ -1124,97 +1147,78 @@ GenerateClassDefinition(io::Printer* printer) {
"\n");
}
+ vars["new_final"] = " PROTOBUF_FINAL";
+
printer->Print(vars,
"void Swap($classname$* other);\n"
"\n"
"// implements Message ----------------------------------------------\n"
"\n"
- "inline $classname$* New() const { return New(NULL); }\n"
+ "inline $classname$* New() const$new_final$ { return New(NULL); }\n"
"\n"
- "$classname$* New(::google::protobuf::Arena* arena) const;\n");
+ "$classname$* New(::google::protobuf::Arena* arena) const$new_final$;\n");
+
+ // For instances that derive from Message (rather than MessageLite), some
+ // methods are virtual and should be marked as final.
+ string use_final = HasDescriptorMethods(descriptor_->file(), options_) ?
+ " PROTOBUF_FINAL" : "";
if (HasGeneratedMethods(descriptor_->file(), options_)) {
if (HasDescriptorMethods(descriptor_->file(), options_)) {
printer->Print(vars,
- "void CopyFrom(const ::google::protobuf::Message& from);\n"
- "void MergeFrom(const ::google::protobuf::Message& from);\n");
+ "void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;\n"
+ "void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;\n");
} else {
printer->Print(vars,
- "void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);\n");
+ "void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from)\n"
+ " PROTOBUF_FINAL;\n");
}
- printer->Print(vars,
- "void CopyFrom(const $classname$& from);\n"
- "void MergeFrom(const $classname$& from);\n"
- "void Clear();\n"
- "bool IsInitialized() const;\n"
- "\n"
- "size_t ByteSizeLong() const;\n"
- "bool MergePartialFromCodedStream(\n"
- " ::google::protobuf::io::CodedInputStream* input);\n"
- "void SerializeWithCachedSizes(\n"
- " ::google::protobuf::io::CodedOutputStream* output) const;\n");
+ vars["clear_final"] = " PROTOBUF_FINAL";
+ vars["is_initialized_final"] = " PROTOBUF_FINAL";
+ vars["merge_partial_final"] = " PROTOBUF_FINAL";
+
+ printer->Print(
+ vars,
+ "void CopyFrom(const $classname$& from);\n"
+ "void MergeFrom(const $classname$& from);\n"
+ "void Clear()$clear_final$;\n"
+ "bool IsInitialized() const$is_initialized_final$;\n"
+ "\n"
+ "size_t ByteSizeLong() const PROTOBUF_FINAL;\n"
+ "bool MergePartialFromCodedStream(\n"
+ " ::google::protobuf::io::CodedInputStream* input)$merge_partial_final$;\n"
+ "void SerializeWithCachedSizes(\n"
+ " ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;\n");
// DiscardUnknownFields() is implemented in message.cc using reflections. We
// need to implement this function in generated code for messages.
if (!UseUnknownFieldSet(descriptor_->file(), options_)) {
printer->Print(
- "void DiscardUnknownFields();\n");
+ "void DiscardUnknownFields()$final$;\n",
+ "final", use_final);
}
if (HasFastArraySerialization(descriptor_->file(), options_)) {
printer->Print(
- "::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n"
- " bool deterministic, ::google::protobuf::uint8* output) const;\n"
- "::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n"
- " return InternalSerializeWithCachedSizesToArray(false, output);\n"
- "}\n");
- }
- }
-
- // Check all FieldDescriptors including those in oneofs to estimate
- // whether ::std::string is likely to be used, and depending on that
- // estimate, set uses_string_ to true or false. That contols
- // whether to force initialization of empty_string_ in SharedCtor().
- // It's often advantageous to do so to keep "is empty_string_
- // inited?" code from appearing all over the place.
- vector<const FieldDescriptor*> descriptors;
- for (int i = 0; i < descriptor_->field_count(); i++) {
- descriptors.push_back(descriptor_->field(i));
- }
- for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
- for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {
- descriptors.push_back(descriptor_->oneof_decl(i)->field(j));
- }
- }
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- const Descriptor* nested_type = descriptor_->nested_type(i);
- if (IsMapEntryMessage(nested_type)) {
- descriptors.push_back(nested_type->FindFieldByName("key"));
- descriptors.push_back(nested_type->FindFieldByName("value"));
- }
- }
- uses_string_ = false;
- if (PreserveUnknownFields(descriptor_) &&
- !UseUnknownFieldSet(descriptor_->file(), options_)) {
- uses_string_ = true;
- }
- for (int i = 0; i < descriptors.size(); i++) {
- const FieldDescriptor* field = descriptors[i];
- if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) {
- switch (field->options().ctype()) {
- default: uses_string_ = true; break;
- }
+ "::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n"
+ " bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;\n"
+ "::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)\n"
+ " const PROTOBUF_FINAL {\n"
+ " return InternalSerializeWithCachedSizesToArray(\n"
+ " ::google::protobuf::io::CodedOutputStream::"
+ "IsDefaultSerializationDeterministic(), output);\n"
+ "}\n");
}
}
printer->Print(
- "int GetCachedSize() const { return _cached_size_; }\n"
+ "int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }\n"
"private:\n"
"void SharedCtor();\n"
"void SharedDtor();\n"
- "void SetCachedSize(int size) const;\n"
- "void InternalSwap($classname$* other);\n"
- "void UnsafeMergeFrom(const $classname$& from);\n",
- "classname", classname_);
+ "void SetCachedSize(int size) const$final$;\n"
+ "void InternalSwap($classname$* other);\n",
+ "classname", classname_,
+ "final", use_final);
if (SupportsArenas(descriptor_)) {
printer->Print(
"protected:\n"
@@ -1225,7 +1229,7 @@ GenerateClassDefinition(io::Printer* printer) {
"classname", classname_);
}
- if (UseUnknownFieldSet(descriptor_->file(), options_)) {
+ if (SupportsArenas(descriptor_)) {
printer->Print(
"private:\n"
"inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n"
@@ -1233,29 +1237,29 @@ GenerateClassDefinition(io::Printer* printer) {
"}\n"
"inline void* MaybeArenaPtr() const {\n"
" return _internal_metadata_.raw_arena_ptr();\n"
- "}\n"
- "public:\n"
- "\n");
+ "}\n");
} else {
printer->Print(
"private:\n"
"inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n"
- " return _arena_ptr_;\n"
- "}\n"
- "inline ::google::protobuf::Arena* MaybeArenaPtr() const {\n"
- " return _arena_ptr_;\n"
+ " return NULL;\n"
"}\n"
+ "inline void* MaybeArenaPtr() const {\n"
+ " return NULL;\n"
+ "}\n");
+ }
+
+ printer->Print(
"public:\n"
"\n");
- }
if (HasDescriptorMethods(descriptor_->file(), options_)) {
printer->Print(
- "::google::protobuf::Metadata GetMetadata() const;\n"
+ "::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;\n"
"\n");
} else {
printer->Print(
- "::std::string GetTypeName() const;\n"
+ "::std::string GetTypeName() const PROTOBUF_FINAL;\n"
"\n");
}
@@ -1313,17 +1317,15 @@ GenerateClassDefinition(io::Printer* printer) {
// messages without true field presence.
if (HasFieldPresence(descriptor_->file()) ||
descriptor_->field(i)->containing_oneof()) {
- printer->Print(
- "inline void set_has_$name$();\n",
- "name", FieldName(descriptor_->field(i)));
+ printer->Print("void set_has_$name$();\n", "name",
+ FieldName(descriptor_->field(i)));
}
// clear_has_***() generated only for non-oneof fields
// in proto1/2.
if (!descriptor_->field(i)->containing_oneof() &&
HasFieldPresence(descriptor_->file())) {
- printer->Print(
- "inline void clear_has_$name$();\n",
- "name", FieldName(descriptor_->field(i)));
+ printer->Print("void clear_has_$name$();\n", "name",
+ FieldName(descriptor_->field(i)));
}
}
}
@@ -1353,7 +1355,7 @@ GenerateClassDefinition(io::Printer* printer) {
// TODO(kenton): Make _cached_size_ an atomic<int> when C++ supports it.
const string cached_size_decl = "mutable int _cached_size_;\n";
- const size_t sizeof_has_bits = HasBitsSize(descriptor_);
+ const size_t sizeof_has_bits = HasBitsSize();
const string has_bits_decl = sizeof_has_bits == 0 ? "" :
"::google::protobuf::internal::HasBits<" + SimpleItoa(sizeof_has_bits / 4) +
"> _has_bits_;\n";
@@ -1377,9 +1379,8 @@ GenerateClassDefinition(io::Printer* printer) {
"::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n");
} else {
printer->Print(
- "::google::protobuf::internal::ArenaStringPtr _unknown_fields_;\n"
- "::google::protobuf::Arena* _arena_ptr_;\n"
- "\n");
+ "::google::protobuf::internal::InternalMetadataWithArenaLite "
+ "_internal_metadata_;\n");
}
if (SupportsArenas(descriptor_)) {
@@ -1404,33 +1405,12 @@ GenerateClassDefinition(io::Printer* printer) {
// Field members:
- // List fields which doesn't belong to any oneof
- hash_map<string, int> fieldname_to_chunk;
- for (int i = 0; i < descriptor_->field_count(); i++) {
- if (!descriptor_->field(i)->containing_oneof()) {
- const FieldDescriptor* field = descriptor_->field(i);
- fieldname_to_chunk[FieldName(field)] = i / 8;
- }
- }
-
// Emit some private and static members
- runs_of_fields_ = vector< vector<string> >(1);
for (int i = 0; i < optimized_order_.size(); ++i) {
const FieldDescriptor* field = optimized_order_[i];
const FieldGenerator& generator = field_generators_.get(field);
generator.GenerateStaticMembers(printer);
generator.GeneratePrivateMembers(printer);
- if (CanInitializeByZeroing(field)) {
- const string& fieldname = FieldName(field);
- if (!runs_of_fields_.back().empty() &&
- (fieldname_to_chunk[runs_of_fields_.back().back()] !=
- fieldname_to_chunk[fieldname])) {
- runs_of_fields_.push_back(vector<string>());
- }
- runs_of_fields_.back().push_back(fieldname);
- } else if (!runs_of_fields_.back().empty()) {
- runs_of_fields_.push_back(vector<string>());
- }
}
// For each oneof generate a union
@@ -1477,79 +1457,41 @@ GenerateClassDefinition(io::Printer* printer) {
"::google::protobuf::internal::AnyMetadata _any_metadata_;\n");
}
- // Declare AddDescriptors(), BuildDescriptors(), and ShutdownFile() as
- // friends so that they can access private static variables like
- // default_instance_ and reflection_.
- printer->Print("friend void $dllexport_decl$ $initdefaultsname$_impl();\n",
- // Vars.
- "dllexport_decl", options_.dllexport_decl, "initdefaultsname",
- GlobalInitDefaultsName(descriptor_->file()->name()));
- printer->Print("friend void $dllexport_decl$ $adddescriptorsname$_impl();\n",
- // Vars.
- "dllexport_decl", options_.dllexport_decl,
- "adddescriptorsname",
- GlobalAddDescriptorsName(descriptor_->file()->name()));
-
+ // The TableStruct struct needs access to the private parts, in order to
+ // construct the offsets of all members.
+ // Some InitDefault and Shutdown are defined as static member functions of
+ // TableStruct such that they are also allowed to access private members.
printer->Print(
- "friend void $assigndescriptorsname$();\n"
- "friend void $shutdownfilename$();\n"
- "\n",
- "assigndescriptorsname",
- GlobalAssignDescriptorsName(descriptor_->file()->name()),
- "shutdownfilename", GlobalShutdownFileName(descriptor_->file()->name()));
-
- printer->Print(
- "void InitAsDefaultInstance();\n",
- "classname", classname_);
+ "friend struct $dllexport_decl$ $file_namespace$::TableStruct;\n",
+ // Vars.
+ "dllexport_decl", options_.dllexport_decl, "file_namespace",
+ FileLevelNamespace(descriptor_->file()->name()));
printer->Outdent();
- printer->Print("};\n");
-
- // This should ideally be put into the class scope, but Visual Studio just
- // refuses to compile it and complains about "use of undefined XXX":
- // https://ci.appveyor.com/project/protobuf/protobuf/build/1.0.2673/job/nrdf4tb9dau0sck5
- // A program as simple as "struct X { enum { value = sizeof(X) }; };" will
- // trigger the same error.
- printer->Print(
- "extern ::google::protobuf::internal::ExplicitlyConstructed<$classname$> "
- "$classname$_default_instance_;\n",
- "classname", classname_);
-
+ printer->Print("};");
GOOGLE_DCHECK(!need_to_emit_cached_size);
}
void MessageGenerator::
GenerateDependentInlineMethods(io::Printer* printer) {
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- // map entry message doesn't need inline methods. Since map entry message
- // cannot be a top level class, we just need to avoid calling
- // GenerateInlineMethods here.
- if (IsMapEntryMessage(descriptor_->nested_type(i))) continue;
- nested_generators_[i]->GenerateDependentInlineMethods(printer);
- printer->Print(kThinSeparator);
- printer->Print("\n");
+ if (IsMapEntryMessage(descriptor_)) return;
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ if (descriptor_->field(i)->options().weak()) {
+ field_generators_.get(descriptor_->field(i))
+ .GenerateDependentInlineAccessorDefinitions(printer);
+ }
}
-
GenerateDependentFieldAccessorDefinitions(printer);
}
void MessageGenerator::
GenerateInlineMethods(io::Printer* printer, bool is_inline) {
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- // map entry message doesn't need inline methods. Since map entry message
- // cannot be a top level class, we just need to avoid calling
- // GenerateInlineMethods here.
- if (IsMapEntryMessage(descriptor_->nested_type(i))) continue;
- nested_generators_[i]->GenerateInlineMethods(printer, is_inline);
- printer->Print(kThinSeparator);
- printer->Print("\n");
- }
-
+ if (IsMapEntryMessage(descriptor_)) return;
GenerateFieldAccessorDefinitions(printer, is_inline);
// Generate oneof_case() functions.
for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars["class_name"] = classname_;
vars["camel_oneof_name"] = UnderscoresToCamelCase(
descriptor_->oneof_decl(i)->name(), true);
@@ -1565,36 +1507,16 @@ GenerateInlineMethods(io::Printer* printer, bool is_inline) {
"_oneof_case_[$oneof_index$]);\n"
"}\n");
}
-
- printer->Print(
- "inline const $classname$* $classname$::internal_default_instance() {\n"
- " return &$classname$_default_instance_.get();\n"
- "}\n",
- "classname", classname_);
}
void MessageGenerator::
-GenerateDescriptorDeclarations(io::Printer* printer) {
- if (!IsMapEntryMessage(descriptor_)) {
- printer->Print(
- "const ::google::protobuf::Descriptor* $name$_descriptor_ = NULL;\n"
- "const ::google::protobuf::internal::GeneratedMessageReflection*\n"
- " $name$_reflection_ = NULL;\n",
- "name", classname_);
- } else {
- printer->Print(
- "const ::google::protobuf::Descriptor* $name$_descriptor_ = NULL;\n",
- "name", classname_);
- }
-
+GenerateExtraDefaultFields(io::Printer* printer) {
// Generate oneof default instance for reflection usage.
if (descriptor_->oneof_decl_count() > 0) {
- printer->Print("struct $name$OneofInstance {\n",
- "name", classname_);
+ printer->Print("public:\n");
for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {
const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);
- printer->Print(" ");
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE ||
(field->cpp_type() == FieldDescriptor::CPPTYPE_STRING &&
EffectiveStringCType(field) != FieldOptions::STRING)) {
@@ -1603,143 +1525,33 @@ GenerateDescriptorDeclarations(io::Printer* printer) {
field_generators_.get(field).GeneratePrivateMembers(printer);
}
}
-
- printer->Print("}* $name$_default_oneof_instance_ = NULL;\n",
- "name", classname_);
- }
-
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- nested_generators_[i]->GenerateDescriptorDeclarations(printer);
- }
-
- for (int i = 0; i < descriptor_->enum_type_count(); i++) {
- printer->Print(
- "const ::google::protobuf::EnumDescriptor* $name$_descriptor_ = NULL;\n",
- "name", ClassName(descriptor_->enum_type(i), false));
}
}
-void MessageGenerator::
-GenerateDescriptorInitializer(io::Printer* printer, int index) {
- // TODO(kenton): Passing the index to this method is redundant; just use
- // descriptor_->index() instead.
- map<string, string> vars;
- vars["classname"] = classname_;
- vars["index"] = SimpleItoa(index);
-
- // Obtain the descriptor from the parent's descriptor.
- if (descriptor_->containing_type() == NULL) {
- printer->Print(vars,
- "$classname$_descriptor_ = file->message_type($index$);\n");
- } else {
- vars["parent"] = ClassName(descriptor_->containing_type(), false);
- printer->Print(vars,
- "$classname$_descriptor_ = "
- "$parent$_descriptor_->nested_type($index$);\n");
- }
-
+void MessageGenerator::GenerateSchema(io::Printer* printer, int offset,
+ int has_offset) {
if (IsMapEntryMessage(descriptor_)) return;
- // Generate the offsets.
- GenerateOffsets(printer);
-
- const bool pass_pool_and_factory = false;
- vars["fn"] = pass_pool_and_factory ?
- "new ::google::protobuf::internal::GeneratedMessageReflection" :
- "::google::protobuf::internal::GeneratedMessageReflection"
- "::NewGeneratedMessageReflection";
- // Construct the reflection object.
- printer->Print(vars,
- "$classname$_reflection_ =\n"
- " $fn$(\n"
- " $classname$_descriptor_,\n"
- " $classname$::internal_default_instance(),\n"
- " $classname$_offsets_,\n");
- if (!HasFieldPresence(descriptor_->file())) {
- // If we don't have field presence, then _has_bits_ does not exist.
- printer->Print(vars,
- " -1,\n");
- } else {
- printer->Print(vars,
- " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, _has_bits_),\n");
- }
-
- // Unknown field offset: either points to the unknown field set if embedded
- // directly, or indicates that the unknown field set is stored as part of the
- // internal metadata if not.
- if (UseUnknownFieldSet(descriptor_->file(), options_)) {
- printer->Print(vars,
- " -1,\n");
- } else {
- printer->Print(vars,
- " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET("
- "$classname$, _unknown_fields_),\n");
- }
-
- if (descriptor_->extension_range_count() > 0) {
- printer->Print(vars,
- " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET("
- "$classname$, _extensions_),\n");
- } else {
- // No extensions.
- printer->Print(vars,
- " -1,\n");
- }
+ std::map<string, string> vars;
- if (descriptor_->oneof_decl_count() > 0) {
- printer->Print(vars,
- " $classname$_default_oneof_instance_,\n"
- " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET("
- "$classname$, _oneof_case_[0]),\n");
- }
-
- if (pass_pool_and_factory) {
- printer->Print(
- " ::google::protobuf::DescriptorPool::generated_pool(),\n");
- printer->Print(vars,
- " ::google::protobuf::MessageFactory::generated_factory(),\n");
- }
+ vars["classname"] = classname_;
+ vars["offset"] = SimpleItoa(offset);
+ vars["has_bits_offsets"] = HasFieldPresence(descriptor_->file())
+ ? SimpleItoa(offset + has_offset)
+ : "-1";
printer->Print(vars,
- " sizeof($classname$),\n");
-
- // Arena offset: either an offset to the metadata struct that contains the
- // arena pointer and unknown field set (in a space-efficient way) if we use
- // that implementation strategy, or an offset directly to the arena pointer if
- // not (because e.g. we don't have an unknown field set).
- if (UseUnknownFieldSet(descriptor_->file(), options_)) {
- printer->Print(vars,
- " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET("
- "$classname$, _internal_metadata_));\n");
- } else {
- printer->Print(vars,
- " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET("
- "$classname$, _arena_));\n");
- }
-
- // Handle nested types.
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- nested_generators_[i]->GenerateDescriptorInitializer(printer, i);
- }
-
- for (int i = 0; i < descriptor_->enum_type_count(); i++) {
- enum_generators_[i]->GenerateDescriptorInitializer(printer, i);
- }
+ "{ $offset$, $has_bits_offsets$, sizeof($classname$)},\n");
}
void MessageGenerator::
GenerateTypeRegistrations(io::Printer* printer) {
// Register this message type with the message factory.
- if (!IsMapEntryMessage(descriptor_)) {
- printer->Print(
- "::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n"
- " $classname$_descriptor_, "
- "$classname$::internal_default_instance());\n",
- "classname", classname_);
- } else {
- map<string, string> vars;
+ if (IsMapEntryMessage(descriptor_)) {
+ std::map<string, string> vars;
CollectMapInfo(descriptor_, &vars);
vars["classname"] = classname_;
+ vars["file_namespace"] = FileLevelNamespace(descriptor_->file()->name());
const FieldDescriptor* val = descriptor_->FindFieldByName("value");
if (descriptor_->file()->syntax() == FileDescriptor::SYNTAX_PROTO2 &&
@@ -1750,31 +1562,28 @@ GenerateTypeRegistrations(io::Printer* printer) {
vars["default_enum_value"] = "0";
}
- printer->Print(vars,
- "::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n"
- " $classname$_descriptor_,\n"
- " ::google::protobuf::internal::MapEntry<\n"
- " $key$,\n"
- " $val$,\n"
- " $key_wire_type$,\n"
- " $val_wire_type$,\n"
- " $default_enum_value$>::CreateDefaultInstance(\n"
- " $classname$_descriptor_));\n");
- }
-
- // Handle nested types.
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- nested_generators_[i]->GenerateTypeRegistrations(printer);
+ vars["index_in_metadata"] = SimpleItoa(index_in_metadata_);
+
+ printer->Print(
+ vars,
+ "const ::google::protobuf::Descriptor* $classname$_descriptor = "
+ "$file_namespace$::file_level_metadata[$index_in_metadata$].descriptor;"
+ "\n"
+ "::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n"
+ " $classname$_descriptor,\n"
+ " ::google::protobuf::internal::MapEntry<\n"
+ " $key$,\n"
+ " $val$,\n"
+ " $key_wire_type$,\n"
+ " $val_wire_type$,\n"
+ " $default_enum_value$>::CreateDefaultInstance(\n"
+ " $classname$_descriptor));\n");
}
}
void MessageGenerator::
GenerateDefaultInstanceAllocator(io::Printer* printer) {
- // Force initialization of primitive values we depend on.
- printer->Print(
- StrCat(
- uses_string_ ? "::google::protobuf::internal::GetEmptyString();\n" : "")
- .c_str());
+ if (IsMapEntryMessage(descriptor_)) return;
// Construct the default instances of all fields, as they will be used
// when creating the default instance of the entire message.
@@ -1783,64 +1592,60 @@ GenerateDefaultInstanceAllocator(io::Printer* printer) {
.GenerateDefaultInstanceAllocator(printer);
}
- if (IsMapEntryMessage(descriptor_)) return;
-
// Construct the default instance. We can't call InitAsDefaultInstance() yet
// because we need to make sure all default instances that this one might
// depend on are constructed first.
- printer->Print("$classname$_default_instance_.DefaultConstruct();\n",
+ printer->Print("_$classname$_default_instance_.DefaultConstruct();\n",
"classname", classname_);
-
- if ((descriptor_->oneof_decl_count() > 0) &&
- HasDescriptorMethods(descriptor_->file(), options_)) {
- printer->Print(
- "$classname$_default_oneof_instance_ = new $classname$OneofInstance();\n",
- "classname", classname_);
- }
-
- // Handle nested types.
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- nested_generators_[i]->GenerateDefaultInstanceAllocator(printer);
- }
-
}
void MessageGenerator::
GenerateDefaultInstanceInitializer(io::Printer* printer) {
- printer->Print(
- "$classname$_default_instance_.get_mutable()->InitAsDefaultInstance();"
- "\n",
- "classname", classname_);
+ if (IsMapEntryMessage(descriptor_)) return;
- // Register extensions.
- for (int i = 0; i < descriptor_->extension_count(); i++) {
- extension_generators_[i]->GenerateRegistration(printer);
- }
+ // The default instance needs all of its embedded message pointers
+ // cross-linked to other default instances. We can't do this initialization
+ // in the constructor because some other default instances may not have been
+ // constructed yet at that time.
+ // TODO(kenton): Maybe all message fields (even for non-default messages)
+ // should be initialized to point at default instances rather than NULL?
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const FieldDescriptor* field = descriptor_->field(i);
- // Handle nested types.
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- // map entry message doesn't need to initialize default instance manually.
- // Since map entry message cannot be a top level class, we just need to
- // avoid calling DefaultInstanceInitializer here.
- if (IsMapEntryMessage(descriptor_->nested_type(i))) continue;
- nested_generators_[i]->GenerateDefaultInstanceInitializer(printer);
+ if (!field->is_repeated() &&
+ field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
+ (field->containing_oneof() == NULL ||
+ HasDescriptorMethods(descriptor_->file(), options_))) {
+ string name;
+ if (field->containing_oneof()) {
+ name = "_" + classname_ + "_default_instance_.";
+ } else {
+ name = "_" + classname_ + "_default_instance_.get_mutable()->";
+ }
+ name += FieldName(field);
+ printer->Print(
+ "$name$_ = const_cast< $type$*>(\n"
+ " $type$::internal_default_instance());\n",
+ // Vars.
+ "name", name, "type", FieldMessageTypeName(field));
+ } else if (field->containing_oneof() &&
+ HasDescriptorMethods(descriptor_->file(), options_)) {
+ field_generators_.get(descriptor_->field(i))
+ .GenerateConstructorCode(printer);
+ }
}
}
void MessageGenerator::
GenerateShutdownCode(io::Printer* printer) {
- printer->Print(
- "$classname$_default_instance_.Shutdown();\n",
- "classname", classname_);
+ if (IsMapEntryMessage(descriptor_)) return;
+
+ printer->Print("_$classname$_default_instance_.Shutdown();\n", "classname",
+ classname_);
+
if (HasDescriptorMethods(descriptor_->file(), options_)) {
- if (descriptor_->oneof_decl_count() > 0) {
- printer->Print(
- "delete $classname$_default_oneof_instance_;\n",
- "classname", classname_);
- }
- printer->Print(
- "delete $classname$_reflection_;\n",
- "classname", classname_);
+ printer->Print("delete file_level_metadata[$index$].reflection;\n", "index",
+ SimpleItoa(index_in_metadata_));
}
// Handle default instances of fields.
@@ -1848,28 +1653,12 @@ GenerateShutdownCode(io::Printer* printer) {
field_generators_.get(descriptor_->field(i))
.GenerateShutdownCode(printer);
}
-
- // Handle nested types.
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- if (IsMapEntryMessage(descriptor_->nested_type(i))) continue;
- nested_generators_[i]->GenerateShutdownCode(printer);
- }
}
void MessageGenerator::
GenerateClassMethods(io::Printer* printer) {
- // mutable_unknown_fields wrapper function for LazyStringOutputStream
- // callback.
- if (PreserveUnknownFields(descriptor_) &&
- !UseUnknownFieldSet(descriptor_->file(), options_)) {
- printer->Print(
- "static ::std::string* MutableUnknownFieldsFor$classname$(\n"
- " $classname$* ptr) {\n"
- " return ptr->mutable_unknown_fields();\n"
- "}\n"
- "\n",
- "classname", classname_);
- }
+ if (IsMapEntryMessage(descriptor_)) return;
+
if (IsAnyMessage(descriptor_)) {
printer->Print(
"void $classname$::PackFrom(const ::google::protobuf::Message& message) {\n"
@@ -1888,21 +1677,6 @@ GenerateClassMethods(io::Printer* printer) {
"classname", classname_);
}
- for (int i = 0; i < descriptor_->enum_type_count(); i++) {
- enum_generators_[i]->GenerateMethods(printer);
- }
-
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- // map entry message doesn't need class methods. Since map entry message
- // cannot be a top level class, we just need to avoid calling
- // GenerateClassMethods here.
- if (IsMapEntryMessage(descriptor_->nested_type(i))) continue;
- nested_generators_[i]->GenerateClassMethods(printer);
- printer->Print("\n");
- printer->Print(kThinSeparator);
- printer->Print("\n");
- }
-
// Generate non-inline field definitions.
for (int i = 0; i < descriptor_->field_count(); i++) {
field_generators_.get(descriptor_->field(i))
@@ -1922,11 +1696,6 @@ GenerateClassMethods(io::Printer* printer) {
"#endif // !defined(_MSC_VER) || _MSC_VER >= 1900\n"
"\n");
- // Define extension identifiers.
- for (int i = 0; i < descriptor_->extension_count(); i++) {
- extension_generators_[i]->GenerateDefinition(printer);
- }
-
GenerateStructors(printer);
printer->Print("\n");
@@ -1961,12 +1730,6 @@ GenerateClassMethods(io::Printer* printer) {
GenerateIsInitialized(printer);
printer->Print("\n");
- } else {
- printer->Print(
- "void $classname$::UnsafeMergeFrom(const $classname$& from) {\n"
- " MergeFrom(from);\n"
- "}\n",
- "classname", classname_);
}
GenerateSwap(printer);
@@ -1974,15 +1737,13 @@ GenerateClassMethods(io::Printer* printer) {
if (HasDescriptorMethods(descriptor_->file(), options_)) {
printer->Print(
- "::google::protobuf::Metadata $classname$::GetMetadata() const {\n"
- " protobuf_AssignDescriptorsOnce();\n"
- " ::google::protobuf::Metadata metadata;\n"
- " metadata.descriptor = $classname$_descriptor_;\n"
- " metadata.reflection = $classname$_reflection_;\n"
- " return metadata;\n"
- "}\n"
- "\n",
- "classname", classname_);
+ "::google::protobuf::Metadata $classname$::GetMetadata() const {\n"
+ " $file_namespace$::protobuf_AssignDescriptorsOnce();\n"
+ " return $file_namespace$::file_level_metadata[$index$];\n"
+ "}\n"
+ "\n",
+ "classname", classname_, "index", SimpleItoa(index_in_metadata_),
+ "file_namespace", FileLevelNamespace(descriptor_->file()->name()));
} else {
printer->Print(
"::std::string $classname$::GetTypeName() const {\n"
@@ -1995,22 +1756,49 @@ GenerateClassMethods(io::Printer* printer) {
}
-void MessageGenerator::
-GenerateOffsets(io::Printer* printer) {
- printer->Print("static const int $classname$_offsets_[$field_count$] = {\n",
- "classname", classname_, "field_count",
- SimpleItoa(std::max(1, descriptor_->field_count() +
- descriptor_->oneof_decl_count())));
- printer->Indent();
+std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
+ io::Printer* printer) {
+ if (IsMapEntryMessage(descriptor_)) return std::make_pair(0, 0);
+ std::map<string, string> variables;
+ variables["classname"] = classname_;
+ if (HasFieldPresence(descriptor_->file())) {
+ printer->Print(
+ variables,
+ "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, _has_bits_),\n");
+ } else {
+ printer->Print("~0u, // no _has_bits_\n");
+ }
+ printer->Print(variables,
+ "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, "
+ "_internal_metadata_),\n");
+ if (descriptor_->extension_range_count() > 0) {
+ printer->Print(
+ variables,
+ "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, _extensions_),\n");
+ } else {
+ printer->Print("~0u, // no _extensions_\n");
+ }
+ if (descriptor_->oneof_decl_count() > 0) {
+ printer->Print(variables,
+ "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, "
+ "_oneof_case_[0]),\n");
+ } else {
+ printer->Print("~0u, // no _oneof_case_\n");
+ }
+
+ const int kNumGenericOffsets = 4; // the number of fixed offsets above
+ const size_t offsets = kNumGenericOffsets +
+ descriptor_->field_count() +
+ descriptor_->oneof_decl_count();
+ size_t entries = offsets;
for (int i = 0; i < descriptor_->field_count(); i++) {
const FieldDescriptor* field = descriptor_->field(i);
if (field->containing_oneof()) {
printer->Print(
"PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET("
- "$classname$_default_oneof_instance_, $name$_),\n",
- "classname", classname_,
- "name", FieldName(field));
+ "(&_$classname$_default_instance_), $name$_),\n",
+ "classname", classname_, "name", FieldName(field));
} else {
printer->Print(
"GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, "
@@ -2028,8 +1816,16 @@ GenerateOffsets(io::Printer* printer) {
"name", oneof->name());
}
- printer->Outdent();
- printer->Print("};\n");
+ if (HasFieldPresence(descriptor_->file())) {
+ entries += has_bit_indices_.size();
+ for (int i = 0; i < has_bit_indices_.size(); i++) {
+ const string index = has_bit_indices_[i] >= 0 ?
+ SimpleItoa(has_bit_indices_[i]) : "~0u";
+ printer->Print("$index$,\n", "index", index);
+ }
+ }
+
+ return std::make_pair(entries, offsets);
}
void MessageGenerator::
@@ -2043,66 +1839,27 @@ GenerateSharedConstructorCode(io::Printer* printer) {
// We reproduce the logic used for laying out _cached_sized_ in the class
// definition, as to initialize it in-order.
if (HasFieldPresence(descriptor_->file()) &&
- (HasBitsSize(descriptor_) % 8) != 0) {
+ (HasBitsSize() % 8) != 0) {
printer->Print("_cached_size_ = 0;\n");
need_to_clear_cached_size = false;
}
- if (PreserveUnknownFields(descriptor_) &&
- !UseUnknownFieldSet(descriptor_->file(), options_)) {
- printer->Print(
- "_unknown_fields_.UnsafeSetDefault(\n"
- " &::google::protobuf::internal::GetEmptyStringAlreadyInited());\n");
- }
-
- const FieldDescriptor* last_start = NULL;
- // RunMap maps from fields that start each run to the number of fields in that
- // run. This is optimized for the common case that there are very few runs in
- // a message and that most of the eligible fields appear together.
- typedef hash_map<const FieldDescriptor*, size_t> RunMap;
- RunMap runs;
-
- for (int i = 0; i < optimized_order_.size(); ++i) {
- const FieldDescriptor* field = optimized_order_[i];
- // TODO(ckennelly): Scalar messages (raw pointers) can be initialized by
- // zero as well.
- if (CanInitializeByZeroing(field)) {
- if (last_start == NULL) {
- last_start = field;
- }
-
- runs[last_start]++;
- } else {
- last_start = NULL;
- }
- }
-
- for (int i = 0; i < optimized_order_.size(); ++i) {
- const FieldDescriptor* field = optimized_order_[i];
- RunMap::const_iterator it = runs.find(field);
-
- // We only apply the memset technique to runs of more than one field, as
- // assignment is better than memset for generated code clarity.
- if (it != runs.end() && it->second > 1) {
- // Use a memset, then skip run_length fields.
- const size_t run_length = it->second;
- const string first_field_name = FieldName(field);
- const string last_field_name =
- FieldName(optimized_order_[i + run_length - 1]);
-
+ // TODO(gerbens) Clean this hack, and why do i need a reference to a pointer??
+ for (int i = 0; i < descriptor_->nested_type_count(); i++) {
+ if (HasDescriptorMethods(descriptor_->file(), options_) &&
+ IsMapEntryMessage(descriptor_->nested_type(i))) {
printer->Print(
- "::memset(&$first$_, 0, reinterpret_cast<char*>(&$last$_) -\n"
- " reinterpret_cast<char*>(&$first$_) + sizeof($last$_));\n",
- "first", first_field_name,
- "last", last_field_name);
-
- i += run_length - 1;
- // ++i at the top of the loop.
- } else {
- field_generators_.get(field).GenerateConstructorCode(printer);
+ "const ::google::protobuf::Descriptor*& $type$_descriptor = "
+ "$file_namespace$::file_level_metadata[$index$].descriptor;\n",
+ "type", ClassName(descriptor_->nested_type(i), false), "index",
+ SimpleItoa(nested_generators_[i]->index_in_metadata_),
+ "file_namespace", FileLevelNamespace(descriptor_->file()->name()));
}
}
+ std::vector<bool> processed(optimized_order_.size(), false);
+ GenerateConstructorBody(printer, processed, false);
+
for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
printer->Print(
"clear_has_$oneof_name$();\n",
@@ -2133,21 +1890,6 @@ GenerateSharedDestructorCode(io::Printer* printer) {
"\n");
}
- // Write the desctructor for _unknown_fields_ in lite runtime.
- if (PreserveUnknownFields(descriptor_) &&
- !UseUnknownFieldSet(descriptor_->file(), options_)) {
- if (SupportsArenas(descriptor_)) {
- printer->Print(
- "_unknown_fields_.Destroy(\n"
- " &::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n"
- " arena);\n");
- } else {
- printer->Print(
- "_unknown_fields_.DestroyNoArena(\n"
- " &::google::protobuf::internal::GetEmptyStringAlreadyInited());\n");
- }
- }
-
// Write the destructors for each field except oneof members.
// optimized_order_ does not contain oneof fields.
for (int i = 0; i < optimized_order_.size(); i++) {
@@ -2164,35 +1906,6 @@ GenerateSharedDestructorCode(io::Printer* printer) {
"oneof_name", descriptor_->oneof_decl(i)->name());
}
- // We need to delete all embedded messages.
- // TODO(kenton): If we make unset messages point at default instances
- // instead of NULL, then it would make sense to move this code into
- // MessageFieldGenerator::GenerateDestructorCode().
- bool need_delete_message_field = false;
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* field = descriptor_->field(i);
-
- if (!field->is_repeated() &&
- field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
- // Skip oneof members
- if (!field->containing_oneof()) {
- if (!need_delete_message_field) {
- need_delete_message_field = true;
- printer->Print(
- "if (this != &$classname$_default_instance_.get()) {\n",
- "classname", classname_);
- printer->Indent();
- }
- printer->Print("delete $name$_;\n", "name", FieldName(field));
- }
- }
- }
- if (need_delete_message_field) {
- printer->Outdent();
- printer->Print(
- "}\n");
- }
-
printer->Outdent();
printer->Print(
"}\n"
@@ -2219,12 +1932,31 @@ GenerateArenaDestructorCode(io::Printer* printer) {
"classname", classname_);
bool need_registration = false;
- for (int i = 0; i < descriptor_->field_count(); i++) {
- if (field_generators_.get(descriptor_->field(i))
+ // Process non-oneof fields first.
+ for (int i = 0; i < optimized_order_.size(); i++) {
+ const FieldDescriptor* field = optimized_order_[i];
+ if (field_generators_.get(field)
.GenerateArenaDestructorCode(printer)) {
need_registration = true;
}
}
+
+ // Process oneof fields.
+ //
+ // Note: As of 10/5/2016, GenerateArenaDestructorCode does not emit anything
+ // and returns false for oneof fields.
+ for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
+ const OneofDescriptor* oneof = descriptor_->oneof_decl(i);
+
+ for (int j = 0; j < oneof->field_count(); j++) {
+ const FieldDescriptor* field = oneof->field(j);
+ if (field_generators_.get(field)
+ .GenerateArenaDestructorCode(printer)) {
+ need_registration = true;
+ }
+ }
+ }
+
printer->Outdent();
printer->Print(
"}\n");
@@ -2245,6 +1977,75 @@ GenerateArenaDestructorCode(io::Printer* printer) {
}
}
+void MessageGenerator::GenerateConstructorBody(io::Printer* printer,
+ std::vector<bool> processed,
+ bool copy_constructor) const {
+ const FieldDescriptor* last_start = NULL;
+ // RunMap maps from fields that start each run to the number of fields in that
+ // run. This is optimized for the common case that there are very few runs in
+ // a message and that most of the eligible fields appear together.
+ typedef hash_map<const FieldDescriptor*, size_t> RunMap;
+ RunMap runs;
+
+ for (int i = 0; i < optimized_order_.size(); ++i) {
+ const FieldDescriptor* field = optimized_order_[i];
+ if ((copy_constructor && IsPOD(field)) ||
+ (!copy_constructor && CanConstructByZeroing(field, options_))) {
+ if (last_start == NULL) {
+ last_start = field;
+ }
+
+ runs[last_start]++;
+ } else {
+ last_start = NULL;
+ }
+ }
+
+ string pod_template;
+ if (copy_constructor) {
+ pod_template =
+ "::memcpy(&$first$_, &from.$first$_,\n"
+ " reinterpret_cast<char*>(&$last$_) -\n"
+ " reinterpret_cast<char*>(&$first$_) + sizeof($last$_));\n";
+ } else {
+ pod_template =
+ "::memset(&$first$_, 0, reinterpret_cast<char*>(&$last$_) -\n"
+ " reinterpret_cast<char*>(&$first$_) + sizeof($last$_));\n";
+ }
+
+ for (int i = 0; i < optimized_order_.size(); ++i) {
+ if (processed[i]) {
+ continue;
+ }
+
+ const FieldDescriptor* field = optimized_order_[i];
+ RunMap::const_iterator it = runs.find(field);
+
+ // We only apply the memset technique to runs of more than one field, as
+ // assignment is better than memset for generated code clarity.
+ if (it != runs.end() && it->second > 1) {
+ // Use a memset, then skip run_length fields.
+ const size_t run_length = it->second;
+ const string first_field_name = FieldName(field);
+ const string last_field_name =
+ FieldName(optimized_order_[i + run_length - 1]);
+
+ printer->Print(pod_template.c_str(),
+ "first", first_field_name,
+ "last", last_field_name);
+
+ i += run_length - 1;
+ // ++i at the top of the loop.
+ } else {
+ if (copy_constructor) {
+ field_generators_.get(field).GenerateCopyConstructorCode(printer);
+ } else {
+ field_generators_.get(field).GenerateConstructorCode(printer);
+ }
+ }
+ }
+}
+
void MessageGenerator::
GenerateStructors(io::Printer* printer) {
string superclass;
@@ -2260,11 +2061,7 @@ GenerateStructors(io::Printer* printer) {
initializer_with_arena += ",\n _extensions_(arena)";
}
- if (UseUnknownFieldSet(descriptor_->file(), options_)) {
- initializer_with_arena += ",\n _internal_metadata_(arena)";
- } else {
- initializer_with_arena += ",\n _arena_ptr_(arena)";
- }
+ initializer_with_arena += ",\n _internal_metadata_(arena)";
// Initialize member variables with arena constructor.
for (int i = 0; i < optimized_order_.size(); i++) {
@@ -2282,8 +2079,7 @@ GenerateStructors(io::Printer* printer) {
}
string initializer_null;
- initializer_null = (UseUnknownFieldSet(descriptor_->file(), options_) ?
- ", _internal_metadata_(NULL)" : ", _arena_ptr_(NULL)");
+ initializer_null = ", _internal_metadata_(NULL)";
if (IsAnyMessage(descriptor_)) {
initializer_null += ", _any_metadata_(&type_url_, &value_)";
}
@@ -2291,13 +2087,15 @@ GenerateStructors(io::Printer* printer) {
printer->Print(
"$classname$::$classname$()\n"
" : $superclass$()$initializer$ {\n"
- " if (this != internal_default_instance()) $initdefaultsname$();\n"
+ " if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {\n"
+ " $file_namespace$::InitDefaults();\n"
+ " }\n"
" SharedCtor();\n"
" // @@protoc_insertion_point(constructor:$full_name$)\n"
"}\n",
"classname", classname_, "superclass", superclass, "full_name",
descriptor_->full_name(), "initializer", initializer_null,
- "initdefaultsname", GlobalInitDefaultsName(descriptor_->file()->name()));
+ "file_namespace", FileLevelNamespace(descriptor_->file()->name()));
if (SupportsArenas(descriptor_)) {
printer->Print(
@@ -2306,7 +2104,7 @@ GenerateStructors(io::Printer* printer) {
// When arenas are used it's safe to assume we have finished
// static init time (protos with arenas are unsafe during static init)
"#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n"
- " $initdefaultsname$();\n"
+ " $file_namespace$::InitDefaults();\n"
"#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n"
" SharedCtor();\n"
" RegisterArenaDtor(arena);\n"
@@ -2314,47 +2112,8 @@ GenerateStructors(io::Printer* printer) {
"}\n",
"initializer", initializer_with_arena, "classname", classname_,
"superclass", superclass, "full_name", descriptor_->full_name(),
- "initdefaultsname",
- GlobalInitDefaultsName(descriptor_->file()->name()));
- }
-
- printer->Print(
- "\n"
- "void $classname$::InitAsDefaultInstance() {\n",
- "classname", classname_);
-
- // The default instance needs all of its embedded message pointers
- // cross-linked to other default instances. We can't do this initialization
- // in the constructor because some other default instances may not have been
- // constructed yet at that time.
- // TODO(kenton): Maybe all message fields (even for non-default messages)
- // should be initialized to point at default instances rather than NULL?
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* field = descriptor_->field(i);
-
- if (!field->is_repeated() &&
- field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
- (field->containing_oneof() == NULL ||
- HasDescriptorMethods(descriptor_->file(), options_))) {
- string name;
- if (field->containing_oneof()) {
- name = classname_ + "_default_oneof_instance_->";
- }
- name += FieldName(field);
- printer->Print(
- " $name$_ = const_cast< $type$*>(\n"
- " $type$::internal_default_instance());\n",
- // Vars.
- "name", name, "type", FieldMessageTypeName(field));
- } else if (field->containing_oneof() &&
- HasDescriptorMethods(descriptor_->file(), options_)) {
- field_generators_.get(descriptor_->field(i))
- .GenerateConstructorCode(printer);
- }
+ "file_namespace", FileLevelNamespace(descriptor_->file()->name()));
}
- printer->Print(
- "}\n"
- "\n");
// Generate the copy constructor.
printer->Print(
@@ -2363,24 +2122,114 @@ GenerateStructors(io::Printer* printer) {
"classname", classname_,
"superclass", superclass,
"full_name", descriptor_->full_name());
- if (UseUnknownFieldSet(descriptor_->file(), options_)) {
- printer->Print(
- ",\n _internal_metadata_(NULL)");
- } else if (!UseUnknownFieldSet(descriptor_->file(), options_)) {
- printer->Print(",\n _arena_ptr_(NULL)");
+ printer->Indent();
+ printer->Indent();
+ printer->Indent();
+
+ printer->Print(
+ ",\n_internal_metadata_(NULL)");
+
+ if (HasFieldPresence(descriptor_->file())) {
+ printer->Print(",\n_has_bits_(from._has_bits_)");
}
+
+ bool need_to_emit_cached_size = true;
+ const string cached_size_decl = ",\n_cached_size_(0)";
+ // We reproduce the logic used for laying out _cached_sized_ in the class
+ // definition, as to initialize it in-order.
+ if (HasFieldPresence(descriptor_->file()) &&
+ (HasBitsSize() % 8) != 0) {
+ printer->Print(cached_size_decl.c_str());
+ need_to_emit_cached_size = false;
+ }
+
+ std::vector<bool> processed(optimized_order_.size(), false);
+ for (int i = 0; i < optimized_order_.size(); ++i) {
+ const FieldDescriptor* field = optimized_order_[i];
+
+ if (!(field->is_repeated() && !(field->is_map()))
+ ) {
+ continue;
+ }
+
+ processed[i] = true;
+ printer->Print(",\n$name$_(from.$name$_)",
+ "name", FieldName(field));
+ }
+
+ if (need_to_emit_cached_size) {
+ printer->Print(cached_size_decl.c_str());
+ need_to_emit_cached_size = false;
+ }
+
if (IsAnyMessage(descriptor_)) {
- printer->Print(",\n _any_metadata_(&type_url_, &value_)");
+ printer->Print(",\n_any_metadata_(&type_url_, &value_)");
}
+
+ printer->Outdent();
+ printer->Outdent();
printer->Print(" {\n");
+
+ printer->Print(
+ "_internal_metadata_.MergeFrom(from._internal_metadata_);\n");
+
+ if (descriptor_->extension_range_count() > 0) {
+ printer->Print("_extensions_.MergeFrom(from._extensions_);\n");
+ }
+
+ // TODO(gerbens) Clean this hack, and why do i need a reference to a pointer??
+ for (int i = 0; i < descriptor_->nested_type_count(); i++) {
+ if (HasDescriptorMethods(descriptor_->file(), options_) &&
+ IsMapEntryMessage(descriptor_->nested_type(i))) {
+ printer->Print(
+ "const ::google::protobuf::Descriptor*& $type$_descriptor = "
+ "$file_namespace$::file_level_metadata[$index$].descriptor;\n",
+ "type", ClassName(descriptor_->nested_type(i), false), "index",
+ SimpleItoa(nested_generators_[i]->index_in_metadata_),
+ "file_namespace", FileLevelNamespace(descriptor_->file()->name()));
+ }
+ }
+
+ GenerateConstructorBody(printer, processed, true);
+
+ // Copy oneof fields. Oneof field requires oneof case check.
+ for (int i = 0; i < descriptor_->oneof_decl_count(); ++i) {
+ printer->Print(
+ "clear_has_$oneofname$();\n"
+ "switch (from.$oneofname$_case()) {\n",
+ "oneofname", descriptor_->oneof_decl(i)->name());
+ printer->Indent();
+ for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {
+ const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);
+ printer->Print(
+ "case k$field_name$: {\n",
+ "field_name", UnderscoresToCamelCase(field->name(), true));
+ printer->Indent();
+ field_generators_.get(field).GenerateMergingCode(printer);
+ printer->Print(
+ "break;\n");
+ printer->Outdent();
+ printer->Print(
+ "}\n");
+ }
+ printer->Print(
+ "case $cap_oneof_name$_NOT_SET: {\n"
+ " break;\n"
+ "}\n",
+ "oneof_index",
+ SimpleItoa(descriptor_->oneof_decl(i)->index()),
+ "cap_oneof_name",
+ ToUpper(descriptor_->oneof_decl(i)->name()));
+ printer->Outdent();
+ printer->Print(
+ "}\n");
+ }
+
+ printer->Outdent();
printer->Print(
- " SharedCtor();\n"
- " UnsafeMergeFrom(from);\n"
" // @@protoc_insertion_point(copy_constructor:$full_name$)\n"
"}\n"
"\n",
- "classname", classname_,
- "superclass", superclass,
"full_name", descriptor_->full_name());
// Generate the shared constructor code.
@@ -2418,28 +2267,21 @@ GenerateStructors(io::Printer* printer) {
!descriptor_->options().no_standard_descriptor_accessor()) {
printer->Print(
"const ::google::protobuf::Descriptor* $classname$::descriptor() {\n"
- " protobuf_AssignDescriptorsOnce();\n"
- " return $classname$_descriptor_;\n"
+ " $file_namespace$::protobuf_AssignDescriptorsOnce();\n"
+ " return $file_namespace$::file_level_metadata[$index$].descriptor;\n"
"}\n"
"\n",
- "classname", classname_, "initdefaultsname",
- GlobalInitDefaultsName(descriptor_->file()->name()));
+ "index", SimpleItoa(index_in_metadata_), "classname", classname_,
+ "file_namespace", FileLevelNamespace(descriptor_->file()->name()));
}
printer->Print(
"const $classname$& $classname$::default_instance() {\n"
- " $initdefaultsname$();\n"
+ " $file_namespace$::InitDefaults();\n"
" return *internal_default_instance();\n"
- "}\n",
- "classname", classname_, "initdefaultsname",
- GlobalInitDefaultsName(descriptor_->file()->name()));
-
- printer->Print(
- "\n"
- "::google::protobuf::internal::ExplicitlyConstructed<$classname$> "
- "$classname$_default_instance_;\n"
- "\n",
- "classname", classname_);
+ "}\n\n",
+ "classname", classname_, "file_namespace",
+ FileLevelNamespace(descriptor_->file()->name()));
if (SupportsArenas(descriptor_)) {
printer->Print(
@@ -2484,154 +2326,173 @@ GenerateClear(io::Printer* printer) {
printer->Print("_extensions_.Clear();\n");
}
- // Step 2: Everything but extensions, repeateds, unions.
- // These are handled in chunks of 8. The first chunk is
- // the non-extensions-non-repeateds-non-unions in
- // descriptor_->field(0), descriptor_->field(1), ... descriptor_->field(7),
- // and the second chunk is the same for
- // descriptor_->field(8), descriptor_->field(9), ... descriptor_->field(15),
- // etc.
- set<int> step2_indices;
- hash_map<string, int> fieldname_to_chunk;
- hash_map<int, string> memsets_for_chunk;
- hash_map<int, int> memset_field_count_for_chunk;
- hash_set<string> handled; // fields that appear anywhere in memsets_for_chunk
- hash_map<int, uint32> fields_mask_for_chunk;
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* field = descriptor_->field(i);
- if (!field->is_repeated() && !field->containing_oneof()) {
- step2_indices.insert(i);
- int chunk = i / 8;
- fieldname_to_chunk[FieldName(field)] = chunk;
- fields_mask_for_chunk[chunk] |= static_cast<uint32>(1) << (i % 32);
- }
- }
-
- // Step 2a: Greedily seek runs of fields that can be cleared by memset-to-0.
- // The generated code uses two macros to help it clear runs of fields:
- // ZR_HELPER_(f1) - ZR_HELPER_(f0) computes the difference, in bytes, of the
- // positions of two fields in the Message.
- // ZR_ zeroes a non-empty range of fields via memset.
- const char* macros =
- "#if defined(__clang__)\n"
- "#define ZR_HELPER_(f) \\\n"
- " _Pragma(\"clang diagnostic push\") \\\n"
- " _Pragma(\"clang diagnostic ignored \\\"-Winvalid-offsetof\\\"\") \\\n"
- " __builtin_offsetof($classname$, f) \\\n"
- " _Pragma(\"clang diagnostic pop\")\n"
- "#else\n"
- "#define ZR_HELPER_(f) reinterpret_cast<char*>(\\\n"
- " &reinterpret_cast<$classname$*>(16)->f)\n"
- "#endif\n\n"
- "#define ZR_(first, last) do {\\\n"
- " ::memset(&(first), 0,\\\n"
- " ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\\\n"
- "} while (0)\n\n";
- for (int i = 0; i < runs_of_fields_.size(); i++) {
- const vector<string>& run = runs_of_fields_[i];
- if (run.size() < 2) continue;
- const string& first_field_name = run[0];
- const string& last_field_name = run.back();
- int chunk = fieldname_to_chunk[run[0]];
- memsets_for_chunk[chunk].append(
- "ZR_(" + first_field_name + "_, " + last_field_name + "_);\n");
- for (int j = 0; j < run.size(); j++) {
- GOOGLE_DCHECK_EQ(chunk, fieldname_to_chunk[run[j]]);
- handled.insert(run[j]);
- }
- memset_field_count_for_chunk[chunk] += run.size();
- }
- const bool macros_are_needed = handled.size() > 0;
- if (macros_are_needed) {
- printer->Outdent();
- printer->Print(macros,
- "classname", classname_);
- printer->Indent();
- }
- // Step 2b: Finish step 2, ignoring fields handled in step 2a.
- int last_index = -1;
- bool chunk_block_in_progress = false;
- for (int i = 0; i < descriptor_->field_count(); i++) {
- if (step2_indices.count(i) == 0) continue;
- const FieldDescriptor* field = descriptor_->field(i);
- const string fieldname = FieldName(field);
- if (i / 8 != last_index / 8 || last_index < 0) {
- // End previous chunk, if there was one.
- if (chunk_block_in_progress) {
- printer->Outdent();
- printer->Print("}\n");
- chunk_block_in_progress = false;
+ int last_i = -1;
+ for (int i = 0; i < optimized_order_.size(); ) {
+ // Detect infinite loops.
+ GOOGLE_CHECK_NE(i, last_i);
+ last_i = i;
+
+ // Step 2: Repeated fields don't use _has_bits_; emit code to clear them
+ // here.
+ for (; i < optimized_order_.size(); i++) {
+ const FieldDescriptor* field = optimized_order_[i];
+ const FieldGenerator& generator = field_generators_.get(field);
+
+ if (!field->is_repeated()) {
+ break;
}
- // Start chunk.
- const string& memsets = memsets_for_chunk[i / 8];
- uint32 mask = fields_mask_for_chunk[i / 8];
- int count = popcnt(mask);
- GOOGLE_DCHECK_GE(count, 1);
- if (count == 1 ||
- count == memset_field_count_for_chunk[i / 8]) {
- // No "if" here because the chunk is trivial.
+
+ if (use_dependent_base_ && IsFieldDependent(field)) {
+ printer->Print("clear_$name$();\n", "name", FieldName(field));
} else {
- if (HasFieldPresence(descriptor_->file())) {
- printer->Print(
- "if (_has_bits_[$index$ / 32] & $mask$u) {\n",
- "index", SimpleItoa(i / 8 * 8),
- "mask", SimpleItoa(mask));
- printer->Indent();
- chunk_block_in_progress = true;
- }
+ generator.GenerateMessageClearingCode(printer);
}
- printer->Print(memsets.c_str());
- }
- last_index = i;
- if (handled.count(fieldname) > 0) continue;
-
- // It's faster to just overwrite primitive types, but we should
- // only clear strings and messages if they were set.
- // TODO(kenton): Let the CppFieldGenerator decide this somehow.
- bool should_check_bit =
- field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE ||
- field->cpp_type() == FieldDescriptor::CPPTYPE_STRING;
-
- bool have_enclosing_if = false;
- if (should_check_bit &&
- // If no field presence, then always clear strings/messages as well.
- HasFieldPresence(descriptor_->file())) {
- printer->Print("if (has_$name$()) {\n", "name", fieldname);
- printer->Indent();
- have_enclosing_if = true;
}
- if (use_dependent_base_ && IsFieldDependent(field)) {
- printer->Print("clear_$name$();\n", "name", fieldname);
- } else {
- field_generators_.get(field).GenerateClearingCode(printer);
+ // Step 3: Greedily seek runs of fields that can be cleared by
+ // memset-to-0.
+ int last_chunk = -1;
+ int last_chunk_start = -1;
+ int last_chunk_end = -1;
+ uint32 last_chunk_mask = 0;
+
+ int memset_run_start = -1;
+ int memset_run_end = -1;
+ for (; i < optimized_order_.size(); i++) {
+ const FieldDescriptor* field = optimized_order_[i];
+
+ if (!CanInitializeByZeroing(field)) {
+ break;
+ }
+
+ // "index" defines where in the _has_bits_ the field appears.
+ // "i" is our loop counter within optimized_order_.
+ int index = HasFieldPresence(descriptor_->file()) ?
+ has_bit_indices_[field->index()] : 0;
+ int chunk = index / 8;
+
+ if (last_chunk == -1) {
+ last_chunk = chunk;
+ last_chunk_start = i;
+ } else if (chunk != last_chunk) {
+ // Emit the fields for this chunk so far.
+ break;
+ }
+
+ if (memset_run_start == -1) {
+ memset_run_start = i;
+ }
+
+ memset_run_end = i;
+ last_chunk_end = i;
+ last_chunk_mask |= static_cast<uint32>(1) << (index % 32);
}
- if (have_enclosing_if) {
- printer->Outdent();
- printer->Print("}\n");
+ // Step 4: Non-repeated, non-zero initializable fields.
+ for (; i < optimized_order_.size(); i++) {
+ const FieldDescriptor* field = optimized_order_[i];
+ if (field->is_repeated() || CanInitializeByZeroing(field)) {
+ break;
+ }
+
+ // "index" defines where in the _has_bits_ the field appears.
+ // "i" is our loop counter within optimized_order_.
+ int index = HasFieldPresence(descriptor_->file()) ?
+ has_bit_indices_[field->index()] : 0;
+ int chunk = index / 8;
+
+ if (last_chunk == -1) {
+ last_chunk = chunk;
+ last_chunk_start = i;
+ } else if (chunk != last_chunk) {
+ // Emit the fields for this chunk so far.
+ break;
+ }
+
+ last_chunk_end = i;
+ last_chunk_mask |= static_cast<uint32>(1) << (index % 32);
}
- }
- if (chunk_block_in_progress) {
- printer->Outdent();
- printer->Print("}\n");
- }
- if (macros_are_needed) {
- printer->Outdent();
- printer->Print("\n#undef ZR_HELPER_\n#undef ZR_\n\n");
- printer->Indent();
- }
+ if (last_chunk != -1) {
+ GOOGLE_DCHECK_NE(-1, last_chunk_start);
+ GOOGLE_DCHECK_NE(-1, last_chunk_end);
+ GOOGLE_DCHECK_NE(0, last_chunk_mask);
- // Step 3: Repeated fields don't use _has_bits_; emit code to clear them here.
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* field = descriptor_->field(i);
+ const int count = popcnt(last_chunk_mask);
+ const bool have_outer_if = HasFieldPresence(descriptor_->file()) &&
+ (last_chunk_start != last_chunk_end);
- if (field->is_repeated()) {
- if (use_dependent_base_ && IsFieldDependent(field)) {
- printer->Print("clear_$name$();\n", "name", FieldName(field));
- } else {
- field_generators_.get(field).GenerateClearingCode(printer);
+ if (have_outer_if) {
+ // Check (up to) 8 has_bits at a time if we have more than one field in
+ // this chunk. Due to field layout ordering, we may check
+ // _has_bits_[last_chunk * 8 / 32] multiple times.
+ GOOGLE_DCHECK_LE(2, count);
+ GOOGLE_DCHECK_GE(8, count);
+
+ printer->Print(
+ "if (_has_bits_[$index$ / 32] & $mask$u) {\n",
+ "index", SimpleItoa(last_chunk * 8),
+ "mask", SimpleItoa(last_chunk_mask));
+ printer->Indent();
+ }
+
+ if (memset_run_start != -1) {
+ if (memset_run_start == memset_run_end) {
+ // For clarity, do not memset a single field.
+ const FieldGenerator& generator =
+ field_generators_.get(optimized_order_[memset_run_start]);
+ generator.GenerateMessageClearingCode(printer);
+ } else {
+ const string first_field_name =
+ FieldName(optimized_order_[memset_run_start]);
+ const string last_field_name =
+ FieldName(optimized_order_[memset_run_end]);
+
+ printer->Print(
+ "::memset(&$first$_, 0, reinterpret_cast<char*>(&$last$_) -\n"
+ " reinterpret_cast<char*>(&$first$_) + sizeof($last$_));\n",
+ "first", first_field_name,
+ "last", last_field_name);
+ }
+
+ // Advance last_chunk_start to skip over the fields we zeroed/memset.
+ last_chunk_start = memset_run_end + 1;
+ }
+
+ // Go back and emit clears for each of the fields we processed.
+ for (int j = last_chunk_start; j <= last_chunk_end; j++) {
+ const FieldDescriptor* field = optimized_order_[j];
+ const string fieldname = FieldName(field);
+ const FieldGenerator& generator = field_generators_.get(field);
+
+ // It's faster to just overwrite primitive types, but we should only
+ // clear strings and messages if they were set.
+ //
+ // TODO(kenton): Let the CppFieldGenerator decide this somehow.
+ bool should_check_bit =
+ field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE ||
+ field->cpp_type() == FieldDescriptor::CPPTYPE_STRING;
+
+ bool have_enclosing_if = false;
+ if (should_check_bit &&
+ // If no field presence, then always clear strings/messages as well.
+ HasFieldPresence(descriptor_->file())) {
+ printer->Print("if (has_$name$()) {\n", "name", fieldname);
+ printer->Indent();
+ have_enclosing_if = true;
+ }
+
+ generator.GenerateMessageClearingCode(printer);
+
+ if (have_enclosing_if) {
+ printer->Outdent();
+ printer->Print("}\n");
+ }
+ }
+
+ if (have_outer_if) {
+ printer->Outdent();
+ printer->Print("}\n");
}
}
}
@@ -2649,23 +2510,7 @@ GenerateClear(io::Printer* printer) {
}
if (PreserveUnknownFields(descriptor_)) {
- if (UseUnknownFieldSet(descriptor_->file(), options_)) {
- printer->Print(
- "if (_internal_metadata_.have_unknown_fields()) {\n"
- " mutable_unknown_fields()->Clear();\n"
- "}\n");
- } else {
- if (SupportsArenas(descriptor_)) {
- printer->Print(
- "_unknown_fields_.ClearToEmpty(\n"
- " &::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n"
- " GetArenaNoVirtual());\n");
- } else {
- printer->Print(
- "_unknown_fields_.ClearToEmptyNoArena(\n"
- " &::google::protobuf::internal::GetEmptyStringAlreadyInited());\n");
- }
- }
+ printer->Print("_internal_metadata_.Clear();\n");
}
printer->Outdent();
@@ -2676,7 +2521,7 @@ void MessageGenerator::
GenerateOneofClear(io::Printer* printer) {
// Generated function clears the active field and union case (e.g. foo_case_).
for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
- map<string, string> oneof_vars;
+ std::map<string, string> oneof_vars;
oneof_vars["classname"] = classname_;
oneof_vars["oneofname"] = descriptor_->oneof_decl(i)->name();
oneof_vars["full_name"] = descriptor_->full_name();
@@ -2742,10 +2587,13 @@ GenerateSwap(io::Printer* printer) {
" if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {\n"
" InternalSwap(other);\n"
" } else {\n"
- " $classname$ temp;\n"
- " temp.UnsafeMergeFrom(*this);\n"
- " CopyFrom(*other);\n"
- " other->CopyFrom(temp);\n"
+ " $classname$* temp = New(GetArenaNoVirtual());\n"
+ " temp->MergeFrom(*other);\n"
+ " other->CopyFrom(*this);\n"
+ " InternalSwap(temp);\n"
+ " if (GetArenaNoVirtual() == NULL) {\n"
+ " delete temp;\n"
+ " }\n"
" }\n"
"}\n"
"void $classname$::UnsafeArenaSwap($classname$* other) {\n"
@@ -2769,8 +2617,10 @@ GenerateSwap(io::Printer* printer) {
printer->Indent();
if (HasGeneratedMethods(descriptor_->file(), options_)) {
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* field = descriptor_->field(i);
+ for (int i = 0; i < optimized_order_.size(); i++) {
+ // optimized_order_ does not contain oneof fields, but the field
+ // generators for these fields do not emit swapping code on their own.
+ const FieldDescriptor* field = optimized_order_[i];
field_generators_.get(field).GenerateSwappingCode(printer);
}
@@ -2783,19 +2633,14 @@ GenerateSwap(io::Printer* printer) {
}
if (HasFieldPresence(descriptor_->file())) {
- for (int i = 0; i < (descriptor_->field_count() + 31) / 32; ++i) {
+ for (int i = 0; i < HasBitsSize() / 4; ++i) {
printer->Print("std::swap(_has_bits_[$i$], other->_has_bits_[$i$]);\n",
"i", SimpleItoa(i));
}
}
- // Ignore PreserveUnknownFields here - always swap internal_metadata as it
- // may contain more than just unknown fields.
- if (UseUnknownFieldSet(descriptor_->file(), options_)) {
- printer->Print(
- "_internal_metadata_.Swap(&other->_internal_metadata_);\n");
- } else {
- printer->Print("_unknown_fields_.Swap(&other->_unknown_fields_);\n");
+ if (PreserveUnknownFields(descriptor_)) {
+ printer->Print("_internal_metadata_.Swap(&other->_internal_metadata_);\n");
}
printer->Print("std::swap(_cached_size_, other->_cached_size_);\n");
@@ -2819,7 +2664,7 @@ GenerateMergeFrom(io::Printer* printer) {
"void $classname$::MergeFrom(const ::google::protobuf::Message& from) {\n"
"// @@protoc_insertion_point(generalized_merge_from_start:"
"$full_name$)\n"
- " if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);\n",
+ " GOOGLE_DCHECK_NE(&from, this);\n",
"classname", classname_, "full_name", descriptor_->full_name());
printer->Indent();
@@ -2838,7 +2683,7 @@ GenerateMergeFrom(io::Printer* printer) {
"} else {\n"
"// @@protoc_insertion_point(generalized_merge_from_cast_success:"
"$full_name$)\n"
- " UnsafeMergeFrom(*source);\n"
+ " MergeFrom(*source);\n"
"}\n",
"classname", classname_, "full_name", descriptor_->full_name());
@@ -2860,25 +2705,118 @@ GenerateMergeFrom(io::Printer* printer) {
"void $classname$::MergeFrom(const $classname$& from) {\n"
"// @@protoc_insertion_point(class_specific_merge_from_start:"
"$full_name$)\n"
- " if (GOOGLE_PREDICT_TRUE(&from != this)) {\n"
- " UnsafeMergeFrom(from);\n"
- " } else {\n"
- " MergeFromFail(__LINE__);\n"
- " }\n"
- "}\n"
- "\n"
- "void $classname$::UnsafeMergeFrom(const $classname$& from) {\n"
- " GOOGLE_DCHECK(&from != this);\n",
+ " GOOGLE_DCHECK_NE(&from, this);\n",
"classname", classname_, "full_name", descriptor_->full_name());
printer->Indent();
- // Merge Repeated fields. These fields do not require a
- // check as we can simply iterate over them.
- for (int i = 0; i < descriptor_->field_count(); ++i) {
- const FieldDescriptor* field = descriptor_->field(i);
+ if (descriptor_->extension_range_count() > 0) {
+ printer->Print("_extensions_.MergeFrom(from._extensions_);\n");
+ }
- if (field->is_repeated()) {
- field_generators_.get(field).GenerateUnsafeMergingCode(printer);
+ printer->Print(
+ "_internal_metadata_.MergeFrom(from._internal_metadata_);\n");
+
+ int last_i = -1;
+ for (int i = 0; i < optimized_order_.size(); ) {
+ // Detect infinite loops.
+ GOOGLE_CHECK_NE(i, last_i);
+ last_i = i;
+
+ // Merge Repeated fields. These fields do not require a
+ // check as we can simply iterate over them.
+ for (; i < optimized_order_.size(); i++) {
+ const FieldDescriptor* field = optimized_order_[i];
+ if (!field->is_repeated()) {
+ break;
+ }
+
+ const FieldGenerator& generator = field_generators_.get(field);
+ generator.GenerateMergingCode(printer);
+ }
+
+ // Merge Optional and Required fields (after a _has_bit check).
+ int last_chunk = -1;
+ int last_chunk_start = -1;
+ int last_chunk_end = -1;
+ uint32 last_chunk_mask = 0;
+ for (; i < optimized_order_.size(); i++) {
+ const FieldDescriptor* field = optimized_order_[i];
+ if (field->is_repeated()) {
+ break;
+ }
+
+ // "index" defines where in the _has_bits_ the field appears.
+ // "i" is our loop counter within optimized_order_.
+ int index = HasFieldPresence(descriptor_->file()) ?
+ has_bit_indices_[field->index()] : 0;
+ int chunk = index / 8;
+
+ if (last_chunk == -1) {
+ last_chunk = chunk;
+ last_chunk_start = i;
+ } else if (chunk != last_chunk) {
+ // Emit the fields for this chunk so far.
+ break;
+ }
+
+ last_chunk_end = i;
+ last_chunk_mask |= static_cast<uint32>(1) << (index % 32);
+ }
+
+ if (last_chunk != -1) {
+ GOOGLE_DCHECK_NE(-1, last_chunk_start);
+ GOOGLE_DCHECK_NE(-1, last_chunk_end);
+ GOOGLE_DCHECK_NE(0, last_chunk_mask);
+
+ const int count = popcnt(last_chunk_mask);
+ const bool have_outer_if = HasFieldPresence(descriptor_->file()) &&
+ (last_chunk_start != last_chunk_end);
+
+ if (have_outer_if) {
+ // Check (up to) 8 has_bits at a time if we have more than one field in
+ // this chunk. Due to field layout ordering, we may check
+ // _has_bits_[last_chunk * 8 / 32] multiple times.
+ GOOGLE_DCHECK_LE(2, count);
+ GOOGLE_DCHECK_GE(8, count);
+
+ printer->Print(
+ "if (from._has_bits_[$index$ / 32] & $mask$u) {\n",
+ "index", SimpleItoa(last_chunk * 8),
+ "mask", SimpleItoa(last_chunk_mask));
+ printer->Indent();
+ }
+
+ // Go back and emit clears for each of the fields we processed.
+ for (int j = last_chunk_start; j <= last_chunk_end; j++) {
+ const FieldDescriptor* field = optimized_order_[j];
+ const FieldGenerator& generator = field_generators_.get(field);
+
+ bool have_enclosing_if = false;
+ if (HasFieldPresence(descriptor_->file())) {
+ printer->Print(
+ "if (from.has_$name$()) {\n",
+ "name", FieldName(field));
+ printer->Indent();
+ have_enclosing_if = true;
+ } else {
+ // Merge semantics without true field presence: primitive fields are
+ // merged only if non-zero (numeric) or non-empty (string).
+ have_enclosing_if = EmitFieldNonDefaultCondition(
+ printer, "from.", field);
+ }
+
+ generator.GenerateMergingCode(printer);
+
+ if (have_enclosing_if) {
+ printer->Outdent();
+ printer->Print("}\n");
+ }
+ }
+
+ if (have_outer_if) {
+ printer->Outdent();
+ printer->Print("}\n");
+ }
}
}
@@ -2912,78 +2850,6 @@ GenerateMergeFrom(io::Printer* printer) {
"}\n");
}
- // Merge Optional and Required fields (after a _has_bit check).
- int last_index = -1;
-
- for (int i = 0; i < descriptor_->field_count(); ++i) {
- const FieldDescriptor* field = descriptor_->field(i);
-
- if (!field->is_repeated() && !field->containing_oneof()) {
- if (HasFieldPresence(descriptor_->file())) {
- // See above in GenerateClear for an explanation of this.
- if (i / 8 != last_index / 8 || last_index < 0) {
- if (last_index >= 0) {
- printer->Outdent();
- printer->Print("}\n");
- }
- printer->Print(
- "if (from._has_bits_[$index$ / 32] & "
- "(0xffu << ($index$ % 32))) {\n",
- "index", SimpleItoa(field->index()));
- printer->Indent();
- }
- }
-
- last_index = i;
-
- bool have_enclosing_if = false;
- if (HasFieldPresence(descriptor_->file())) {
- printer->Print(
- "if (from.has_$name$()) {\n",
- "name", FieldName(field));
- printer->Indent();
- have_enclosing_if = true;
- } else {
- // Merge semantics without true field presence: primitive fields are
- // merged only if non-zero (numeric) or non-empty (string).
- have_enclosing_if = EmitFieldNonDefaultCondition(
- printer, "from.", field);
- }
-
- field_generators_.get(field).GenerateMergingCode(printer);
-
- if (have_enclosing_if) {
- printer->Outdent();
- printer->Print("}\n");
- }
- }
- }
-
- if (HasFieldPresence(descriptor_->file()) &&
- last_index >= 0) {
- printer->Outdent();
- printer->Print("}\n");
- }
-
- if (descriptor_->extension_range_count() > 0) {
- printer->Print("_extensions_.MergeFrom(from._extensions_);\n");
- }
-
- if (PreserveUnknownFields(descriptor_)) {
- if (UseUnknownFieldSet(descriptor_->file(), options_)) {
- printer->Print(
- "if (from._internal_metadata_.have_unknown_fields()) {\n"
- " ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(\n"
- " from.unknown_fields(), &_internal_metadata_);\n"
- "}\n");
- } else {
- printer->Print(
- "if (!from.unknown_fields().empty()) {\n"
- " mutable_unknown_fields()->append(from.unknown_fields());\n"
- "}\n");
- }
- }
-
printer->Outdent();
printer->Print("}\n");
}
@@ -3020,7 +2886,7 @@ GenerateCopyFrom(io::Printer* printer) {
printer->Print(
"if (&from == this) return;\n"
"Clear();\n"
- "UnsafeMergeFrom(from);\n");
+ "MergeFrom(from);\n");
printer->Outdent();
printer->Print("}\n");
@@ -3061,8 +2927,8 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
// on the CodedOutputStream.
printer->Print(
" ::google::protobuf::io::LazyStringOutputStream unknown_fields_string(\n"
- " ::google::protobuf::NewPermanentCallback(\n"
- " &MutableUnknownFieldsFor$classname$, this));\n"
+ " ::google::protobuf::NewPermanentCallback(&_internal_metadata_,\n"
+ " &::google::protobuf::internal::InternalMetadataWithArenaLite::mutable_unknown_fields));\n"
" ::google::protobuf::io::CodedOutputStream unknown_fields_stream(\n"
" &unknown_fields_string, false);\n",
"classname", classname_);
@@ -3082,13 +2948,41 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
WireFormat::MakeTag(ordered_fields[descriptor_->field_count() - 1]);
const int kCutoff0 = 127; // fits in 1-byte varint
const int kCutoff1 = (127 << 7) + 127; // fits in 2-byte varint
+
+ // We need to capture the last tag when parsing if this is a Group type, as
+ // our caller will verify (via CodedInputStream::LastTagWas) that the correct
+ // closing tag was received.
+ bool capture_last_tag = false;
+ const Descriptor* parent = descriptor_->containing_type();
+ if (parent) {
+ for (int i = 0; i < parent->field_count(); i++) {
+ const FieldDescriptor* field = parent->field(i);
+ if (field->type() == FieldDescriptor::TYPE_GROUP &&
+ field->message_type() == descriptor_) {
+ capture_last_tag = true;
+ break;
+ }
+ }
+ }
+
+ for (int i = 0; i < descriptor_->file()->extension_count(); i++) {
+ const FieldDescriptor* field = descriptor_->file()->extension(i);
+ if (field->type() == FieldDescriptor::TYPE_GROUP &&
+ field->message_type() == descriptor_) {
+ capture_last_tag = true;
+ break;
+ }
+ }
+
printer->Print("::std::pair< ::google::protobuf::uint32, bool> p = "
- "input->ReadTagWithCutoff($max$);\n"
+ "input->ReadTagWithCutoff$lasttag$($max$u);\n"
"tag = p.first;\n"
"if (!p.second) goto handle_unusual;\n",
"max", SimpleItoa(maxtag <= kCutoff0 ? kCutoff0 :
(maxtag <= kCutoff1 ? kCutoff1 :
- maxtag)));
+ maxtag)),
+ "lasttag", !capture_last_tag ? "NoLastTag" : "");
+
if (descriptor_->field_count() > 0) {
// We don't even want to print the switch() if we have no fields because
// MSVC dislikes switch() statements that contain only a default value.
@@ -3098,6 +2992,13 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
// of each case. However, this is actually a bit slower in practice as it
// creates a jump table that is 8x larger and sparser, and meanwhile the
// if()s are highly predictable.
+ //
+ // Historically, we inserted checks to peek at the next tag on the wire and
+ // jump directly to the next case statement. While this avoids the jump
+ // table that the switch uses, it greatly increases code size (20-60%) and
+ // inserts branches that may fail (especially for real world protos that
+ // interleave--in field number order--hot and cold fields). Loadtests
+ // confirmed that removing this optimization is performance neutral.
printer->Print("switch (::google::protobuf::internal::WireFormatLite::"
"GetTagFieldNumber(tag)) {\n");
@@ -3114,19 +3015,9 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
}
}
- // need_label is true if we generated "goto parse_$name$" while handling the
- // previous field.
- bool need_label = false;
- // Pay attention to whether we are in a run of fields from the same oneof.
- // Motivation: it would be unusual to parse multiple values for a single
- // oneof, since only the last would be used.
- const FieldDescriptor* last_of_current_oneof = NULL;
- // The following is valid iff last_of_current_oneof is non-NULL.
- int index_of_last_of_current_oneof = -1;
for (int i = 0; i < ordered_fields.size(); i++) {
const FieldDescriptor* field = ordered_fields[i];
const bool loops = fields_with_parse_loop.count(i) > 0;
- const bool next_field_loops = fields_with_parse_loop.count(i + 1) > 0;
PrintFieldComment(printer, field);
@@ -3137,20 +3028,12 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
const FieldGenerator& field_generator = field_generators_.get(field);
// Emit code to parse the common, expected case.
- printer->Print("if (tag == $commontag$) {\n",
+ printer->Print("if (static_cast<::google::protobuf::uint8>(tag) ==\n"
+ " static_cast<::google::protobuf::uint8>($commontag$u)) {\n",
"commontag", SimpleItoa(WireFormat::MakeTag(field)));
- if (need_label ||
- (field->is_repeated() && !field->is_packed() && !loops)) {
- printer->Print(
- " parse_$name$:\n",
- "name", field->name());
- }
if (loops) {
- printer->Print(
- " DO_(input->IncrementRecursionDepth());\n"
- " parse_loop_$name$:\n",
- "name", field->name());
+ printer->Print(" DO_(input->IncrementRecursionDepth());\n");
}
printer->Indent();
@@ -3165,7 +3048,8 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
if (field->is_packed()) {
internal::WireFormatLite::WireType wiretype =
WireFormat::WireTypeForFieldType(field->type());
- printer->Print("} else if (tag == $uncommontag$) {\n",
+ printer->Print("} else if (static_cast<::google::protobuf::uint8>(tag) ==\n"
+ " static_cast<::google::protobuf::uint8>($uncommontag$u)) {\n",
"uncommontag", SimpleItoa(
internal::WireFormatLite::MakeTag(
field->number(), wiretype)));
@@ -3175,7 +3059,8 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
} else if (field->is_packable() && !field->is_packed()) {
internal::WireFormatLite::WireType wiretype =
internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED;
- printer->Print("} else if (tag == $uncommontag$) {\n",
+ printer->Print("} else if (static_cast<::google::protobuf::uint8>(tag) ==\n"
+ " static_cast<::google::protobuf::uint8>($uncommontag$u)) {\n",
"uncommontag", SimpleItoa(
internal::WireFormatLite::MakeTag(
field->number(), wiretype)));
@@ -3189,87 +3074,10 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
" goto handle_unusual;\n"
"}\n");
- // switch() is slow since it can't be predicted well. Insert some if()s
- // here that attempt to predict the next tag.
- // For non-packed repeated fields, expect the same tag again.
+ // For repeated messages/groups, we need to decrement recursion depth.
if (loops) {
printer->Print(
- "if (input->ExpectTag($tag$)) goto parse_loop_$name$;\n",
- "tag", SimpleItoa(WireFormat::MakeTag(field)),
- "name", field->name());
- } else if (field->is_repeated() && !field->is_packed()) {
- printer->Print(
- "if (input->ExpectTag($tag$)) goto parse_$name$;\n",
- "tag", SimpleItoa(WireFormat::MakeTag(field)),
- "name", field->name());
- }
-
- // Have we emitted "if (input->ExpectTag($next_tag$)) ..." yet?
- bool emitted_goto_next_tag = false;
-
- // For repeated messages/groups, we need to decrement recursion depth,
- // unless the next tag is also for a repeated message/group.
- if (loops) {
- if (next_field_loops) {
- const FieldDescriptor* next_field = ordered_fields[i + 1];
- printer->Print(
- "if (input->ExpectTag($next_tag$)) goto parse_loop_$next_name$;\n",
- "next_tag", SimpleItoa(WireFormat::MakeTag(next_field)),
- "next_name", next_field->name());
- emitted_goto_next_tag = true;
- }
- printer->Print(
- "input->UnsafeDecrementRecursionDepth();\n");
- }
-
- // If there are more fields, expect the next one, unless we just parsed
- // a oneof and the next field would be from the same oneof. (There's no
- // reason to expect something that makes what we just read irrelevant,
- // so guess something after the current string of fields from this oneof.)
- need_label = false;
- if (!emitted_goto_next_tag) {
- // delta is the distance in ordered_fields[] from the current field to
- // the field we'll guess is next.
- int delta = last_of_current_oneof == NULL
- ? 1
- : std::max(index_of_last_of_current_oneof - i, 1);
- if (i == index_of_last_of_current_oneof) {
- printer->Outdent();
- printer->Print(
- " after_$last$:\n",
- "last", FieldName(last_of_current_oneof));
- printer->Indent();
- last_of_current_oneof = NULL;
- } else if (last_of_current_oneof == NULL) {
- delta = 1;
- // Check for the unlikely case that delta > 1 is better.
- if (field->containing_oneof() != NULL) {
- while (i + delta < ordered_fields.size() &&
- ordered_fields[i + delta]->containing_oneof() ==
- field->containing_oneof()) {
- index_of_last_of_current_oneof = i + delta;
- last_of_current_oneof = ordered_fields[i + delta];
- ++delta;
- }
- }
- }
- if (delta > 1) {
- printer->Print(
- "goto after_$last$;\n",
- "last", FieldName(last_of_current_oneof));
- } else if (i + delta == descriptor_->field_count()) {
- // Expect EOF.
- // TODO(kenton): Expect group end-tag?
- printer->Print(
- "if (input->ExpectAtEnd()) goto success;\n");
- } else {
- const FieldDescriptor* next_field = ordered_fields[i + delta];
- printer->Print(
- "if (input->ExpectTag($next_tag$)) goto parse_$next_name$;\n",
- "next_tag", SimpleItoa(WireFormat::MakeTag(next_field)),
- "next_name", next_field->name());
- need_label = delta == 1;
- }
+ "input->UnsafeDecrementRecursionDepth();\n");
}
printer->Print(
@@ -3382,7 +3190,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
}
void MessageGenerator::GenerateSerializeOneofFields(
- io::Printer* printer, const vector<const FieldDescriptor*>& fields,
+ io::Printer* printer, const std::vector<const FieldDescriptor*>& fields,
bool to_array) {
GOOGLE_CHECK(!fields.empty());
if (fields.size() == 1) {
@@ -3450,7 +3258,7 @@ void MessageGenerator::GenerateSerializeOneField(
void MessageGenerator::GenerateSerializeOneExtensionRange(
io::Printer* printer, const Descriptor::ExtensionRange* range,
bool to_array) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars["start"] = SimpleItoa(range->start);
vars["end"] = SimpleItoa(range->end);
printer->Print(vars,
@@ -3458,7 +3266,7 @@ void MessageGenerator::GenerateSerializeOneExtensionRange(
if (to_array) {
printer->Print(vars,
"target = _extensions_.InternalSerializeWithCachedSizesToArray(\n"
- " $start$, $end$, false, target);\n\n");
+ " $start$, $end$, deterministic, target);\n\n");
} else {
printer->Print(vars,
"_extensions_.SerializeWithCachedSizes(\n"
@@ -3533,7 +3341,7 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) {
"classname", classname_);
printer->Indent();
- printer->Print("(void)deterministic; // Unused\n");
+ printer->Print("(void)deterministic; // Unused\n");
printer->Print(
"// @@protoc_insertion_point(serialize_to_array_start:$full_name$)\n",
"full_name", descriptor_->full_name());
@@ -3600,7 +3408,7 @@ GenerateSerializeWithCachedSizesBody(io::Printer* printer, bool to_array) {
io::Printer* printer_;
const bool to_array_;
const bool eager_;
- vector<const FieldDescriptor*> v_;
+ std::vector<const FieldDescriptor*> v_;
};
std::vector<const FieldDescriptor*> ordered_fields =
@@ -3663,30 +3471,29 @@ GenerateSerializeWithCachedSizesBody(io::Printer* printer, bool to_array) {
}
}
-static vector<uint32> RequiredFieldsBitMask(const Descriptor* desc) {
- vector<uint32> result;
- uint32 mask = 0;
- for (int i = 0; i < desc->field_count(); i++) {
- if (i > 0 && i % 32 == 0) {
- result.push_back(mask);
- mask = 0;
- }
- if (desc->field(i)->is_required()) {
- mask |= (1 << (i & 31));
+std::vector<uint32> MessageGenerator::RequiredFieldsBitMask() const {
+ const int array_size = HasBitsSize();
+ std::vector<uint32> masks(array_size, 0);
+
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const FieldDescriptor* field = descriptor_->field(i);
+ if (!field->is_required()) {
+ continue;
}
+
+ const int has_bit_index = has_bit_indices_[field->index()];
+ masks[has_bit_index / 32] |=
+ static_cast<uint32>(1) << (has_bit_index % 32);
}
- if (mask != 0) {
- result.push_back(mask);
- }
- return result;
+ return masks;
}
// Create an expression that evaluates to
// "for all i, (_has_bits_[i] & masks[i]) == masks[i]"
// masks is allowed to be shorter than _has_bits_, but at least one element of
// masks must be non-zero.
-static string ConditionalToCheckBitmasks(const vector<uint32>& masks) {
- vector<string> parts;
+static string ConditionalToCheckBitmasks(const std::vector<uint32>& masks) {
+ std::vector<string> parts;
for (int i = 0; i < masks.size(); i++) {
if (masks[i] == 0) continue;
string m = StrCat("0x", strings::Hex(masks[i], strings::ZERO_PAD_8));
@@ -3735,8 +3542,8 @@ GenerateByteSize(io::Printer* printer) {
"classname", classname_, "full_name", descriptor_->full_name());
printer->Indent();
printer->Print("size_t total_size = 0;\n");
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* field = descriptor_->field(i);
+ for (int i = 0; i < optimized_order_.size(); i++) {
+ const FieldDescriptor* field = optimized_order_[i];
if (field->is_required()) {
printer->Print("\n"
"if (has_$name$()) {\n",
@@ -3763,18 +3570,41 @@ GenerateByteSize(io::Printer* printer) {
"size_t total_size = 0;\n"
"\n");
+ if (descriptor_->extension_range_count() > 0) {
+ printer->Print(
+ "total_size += _extensions_.ByteSize();\n"
+ "\n");
+ }
+
+ if (PreserveUnknownFields(descriptor_)) {
+ if (UseUnknownFieldSet(descriptor_->file(), options_)) {
+ printer->Print(
+ "if (_internal_metadata_.have_unknown_fields()) {\n"
+ " total_size +=\n"
+ " ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n"
+ " unknown_fields());\n"
+ "}\n");
+ } else {
+ printer->Print(
+ "total_size += unknown_fields().size();\n"
+ "\n");
+ }
+ }
+
// Handle required fields (if any). We expect all of them to be
// present, so emit one conditional that checks for that. If they are all
// present then the fast path executes; otherwise the slow path executes.
if (num_required_fields_ > 1 && HasFieldPresence(descriptor_->file())) {
// The fast path works if all required fields are present.
- vector<uint32> masks_for_has_bits = RequiredFieldsBitMask(descriptor_);
+ const std::vector<uint32> masks_for_has_bits = RequiredFieldsBitMask();
printer->Print((string("if (") +
ConditionalToCheckBitmasks(masks_for_has_bits) +
") { // All required fields are present.\n").c_str());
printer->Indent();
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* field = descriptor_->field(i);
+ // Oneof fields cannot be required, so optimized_order_ contains all of the
+ // fields that we need to potentially emit.
+ for (int i = 0; i < optimized_order_.size(); i++) {
+ const FieldDescriptor* field = optimized_order_[i];
if (!field->is_required()) continue;
PrintFieldComment(printer, field);
field_generators_.get(field).GenerateByteSize(printer);
@@ -3786,8 +3616,8 @@ GenerateByteSize(io::Printer* printer) {
"}\n");
} else {
// num_required_fields_ <= 1: no need to be tricky
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* field = descriptor_->field(i);
+ for (int i = 0; i < optimized_order_.size(); i++) {
+ const FieldDescriptor* field = optimized_order_[i];
if (!field->is_required()) continue;
PrintFieldComment(printer, field);
printer->Print("if (has_$name$()) {\n",
@@ -3799,98 +3629,125 @@ GenerateByteSize(io::Printer* printer) {
}
}
- // Handle optional fields (worry below about repeateds, oneofs, etc.).
- // These are handled in chunks of 8. The first chunk is
- // the non-requireds-non-repeateds-non-unions-non-extensions in
- // descriptor_->field(0), descriptor_->field(1), ... descriptor_->field(7),
- // and the second chunk is the same for
- // descriptor_->field(8), descriptor_->field(9), ... descriptor_->field(15),
- // etc.
- hash_map<int, uint32> fields_mask_for_chunk;
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* field = descriptor_->field(i);
- if (!field->is_required() && !field->is_repeated() &&
- !field->containing_oneof()) {
- fields_mask_for_chunk[i / 8] |= static_cast<uint32>(1) << (i % 32);
+ int last_i = -1;
+ for (int i = 0; i < optimized_order_.size(); ) {
+ // Detect infinite loops.
+ GOOGLE_CHECK_NE(i, last_i);
+ last_i = i;
+
+ // Skip required fields.
+ for (; i < optimized_order_.size() &&
+ optimized_order_[i]->is_required(); i++) {
}
- }
- int last_index = -1;
- bool chunk_block_in_progress = false;
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* field = descriptor_->field(i);
- if (!field->is_required() && !field->is_repeated() &&
- !field->containing_oneof()) {
- // See above in GenerateClear for an explanation of this.
- // TODO(kenton): Share code? Unclear how to do so without
- // over-engineering.
- if (i / 8 != last_index / 8 || last_index < 0) {
- // End previous chunk, if there was one.
- if (chunk_block_in_progress) {
- printer->Outdent();
- printer->Print("}\n");
- chunk_block_in_progress = false;
- }
- // Start chunk.
- uint32 mask = fields_mask_for_chunk[i / 8];
- int count = popcnt(mask);
- GOOGLE_DCHECK_GE(count, 1);
- if (count == 1) {
- // No "if" here because the chunk is trivial.
- } else {
- if (HasFieldPresence(descriptor_->file())) {
- printer->Print(
- "if (_has_bits_[$index$ / 32] & $mask$u) {\n",
- "index", SimpleItoa(i),
- "mask", SimpleItoa(mask));
- printer->Indent();
- chunk_block_in_progress = true;
- }
- }
+ // Handle repeated fields.
+ for (; i < optimized_order_.size(); i++) {
+ const FieldDescriptor* field = optimized_order_[i];
+ if (!field->is_repeated()) {
+ break;
}
- last_index = i;
PrintFieldComment(printer, field);
+ const FieldGenerator& generator = field_generators_.get(field);
+ generator.GenerateByteSize(printer);
+ printer->Print("\n");
+ }
- bool have_enclosing_if = false;
- if (HasFieldPresence(descriptor_->file())) {
- printer->Print(
- "if (has_$name$()) {\n",
- "name", FieldName(field));
- printer->Indent();
- have_enclosing_if = true;
- } else {
- // Without field presence: field is serialized only if it has a
- // non-default value.
- have_enclosing_if = EmitFieldNonDefaultCondition(
- printer, "this->", field);
+ // Handle optional (non-repeated/oneof) fields.
+ //
+ // These are handled in chunks of 8. The first chunk is
+ // the non-requireds-non-repeateds-non-unions-non-extensions in
+ // descriptor_->field(0), descriptor_->field(1), ... descriptor_->field(7),
+ // and the second chunk is the same for
+ // descriptor_->field(8), descriptor_->field(9), ...
+ // descriptor_->field(15),
+ // etc.
+ int last_chunk = -1;
+ int last_chunk_start = -1;
+ int last_chunk_end = -1;
+ uint32 last_chunk_mask = 0;
+ for (; i < optimized_order_.size(); i++) {
+ const FieldDescriptor* field = optimized_order_[i];
+ if (field->is_repeated() || field->is_required()) {
+ break;
}
- field_generators_.get(field).GenerateByteSize(printer);
+ // "index" defines where in the _has_bits_ the field appears.
+ // "i" is our loop counter within optimized_order_.
+ int index = HasFieldPresence(descriptor_->file()) ?
+ has_bit_indices_[field->index()] : 0;
+ int chunk = index / 8;
+
+ if (last_chunk == -1) {
+ last_chunk = chunk;
+ last_chunk_start = i;
+ } else if (chunk != last_chunk) {
+ // Emit the fields for this chunk so far.
+ break;
+ }
+
+ last_chunk_end = i;
+ last_chunk_mask |= static_cast<uint32>(1) << (index % 32);
+ }
+
+ if (last_chunk != -1) {
+ GOOGLE_DCHECK_NE(-1, last_chunk_start);
+ GOOGLE_DCHECK_NE(-1, last_chunk_end);
+ GOOGLE_DCHECK_NE(0, last_chunk_mask);
+
+ const int count = popcnt(last_chunk_mask);
+ const bool have_outer_if = HasFieldPresence(descriptor_->file()) &&
+ (last_chunk_start != last_chunk_end);
+
+ if (have_outer_if) {
+ // Check (up to) 8 has_bits at a time if we have more than one field in
+ // this chunk. Due to field layout ordering, we may check
+ // _has_bits_[last_chunk * 8 / 32] multiple times.
+ GOOGLE_DCHECK_LE(2, count);
+ GOOGLE_DCHECK_GE(8, count);
- if (have_enclosing_if) {
- printer->Outdent();
printer->Print(
- "}\n"
- "\n");
+ "if (_has_bits_[$index$ / 32] & $mask$u) {\n",
+ "index", SimpleItoa(last_chunk * 8),
+ "mask", SimpleItoa(last_chunk_mask));
+ printer->Indent();
}
- }
- }
- if (chunk_block_in_progress) {
- printer->Outdent();
- printer->Print("}\n");
- }
+ // Go back and emit checks for each of the fields we processed.
+ for (int j = last_chunk_start; j <= last_chunk_end; j++) {
+ const FieldDescriptor* field = optimized_order_[j];
+ const FieldGenerator& generator = field_generators_.get(field);
- // Repeated fields don't use _has_bits_ so we count them in a separate
- // pass.
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* field = descriptor_->field(i);
+ PrintFieldComment(printer, field);
- if (field->is_repeated()) {
- PrintFieldComment(printer, field);
- field_generators_.get(field).GenerateByteSize(printer);
- printer->Print("\n");
+ bool have_enclosing_if = false;
+ if (HasFieldPresence(descriptor_->file())) {
+ printer->Print(
+ "if (has_$name$()) {\n",
+ "name", FieldName(field));
+ printer->Indent();
+ have_enclosing_if = true;
+ } else {
+ // Without field presence: field is serialized only if it has a
+ // non-default value.
+ have_enclosing_if = EmitFieldNonDefaultCondition(
+ printer, "this->", field);
+ }
+
+ generator.GenerateByteSize(printer);
+
+ if (have_enclosing_if) {
+ printer->Outdent();
+ printer->Print(
+ "}\n"
+ "\n");
+ }
+ }
+
+ if (have_outer_if) {
+ printer->Outdent();
+ printer->Print("}\n");
+ }
}
}
@@ -3926,27 +3783,6 @@ GenerateByteSize(io::Printer* printer) {
"}\n");
}
- if (descriptor_->extension_range_count() > 0) {
- printer->Print(
- "total_size += _extensions_.ByteSize();\n"
- "\n");
- }
-
- if (PreserveUnknownFields(descriptor_)) {
- if (UseUnknownFieldSet(descriptor_->file(), options_)) {
- printer->Print(
- "if (_internal_metadata_.have_unknown_fields()) {\n"
- " total_size +=\n"
- " ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n"
- " unknown_fields());\n"
- "}\n");
- } else {
- printer->Print(
- "total_size += unknown_fields().size();\n"
- "\n");
- }
- }
-
// We update _cached_size_ even though this is a const method. In theory,
// this is not thread-compatible, because concurrent writes have undefined
// results. In practice, since any concurrent writes will be writing the
@@ -3970,35 +3806,38 @@ GenerateIsInitialized(io::Printer* printer) {
"classname", classname_);
printer->Indent();
+ if (descriptor_->extension_range_count() > 0) {
+ printer->Print(
+ "if (!_extensions_.IsInitialized()) {\n"
+ " return false;\n"
+ "}\n\n");
+ }
+
if (HasFieldPresence(descriptor_->file())) {
// Check that all required fields in this message are set. We can do this
// most efficiently by checking 32 "has bits" at a time.
- int has_bits_array_size = (descriptor_->field_count() + 31) / 32;
- for (int i = 0; i < has_bits_array_size; i++) {
- uint32 mask = 0;
- for (int bit = 0; bit < 32; bit++) {
- int index = i * 32 + bit;
- if (index >= descriptor_->field_count()) break;
- const FieldDescriptor* field = descriptor_->field(index);
-
- if (field->is_required()) {
- mask |= 1 << bit;
- }
- }
+ const std::vector<uint32> masks = RequiredFieldsBitMask();
- if (mask != 0) {
- printer->Print(
- "if ((_has_bits_[$i$] & 0x$mask$) != 0x$mask$) return false;\n",
- "i", SimpleItoa(i),
- "mask", StrCat(strings::Hex(mask, strings::ZERO_PAD_8)));
+ for (int i = 0; i < masks.size(); i++) {
+ uint32 mask = masks[i];
+ if (mask == 0) {
+ continue;
}
+
+ // TODO(ckennelly): Consider doing something similar to ByteSizeLong(),
+ // where we check all of the required fields in a single branch (assuming
+ // that we aren't going to benefit from early termination).
+ printer->Print(
+ "if ((_has_bits_[$i$] & 0x$mask$) != 0x$mask$) return false;\n",
+ "i", SimpleItoa(i),
+ "mask", StrCat(strings::Hex(mask, strings::ZERO_PAD_8)));
}
}
- // Now check that all embedded messages are initialized.
- printer->Print("\n");
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* field = descriptor_->field(i);
+ // Now check that all non-oneof embedded messages are initialized.
+ for (int i = 0; i < optimized_order_.size(); i++) {
+ const FieldDescriptor* field = optimized_order_[i];
+ // TODO(ckennelly): Push this down into a generator?
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
!ShouldIgnoreRequiredFieldCheck(field, options_) &&
HasRequiredFields(field->message_type(), options_)) {
@@ -4008,7 +3847,56 @@ GenerateIsInitialized(io::Printer* printer) {
" return false;\n",
"name", FieldName(field));
} else {
- if (field->options().weak() || !field->containing_oneof()) {
+ GOOGLE_CHECK(field->options().weak() || !field->containing_oneof());
+ // For weak fields, use the data member (::google::protobuf::Message*) instead
+ // of the getter to avoid a link dependency on the weak message type
+ // which is only forward declared.
+ printer->Print(
+ "if (has_$name$()) {\n"
+ " if (!this->$name$_->IsInitialized()) return false;\n"
+ "}\n",
+ "name", FieldName(field));
+ }
+ }
+ }
+
+ // Go through the oneof fields, emitting a switch if any might have required
+ // fields.
+ for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
+ const OneofDescriptor* oneof = descriptor_->oneof_decl(i);
+
+ bool has_required_fields = false;
+ for (int j = 0; j < oneof->field_count(); j++) {
+ const FieldDescriptor* field = oneof->field(j);
+
+ if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
+ !ShouldIgnoreRequiredFieldCheck(field, options_) &&
+ HasRequiredFields(field->message_type(), options_)) {
+ has_required_fields = true;
+ break;
+ }
+ }
+
+ if (!has_required_fields) {
+ continue;
+ }
+
+ printer->Print(
+ "switch ($oneofname$_case()) {\n",
+ "oneofname", oneof->name());
+ printer->Indent();
+ for (int j = 0; j < oneof->field_count(); j++) {
+ const FieldDescriptor* field = oneof->field(j);
+ printer->Print(
+ "case k$field_name$: {\n",
+ "field_name", UnderscoresToCamelCase(field->name(), true));
+ printer->Indent();
+
+ if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
+ !ShouldIgnoreRequiredFieldCheck(field, options_) &&
+ HasRequiredFields(field->message_type(), options_)) {
+ GOOGLE_CHECK(!(field->options().weak() || !field->containing_oneof()));
+ if (field->options().weak()) {
// For weak fields, use the data member (::google::protobuf::Message*) instead
// of the getter to avoid a link dependency on the weak message type
// which is only forward declared.
@@ -4025,15 +3913,22 @@ GenerateIsInitialized(io::Printer* printer) {
"name", FieldName(field));
}
}
- }
- }
- if (descriptor_->extension_range_count() > 0) {
+ printer->Print(
+ "break;\n");
+ printer->Outdent();
+ printer->Print(
+ "}\n");
+ }
printer->Print(
- "\n"
- "if (!_extensions_.IsInitialized()) {\n"
- " return false;\n"
- "}\n");
+ "case $cap_oneof_name$_NOT_SET: {\n"
+ " break;\n"
+ "}\n",
+ "cap_oneof_name",
+ ToUpper(oneof->name()));
+ printer->Outdent();
+ printer->Print(
+ "}\n");
}
printer->Outdent();
diff --git a/src/google/protobuf/compiler/cpp/cpp_message.h b/src/google/protobuf/compiler/cpp/cpp_message.h
index 3bdc0ed3..1a804a16 100644
--- a/src/google/protobuf/compiler/cpp/cpp_message.h
+++ b/src/google/protobuf/compiler/cpp/cpp_message.h
@@ -64,6 +64,12 @@ class MessageGenerator {
MessageGenerator(const Descriptor* descriptor, const Options& options);
~MessageGenerator();
+ // Appends the pre-order walk of the nested generators to list.
+ void Flatten(std::vector<MessageGenerator*>* list);
+ // Append the two types of nested generators to the corresponding vector.
+ void AddGenerators(std::vector<EnumGenerator*>* enum_generators,
+ std::vector<ExtensionGenerator*>* extension_generators);
+
// Header stuff.
// Return names for forward declarations of this class and all its nested
@@ -71,17 +77,7 @@ class MessageGenerator {
// descriptor that was responsible for its inclusion in the map. This can be
// used to associate the descriptor with the code generated for it.
void FillMessageForwardDeclarations(
- map<string, const Descriptor*>* class_names);
- void FillEnumForwardDeclarations(
- map<string, const EnumDescriptor*>* enum_names);
-
- // Generate definitions of all nested enums (must come before class
- // definitions because those classes use the enums definitions).
- void GenerateEnumDefinitions(io::Printer* printer);
-
- // Generate specializations of GetEnumDescriptor<MyEnum>().
- // Precondition: in ::google::protobuf namespace.
- void GenerateGetEnumDescriptorSpecializations(io::Printer* printer);
+ std::map<string, const Descriptor*>* class_names);
// Generate definitions for this class and all its nested types.
void GenerateClassDefinition(io::Printer* printer);
@@ -95,13 +91,8 @@ class MessageGenerator {
// Source file stuff.
- // Generate code which declares all the global descriptor pointers which
- // will be initialized by the methods below.
- void GenerateDescriptorDeclarations(io::Printer* printer);
-
- // Generate code that initializes the global variable storing the message's
- // descriptor.
- void GenerateDescriptorInitializer(io::Printer* printer, int index);
+ // Generate extra fields
+ void GenerateExtraDefaultFields(io::Printer* printer);
// Generate code that calls MessageFactory::InternalRegisterGeneratedMessage()
// for all types.
@@ -130,8 +121,10 @@ class MessageGenerator {
void GenerateDependentFieldAccessorDefinitions(io::Printer* printer);
void GenerateFieldAccessorDefinitions(io::Printer* printer, bool is_inline);
- // Generate the field offsets array.
- void GenerateOffsets(io::Printer* printer);
+ // Generate the field offsets array. Returns the a pair of the total numer
+ // of entries generated and the index of the first has_bit entry.
+ std::pair<size_t, size_t> GenerateOffsets(io::Printer* printer);
+ void GenerateSchema(io::Printer* printer, int offset, int has_offset);
// Generate constructors and destructor.
void GenerateStructors(io::Printer* printer);
@@ -168,7 +161,7 @@ class MessageGenerator {
// Generate a switch statement to serialize 2+ fields from the same oneof.
// Or, if fields.size() == 1, just call GenerateSerializeOneField().
void GenerateSerializeOneofFields(
- io::Printer* printer, const vector<const FieldDescriptor*>& fields,
+ io::Printer* printer, const std::vector<const FieldDescriptor*>& fields,
bool to_array);
void GenerateSerializeOneExtensionRange(
io::Printer* printer, const Descriptor::ExtensionRange* range,
@@ -177,19 +170,26 @@ class MessageGenerator {
// Generates has_foo() functions and variables for singular field has-bits.
void GenerateSingularFieldHasBits(const FieldDescriptor* field,
- map<string, string> vars,
+ std::map<string, string> vars,
io::Printer* printer);
// Generates has_foo() functions and variables for oneof field has-bits.
void GenerateOneofHasBits(io::Printer* printer, bool is_inline);
// Generates has_foo_bar() functions for oneof members.
void GenerateOneofMemberHasBits(const FieldDescriptor* field,
- const map<string, string>& vars,
+ const std::map<string, string>& vars,
io::Printer* printer);
// Generates the clear_foo() method for a field.
void GenerateFieldClear(const FieldDescriptor* field,
- const map<string, string>& vars,
+ const std::map<string, string>& vars,
io::Printer* printer);
+ void GenerateConstructorBody(io::Printer* printer,
+ std::vector<bool> already_processed,
+ bool copy_constructor) const;
+
+ size_t HasBitsSize() const;
+ std::vector<uint32> RequiredFieldsBitMask() const;
+
const Descriptor* descriptor_;
string classname_;
Options options_;
@@ -198,15 +198,18 @@ class MessageGenerator {
// This is reused to initialize the fields in-order for cache efficiency.
//
// optimized_order_ excludes oneof fields.
- vector<const FieldDescriptor *> optimized_order_;
- vector< vector<string> > runs_of_fields_; // that might be trivially cleared
+ std::vector<const FieldDescriptor *> optimized_order_;
+ std::vector<int> has_bit_indices_;
+ int max_has_bit_index_;
google::protobuf::scoped_array<google::protobuf::scoped_ptr<MessageGenerator> > nested_generators_;
google::protobuf::scoped_array<google::protobuf::scoped_ptr<EnumGenerator> > enum_generators_;
google::protobuf::scoped_array<google::protobuf::scoped_ptr<ExtensionGenerator> > extension_generators_;
int num_required_fields_;
- bool uses_string_;
bool use_dependent_base_;
+ int index_in_metadata_;
+
+ friend class FileGenerator;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator);
};
diff --git a/src/google/protobuf/compiler/cpp/cpp_message_field.cc b/src/google/protobuf/compiler/cpp/cpp_message_field.cc
index ca7bae02..c3d1745c 100644
--- a/src/google/protobuf/compiler/cpp/cpp_message_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_message_field.cc
@@ -45,7 +45,7 @@ namespace cpp {
namespace {
void SetMessageVariables(const FieldDescriptor* descriptor,
- map<string, string>* variables,
+ std::map<string, string>* variables,
const Options& options) {
SetCommonFieldVariables(descriptor, variables, options);
(*variables)["type"] = FieldMessageTypeName(descriptor);
@@ -218,7 +218,7 @@ GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const {
return;
}
- map<string, string> variables(variables_);
+ std::map<string, string> variables(variables_);
// For the CRTP base class, all mutation methods are dependent, and so
// they must be in the header.
variables["dependent_classname"] =
@@ -349,7 +349,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer,
// for dependent fields we cannot access its internal_default_instance,
// because the type is incomplete.
// TODO(gerbens) deprecate dependent base class.
- map<string, string> variables(variables_);
+ std::map<string, string> variables(variables_);
variables["inline"] = is_inline ? "inline " : "";
printer->Print(variables,
"$inline$const $type$& $classname$::$name$() const {\n"
@@ -360,7 +360,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer,
return;
}
- map<string, string> variables(variables_);
+ std::map<string, string> variables(variables_);
variables["inline"] = is_inline ? "inline " : "";
printer->Print(variables,
"$inline$const $type$& $classname$::$name$() const {\n"
@@ -469,7 +469,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer,
void MessageFieldGenerator::
GenerateClearingCode(io::Printer* printer) const {
- map<string, string> variables(variables_);
+ std::map<string, string> variables(variables_);
variables["this_message"] = dependent_field_ ? DependentBaseDownCast() : "";
if (!HasFieldPresence(descriptor_->file())) {
// If we don't have has-bits, message presence is indicated only by ptr !=
@@ -486,6 +486,23 @@ GenerateClearingCode(io::Printer* printer) const {
}
void MessageFieldGenerator::
+GenerateMessageClearingCode(io::Printer* printer) const {
+ if (!HasFieldPresence(descriptor_->file())) {
+ // If we don't have has-bits, message presence is indicated only by ptr !=
+ // NULL. Thus on clear, we need to delete the object.
+ printer->Print(variables_,
+ "if (GetArenaNoVirtual() == NULL && $name$_ != NULL) {\n"
+ " delete $name$_;\n"
+ "}\n"
+ "$name$_ = NULL;\n");
+ } else {
+ printer->Print(variables_,
+ "GOOGLE_DCHECK($name$_ != NULL);\n"
+ "$name$_->$type$::Clear();\n");
+ }
+}
+
+void MessageFieldGenerator::
GenerateMergingCode(io::Printer* printer) const {
printer->Print(variables_,
"mutable_$name$()->$type$::MergeFrom(from.$name$());\n");
@@ -497,11 +514,51 @@ GenerateSwappingCode(io::Printer* printer) const {
}
void MessageFieldGenerator::
+GenerateDestructorCode(io::Printer* printer) const {
+ // In google3 a default instance will never get deleted so we don't need to
+ // worry about that but in opensource protobuf default instances are deleted
+ // in shutdown process and we need to take special care when handling them.
+ printer->Print(variables_,
+ "if (this != internal_default_instance()) {\n"
+ " delete $name$_;\n"
+ "}\n");
+}
+
+void MessageFieldGenerator::
GenerateConstructorCode(io::Printer* printer) const {
printer->Print(variables_, "$name$_ = NULL;\n");
}
void MessageFieldGenerator::
+GenerateCopyConstructorCode(io::Printer* printer) const {
+ // For non-Arena enabled messages, everything always goes on the heap.
+ //
+ // For Arena enabled messages, the logic is a bit more convoluted.
+ //
+ // In the copy constructor, we call InternalMetadataWithArena::MergeFrom,
+ // which does *not* copy the Arena pointer. In the generated MergeFrom
+ // (see MessageFieldGenerator::GenerateMergingCode), we:
+ // -> copy the has bits (but this is done in bulk by a memcpy in the copy
+ // constructor)
+ // -> check whether the destination field pointer is NULL (it will be, since
+ // we're initializing it and would have called SharedCtor) and if so:
+ // -> call _slow_mutable_$name$(), which calls either
+ // ::google::protobuf::Arena::CreateMessage<>(GetArenaNoVirtual()), or
+ // ::google::protobuf::Arena::Create<>(GetArenaNoVirtual())
+ //
+ // At this point, GetArenaNoVirtual returns NULL since the Arena pointer
+ // wasn't copied, so both of these methods allocate the submessage on the
+ // heap.
+
+ printer->Print(variables_,
+ "if (from.has_$name$()) {\n"
+ " $name$_ = new $type$(*from.$name$_);\n"
+ "} else {\n"
+ " $name$_ = NULL;\n"
+ "}\n");
+}
+
+void MessageFieldGenerator::
GenerateMergeFromCodedStream(io::Printer* printer) const {
if (descriptor_->type() == FieldDescriptor::TYPE_MESSAGE) {
printer->Print(variables_,
@@ -581,7 +638,7 @@ GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const {
if (!dependent_base_) {
return;
}
- map<string, string> variables(variables_);
+ std::map<string, string> variables(variables_);
variables["inline"] = "inline ";
variables["dependent_classname"] =
DependentBaseClassTemplateName(descriptor_->containing_type()) + "<T>";
@@ -601,7 +658,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer,
if (dependent_base_) {
return;
}
- map<string, string> variables(variables_);
+ std::map<string, string> variables(variables_);
variables["inline"] = is_inline ? "inline " : "";
variables["dependent_classname"] = variables["classname"];
variables["this_message"] = "";
@@ -615,16 +672,15 @@ GenerateInlineAccessorDefinitions(io::Printer* printer,
void MessageOneofFieldGenerator::
GenerateNonInlineAccessorDefinitions(io::Printer* printer) const {
- map<string, string> variables(variables_);
+ std::map<string, string> variables(variables_);
variables["field_member"] =
variables["oneof_prefix"] + variables["name"] + "_";
//printer->Print(variables,
}
-void MessageOneofFieldGenerator::
-InternalGenerateInlineAccessorDefinitions(const map<string, string>& variables,
- io::Printer* printer) const {
+void MessageOneofFieldGenerator::InternalGenerateInlineAccessorDefinitions(
+ const std::map<string, string>& variables, io::Printer* printer) const {
printer->Print(variables,
"$tmpl$"
"$inline$ "
@@ -794,7 +850,7 @@ InternalGenerateInlineAccessorDefinitions(const map<string, string>& variables,
void MessageOneofFieldGenerator::
GenerateClearingCode(io::Printer* printer) const {
- map<string, string> variables(variables_);
+ std::map<string, string> variables(variables_);
variables["this_message"] = dependent_field_ ? DependentBaseDownCast() : "";
if (SupportsArenas(descriptor_)) {
printer->Print(variables,
@@ -808,11 +864,22 @@ GenerateClearingCode(io::Printer* printer) const {
}
void MessageOneofFieldGenerator::
+GenerateMessageClearingCode(io::Printer* printer) const {
+ GenerateClearingCode(printer);
+}
+
+void MessageOneofFieldGenerator::
GenerateSwappingCode(io::Printer* printer) const {
// Don't print any swapping code. Swapping the union will swap this field.
}
void MessageOneofFieldGenerator::
+GenerateDestructorCode(io::Printer* printer) const {
+ // We inherit from MessageFieldGenerator, so we need to override the default
+ // behavior.
+}
+
+void MessageOneofFieldGenerator::
GenerateConstructorCode(io::Printer* printer) const {
// Don't print any constructor code. The field is in a union. We allocate
// space only when this field is used.
@@ -884,7 +951,7 @@ GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const {
if (!dependent_field_) {
return;
}
- map<string, string> variables(variables_);
+ std::map<string, string> variables(variables_);
// For the CRTP base class, all mutation methods are dependent, and so
// they must be in the header.
variables["dependent_classname"] =
@@ -915,7 +982,6 @@ GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const {
" return $this_message$$name$_.Add();\n"
"}\n");
-
if (dependent_getter_) {
printer->Print(variables,
"template <class T>\n"
@@ -939,7 +1005,7 @@ GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const {
void RepeatedMessageFieldGenerator::
GenerateInlineAccessorDefinitions(io::Printer* printer,
bool is_inline) const {
- map<string, string> variables(variables_);
+ std::map<string, string> variables(variables_);
variables["inline"] = is_inline ? "inline " : "";
if (!dependent_getter_) {
@@ -966,7 +1032,6 @@ GenerateInlineAccessorDefinitions(io::Printer* printer,
"}\n");
}
-
if (!dependent_field_) {
printer->Print(variables,
"$inline$"
@@ -989,7 +1054,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer,
void RepeatedMessageFieldGenerator::
GenerateClearingCode(io::Printer* printer) const {
- map<string, string> variables(variables_);
+ std::map<string, string> variables(variables_);
variables["this_message"] = dependent_field_ ? DependentBaseDownCast() : "";
printer->Print(variables, "$this_message$$name$_.Clear();\n");
}
diff --git a/src/google/protobuf/compiler/cpp/cpp_message_field.h b/src/google/protobuf/compiler/cpp/cpp_message_field.h
index d8d9279c..9ca91153 100644
--- a/src/google/protobuf/compiler/cpp/cpp_message_field.h
+++ b/src/google/protobuf/compiler/cpp/cpp_message_field.h
@@ -59,23 +59,26 @@ class MessageFieldGenerator : public FieldGenerator {
bool is_inline) const;
void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const;
void GenerateClearingCode(io::Printer* printer) const;
+ void GenerateMessageClearingCode(io::Printer* printer) const;
void GenerateMergingCode(io::Printer* printer) const;
void GenerateSwappingCode(io::Printer* printer) const;
+ void GenerateDestructorCode(io::Printer* printer) const;
void GenerateConstructorCode(io::Printer* printer) const;
+ void GenerateCopyConstructorCode(io::Printer* printer) const;
void GenerateMergeFromCodedStream(io::Printer* printer) const;
void GenerateSerializeWithCachedSizes(io::Printer* printer) const;
void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
void GenerateByteSize(io::Printer* printer) const;
protected:
- void GenerateArenaManipulationCode(const map<string, string>& variables,
+ void GenerateArenaManipulationCode(const std::map<string, string>& variables,
io::Printer* printer) const;
virtual void GenerateGetterDeclaration(io::Printer* printer) const;
const FieldDescriptor* descriptor_;
const bool dependent_field_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFieldGenerator);
@@ -94,7 +97,12 @@ class MessageOneofFieldGenerator : public MessageFieldGenerator {
bool is_inline) const;
void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const;
void GenerateClearingCode(io::Printer* printer) const;
+
+ // MessageFieldGenerator, from which we inherit, overrides this so we need to
+ // override it as well.
+ void GenerateMessageClearingCode(io::Printer* printer) const;
void GenerateSwappingCode(io::Printer* printer) const;
+ void GenerateDestructorCode(io::Printer* printer) const;
void GenerateConstructorCode(io::Printer* printer) const;
protected:
@@ -102,7 +110,7 @@ class MessageOneofFieldGenerator : public MessageFieldGenerator {
private:
void InternalGenerateInlineAccessorDefinitions(
- const map<string, string>& variables, io::Printer* printer) const;
+ const std::map<string, string>& variables, io::Printer* printer) const;
const bool dependent_base_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageOneofFieldGenerator);
@@ -125,6 +133,7 @@ class RepeatedMessageFieldGenerator : public FieldGenerator {
void GenerateMergingCode(io::Printer* printer) const;
void GenerateSwappingCode(io::Printer* printer) const;
void GenerateConstructorCode(io::Printer* printer) const;
+ void GenerateCopyConstructorCode(io::Printer* printer) const {}
void GenerateMergeFromCodedStream(io::Printer* printer) const;
void GenerateSerializeWithCachedSizes(io::Printer* printer) const;
void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
@@ -137,7 +146,7 @@ class RepeatedMessageFieldGenerator : public FieldGenerator {
const FieldDescriptor* descriptor_;
const bool dependent_field_;
const bool dependent_getter_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedMessageFieldGenerator);
};
diff --git a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
index 54b3d24a..4a0a23f6 100644
--- a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
@@ -80,7 +80,7 @@ int FixedSize(FieldDescriptor::Type type) {
}
void SetPrimitiveVariables(const FieldDescriptor* descriptor,
- map<string, string>* variables,
+ std::map<string, string>* variables,
const Options& options) {
SetCommonFieldVariables(descriptor, variables, options);
(*variables)["type"] = PrimitiveTypeName(descriptor->cpp_type());
@@ -122,7 +122,7 @@ GenerateAccessorDeclarations(io::Printer* printer) const {
void PrimitiveFieldGenerator::
GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const {
- map<string, string> variables(variables_);
+ std::map<string, string> variables(variables_);
variables["inline"] = is_inline ? "inline " : "";
printer->Print(variables,
"$inline$$type$ $classname$::$name$() const {\n"
@@ -157,6 +157,11 @@ GenerateConstructorCode(io::Printer* printer) const {
}
void PrimitiveFieldGenerator::
+GenerateCopyConstructorCode(io::Printer* printer) const {
+ printer->Print(variables_, "$name$_ = from.$name$_;\n");
+}
+
+void PrimitiveFieldGenerator::
GenerateMergeFromCodedStream(io::Printer* printer) const {
printer->Print(variables_,
"$set_hasbit$\n"
@@ -206,7 +211,7 @@ PrimitiveOneofFieldGenerator::~PrimitiveOneofFieldGenerator() {}
void PrimitiveOneofFieldGenerator::
GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const {
- map<string, string> variables(variables_);
+ std::map<string, string> variables(variables_);
variables["inline"] = is_inline ? "inline " : "";
printer->Print(variables,
"$inline$$type$ $classname$::$name$() const {\n"
@@ -240,7 +245,7 @@ void PrimitiveOneofFieldGenerator::
GenerateConstructorCode(io::Printer* printer) const {
printer->Print(
variables_,
- " $classname$_default_oneof_instance_->$name$_ = $default$;\n");
+ "_$classname$_default_instance_.$name$_ = $default$;\n");
}
void PrimitiveOneofFieldGenerator::
@@ -297,7 +302,7 @@ GenerateAccessorDeclarations(io::Printer* printer) const {
void RepeatedPrimitiveFieldGenerator::
GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const {
- map<string, string> variables(variables_);
+ std::map<string, string> variables(variables_);
variables["inline"] = is_inline ? "inline " : "";
printer->Print(variables,
"$inline$$type$ $classname$::$name$(int index) const {\n"
@@ -336,11 +341,6 @@ GenerateMergingCode(io::Printer* printer) const {
}
void RepeatedPrimitiveFieldGenerator::
-GenerateUnsafeMergingCode(io::Printer* printer) const {
- printer->Print(variables_, "$name$_.UnsafeMergeFrom(from.$name$_);\n");
-}
-
-void RepeatedPrimitiveFieldGenerator::
GenerateSwappingCode(io::Printer* printer) const {
printer->Print(variables_, "$name$_.UnsafeArenaSwap(&other->$name$_);\n");
}
@@ -351,11 +351,16 @@ GenerateConstructorCode(io::Printer* printer) const {
}
void RepeatedPrimitiveFieldGenerator::
+GenerateCopyConstructorCode(io::Printer* printer) const {
+ printer->Print(variables_, "$name$_.CopyFrom(from.$name$_);\n");
+}
+
+void RepeatedPrimitiveFieldGenerator::
GenerateMergeFromCodedStream(io::Printer* printer) const {
printer->Print(variables_,
"DO_((::google::protobuf::internal::WireFormatLite::$repeated_reader$<\n"
" $type$, $wire_format_field_type$>(\n"
- " $tag_size$, $tag$, input, this->mutable_$name$())));\n");
+ " $tag_size$, $tag$u, input, this->mutable_$name$())));\n");
}
void RepeatedPrimitiveFieldGenerator::
@@ -368,6 +373,7 @@ GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const {
void RepeatedPrimitiveFieldGenerator::
GenerateSerializeWithCachedSizes(io::Printer* printer) const {
+ bool array_written = false;
if (descriptor_->is_packed()) {
// Write the tag and the size.
printer->Print(variables_,
@@ -376,21 +382,30 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const {
"$number$, "
"::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, "
"output);\n"
- " output->WriteVarint32(_$name$_cached_byte_size_);\n"
- "}\n");
+ " output->WriteVarint32(_$name$_cached_byte_size_);\n");
+
+ if (FixedSize(descriptor_->type()) > 0) {
+ printer->Print(variables_,
+ " ::google::protobuf::internal::WireFormatLite::Write$declared_type$Array(\n"
+ " this->$name$().data(), this->$name$_size(), output);\n");
+ array_written = true; // Wrote array all at once
+ }
+ printer->Print(variables_, "}\n");
}
- printer->Print(variables_,
- "for (int i = 0; i < this->$name$_size(); i++) {\n");
- if (descriptor_->is_packed()) {
- printer->Print(variables_,
- " ::google::protobuf::internal::WireFormatLite::Write$declared_type$NoTag(\n"
- " this->$name$(i), output);\n");
- } else {
+ if (!array_written) {
printer->Print(variables_,
- " ::google::protobuf::internal::WireFormatLite::Write$declared_type$(\n"
- " $number$, this->$name$(i), output);\n");
+ "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n");
+ if (descriptor_->is_packed()) {
+ printer->Print(variables_,
+ " ::google::protobuf::internal::WireFormatLite::Write$declared_type$NoTag(\n"
+ " this->$name$(i), output);\n");
+ } else {
+ printer->Print(variables_,
+ " ::google::protobuf::internal::WireFormatLite::Write$declared_type$(\n"
+ " $number$, this->$name$(i), output);\n");
+ }
+ printer->Print("}\n");
}
- printer->Print("}\n");
}
void RepeatedPrimitiveFieldGenerator::
@@ -408,7 +423,7 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
"}\n");
}
printer->Print(variables_,
- "for (int i = 0; i < this->$name$_size(); i++) {\n");
+ "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n");
if (descriptor_->is_packed()) {
printer->Print(variables_,
" target = ::google::protobuf::internal::WireFormatLite::\n"
@@ -423,21 +438,17 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
void RepeatedPrimitiveFieldGenerator::
GenerateByteSize(io::Printer* printer) const {
- printer->Print(variables_,
- "{\n"
- " size_t data_size = 0;\n"
- " unsigned int count = this->$name$_size();\n");
+ printer->Print(variables_, "{\n");
printer->Indent();
int fixed_size = FixedSize(descriptor_->type());
if (fixed_size == -1) {
printer->Print(variables_,
- "for (unsigned int i = 0; i < count; i++) {\n"
- " data_size += ::google::protobuf::internal::WireFormatLite::\n"
- " $declared_type$Size(this->$name$(i));\n"
- "}\n");
+ "size_t data_size = ::google::protobuf::internal::WireFormatLite::\n"
+ " $declared_type$Size(this->$name$_);\n");
} else {
printer->Print(variables_,
- "data_size = $fixed_size$UL * count;\n");
+ "unsigned int count = this->$name$_size();\n"
+ "size_t data_size = $fixed_size$UL * count;\n");
}
if (descriptor_->is_packed()) {
diff --git a/src/google/protobuf/compiler/cpp/cpp_primitive_field.h b/src/google/protobuf/compiler/cpp/cpp_primitive_field.h
index 23cc697e..44c9ff3e 100644
--- a/src/google/protobuf/compiler/cpp/cpp_primitive_field.h
+++ b/src/google/protobuf/compiler/cpp/cpp_primitive_field.h
@@ -59,6 +59,7 @@ class PrimitiveFieldGenerator : public FieldGenerator {
void GenerateMergingCode(io::Printer* printer) const;
void GenerateSwappingCode(io::Printer* printer) const;
void GenerateConstructorCode(io::Printer* printer) const;
+ void GenerateCopyConstructorCode(io::Printer* printer) const;
void GenerateMergeFromCodedStream(io::Printer* printer) const;
void GenerateSerializeWithCachedSizes(io::Printer* printer) const;
void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
@@ -66,7 +67,7 @@ class PrimitiveFieldGenerator : public FieldGenerator {
protected:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveFieldGenerator);
@@ -103,9 +104,9 @@ class RepeatedPrimitiveFieldGenerator : public FieldGenerator {
bool is_inline) const;
void GenerateClearingCode(io::Printer* printer) const;
void GenerateMergingCode(io::Printer* printer) const;
- virtual void GenerateUnsafeMergingCode(io::Printer* printer) const;
void GenerateSwappingCode(io::Printer* printer) const;
void GenerateConstructorCode(io::Printer* printer) const;
+ void GenerateCopyConstructorCode(io::Printer* printer) const;
void GenerateMergeFromCodedStream(io::Printer* printer) const;
void GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const;
void GenerateSerializeWithCachedSizes(io::Printer* printer) const;
@@ -114,7 +115,7 @@ class RepeatedPrimitiveFieldGenerator : public FieldGenerator {
private:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPrimitiveFieldGenerator);
};
diff --git a/src/google/protobuf/compiler/cpp/cpp_service.cc b/src/google/protobuf/compiler/cpp/cpp_service.cc
index 6030f7ce..95357d9f 100644
--- a/src/google/protobuf/compiler/cpp/cpp_service.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_service.cc
@@ -46,6 +46,7 @@ ServiceGenerator::ServiceGenerator(const ServiceDescriptor* descriptor,
const Options& options)
: descriptor_(descriptor) {
vars_["classname"] = descriptor_->name();
+ vars_["file_namespace"] = FileLevelNamespace(descriptor_->file()->name());
vars_["full_name"] = descriptor_->full_name();
if (options.dllexport_decl.empty()) {
vars_["dllexport"] = "";
@@ -143,7 +144,7 @@ void ServiceGenerator::GenerateMethodSignatures(
VirtualOrNon virtual_or_non, io::Printer* printer) {
for (int i = 0; i < descriptor_->method_count(); i++) {
const MethodDescriptor* method = descriptor_->method(i);
- map<string, string> sub_vars;
+ std::map<string, string> sub_vars;
sub_vars["name"] = method->name();
sub_vars["input_type"] = ClassName(method->input_type(), true);
sub_vars["output_type"] = ClassName(method->output_type(), true);
@@ -161,7 +162,7 @@ void ServiceGenerator::GenerateMethodSignatures(
void ServiceGenerator::GenerateDescriptorInitializer(
io::Printer* printer, int index) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars["classname"] = descriptor_->name();
vars["index"] = SimpleItoa(index);
@@ -172,19 +173,20 @@ void ServiceGenerator::GenerateDescriptorInitializer(
// ===================================================================
void ServiceGenerator::GenerateImplementation(io::Printer* printer) {
- printer->Print(vars_,
- "$classname$::~$classname$() {}\n"
- "\n"
- "const ::google::protobuf::ServiceDescriptor* $classname$::descriptor() {\n"
- " protobuf_AssignDescriptorsOnce();\n"
- " return $classname$_descriptor_;\n"
- "}\n"
- "\n"
- "const ::google::protobuf::ServiceDescriptor* $classname$::GetDescriptor() {\n"
- " protobuf_AssignDescriptorsOnce();\n"
- " return $classname$_descriptor_;\n"
- "}\n"
- "\n");
+ vars_["index"] = SimpleItoa(index_in_metadata_);
+ printer->Print(
+ vars_,
+ "$classname$::~$classname$() {}\n"
+ "\n"
+ "const ::google::protobuf::ServiceDescriptor* $classname$::descriptor() {\n"
+ " $file_namespace$::protobuf_AssignDescriptorsOnce();\n"
+ " return $file_namespace$::file_level_service_descriptors[$index$];\n"
+ "}\n"
+ "\n"
+ "const ::google::protobuf::ServiceDescriptor* $classname$::GetDescriptor() {\n"
+ " return descriptor();\n"
+ "}\n"
+ "\n");
// Generate methods of the interface.
GenerateNotImplementedMethods(printer);
@@ -212,7 +214,7 @@ void ServiceGenerator::GenerateImplementation(io::Printer* printer) {
void ServiceGenerator::GenerateNotImplementedMethods(io::Printer* printer) {
for (int i = 0; i < descriptor_->method_count(); i++) {
const MethodDescriptor* method = descriptor_->method(i);
- map<string, string> sub_vars;
+ std::map<string, string> sub_vars;
sub_vars["classname"] = descriptor_->name();
sub_vars["name"] = method->name();
sub_vars["index"] = SimpleItoa(i);
@@ -232,18 +234,20 @@ void ServiceGenerator::GenerateNotImplementedMethods(io::Printer* printer) {
}
void ServiceGenerator::GenerateCallMethod(io::Printer* printer) {
- printer->Print(vars_,
- "void $classname$::CallMethod(const ::google::protobuf::MethodDescriptor* method,\n"
- " ::google::protobuf::RpcController* controller,\n"
- " const ::google::protobuf::Message* request,\n"
- " ::google::protobuf::Message* response,\n"
- " ::google::protobuf::Closure* done) {\n"
- " GOOGLE_DCHECK_EQ(method->service(), $classname$_descriptor_);\n"
- " switch(method->index()) {\n");
+ printer->Print(
+ vars_,
+ "void $classname$::CallMethod(const ::google::protobuf::MethodDescriptor* method,\n"
+ " ::google::protobuf::RpcController* controller,\n"
+ " const ::google::protobuf::Message* request,\n"
+ " ::google::protobuf::Message* response,\n"
+ " ::google::protobuf::Closure* done) {\n"
+ " GOOGLE_DCHECK_EQ(method->service(), "
+ "$file_namespace$::file_level_service_descriptors[$index$]);\n"
+ " switch(method->index()) {\n");
for (int i = 0; i < descriptor_->method_count(); i++) {
const MethodDescriptor* method = descriptor_->method(i);
- map<string, string> sub_vars;
+ std::map<string, string> sub_vars;
sub_vars["name"] = method->name();
sub_vars["index"] = SimpleItoa(i);
sub_vars["input_type"] = ClassName(method->input_type(), true);
@@ -289,7 +293,7 @@ void ServiceGenerator::GenerateGetPrototype(RequestOrResponse which,
const Descriptor* type =
(which == REQUEST) ? method->input_type() : method->output_type();
- map<string, string> sub_vars;
+ std::map<string, string> sub_vars;
sub_vars["index"] = SimpleItoa(i);
sub_vars["type"] = ClassName(type, true);
@@ -312,7 +316,7 @@ void ServiceGenerator::GenerateGetPrototype(RequestOrResponse which,
void ServiceGenerator::GenerateStubMethods(io::Printer* printer) {
for (int i = 0; i < descriptor_->method_count(); i++) {
const MethodDescriptor* method = descriptor_->method(i);
- map<string, string> sub_vars;
+ std::map<string, string> sub_vars;
sub_vars["classname"] = descriptor_->name();
sub_vars["name"] = method->name();
sub_vars["index"] = SimpleItoa(i);
diff --git a/src/google/protobuf/compiler/cpp/cpp_service.h b/src/google/protobuf/compiler/cpp/cpp_service.h
index ede2fd80..33c02547 100644
--- a/src/google/protobuf/compiler/cpp/cpp_service.h
+++ b/src/google/protobuf/compiler/cpp/cpp_service.h
@@ -105,8 +105,11 @@ class ServiceGenerator {
void GenerateStubMethods(io::Printer* printer);
const ServiceDescriptor* descriptor_;
- map<string, string> vars_;
+ std::map<string, string> vars_;
+ int index_in_metadata_;
+
+ friend class FileGenerator;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceGenerator);
};
diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.cc b/src/google/protobuf/compiler/cpp/cpp_string_field.cc
index aee3d1ea..664a2779 100644
--- a/src/google/protobuf/compiler/cpp/cpp_string_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_string_field.cc
@@ -46,20 +46,19 @@ namespace cpp {
namespace {
void SetStringVariables(const FieldDescriptor* descriptor,
- map<string, string>* variables,
+ std::map<string, string>* variables,
const Options& options) {
SetCommonFieldVariables(descriptor, variables, options);
(*variables)["default"] = DefaultValue(descriptor);
(*variables)["default_length"] =
SimpleItoa(descriptor->default_value_string().length());
- string default_variable_string =
+ string default_variable_string = "_default_" + FieldName(descriptor) + "_";
+ (*variables)["default_variable_name"] = default_variable_string;
+ (*variables)["default_variable"] =
descriptor->default_value_string().empty()
? "&::google::protobuf::internal::GetEmptyStringAlreadyInited()"
- : "_default_" + FieldName(descriptor) + "_";
- (*variables)["default_variable"] = default_variable_string;
- (*variables)["default_value_init"] =
- descriptor->default_value_string().empty()
- ? "" : "*" + default_variable_string;
+ : "&" + (*variables)["classname"] + "::" + default_variable_string +
+ ".get()";
(*variables)["pointer_type"] =
descriptor->type() == FieldDescriptor::TYPE_BYTES ? "void" : "char";
// NOTE: Escaped here to unblock proto1->proto2 migration.
@@ -104,7 +103,9 @@ GeneratePrivateMembers(io::Printer* printer) const {
void StringFieldGenerator::
GenerateStaticMembers(io::Printer* printer) const {
if (!descriptor_->default_value_string().empty()) {
- printer->Print(variables_, "static ::std::string* $default_variable$;\n");
+ printer->Print(variables_,
+ "static ::google::protobuf::internal::ExplicitlyConstructed< ::std::string>"
+ " $default_variable_name$;\n");
}
}
@@ -140,7 +141,16 @@ GenerateAccessorDeclarations(io::Printer* printer) const {
printer->Print(variables_,
"$deprecated_attr$const ::std::string& $name$() const;\n"
- "$deprecated_attr$void set_$name$(const ::std::string& value);\n"
+ "$deprecated_attr$void set_$name$(const ::std::string& value);\n");
+
+ if (!SupportsArenas(descriptor_)) {
+ printer->Print(variables_,
+ "#if LANG_CXX11\n"
+ "$deprecated_attr$void set_$name$(::std::string&& value);\n"
+ "#endif\n");
+ }
+
+ printer->Print(variables_,
"$deprecated_attr$void set_$name$(const char* value);\n"
"$deprecated_attr$void set_$name$(const $pointer_type$* value, size_t size)"
";\n"
@@ -165,117 +175,129 @@ GenerateAccessorDeclarations(io::Printer* printer) const {
void StringFieldGenerator::
GenerateInlineAccessorDefinitions(io::Printer* printer,
bool is_inline) const {
- map<string, string> variables(variables_);
+ std::map<string, string> variables(variables_);
variables["inline"] = is_inline ? "inline " : "";
if (SupportsArenas(descriptor_)) {
- printer->Print(variables,
- "$inline$const ::std::string& $classname$::$name$() const {\n"
- " // @@protoc_insertion_point(field_get:$full_name$)\n"
- " return $name$_.Get($default_variable$);\n"
- "}\n"
- "$inline$void $classname$::set_$name$(const ::std::string& value) {\n"
- " $set_hasbit$\n"
- " $name$_.Set($default_variable$, value, GetArenaNoVirtual());\n"
- " // @@protoc_insertion_point(field_set:$full_name$)\n"
- "}\n"
- "$inline$void $classname$::set_$name$(const char* value) {\n"
- " $set_hasbit$\n"
- " $name$_.Set($default_variable$, $string_piece$(value),\n"
- " GetArenaNoVirtual());\n"
- " // @@protoc_insertion_point(field_set_char:$full_name$)\n"
- "}\n"
- "$inline$"
- "void $classname$::set_$name$(const $pointer_type$* value,\n"
- " size_t size) {\n"
- " $set_hasbit$\n"
- " $name$_.Set($default_variable$, $string_piece$(\n"
- " reinterpret_cast<const char*>(value), size), GetArenaNoVirtual());\n"
- " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n"
- "}\n"
- "$inline$::std::string* $classname$::mutable_$name$() {\n"
- " $set_hasbit$\n"
- " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
- " return $name$_.Mutable($default_variable$, GetArenaNoVirtual());\n"
- "}\n"
- "$inline$::std::string* $classname$::$release_name$() {\n"
- " // @@protoc_insertion_point(field_release:$full_name$)\n"
- " $clear_hasbit$\n"
- " return $name$_.Release($default_variable$, GetArenaNoVirtual());\n"
- "}\n"
- "$inline$::std::string* $classname$::unsafe_arena_release_$name$() {\n"
- " // @@protoc_insertion_point(field_unsafe_arena_release:$full_name$)\n"
- " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n"
- " $clear_hasbit$\n"
- " return $name$_.UnsafeArenaRelease($default_variable$,\n"
- " GetArenaNoVirtual());\n"
- "}\n"
- "$inline$void $classname$::set_allocated_$name$(::std::string* $name$) {\n"
- " if ($name$ != NULL) {\n"
- " $set_hasbit$\n"
- " } else {\n"
- " $clear_hasbit$\n"
- " }\n"
- " $name$_.SetAllocated($default_variable$, $name$,\n"
- " GetArenaNoVirtual());\n"
- " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
- "}\n"
- "$inline$void $classname$::unsafe_arena_set_allocated_$name$(\n"
- " ::std::string* $name$) {\n"
- " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n"
- " if ($name$ != NULL) {\n"
- " $set_hasbit$\n"
- " } else {\n"
- " $clear_hasbit$\n"
- " }\n"
- " $name$_.UnsafeArenaSetAllocated($default_variable$,\n"
- " $name$, GetArenaNoVirtual());\n"
- " // @@protoc_insertion_point(field_unsafe_arena_set_allocated:"
- "$full_name$)\n"
- "}\n");
+ printer->Print(
+ variables,
+ "$inline$const ::std::string& $classname$::$name$() const {\n"
+ " // @@protoc_insertion_point(field_get:$full_name$)\n"
+ " return $name$_.Get();\n"
+ "}\n"
+ "$inline$void $classname$::set_$name$(const ::std::string& value) {\n"
+ " $set_hasbit$\n"
+ " $name$_.Set($default_variable$, value, GetArenaNoVirtual());\n"
+ " // @@protoc_insertion_point(field_set:$full_name$)\n"
+ "}\n"
+ "$inline$void $classname$::set_$name$(const char* value) {\n"
+ " $set_hasbit$\n"
+ " $name$_.Set($default_variable$, $string_piece$(value),\n"
+ " GetArenaNoVirtual());\n"
+ " // @@protoc_insertion_point(field_set_char:$full_name$)\n"
+ "}\n"
+ "$inline$"
+ "void $classname$::set_$name$(const $pointer_type$* value,\n"
+ " size_t size) {\n"
+ " $set_hasbit$\n"
+ " $name$_.Set($default_variable$, $string_piece$(\n"
+ " reinterpret_cast<const char*>(value), size), "
+ "GetArenaNoVirtual());\n"
+ " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n"
+ "}\n"
+ "$inline$::std::string* $classname$::mutable_$name$() {\n"
+ " $set_hasbit$\n"
+ " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
+ " return $name$_.Mutable($default_variable$, GetArenaNoVirtual());\n"
+ "}\n"
+ "$inline$::std::string* $classname$::$release_name$() {\n"
+ " // @@protoc_insertion_point(field_release:$full_name$)\n"
+ " $clear_hasbit$\n"
+ " return $name$_.Release($default_variable$, GetArenaNoVirtual());\n"
+ "}\n"
+ "$inline$::std::string* $classname$::unsafe_arena_release_$name$() {\n"
+ " // "
+ "@@protoc_insertion_point(field_unsafe_arena_release:$full_name$)\n"
+ " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n"
+ " $clear_hasbit$\n"
+ " return $name$_.UnsafeArenaRelease($default_variable$,\n"
+ " GetArenaNoVirtual());\n"
+ "}\n"
+ "$inline$void $classname$::set_allocated_$name$(::std::string* $name$) {\n"
+ " if ($name$ != NULL) {\n"
+ " $set_hasbit$\n"
+ " } else {\n"
+ " $clear_hasbit$\n"
+ " }\n"
+ " $name$_.SetAllocated($default_variable$, $name$,\n"
+ " GetArenaNoVirtual());\n"
+ " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
+ "}\n"
+ "$inline$void $classname$::unsafe_arena_set_allocated_$name$(\n"
+ " ::std::string* $name$) {\n"
+ " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n"
+ " if ($name$ != NULL) {\n"
+ " $set_hasbit$\n"
+ " } else {\n"
+ " $clear_hasbit$\n"
+ " }\n"
+ " $name$_.UnsafeArenaSetAllocated($default_variable$,\n"
+ " $name$, GetArenaNoVirtual());\n"
+ " // @@protoc_insertion_point(field_unsafe_arena_set_allocated:"
+ "$full_name$)\n"
+ "}\n");
} else {
// No-arena case.
- printer->Print(variables,
- "$inline$const ::std::string& $classname$::$name$() const {\n"
- " // @@protoc_insertion_point(field_get:$full_name$)\n"
- " return $name$_.GetNoArena($default_variable$);\n"
- "}\n"
- "$inline$void $classname$::set_$name$(const ::std::string& value) {\n"
- " $set_hasbit$\n"
- " $name$_.SetNoArena($default_variable$, value);\n"
- " // @@protoc_insertion_point(field_set:$full_name$)\n"
- "}\n"
- "$inline$void $classname$::set_$name$(const char* value) {\n"
- " $set_hasbit$\n"
- " $name$_.SetNoArena($default_variable$, $string_piece$(value));\n"
- " // @@protoc_insertion_point(field_set_char:$full_name$)\n"
- "}\n"
- "$inline$"
- "void $classname$::set_$name$(const $pointer_type$* value, "
- "size_t size) {\n"
- " $set_hasbit$\n"
- " $name$_.SetNoArena($default_variable$,\n"
- " $string_piece$(reinterpret_cast<const char*>(value), size));\n"
- " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n"
- "}\n"
- "$inline$::std::string* $classname$::mutable_$name$() {\n"
- " $set_hasbit$\n"
- " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
- " return $name$_.MutableNoArena($default_variable$);\n"
- "}\n"
- "$inline$::std::string* $classname$::$release_name$() {\n"
- " // @@protoc_insertion_point(field_release:$full_name$)\n"
- " $clear_hasbit$\n"
- " return $name$_.ReleaseNoArena($default_variable$);\n"
- "}\n"
- "$inline$void $classname$::set_allocated_$name$(::std::string* $name$) {\n"
- " if ($name$ != NULL) {\n"
- " $set_hasbit$\n"
- " } else {\n"
- " $clear_hasbit$\n"
- " }\n"
- " $name$_.SetAllocatedNoArena($default_variable$, $name$);\n"
- " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
- "}\n");
+ printer->Print(
+ variables,
+ "$inline$const ::std::string& $classname$::$name$() const {\n"
+ " // @@protoc_insertion_point(field_get:$full_name$)\n"
+ " return $name$_.GetNoArena();\n"
+ "}\n"
+ "$inline$void $classname$::set_$name$(const ::std::string& value) {\n"
+ " $set_hasbit$\n"
+ " $name$_.SetNoArena($default_variable$, value);\n"
+ " // @@protoc_insertion_point(field_set:$full_name$)\n"
+ "}\n"
+ "#if LANG_CXX11\n"
+ "$inline$void $classname$::set_$name$(::std::string&& value) {\n"
+ " $set_hasbit$\n"
+ " $name$_.SetNoArena(\n"
+ " $default_variable$, ::std::move(value));\n"
+ " // @@protoc_insertion_point(field_set_rvalue:$full_name$)\n"
+ "}\n"
+ "#endif\n"
+ "$inline$void $classname$::set_$name$(const char* value) {\n"
+ " $set_hasbit$\n"
+ " $name$_.SetNoArena($default_variable$, $string_piece$(value));\n"
+ " // @@protoc_insertion_point(field_set_char:$full_name$)\n"
+ "}\n"
+ "$inline$"
+ "void $classname$::set_$name$(const $pointer_type$* value, "
+ "size_t size) {\n"
+ " $set_hasbit$\n"
+ " $name$_.SetNoArena($default_variable$,\n"
+ " $string_piece$(reinterpret_cast<const char*>(value), size));\n"
+ " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n"
+ "}\n"
+ "$inline$::std::string* $classname$::mutable_$name$() {\n"
+ " $set_hasbit$\n"
+ " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
+ " return $name$_.MutableNoArena($default_variable$);\n"
+ "}\n"
+ "$inline$::std::string* $classname$::$release_name$() {\n"
+ " // @@protoc_insertion_point(field_release:$full_name$)\n"
+ " $clear_hasbit$\n"
+ " return $name$_.ReleaseNoArena($default_variable$);\n"
+ "}\n"
+ "$inline$void $classname$::set_allocated_$name$(::std::string* $name$) {\n"
+ " if ($name$ != NULL) {\n"
+ " $set_hasbit$\n"
+ " } else {\n"
+ " $clear_hasbit$\n"
+ " }\n"
+ " $name$_.SetAllocatedNoArena($default_variable$, $name$);\n"
+ " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
+ "}\n");
}
}
@@ -284,7 +306,8 @@ GenerateNonInlineAccessorDefinitions(io::Printer* printer) const {
if (!descriptor_->default_value_string().empty()) {
// Initialized in GenerateDefaultInstanceAllocator.
printer->Print(variables_,
- "::std::string* $classname$::$default_variable$ = NULL;\n");
+ "::google::protobuf::internal::ExplicitlyConstructed< ::std::string> "
+ "$classname$::$default_variable_name$;\n");
}
}
@@ -314,6 +337,52 @@ GenerateClearingCode(io::Printer* printer) const {
}
void StringFieldGenerator::
+GenerateMessageClearingCode(io::Printer* printer) const {
+ // Two-dimension specialization here: supporting arenas, field presence, or
+ // not, and default value is the empty string or not. Complexity here ensures
+ // the minimal number of branches / amount of extraneous code at runtime
+ // (given that the below methods are inlined one-liners)!
+
+ // If we have field presence, then the Clear() method of the protocol buffer
+ // will have checked that this field is set. If so, we can avoid redundant
+ // checks against default_variable.
+ const bool must_be_present = HasFieldPresence(descriptor_->file());
+
+ if (must_be_present) {
+ printer->Print(variables_,
+ "GOOGLE_DCHECK(!$name$_.IsDefault($default_variable$));\n");
+ }
+
+ if (SupportsArenas(descriptor_)) {
+ if (descriptor_->default_value_string().empty()) {
+ printer->Print(variables_,
+ "$name$_.ClearToEmpty($default_variable$, GetArenaNoVirtual());\n");
+ } else {
+ printer->Print(variables_,
+ "$name$_.ClearToDefault($default_variable$, GetArenaNoVirtual());\n");
+ }
+ } else if (must_be_present) {
+ // When Arenas are disabled and field presence has been checked, we can
+ // safely treat the ArenaStringPtr as a string*.
+ if (descriptor_->default_value_string().empty()) {
+ printer->Print(variables_,
+ "(*$name$_.UnsafeRawStringPointer())->clear();\n");
+ } else {
+ printer->Print(variables_,
+ "(*$name$_.UnsafeRawStringPointer())->assign(*$default_variable$);\n");
+ }
+ } else {
+ if (descriptor_->default_value_string().empty()) {
+ printer->Print(variables_,
+ "$name$_.ClearToEmptyNoArena($default_variable$);\n");
+ } else {
+ printer->Print(variables_,
+ "$name$_.ClearToDefaultNoArena($default_variable$);\n");
+ }
+ }
+}
+
+void StringFieldGenerator::
GenerateMergingCode(io::Printer* printer) const {
if (SupportsArenas(descriptor_) || descriptor_->containing_oneof() != NULL) {
// TODO(gpike): improve this
@@ -337,6 +406,34 @@ GenerateConstructorCode(io::Printer* printer) const {
}
void StringFieldGenerator::
+GenerateCopyConstructorCode(io::Printer* printer) const {
+ GenerateConstructorCode(printer);
+
+ if (HasFieldPresence(descriptor_->file())) {
+ printer->Print(variables_,
+ "if (from.has_$name$()) {\n");
+ } else {
+ printer->Print(variables_,
+ "if (from.$name$().size() > 0) {\n");
+ }
+
+ printer->Indent();
+
+ if (SupportsArenas(descriptor_) || descriptor_->containing_oneof() != NULL) {
+ // TODO(gpike): improve this
+ printer->Print(variables_,
+ "$name$_.Set($default_variable$, from.$name$(),\n"
+ " GetArenaNoVirtual());\n");
+ } else {
+ printer->Print(variables_,
+ "$name$_.AssignWithDefault($default_variable$, from.$name$_);\n");
+ }
+
+ printer->Outdent();
+ printer->Print("}\n");
+}
+
+void StringFieldGenerator::
GenerateDestructorCode(io::Printer* printer) const {
if (SupportsArenas(descriptor_)) {
// The variable |arena| is defined by the enclosing code.
@@ -353,8 +450,9 @@ void StringFieldGenerator::
GenerateDefaultInstanceAllocator(io::Printer* printer) const {
if (!descriptor_->default_value_string().empty()) {
printer->Print(variables_,
- "$classname$::$default_variable$ =\n"
- " new ::std::string($default$, $default_length$);\n");
+ "$classname$::$default_variable_name$.DefaultConstruct();\n"
+ "*$classname$::$default_variable_name$.get_mutable() = "
+ "::std::string($default$, $default_length$);\n");
}
}
@@ -362,7 +460,7 @@ void StringFieldGenerator::
GenerateShutdownCode(io::Printer* printer) const {
if (!descriptor_->default_value_string().empty()) {
printer->Print(variables_,
- "delete $classname$::$default_variable$;\n");
+ "$classname$::$default_variable_name$.Shutdown();\n");
}
}
@@ -427,185 +525,203 @@ StringOneofFieldGenerator::~StringOneofFieldGenerator() {}
void StringOneofFieldGenerator::
GenerateInlineAccessorDefinitions(io::Printer* printer,
bool is_inline) const {
- map<string, string> variables(variables_);
+ std::map<string, string> variables(variables_);
variables["inline"] = is_inline ? "inline " : "";
if (SupportsArenas(descriptor_)) {
- printer->Print(variables,
- "$inline$const ::std::string& $classname$::$name$() const {\n"
- " // @@protoc_insertion_point(field_get:$full_name$)\n"
- " if (has_$name$()) {\n"
- " return $oneof_prefix$$name$_.Get($default_variable$);\n"
- " }\n"
- " return *$default_variable$;\n"
- "}\n"
- "$inline$void $classname$::set_$name$(const ::std::string& value) {\n"
- " if (!has_$name$()) {\n"
- " clear_$oneof_name$();\n"
- " set_has_$name$();\n"
- " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
- " }\n"
- " $oneof_prefix$$name$_.Set($default_variable$, value,\n"
- " GetArenaNoVirtual());\n"
- " // @@protoc_insertion_point(field_set:$full_name$)\n"
- "}\n"
- "$inline$void $classname$::set_$name$(const char* value) {\n"
- " if (!has_$name$()) {\n"
- " clear_$oneof_name$();\n"
- " set_has_$name$();\n"
- " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
- " }\n"
- " $oneof_prefix$$name$_.Set($default_variable$,\n"
- " $string_piece$(value), GetArenaNoVirtual());\n"
- " // @@protoc_insertion_point(field_set_char:$full_name$)\n"
- "}\n"
- "$inline$"
- "void $classname$::set_$name$(const $pointer_type$* value,\n"
- " size_t size) {\n"
- " if (!has_$name$()) {\n"
- " clear_$oneof_name$();\n"
- " set_has_$name$();\n"
- " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
- " }\n"
- " $oneof_prefix$$name$_.Set($default_variable$, $string_piece$(\n"
- " reinterpret_cast<const char*>(value), size),\n"
- " GetArenaNoVirtual());\n"
- " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n"
- "}\n"
- "$inline$::std::string* $classname$::mutable_$name$() {\n"
- " if (!has_$name$()) {\n"
- " clear_$oneof_name$();\n"
- " set_has_$name$();\n"
- " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
- " }\n"
- " return $oneof_prefix$$name$_.Mutable($default_variable$,\n"
- " GetArenaNoVirtual());\n"
- " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
- "}\n"
- "$inline$::std::string* $classname$::$release_name$() {\n"
- " // @@protoc_insertion_point(field_release:$full_name$)\n"
- " if (has_$name$()) {\n"
- " clear_has_$oneof_name$();\n"
- " return $oneof_prefix$$name$_.Release($default_variable$,\n"
- " GetArenaNoVirtual());\n"
- " } else {\n"
- " return NULL;\n"
- " }\n"
- "}\n"
- "$inline$::std::string* $classname$::unsafe_arena_release_$name$() {\n"
- " // @@protoc_insertion_point(field_unsafe_arena_release:$full_name$)\n"
- " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n"
- " if (has_$name$()) {\n"
- " clear_has_$oneof_name$();\n"
- " return $oneof_prefix$$name$_.UnsafeArenaRelease(\n"
- " $default_variable$, GetArenaNoVirtual());\n"
- " } else {\n"
- " return NULL;\n"
- " }\n"
- "}\n"
- "$inline$void $classname$::set_allocated_$name$(::std::string* $name$) {\n"
- " if (!has_$name$()) {\n"
- " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
- " }\n"
- " clear_$oneof_name$();\n"
- " if ($name$ != NULL) {\n"
- " set_has_$name$();\n"
- " $oneof_prefix$$name$_.SetAllocated($default_variable$, $name$,\n"
- " GetArenaNoVirtual());\n"
- " }\n"
- " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
- "}\n"
- "$inline$void $classname$::unsafe_arena_set_allocated_$name$("
- "::std::string* $name$) {\n"
- " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n"
- " if (!has_$name$()) {\n"
- " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
- " }\n"
- " clear_$oneof_name$();\n"
- " if ($name$) {\n"
- " set_has_$name$();\n"
- " $oneof_prefix$$name$_.UnsafeArenaSetAllocated($default_variable$, "
- "$name$, GetArenaNoVirtual());\n"
- " }\n"
- " // @@protoc_insertion_point(field_unsafe_arena_set_allocated:"
- "$full_name$)\n"
- "}\n");
+ printer->Print(
+ variables,
+ "$inline$const ::std::string& $classname$::$name$() const {\n"
+ " // @@protoc_insertion_point(field_get:$full_name$)\n"
+ " if (has_$name$()) {\n"
+ " return $oneof_prefix$$name$_.Get();\n"
+ " }\n"
+ " return *$default_variable$;\n"
+ "}\n"
+ "$inline$void $classname$::set_$name$(const ::std::string& value) {\n"
+ " if (!has_$name$()) {\n"
+ " clear_$oneof_name$();\n"
+ " set_has_$name$();\n"
+ " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
+ " }\n"
+ " $oneof_prefix$$name$_.Set($default_variable$, value,\n"
+ " GetArenaNoVirtual());\n"
+ " // @@protoc_insertion_point(field_set:$full_name$)\n"
+ "}\n"
+ "$inline$void $classname$::set_$name$(const char* value) {\n"
+ " if (!has_$name$()) {\n"
+ " clear_$oneof_name$();\n"
+ " set_has_$name$();\n"
+ " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
+ " }\n"
+ " $oneof_prefix$$name$_.Set($default_variable$,\n"
+ " $string_piece$(value), GetArenaNoVirtual());\n"
+ " // @@protoc_insertion_point(field_set_char:$full_name$)\n"
+ "}\n"
+ "$inline$"
+ "void $classname$::set_$name$(const $pointer_type$* value,\n"
+ " size_t size) {\n"
+ " if (!has_$name$()) {\n"
+ " clear_$oneof_name$();\n"
+ " set_has_$name$();\n"
+ " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
+ " }\n"
+ " $oneof_prefix$$name$_.Set($default_variable$, $string_piece$(\n"
+ " reinterpret_cast<const char*>(value), size),\n"
+ " GetArenaNoVirtual());\n"
+ " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n"
+ "}\n"
+ "$inline$::std::string* $classname$::mutable_$name$() {\n"
+ " if (!has_$name$()) {\n"
+ " clear_$oneof_name$();\n"
+ " set_has_$name$();\n"
+ " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
+ " }\n"
+ " return $oneof_prefix$$name$_.Mutable($default_variable$,\n"
+ " GetArenaNoVirtual());\n"
+ " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
+ "}\n"
+ "$inline$::std::string* $classname$::$release_name$() {\n"
+ " // @@protoc_insertion_point(field_release:$full_name$)\n"
+ " if (has_$name$()) {\n"
+ " clear_has_$oneof_name$();\n"
+ " return $oneof_prefix$$name$_.Release($default_variable$,\n"
+ " GetArenaNoVirtual());\n"
+ " } else {\n"
+ " return NULL;\n"
+ " }\n"
+ "}\n"
+ "$inline$::std::string* $classname$::unsafe_arena_release_$name$() {\n"
+ " // "
+ "@@protoc_insertion_point(field_unsafe_arena_release:$full_name$)\n"
+ " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n"
+ " if (has_$name$()) {\n"
+ " clear_has_$oneof_name$();\n"
+ " return $oneof_prefix$$name$_.UnsafeArenaRelease(\n"
+ " $default_variable$, GetArenaNoVirtual());\n"
+ " } else {\n"
+ " return NULL;\n"
+ " }\n"
+ "}\n"
+ "$inline$void $classname$::set_allocated_$name$(::std::string* $name$) {\n"
+ " if (!has_$name$()) {\n"
+ " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
+ " }\n"
+ " clear_$oneof_name$();\n"
+ " if ($name$ != NULL) {\n"
+ " set_has_$name$();\n"
+ " $oneof_prefix$$name$_.SetAllocated($default_variable$, $name$,\n"
+ " GetArenaNoVirtual());\n"
+ " }\n"
+ " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
+ "}\n"
+ "$inline$void $classname$::unsafe_arena_set_allocated_$name$("
+ "::std::string* $name$) {\n"
+ " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n"
+ " if (!has_$name$()) {\n"
+ " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
+ " }\n"
+ " clear_$oneof_name$();\n"
+ " if ($name$) {\n"
+ " set_has_$name$();\n"
+ " $oneof_prefix$$name$_.UnsafeArenaSetAllocated($default_variable$, "
+ "$name$, GetArenaNoVirtual());\n"
+ " }\n"
+ " // @@protoc_insertion_point(field_unsafe_arena_set_allocated:"
+ "$full_name$)\n"
+ "}\n");
} else {
// No-arena case.
- printer->Print(variables,
- "$inline$const ::std::string& $classname$::$name$() const {\n"
- " // @@protoc_insertion_point(field_get:$full_name$)\n"
- " if (has_$name$()) {\n"
- " return $oneof_prefix$$name$_.GetNoArena($default_variable$);\n"
- " }\n"
- " return *$default_variable$;\n"
- "}\n"
- "$inline$void $classname$::set_$name$(const ::std::string& value) {\n"
- " // @@protoc_insertion_point(field_set:$full_name$)\n"
- " if (!has_$name$()) {\n"
- " clear_$oneof_name$();\n"
- " set_has_$name$();\n"
- " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
- " }\n"
- " $oneof_prefix$$name$_.SetNoArena($default_variable$, value);\n"
- " // @@protoc_insertion_point(field_set:$full_name$)\n"
- "}\n"
- "$inline$void $classname$::set_$name$(const char* value) {\n"
- " if (!has_$name$()) {\n"
- " clear_$oneof_name$();\n"
- " set_has_$name$();\n"
- " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
- " }\n"
- " $oneof_prefix$$name$_.SetNoArena($default_variable$,\n"
- " $string_piece$(value));\n"
- " // @@protoc_insertion_point(field_set_char:$full_name$)\n"
- "}\n"
- "$inline$"
- "void $classname$::set_$name$(const $pointer_type$* value, size_t size) {\n"
- " if (!has_$name$()) {\n"
- " clear_$oneof_name$();\n"
- " set_has_$name$();\n"
- " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
- " }\n"
- " $oneof_prefix$$name$_.SetNoArena($default_variable$, $string_piece$(\n"
- " reinterpret_cast<const char*>(value), size));\n"
- " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n"
- "}\n"
- "$inline$::std::string* $classname$::mutable_$name$() {\n"
- " if (!has_$name$()) {\n"
- " clear_$oneof_name$();\n"
- " set_has_$name$();\n"
- " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
- " }\n"
- " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
- " return $oneof_prefix$$name$_.MutableNoArena($default_variable$);\n"
- "}\n"
- "$inline$::std::string* $classname$::$release_name$() {\n"
- " // @@protoc_insertion_point(field_release:$full_name$)\n"
- " if (has_$name$()) {\n"
- " clear_has_$oneof_name$();\n"
- " return $oneof_prefix$$name$_.ReleaseNoArena($default_variable$);\n"
- " } else {\n"
- " return NULL;\n"
- " }\n"
- "}\n"
- "$inline$void $classname$::set_allocated_$name$(::std::string* $name$) {\n"
- " if (!has_$name$()) {\n"
- " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
- " }\n"
- " clear_$oneof_name$();\n"
- " if ($name$ != NULL) {\n"
- " set_has_$name$();\n"
- " $oneof_prefix$$name$_.SetAllocatedNoArena($default_variable$,\n"
- " $name$);\n"
- " }\n"
- " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
- "}\n");
+ printer->Print(
+ variables,
+ "$inline$const ::std::string& $classname$::$name$() const {\n"
+ " // @@protoc_insertion_point(field_get:$full_name$)\n"
+ " if (has_$name$()) {\n"
+ " return $oneof_prefix$$name$_.GetNoArena();\n"
+ " }\n"
+ " return *$default_variable$;\n"
+ "}\n"
+ "$inline$void $classname$::set_$name$(const ::std::string& value) {\n"
+ " // @@protoc_insertion_point(field_set:$full_name$)\n"
+ " if (!has_$name$()) {\n"
+ " clear_$oneof_name$();\n"
+ " set_has_$name$();\n"
+ " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
+ " }\n"
+ " $oneof_prefix$$name$_.SetNoArena($default_variable$, value);\n"
+ " // @@protoc_insertion_point(field_set:$full_name$)\n"
+ "}\n"
+ "#if LANG_CXX11\n"
+ "$inline$void $classname$::set_$name$(::std::string&& value) {\n"
+ " // @@protoc_insertion_point(field_set:$full_name$)\n"
+ " if (!has_$name$()) {\n"
+ " clear_$oneof_name$();\n"
+ " set_has_$name$();\n"
+ " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
+ " }\n"
+ " $oneof_prefix$$name$_.SetNoArena(\n"
+ " $default_variable$, ::std::move(value));\n"
+ " // @@protoc_insertion_point(field_set_rvalue:$full_name$)\n"
+ "}\n"
+ "#endif\n"
+ "$inline$void $classname$::set_$name$(const char* value) {\n"
+ " if (!has_$name$()) {\n"
+ " clear_$oneof_name$();\n"
+ " set_has_$name$();\n"
+ " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
+ " }\n"
+ " $oneof_prefix$$name$_.SetNoArena($default_variable$,\n"
+ " $string_piece$(value));\n"
+ " // @@protoc_insertion_point(field_set_char:$full_name$)\n"
+ "}\n"
+ "$inline$"
+ "void $classname$::set_$name$(const $pointer_type$* value, size_t "
+ "size) {\n"
+ " if (!has_$name$()) {\n"
+ " clear_$oneof_name$();\n"
+ " set_has_$name$();\n"
+ " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
+ " }\n"
+ " $oneof_prefix$$name$_.SetNoArena($default_variable$, "
+ "$string_piece$(\n"
+ " reinterpret_cast<const char*>(value), size));\n"
+ " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n"
+ "}\n"
+ "$inline$::std::string* $classname$::mutable_$name$() {\n"
+ " if (!has_$name$()) {\n"
+ " clear_$oneof_name$();\n"
+ " set_has_$name$();\n"
+ " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
+ " }\n"
+ " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
+ " return $oneof_prefix$$name$_.MutableNoArena($default_variable$);\n"
+ "}\n"
+ "$inline$::std::string* $classname$::$release_name$() {\n"
+ " // @@protoc_insertion_point(field_release:$full_name$)\n"
+ " if (has_$name$()) {\n"
+ " clear_has_$oneof_name$();\n"
+ " return $oneof_prefix$$name$_.ReleaseNoArena($default_variable$);\n"
+ " } else {\n"
+ " return NULL;\n"
+ " }\n"
+ "}\n"
+ "$inline$void $classname$::set_allocated_$name$(::std::string* $name$) {\n"
+ " if (!has_$name$()) {\n"
+ " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n"
+ " }\n"
+ " clear_$oneof_name$();\n"
+ " if ($name$ != NULL) {\n"
+ " set_has_$name$();\n"
+ " $oneof_prefix$$name$_.SetAllocatedNoArena($default_variable$,\n"
+ " $name$);\n"
+ " }\n"
+ " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
+ "}\n");
}
}
void StringOneofFieldGenerator::
GenerateClearingCode(io::Printer* printer) const {
- map<string, string> variables(variables_);
+ std::map<string, string> variables(variables_);
if (dependent_field_) {
variables["this_message"] = DependentBaseDownCast();
// This clearing code may be in the dependent base class. If the default
@@ -614,8 +730,9 @@ GenerateClearingCode(io::Printer* printer) const {
// default value's global singleton instance. See SetStringVariables() for
// possible values of default_variable.
if (!descriptor_->default_value_string().empty()) {
- variables["default_variable"] =
- DependentBaseDownCast() + variables["default_variable"];
+ variables["default_variable"] = "&" + DependentBaseDownCast() +
+ variables["default_variable_name"] +
+ ".get()";
}
} else {
variables["this_message"] = "";
@@ -632,15 +749,21 @@ GenerateClearingCode(io::Printer* printer) const {
}
void StringOneofFieldGenerator::
+GenerateMessageClearingCode(io::Printer* printer) const {
+ return GenerateClearingCode(printer);
+}
+
+void StringOneofFieldGenerator::
GenerateSwappingCode(io::Printer* printer) const {
// Don't print any swapping code. Swapping the union will swap this field.
}
void StringOneofFieldGenerator::
GenerateConstructorCode(io::Printer* printer) const {
- printer->Print(variables_,
- " $classname$_default_oneof_instance_->$name$_.UnsafeSetDefault("
- "$default_variable$);\n");
+ printer->Print(
+ variables_,
+ "_$classname$_default_instance_.$name$_.UnsafeSetDefault(\n"
+ " $default_variable$);\n");
}
void StringOneofFieldGenerator::
@@ -707,17 +830,21 @@ GenerateAccessorDeclarations(io::Printer* printer) const {
"$deprecated_attr$const ::std::string& $name$(int index) const;\n"
"$deprecated_attr$::std::string* mutable_$name$(int index);\n"
"$deprecated_attr$void set_$name$(int index, const ::std::string& value);\n"
+ "#if LANG_CXX11\n"
+ "$deprecated_attr$void set_$name$(int index, ::std::string&& value);\n"
+ "#endif\n"
"$deprecated_attr$void set_$name$(int index, const char* value);\n"
""
"$deprecated_attr$void set_$name$("
"int index, const $pointer_type$* value, size_t size);\n"
"$deprecated_attr$::std::string* add_$name$();\n"
"$deprecated_attr$void add_$name$(const ::std::string& value);\n"
+ "#if LANG_CXX11\n"
+ "$deprecated_attr$void add_$name$(::std::string&& value);\n"
+ "#endif\n"
"$deprecated_attr$void add_$name$(const char* value);\n"
"$deprecated_attr$void add_$name$(const $pointer_type$* value, size_t size)"
- ";\n");
-
- printer->Print(variables_,
+ ";\n"
"$deprecated_attr$const ::google::protobuf::RepeatedPtrField< ::std::string>& $name$() "
"const;\n"
"$deprecated_attr$::google::protobuf::RepeatedPtrField< ::std::string>* mutable_$name$()"
@@ -733,7 +860,7 @@ GenerateAccessorDeclarations(io::Printer* printer) const {
void RepeatedStringFieldGenerator::
GenerateInlineAccessorDefinitions(io::Printer* printer,
bool is_inline) const {
- map<string, string> variables(variables_);
+ std::map<string, string> variables(variables_);
variables["inline"] = is_inline ? "inline " : "";
printer->Print(variables,
"$inline$const ::std::string& $classname$::$name$(int index) const {\n"
@@ -748,6 +875,12 @@ GenerateInlineAccessorDefinitions(io::Printer* printer,
" // @@protoc_insertion_point(field_set:$full_name$)\n"
" $name$_.Mutable(index)->assign(value);\n"
"}\n"
+ "#if LANG_CXX11\n"
+ "$inline$void $classname$::set_$name$(int index, ::std::string&& value) {\n"
+ " // @@protoc_insertion_point(field_set:$full_name$)\n"
+ " $name$_.Mutable(index)->assign(std::move(value));\n"
+ "}\n"
+ "#endif\n"
"$inline$void $classname$::set_$name$(int index, const char* value) {\n"
" $name$_.Mutable(index)->assign(value);\n"
" // @@protoc_insertion_point(field_set_char:$full_name$)\n"
@@ -767,6 +900,12 @@ GenerateInlineAccessorDefinitions(io::Printer* printer,
" $name$_.Add()->assign(value);\n"
" // @@protoc_insertion_point(field_add:$full_name$)\n"
"}\n"
+ "#if LANG_CXX11\n"
+ "$inline$void $classname$::add_$name$(::std::string&& value) {\n"
+ " $name$_.Add()->assign(std::move(value));\n"
+ " // @@protoc_insertion_point(field_add:$full_name$)\n"
+ "}\n"
+ "#endif\n"
"$inline$void $classname$::add_$name$(const char* value) {\n"
" $name$_.Add()->assign(value);\n"
" // @@protoc_insertion_point(field_add_char:$full_name$)\n"
@@ -775,8 +914,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer,
"$classname$::add_$name$(const $pointer_type$* value, size_t size) {\n"
" $name$_.Add()->assign(reinterpret_cast<const char*>(value), size);\n"
" // @@protoc_insertion_point(field_add_pointer:$full_name$)\n"
- "}\n");
- printer->Print(variables,
+ "}\n"
"$inline$const ::google::protobuf::RepeatedPtrField< ::std::string>&\n"
"$classname$::$name$() const {\n"
" // @@protoc_insertion_point(field_list:$full_name$)\n"
@@ -800,11 +938,6 @@ GenerateMergingCode(io::Printer* printer) const {
}
void RepeatedStringFieldGenerator::
-GenerateUnsafeMergingCode(io::Printer* printer) const {
- printer->Print(variables_, "$name$_.UnsafeMergeFrom(from.$name$_);\n");
-}
-
-void RepeatedStringFieldGenerator::
GenerateSwappingCode(io::Printer* printer) const {
printer->Print(variables_, "$name$_.UnsafeArenaSwap(&other->$name$_);\n");
}
@@ -815,6 +948,11 @@ GenerateConstructorCode(io::Printer* printer) const {
}
void RepeatedStringFieldGenerator::
+GenerateCopyConstructorCode(io::Printer* printer) const {
+ printer->Print(variables_, "$name$_.CopyFrom(from.$name$_);");
+}
+
+void RepeatedStringFieldGenerator::
GenerateMergeFromCodedStream(io::Printer* printer) const {
printer->Print(variables_,
"DO_(::google::protobuf::internal::WireFormatLite::Read$declared_type$(\n"
@@ -831,7 +969,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
void RepeatedStringFieldGenerator::
GenerateSerializeWithCachedSizes(io::Printer* printer) const {
printer->Print(variables_,
- "for (int i = 0; i < this->$name$_size(); i++) {\n");
+ "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n");
printer->Indent();
if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {
GenerateUtf8CheckCodeForString(
@@ -848,7 +986,7 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const {
void RepeatedStringFieldGenerator::
GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
printer->Print(variables_,
- "for (int i = 0; i < this->$name$_size(); i++) {\n");
+ "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n");
printer->Indent();
if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {
GenerateUtf8CheckCodeForString(
@@ -867,7 +1005,7 @@ GenerateByteSize(io::Printer* printer) const {
printer->Print(variables_,
"total_size += $tag_size$ *\n"
" ::google::protobuf::internal::FromIntSize(this->$name$_size());\n"
- "for (int i = 0; i < this->$name$_size(); i++) {\n"
+ "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n"
" total_size += ::google::protobuf::internal::WireFormatLite::$declared_type$Size(\n"
" this->$name$(i));\n"
"}\n");
diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.h b/src/google/protobuf/compiler/cpp/cpp_string_field.h
index 1dea7663..af263c1a 100644
--- a/src/google/protobuf/compiler/cpp/cpp_string_field.h
+++ b/src/google/protobuf/compiler/cpp/cpp_string_field.h
@@ -58,9 +58,11 @@ class StringFieldGenerator : public FieldGenerator {
bool is_inline) const;
void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const;
void GenerateClearingCode(io::Printer* printer) const;
+ void GenerateMessageClearingCode(io::Printer* printer) const;
void GenerateMergingCode(io::Printer* printer) const;
void GenerateSwappingCode(io::Printer* printer) const;
void GenerateConstructorCode(io::Printer* printer) const;
+ void GenerateCopyConstructorCode(io::Printer* printer) const;
void GenerateDestructorCode(io::Printer* printer) const;
void GenerateDefaultInstanceAllocator(io::Printer* printer) const;
void GenerateShutdownCode(io::Printer* printer) const;
@@ -71,7 +73,7 @@ class StringFieldGenerator : public FieldGenerator {
protected:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringFieldGenerator);
@@ -87,6 +89,10 @@ class StringOneofFieldGenerator : public StringFieldGenerator {
void GenerateInlineAccessorDefinitions(io::Printer* printer,
bool is_inline) const;
void GenerateClearingCode(io::Printer* printer) const;
+
+ // StringFieldGenerator, from which we inherit, overrides this so we need to
+ // override it as well.
+ void GenerateMessageClearingCode(io::Printer* printer) const;
void GenerateSwappingCode(io::Printer* printer) const;
void GenerateConstructorCode(io::Printer* printer) const;
void GenerateDestructorCode(io::Printer* printer) const;
@@ -110,9 +116,9 @@ class RepeatedStringFieldGenerator : public FieldGenerator {
bool is_inline) const;
void GenerateClearingCode(io::Printer* printer) const;
void GenerateMergingCode(io::Printer* printer) const;
- void GenerateUnsafeMergingCode(io::Printer* printer) const;
void GenerateSwappingCode(io::Printer* printer) const;
void GenerateConstructorCode(io::Printer* printer) const;
+ void GenerateCopyConstructorCode(io::Printer* printer) const;
void GenerateMergeFromCodedStream(io::Printer* printer) const;
void GenerateSerializeWithCachedSizes(io::Printer* printer) const;
void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
@@ -120,7 +126,7 @@ class RepeatedStringFieldGenerator : public FieldGenerator {
private:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedStringFieldGenerator);
};
diff --git a/src/google/protobuf/compiler/cpp/cpp_unittest.cc b/src/google/protobuf/compiler/cpp/cpp_unittest.cc
index d214ef0a..6d68ec35 100644
--- a/src/google/protobuf/compiler/cpp/cpp_unittest.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_unittest.cc
@@ -53,6 +53,7 @@
#include <vector>
#include <google/protobuf/unittest.pb.h>
+#include <google/protobuf/unittest_no_arena.pb.h>
#include <google/protobuf/unittest_optimize_for.pb.h>
#include <google/protobuf/unittest_embed_optimize_for.pb.h>
#if !defined(GOOGLE_PROTOBUF_CMAKE_BUILD) && !defined(_MSC_VER)
@@ -67,6 +68,7 @@
#include <google/protobuf/compiler/importer.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
+#include <google/protobuf/arena.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/dynamic_message.h>
@@ -199,14 +201,14 @@ TEST(GeneratedMessageTest, FloatingPointDefaults) {
EXPECT_EQ(-1.5f, extreme_default.negative_float());
EXPECT_EQ(2.0e8f, extreme_default.large_float());
EXPECT_EQ(-8e-28f, extreme_default.small_negative_float());
- EXPECT_EQ(numeric_limits<double>::infinity(),
+ EXPECT_EQ(std::numeric_limits<double>::infinity(),
extreme_default.inf_double());
- EXPECT_EQ(-numeric_limits<double>::infinity(),
+ EXPECT_EQ(-std::numeric_limits<double>::infinity(),
extreme_default.neg_inf_double());
EXPECT_TRUE(extreme_default.nan_double() != extreme_default.nan_double());
- EXPECT_EQ(numeric_limits<float>::infinity(),
+ EXPECT_EQ(std::numeric_limits<float>::infinity(),
extreme_default.inf_float());
- EXPECT_EQ(-numeric_limits<float>::infinity(),
+ EXPECT_EQ(-std::numeric_limits<float>::infinity(),
extreme_default.neg_inf_float());
EXPECT_TRUE(extreme_default.nan_float() != extreme_default.nan_float());
}
@@ -419,6 +421,71 @@ TEST(GeneratedMessageTest, StringCharStarLength) {
EXPECT_EQ("wx", message.repeated_string(0));
}
+#if LANG_CXX11
+TEST(GeneratedMessageTest, StringMove) {
+ // Verify that we trigger the move behavior on a scalar setter.
+ protobuf_unittest_no_arena::TestAllTypes message;
+ {
+ string tmp(32, 'a');
+
+ const char* old_data = tmp.data();
+ message.set_optional_string(std::move(tmp));
+ const char* new_data = message.optional_string().data();
+
+ EXPECT_EQ(old_data, new_data);
+ EXPECT_EQ(string(32, 'a'), message.optional_string());
+
+ string tmp2(32, 'b');
+ old_data = tmp2.data();
+ message.set_optional_string(std::move(tmp2));
+ new_data = message.optional_string().data();
+
+ EXPECT_EQ(old_data, new_data);
+ EXPECT_EQ(string(32, 'b'), message.optional_string());
+ }
+
+ // Verify that we trigger the move behavior on a oneof setter.
+ {
+ string tmp(32, 'a');
+
+ const char* old_data = tmp.data();
+ message.set_oneof_string(std::move(tmp));
+ const char* new_data = message.oneof_string().data();
+
+ EXPECT_EQ(old_data, new_data);
+ EXPECT_EQ(string(32, 'a'), message.oneof_string());
+
+ string tmp2(32, 'b');
+ old_data = tmp2.data();
+ message.set_oneof_string(std::move(tmp2));
+ new_data = message.oneof_string().data();
+
+ EXPECT_EQ(old_data, new_data);
+ EXPECT_EQ(string(32, 'b'), message.oneof_string());
+ }
+
+ // Verify that we trigger the move behavior on a repeated setter.
+ {
+ string tmp(32, 'a');
+
+ const char* old_data = tmp.data();
+ message.add_repeated_string(std::move(tmp));
+ const char* new_data = message.repeated_string(0).data();
+
+ EXPECT_EQ(old_data, new_data);
+ EXPECT_EQ(string(32, 'a'), message.repeated_string(0));
+
+ string tmp2(32, 'b');
+ old_data = tmp2.data();
+ message.set_repeated_string(0, std::move(tmp2));
+ new_data = message.repeated_string(0).data();
+
+ EXPECT_EQ(old_data, new_data);
+ EXPECT_EQ(string(32, 'b'), message.repeated_string(0));
+ }
+}
+#endif
+
TEST(GeneratedMessageTest, CopyFrom) {
unittest::TestAllTypes message1, message2;
@@ -518,6 +585,26 @@ TEST(GeneratedMessageTest, CopyConstructor) {
TestUtil::ExpectAllFieldsSet(message2);
}
+TEST(GeneratedMessageTest, CopyConstructorWithArenas) {
+ Arena arena;
+ unittest::TestAllTypes* message1 =
+ Arena::CreateMessage<unittest::TestAllTypes>(&arena);
+ TestUtil::SetAllFields(message1);
+
+ unittest::TestAllTypes message2_stack(*message1);
+ TestUtil::ExpectAllFieldsSet(message2_stack);
+
+ google::protobuf::scoped_ptr<unittest::TestAllTypes> message2_heap(
+ new unittest::TestAllTypes(*message1));
+ TestUtil::ExpectAllFieldsSet(*message2_heap);
+
+ arena.Reset();
+
+ // Verify that the copies are still intact.
+ TestUtil::ExpectAllFieldsSet(message2_stack);
+ TestUtil::ExpectAllFieldsSet(*message2_heap);
+}
+
TEST(GeneratedMessageTest, CopyAssignmentOperator) {
unittest::TestAllTypes message1;
TestUtil::SetAllFields(&message1);
@@ -600,14 +687,16 @@ TEST(GeneratedMessageTest, NonEmptyMergeFrom) {
#if !defined(PROTOBUF_TEST_NO_DESCRIPTORS) || \
!defined(GOOGLE_PROTOBUF_NO_RTTI)
#ifdef PROTOBUF_HAS_DEATH_TEST
+#ifndef NDEBUG
TEST(GeneratedMessageTest, MergeFromSelf) {
unittest::TestAllTypes message;
- EXPECT_DEATH(message.MergeFrom(message), "Check failed:.*pb[.]cc");
+ EXPECT_DEATH(message.MergeFrom(message), "pb[.]cc.*Check failed:");
EXPECT_DEATH(message.MergeFrom(implicit_cast<const Message&>(message)),
- "Check failed:.*pb[.]cc");
+ "pb[.]cc.*Check failed:");
}
+#endif // NDEBUG
#endif // PROTOBUF_HAS_DEATH_TEST
#endif // !PROTOBUF_TEST_NO_DESCRIPTORS || !GOOGLE_PROTOBUF_NO_RTTI
diff --git a/src/google/protobuf/compiler/cpp/metadata_test.cc b/src/google/protobuf/compiler/cpp/metadata_test.cc
index edd30780..03f6b12b 100644
--- a/src/google/protobuf/compiler/cpp/metadata_test.cc
+++ b/src/google/protobuf/compiler/cpp/metadata_test.cc
@@ -156,7 +156,7 @@ const char kSmallTestFile[] =
// couldn't).
const GeneratedCodeInfo::Annotation* FindAnnotationOnPath(
const GeneratedCodeInfo& info, const string& source_file,
- const vector<int>& path) {
+ const std::vector<int>& path) {
for (int i = 0; i < info.annotation_size(); ++i) {
const GeneratedCodeInfo::Annotation* annotation = &info.annotation(i);
if (annotation->source_file() != source_file ||
@@ -197,7 +197,7 @@ TEST_F(CppMetadataTest, CapturesEnumNames) {
EXPECT_TRUE(
CaptureMetadata("test.proto", &file, &pb_h, &info, NULL, NULL, NULL));
EXPECT_EQ("Enum", file.enum_type(0).name());
- vector<int> enum_path;
+ std::vector<int> enum_path;
enum_path.push_back(FileDescriptorProto::kEnumTypeFieldNumber);
enum_path.push_back(0);
const GeneratedCodeInfo::Annotation* enum_annotation =
@@ -226,7 +226,7 @@ TEST_F(CppMetadataTest, CapturesMessageNames) {
EXPECT_TRUE(
CaptureMetadata("test.proto", &file, &pb_h, &info, NULL, NULL, NULL));
EXPECT_EQ("Message", file.message_type(0).name());
- vector<int> message_path;
+ std::vector<int> message_path;
message_path.push_back(FileDescriptorProto::kMessageTypeFieldNumber);
message_path.push_back(0);
const GeneratedCodeInfo::Annotation* message_annotation =
diff --git a/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc b/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc
index 587e0222..636a76a0 100644
--- a/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc
+++ b/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc
@@ -74,7 +74,7 @@ void WriteDocCommentBodyImpl(io::Printer* printer, SourceLocation location) {
printer->Print("///\n");
}
last_was_empty = false;
- printer->Print("/// $line$\n", "line", *it);
+ printer->Print("///$line$\n", "line", *it);
}
}
printer->Print("/// </summary>\n");
diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/src/google/protobuf/compiler/csharp/csharp_field_base.cc
index e2011b76..139cc753 100644
--- a/src/google/protobuf/compiler/csharp/csharp_field_base.cc
+++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc
@@ -122,8 +122,10 @@ void FieldGeneratorBase::GenerateCodecCode(io::Printer* printer) {
}
void FieldGeneratorBase::AddDeprecatedFlag(io::Printer* printer) {
- if (descriptor_->options().deprecated())
- {
+ if (descriptor_->options().deprecated()) {
+ printer->Print("[global::System.ObsoleteAttribute]\n");
+ } else if (descriptor_->type() == FieldDescriptor::TYPE_MESSAGE &&
+ descriptor_->message_type()->options().deprecated()) {
printer->Print("[global::System.ObsoleteAttribute]\n");
}
}
diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc
index 6c154c5a..5bca1ffa 100644
--- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc
+++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc
@@ -38,6 +38,7 @@
#include <vector>
#include <google/protobuf/compiler/csharp/csharp_helpers.h>
+#include <google/protobuf/compiler/csharp/csharp_names.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/wire_format.h>
diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.h b/src/google/protobuf/compiler/csharp/csharp_helpers.h
index 1563ca7e..c317ad0e 100644
--- a/src/google/protobuf/compiler/csharp/csharp_helpers.h
+++ b/src/google/protobuf/compiler/csharp/csharp_helpers.h
@@ -120,6 +120,22 @@ inline bool IsDescriptorProto(const FileDescriptor* descriptor) {
return descriptor->name() == "google/protobuf/descriptor.proto";
}
+// Determines whether the given message is an options message within descriptor.proto.
+inline bool IsDescriptorOptionMessage(const Descriptor* descriptor) {
+ if (!IsDescriptorProto(descriptor->file())) {
+ return false;
+ }
+ const string name = descriptor->full_name();
+ return name == "google.protobuf.FileOptions" ||
+ name == "google.protobuf.MessageOptions" ||
+ name == "google.protobuf.FieldOptions" ||
+ name == "google.protobuf.OneofOptions" ||
+ name == "google.protobuf.EnumOptions" ||
+ name == "google.protobuf.EnumValueOptions" ||
+ name == "google.protobuf.ServiceOptions" ||
+ name == "google.protobuf.MethodOptions";
+}
+
inline bool IsWrapperType(const FieldDescriptor* descriptor) {
return descriptor->type() == FieldDescriptor::TYPE_MESSAGE &&
descriptor->message_type()->file()->name() == "google/protobuf/wrappers.proto";
diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc
index ed744854..0f00a438 100644
--- a/src/google/protobuf/compiler/csharp/csharp_message.cc
+++ b/src/google/protobuf/compiler/csharp/csharp_message.cc
@@ -98,12 +98,20 @@ const std::vector<const FieldDescriptor*>& MessageGenerator::fields_by_number()
return fields_by_number_;
}
+void MessageGenerator::AddDeprecatedFlag(io::Printer* printer) {
+ if (descriptor_->options().deprecated()) {
+ printer->Print("[global::System.ObsoleteAttribute]\n");
+ }
+}
+
void MessageGenerator::Generate(io::Printer* printer) {
map<string, string> vars;
vars["class_name"] = class_name();
vars["access_level"] = class_access_level();
WriteMessageDocComment(printer, descriptor_);
+ AddDeprecatedFlag(printer);
+
printer->Print(
vars,
"$access_level$ sealed partial class $class_name$ : pb::IMessage<$class_name$> {\n");
@@ -115,6 +123,7 @@ void MessageGenerator::Generate(io::Printer* printer) {
"private static readonly pb::MessageParser<$class_name$> _parser = new pb::MessageParser<$class_name$>(() => new $class_name$());\n");
WriteGeneratedCodeAttributes(printer);
+
printer->Print(
vars,
"public static pb::MessageParser<$class_name$> Parser { get { return _parser; } }\n\n");
@@ -142,6 +151,12 @@ void MessageGenerator::Generate(io::Printer* printer) {
" get { return Descriptor; }\n"
"}\n"
"\n");
+ // CustomOptions property, only for options messages
+ if (IsDescriptorOptionMessage(descriptor_)) {
+ printer->Print(
+ "internal CustomOptions CustomOptions{ get; private set; } = CustomOptions.Empty;\n"
+ "\n");
+ }
// Parameterless constructor and partial OnConstruction method.
WriteGeneratedCodeAttributes(printer);
@@ -466,10 +481,18 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) {
" switch(tag) {\n");
printer->Indent();
printer->Indent();
- printer->Print(
- "default:\n"
- " input.SkipLastField();\n" // We're not storing the data, but we still need to consume it.
- " break;\n");
+ // Option messages need to store unknown fields so that options can be parsed later.
+ if (IsDescriptorOptionMessage(descriptor_)) {
+ printer->Print(
+ "default:\n"
+ " CustomOptions = CustomOptions.ReadOrSkipUnknownField(input);\n"
+ " break;\n");
+ } else {
+ printer->Print(
+ "default:\n"
+ " input.SkipLastField();\n" // We're not storing the data, but we still need to consume it.
+ " break;\n");
+ }
for (int i = 0; i < fields_by_number().size(); i++) {
const FieldDescriptor* field = fields_by_number()[i];
internal::WireFormatLite::WireType wt =
diff --git a/src/google/protobuf/compiler/csharp/csharp_message.h b/src/google/protobuf/compiler/csharp/csharp_message.h
index f794d68d..e7f3b4d0 100644
--- a/src/google/protobuf/compiler/csharp/csharp_message.h
+++ b/src/google/protobuf/compiler/csharp/csharp_message.h
@@ -69,6 +69,8 @@ class MessageGenerator : public SourceGeneratorBase {
bool HasNestedGeneratedTypes();
+ void AddDeprecatedFlag(io::Printer* printer);
+
std::string class_name();
std::string full_class_name();
diff --git a/src/google/protobuf/compiler/csharp/csharp_names.h b/src/google/protobuf/compiler/csharp/csharp_names.h
index 30805187..21758f28 100644
--- a/src/google/protobuf/compiler/csharp/csharp_names.h
+++ b/src/google/protobuf/compiler/csharp/csharp_names.h
@@ -39,6 +39,7 @@
#define GOOGLE_PROTOBUF_COMPILER_CSHARP_NAMES_H__
#include <string>
+#include <google/protobuf/stubs/port.h>
namespace google {
namespace protobuf {
@@ -56,14 +57,14 @@ namespace csharp {
//
// Returns:
// The namespace to use for given file descriptor.
-string GetFileNamespace(const FileDescriptor* descriptor);
+string LIBPROTOC_EXPORT GetFileNamespace(const FileDescriptor* descriptor);
// Requires:
// descriptor != NULL
//
// Returns:
// The fully-qualified C# class name.
-string GetClassName(const Descriptor* descriptor);
+string LIBPROTOC_EXPORT GetClassName(const Descriptor* descriptor);
// Requires:
// descriptor != NULL
@@ -72,7 +73,7 @@ string GetClassName(const Descriptor* descriptor);
// The fully-qualified name of the C# class that provides
// access to the file descriptor. Proto compiler generates
// such class for each .proto file processed.
-string GetReflectionClassName(const FileDescriptor* descriptor);
+string LIBPROTOC_EXPORT GetReflectionClassName(const FileDescriptor* descriptor);
// Generates output file name for given file descriptor. If generate_directories
// is true, the output file will be put under directory corresponding to file's
@@ -88,7 +89,7 @@ string GetReflectionClassName(const FileDescriptor* descriptor);
// The file name to use as output file for given file descriptor. In case
// of failure, this function will return empty string and error parameter
// will contain the error message.
-string GetOutputFile(
+string LIBPROTOC_EXPORT GetOutputFile(
const google::protobuf::FileDescriptor* descriptor,
const string file_extension,
const bool generate_directories,
diff --git a/src/google/protobuf/compiler/importer.cc b/src/google/protobuf/compiler/importer.cc
index 0d9093c0..462748b9 100644
--- a/src/google/protobuf/compiler/importer.cc
+++ b/src/google/protobuf/compiler/importer.cc
@@ -270,8 +270,8 @@ static string CanonicalizePath(string path) {
}
#endif
- vector<string> canonical_parts;
- vector<string> parts = Split(
+ std::vector<string> canonical_parts;
+ std::vector<string> parts = Split(
path, "/", true); // Note: Removes empty parts.
for (int i = 0; i < parts.size(); i++) {
if (parts[i] == ".") {
diff --git a/src/google/protobuf/compiler/importer.h b/src/google/protobuf/compiler/importer.h
index cc8fcc39..759636e1 100644
--- a/src/google/protobuf/compiler/importer.h
+++ b/src/google/protobuf/compiler/importer.h
@@ -305,7 +305,7 @@ class LIBPROTOBUF_EXPORT DiskSourceTree : public SourceTree {
const string& disk_path_param)
: virtual_path(virtual_path_param), disk_path(disk_path_param) {}
};
- vector<Mapping> mappings_;
+ std::vector<Mapping> mappings_;
string last_error_message_;
// Like Open(), but returns the on-disk path in disk_file if disk_file is
diff --git a/src/google/protobuf/compiler/importer_unittest.cc b/src/google/protobuf/compiler/importer_unittest.cc
index 1b6e9700..00285bcc 100644
--- a/src/google/protobuf/compiler/importer_unittest.cc
+++ b/src/google/protobuf/compiler/importer_unittest.cc
@@ -293,7 +293,7 @@ class DiskSourceTreeTest : public testing::Test {
DiskSourceTree source_tree_;
// Paths of two on-disk directories to use during the test.
- vector<string> dirnames_;
+ std::vector<string> dirnames_;
};
TEST_F(DiskSourceTreeTest, MapRoot) {
diff --git a/src/google/protobuf/compiler/java/java_context.cc b/src/google/protobuf/compiler/java/java_context.cc
index 6cfa14a0..b82fb3dd 100644
--- a/src/google/protobuf/compiler/java/java_context.cc
+++ b/src/google/protobuf/compiler/java/java_context.cc
@@ -108,7 +108,7 @@ void Context::InitializeFieldGeneratorInfoForMessage(
for (int i = 0; i < message->nested_type_count(); ++i) {
InitializeFieldGeneratorInfoForMessage(message->nested_type(i));
}
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
for (int i = 0; i < message->field_count(); ++i) {
fields.push_back(message->field(i));
}
@@ -124,11 +124,11 @@ void Context::InitializeFieldGeneratorInfoForMessage(
}
void Context::InitializeFieldGeneratorInfoForFields(
- const vector<const FieldDescriptor*>& fields) {
+ const std::vector<const FieldDescriptor*>& fields) {
// Find out all fields that conflict with some other field in the same
// message.
- vector<bool> is_conflict(fields.size());
- vector<string> conflict_reason(fields.size());
+ std::vector<bool> is_conflict(fields.size());
+ std::vector<string> conflict_reason(fields.size());
for (int i = 0; i < fields.size(); ++i) {
const FieldDescriptor* field = fields[i];
const string& name = UnderscoresToCapitalizedCamelCase(field);
diff --git a/src/google/protobuf/compiler/java/java_context.h b/src/google/protobuf/compiler/java/java_context.h
index f92ae87e..b22e7e3a 100644
--- a/src/google/protobuf/compiler/java/java_context.h
+++ b/src/google/protobuf/compiler/java/java_context.h
@@ -95,11 +95,13 @@ class Context {
void InitializeFieldGeneratorInfo(const FileDescriptor* file);
void InitializeFieldGeneratorInfoForMessage(const Descriptor* message);
void InitializeFieldGeneratorInfoForFields(
- const vector<const FieldDescriptor*>& fields);
+ const std::vector<const FieldDescriptor*>& fields);
google::protobuf::scoped_ptr<ClassNameResolver> name_resolver_;
- map<const FieldDescriptor*, FieldGeneratorInfo> field_generator_info_map_;
- map<const OneofDescriptor*, OneofGeneratorInfo> oneof_generator_info_map_;
+ std::map<const FieldDescriptor*, FieldGeneratorInfo>
+ field_generator_info_map_;
+ std::map<const OneofDescriptor*, OneofGeneratorInfo>
+ oneof_generator_info_map_;
Options options_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Context);
};
diff --git a/src/google/protobuf/compiler/java/java_doc_comment.cc b/src/google/protobuf/compiler/java/java_doc_comment.cc
index 0b5caba4..59c04ad4 100644
--- a/src/google/protobuf/compiler/java/java_doc_comment.cc
+++ b/src/google/protobuf/compiler/java/java_doc_comment.cc
@@ -115,7 +115,7 @@ static void WriteDocCommentBodyForLocation(
// HTML-escape them so that they don't accidentally close the doc comment.
comments = EscapeJavadoc(comments);
- vector<string> lines = Split(comments, "\n");
+ std::vector<string> lines = Split(comments, "\n");
while (!lines.empty() && lines.back().empty()) {
lines.pop_back();
}
diff --git a/src/google/protobuf/compiler/java/java_enum.cc b/src/google/protobuf/compiler/java/java_enum.cc
index b46cfe9c..b9ee00ff 100644
--- a/src/google/protobuf/compiler/java/java_enum.cc
+++ b/src/google/protobuf/compiler/java/java_enum.cc
@@ -49,17 +49,6 @@ namespace protobuf {
namespace compiler {
namespace java {
-namespace {
-bool EnumHasCustomOptions(const EnumDescriptor* descriptor) {
- if (descriptor->options().unknown_fields().field_count() > 0) return true;
- for (int i = 0; i < descriptor->value_count(); ++i) {
- const EnumValueDescriptor* value = descriptor->value(i);
- if (value->options().unknown_fields().field_count() > 0) return true;
- }
- return false;
-}
-} // namespace
-
EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor,
bool immutable_api,
Context* context)
@@ -105,7 +94,7 @@ void EnumGenerator::Generate(io::Printer* printer) {
}
for (int i = 0; i < canonical_values_.size(); i++) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars["name"] = canonical_values_[i]->name();
vars["index"] = SimpleItoa(canonical_values_[i]->index());
vars["number"] = SimpleItoa(canonical_values_[i]->number());
@@ -137,7 +126,7 @@ void EnumGenerator::Generate(io::Printer* printer) {
// -----------------------------------------------------------------
for (int i = 0; i < aliases_.size(); i++) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars["classname"] = descriptor_->name();
vars["name"] = aliases_[i].value->name();
vars["canonical_name"] = aliases_[i].canonical_value->name();
@@ -147,7 +136,7 @@ void EnumGenerator::Generate(io::Printer* printer) {
}
for (int i = 0; i < descriptor_->value_count(); i++) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars["name"] = descriptor_->value(i)->name();
vars["number"] = SimpleItoa(descriptor_->value(i)->number());
WriteEnumValueDocComment(printer, descriptor_->value(i));
@@ -243,49 +232,14 @@ void EnumGenerator::Generate(io::Printer* printer) {
// at module init time because it wouldn't work with descriptor.proto, but
// we can cache the value the first time getDescriptor() is called.
if (descriptor_->containing_type() == NULL) {
- if (!MultipleJavaFiles(descriptor_->file(), immutable_api_)) {
- printer->Print(
- " return $file$.getDescriptor().getEnumTypes().get($index$);\n",
- "file", name_resolver_->GetClassName(descriptor_->file(),
- immutable_api_),
- "index", SimpleItoa(descriptor_->index()));
- } else {
- printer->Indent();
- if (EnumHasCustomOptions(descriptor_)) {
- // We need to load the immutable classes in order to parse custom
- // options. However, since file level enums (no outer class) are
- // shared by immutable code and mutable code, the immutable classes
- // may not exist. So we try to use Java reflection to retrieve the
- // descriptor from immutable classes.
- printer->Print(
- "try {\n"
- " java.lang.Class immutableFileClass =\n"
- " java.lang.Class.forName(\"$immutable_file_class_name$\");\n"
- " @java.lang.SuppressWarnings(\"unchecked\")\n"
- " java.lang.reflect.Method m =\n"
- " immutableFileClass.getMethod(\"getDescriptor\");\n"
- " com.google.protobuf.Descriptors.FileDescriptor file =\n"
- " (com.google.protobuf.Descriptors.FileDescriptor)\n"
- " m.invoke(immutableFileClass);\n"
- " return file.getEnumTypes().get($index$);\n"
- "} catch (java.lang.Exception e) {\n"
- // Immutable classes cannot be found. Proceed as if custom options
- // don't exist.
- "}\n",
- "immutable_file_class_name",
- name_resolver_->GetImmutableClassName(descriptor_->file()),
- "index", SimpleItoa(descriptor_->index()));
- }
- printer->Print(
- "return $immutable_package$.$descriptor_class$.$descriptor$\n"
- " .getEnumTypes().get($index$);\n",
- "immutable_package", FileJavaPackage(descriptor_->file(), true),
- "descriptor_class",
- name_resolver_->GetDescriptorClassName(descriptor_->file()),
- "descriptor", "getDescriptor()",
- "index", SimpleItoa(descriptor_->index()));
- printer->Outdent();
- }
+ // The class generated for the File fully populates the descriptor with
+ // extensions in both the mutable and immutable cases. (In the mutable api
+ // this is accomplished by attempting to load the immutable outer class).
+ printer->Print(
+ " return $file$.getDescriptor().getEnumTypes().get($index$);\n",
+ "file", name_resolver_->GetClassName(descriptor_->file(),
+ immutable_api_),
+ "index", SimpleItoa(descriptor_->index()));
} else {
printer->Print(
" return $parent$.$descriptor$.getEnumTypes().get($index$);\n",
diff --git a/src/google/protobuf/compiler/java/java_enum.h b/src/google/protobuf/compiler/java/java_enum.h
index c33e713d..13dfc32d 100644
--- a/src/google/protobuf/compiler/java/java_enum.h
+++ b/src/google/protobuf/compiler/java/java_enum.h
@@ -72,13 +72,13 @@ class EnumGenerator {
// considered equivalent. We treat the first defined constant for any
// given numeric value as "canonical" and the rest as aliases of that
// canonical value.
- vector<const EnumValueDescriptor*> canonical_values_;
+ std::vector<const EnumValueDescriptor*> canonical_values_;
struct Alias {
const EnumValueDescriptor* value;
const EnumValueDescriptor* canonical_value;
};
- vector<Alias> aliases_;
+ std::vector<Alias> aliases_;
bool immutable_api_;
diff --git a/src/google/protobuf/compiler/java/java_enum_field.cc b/src/google/protobuf/compiler/java/java_enum_field.cc
index 2e916c56..279b9da4 100644
--- a/src/google/protobuf/compiler/java/java_enum_field.cc
+++ b/src/google/protobuf/compiler/java/java_enum_field.cc
@@ -58,7 +58,7 @@ void SetEnumVariables(const FieldDescriptor* descriptor,
int builderBitIndex,
const FieldGeneratorInfo* info,
ClassNameResolver* name_resolver,
- map<string, string>* variables) {
+ std::map<string, string>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
(*variables)["type"] =
@@ -68,7 +68,8 @@ void SetEnumVariables(const FieldDescriptor* descriptor,
(*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
(*variables)["default_number"] = SimpleItoa(
descriptor->default_value_enum()->number());
- (*variables)["tag"] = SimpleItoa(internal::WireFormat::MakeTag(descriptor));
+ (*variables)["tag"] =
+ SimpleItoa(static_cast<int32>(internal::WireFormat::MakeTag(descriptor)));
(*variables)["tag_size"] = SimpleItoa(
internal::WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
// TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
diff --git a/src/google/protobuf/compiler/java/java_enum_field.h b/src/google/protobuf/compiler/java/java_enum_field.h
index b8ff7343..924ff281 100644
--- a/src/google/protobuf/compiler/java/java_enum_field.h
+++ b/src/google/protobuf/compiler/java/java_enum_field.h
@@ -82,7 +82,7 @@ class ImmutableEnumFieldGenerator : public ImmutableFieldGenerator {
protected:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
@@ -143,7 +143,7 @@ class RepeatedImmutableEnumFieldGenerator : public ImmutableFieldGenerator {
private:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
diff --git a/src/google/protobuf/compiler/java/java_enum_field_lite.cc b/src/google/protobuf/compiler/java/java_enum_field_lite.cc
index aa0eb5e8..50eed5da 100644
--- a/src/google/protobuf/compiler/java/java_enum_field_lite.cc
+++ b/src/google/protobuf/compiler/java/java_enum_field_lite.cc
@@ -58,7 +58,7 @@ void SetEnumVariables(const FieldDescriptor* descriptor,
int builderBitIndex,
const FieldGeneratorInfo* info,
ClassNameResolver* name_resolver,
- map<string, string>* variables) {
+ std::map<string, string>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
(*variables)["type"] =
@@ -68,13 +68,15 @@ void SetEnumVariables(const FieldDescriptor* descriptor,
(*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
(*variables)["default_number"] = SimpleItoa(
descriptor->default_value_enum()->number());
- (*variables)["tag"] = SimpleItoa(internal::WireFormat::MakeTag(descriptor));
+ (*variables)["tag"] =
+ SimpleItoa(static_cast<int32>(internal::WireFormat::MakeTag(descriptor)));
(*variables)["tag_size"] = SimpleItoa(
internal::WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
// TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
// by the proto compiler
(*variables)["deprecation"] = descriptor->options().deprecated()
? "@java.lang.Deprecated " : "";
+ (*variables)["required"] = descriptor->is_required() ? "true" : "false";
if (SupportFieldPresence(descriptor->file())) {
// For singular messages and builders, one bit is used for the hasField bit.
diff --git a/src/google/protobuf/compiler/java/java_enum_field_lite.h b/src/google/protobuf/compiler/java/java_enum_field_lite.h
index 9201b8d6..fa004720 100644
--- a/src/google/protobuf/compiler/java/java_enum_field_lite.h
+++ b/src/google/protobuf/compiler/java/java_enum_field_lite.h
@@ -81,7 +81,7 @@ class ImmutableEnumFieldLiteGenerator : public ImmutableFieldLiteGenerator {
protected:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
@@ -142,7 +142,7 @@ class RepeatedImmutableEnumFieldLiteGenerator
private:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
diff --git a/src/google/protobuf/compiler/java/java_enum_lite.cc b/src/google/protobuf/compiler/java/java_enum_lite.cc
index 99f52d40..96815920 100644
--- a/src/google/protobuf/compiler/java/java_enum_lite.cc
+++ b/src/google/protobuf/compiler/java/java_enum_lite.cc
@@ -95,7 +95,7 @@ void EnumLiteGenerator::Generate(io::Printer* printer) {
printer->Indent();
for (int i = 0; i < canonical_values_.size(); i++) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars["name"] = canonical_values_[i]->name();
vars["number"] = SimpleItoa(canonical_values_[i]->number());
WriteEnumValueDocComment(printer, canonical_values_[i]);
@@ -117,7 +117,7 @@ void EnumLiteGenerator::Generate(io::Printer* printer) {
// -----------------------------------------------------------------
for (int i = 0; i < aliases_.size(); i++) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars["classname"] = descriptor_->name();
vars["name"] = aliases_[i].value->name();
vars["canonical_name"] = aliases_[i].canonical_value->name();
@@ -127,7 +127,7 @@ void EnumLiteGenerator::Generate(io::Printer* printer) {
}
for (int i = 0; i < descriptor_->value_count(); i++) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars["name"] = descriptor_->value(i)->name();
vars["number"] = SimpleItoa(descriptor_->value(i)->number());
WriteEnumValueDocComment(printer, descriptor_->value(i));
diff --git a/src/google/protobuf/compiler/java/java_enum_lite.h b/src/google/protobuf/compiler/java/java_enum_lite.h
index f27cb76f..b7be912c 100644
--- a/src/google/protobuf/compiler/java/java_enum_lite.h
+++ b/src/google/protobuf/compiler/java/java_enum_lite.h
@@ -72,13 +72,13 @@ class EnumLiteGenerator {
// considered equivalent. We treat the first defined constant for any
// given numeric value as "canonical" and the rest as aliases of that
// canonical value.
- vector<const EnumValueDescriptor*> canonical_values_;
+ std::vector<const EnumValueDescriptor*> canonical_values_;
struct Alias {
const EnumValueDescriptor* value;
const EnumValueDescriptor* canonical_value;
};
- vector<Alias> aliases_;
+ std::vector<Alias> aliases_;
bool immutable_api_;
diff --git a/src/google/protobuf/compiler/java/java_extension.cc b/src/google/protobuf/compiler/java/java_extension.cc
index 46b5faaa..cb237bf6 100644
--- a/src/google/protobuf/compiler/java/java_extension.cc
+++ b/src/google/protobuf/compiler/java/java_extension.cc
@@ -61,12 +61,10 @@ ImmutableExtensionGenerator::ImmutableExtensionGenerator(
ImmutableExtensionGenerator::~ImmutableExtensionGenerator() {}
// Initializes the vars referenced in the generated code templates.
-void ExtensionGenerator::InitTemplateVars(const FieldDescriptor* descriptor,
- const string& scope,
- bool immutable,
- ClassNameResolver* name_resolver,
- map<string, string>* vars_pointer) {
- map<string, string> &vars = *vars_pointer;
+void ExtensionGenerator::InitTemplateVars(
+ const FieldDescriptor* descriptor, const string& scope, bool immutable,
+ ClassNameResolver* name_resolver, std::map<string, string>* vars_pointer) {
+ std::map<string, string> &vars = *vars_pointer;
vars["scope"] = scope;
vars["name"] = UnderscoresToCamelCase(descriptor);
vars["containing_type"] =
@@ -110,7 +108,7 @@ void ExtensionGenerator::InitTemplateVars(const FieldDescriptor* descriptor,
}
void ImmutableExtensionGenerator::Generate(io::Printer* printer) {
- map<string, string> vars;
+ std::map<string, string> vars;
const bool kUseImmutableNames = true;
InitTemplateVars(descriptor_, scope_, kUseImmutableNames, name_resolver_,
&vars);
diff --git a/src/google/protobuf/compiler/java/java_extension.h b/src/google/protobuf/compiler/java/java_extension.h
index bdd42263..fb8d5201 100644
--- a/src/google/protobuf/compiler/java/java_extension.h
+++ b/src/google/protobuf/compiler/java/java_extension.h
@@ -79,7 +79,7 @@ class ExtensionGenerator {
const string& scope,
bool immutable,
ClassNameResolver* name_resolver,
- map<string, string>* vars_pointer);
+ std::map<string, string>* vars_pointer);
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator);
diff --git a/src/google/protobuf/compiler/java/java_extension_lite.cc b/src/google/protobuf/compiler/java/java_extension_lite.cc
index 23261bac..c48c92e9 100644
--- a/src/google/protobuf/compiler/java/java_extension_lite.cc
+++ b/src/google/protobuf/compiler/java/java_extension_lite.cc
@@ -57,7 +57,7 @@ ImmutableExtensionLiteGenerator::ImmutableExtensionLiteGenerator(
ImmutableExtensionLiteGenerator::~ImmutableExtensionLiteGenerator() {}
void ImmutableExtensionLiteGenerator::Generate(io::Printer* printer) {
- map<string, string> vars;
+ std::map<string, string> vars;
const bool kUseImmutableNames = true;
InitTemplateVars(descriptor_, scope_, kUseImmutableNames, name_resolver_,
&vars);
diff --git a/src/google/protobuf/compiler/java/java_field.cc b/src/google/protobuf/compiler/java/java_field.cc
index 3c7bc5c4..04917296 100644
--- a/src/google/protobuf/compiler/java/java_field.cc
+++ b/src/google/protobuf/compiler/java/java_field.cc
@@ -290,7 +290,7 @@ FieldGeneratorMap<ImmutableFieldLiteGenerator>::~FieldGeneratorMap() {}
void SetCommonFieldVariables(const FieldDescriptor* descriptor,
const FieldGeneratorInfo* info,
- map<string, string>* variables) {
+ std::map<string, string>* variables) {
(*variables)["field_name"] = descriptor->name();
(*variables)["name"] = info->name;
(*variables)["capitalized_name"] = info->capitalized_name;
@@ -301,7 +301,7 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
void SetCommonOneofVariables(const FieldDescriptor* descriptor,
const OneofGeneratorInfo* info,
- map<string, string>* variables) {
+ std::map<string, string>* variables) {
(*variables)["oneof_name"] = info->name;
(*variables)["oneof_capitalized_name"] = info->capitalized_name;
(*variables)["oneof_index"] =
@@ -314,9 +314,9 @@ void SetCommonOneofVariables(const FieldDescriptor* descriptor,
"Case_ == " + SimpleItoa(descriptor->number());
}
-void PrintExtraFieldInfo(const map<string, string>& variables,
+void PrintExtraFieldInfo(const std::map<string, string>& variables,
io::Printer* printer) {
- const map<string, string>::const_iterator it =
+ const std::map<string, string>::const_iterator it =
variables.find("disambiguated_reason");
if (it != variables.end() && !it->second.empty()) {
printer->Print(
diff --git a/src/google/protobuf/compiler/java/java_field.h b/src/google/protobuf/compiler/java/java_field.h
index 4dd4f57f..434e610c 100644
--- a/src/google/protobuf/compiler/java/java_field.h
+++ b/src/google/protobuf/compiler/java/java_field.h
@@ -169,7 +169,7 @@ struct FieldGeneratorInfo {
string disambiguated_reason;
};
-// Oneof information used in OneofFieldGeneartors.
+// Oneof information used in OneofFieldGenerators.
struct OneofGeneratorInfo {
string name;
string capitalized_name;
@@ -178,15 +178,15 @@ struct OneofGeneratorInfo {
// Set some common variables used in variable FieldGenerators.
void SetCommonFieldVariables(const FieldDescriptor* descriptor,
const FieldGeneratorInfo* info,
- map<string, string>* variables);
+ std::map<string, string>* variables);
// Set some common oneof variables used in OneofFieldGenerators.
void SetCommonOneofVariables(const FieldDescriptor* descriptor,
const OneofGeneratorInfo* info,
- map<string, string>* variables);
+ std::map<string, string>* variables);
// Print useful comments before a field's accessors.
-void PrintExtraFieldInfo(const map<string, string>& variables,
+void PrintExtraFieldInfo(const std::map<string, string>& variables,
io::Printer* printer);
} // namespace java
diff --git a/src/google/protobuf/compiler/java/java_file.cc b/src/google/protobuf/compiler/java/java_file.cc
index 3cbc530e..86719f70 100644
--- a/src/google/protobuf/compiler/java/java_file.cc
+++ b/src/google/protobuf/compiler/java/java_file.cc
@@ -65,7 +65,7 @@ namespace java {
namespace {
struct FieldDescriptorCompare {
- bool operator ()(const FieldDescriptor* f1, const FieldDescriptor* f2) {
+ bool operator ()(const FieldDescriptor* f1, const FieldDescriptor* f2) const {
if(f1 == NULL) {
return false;
}
@@ -90,7 +90,7 @@ bool CollectExtensions(const Message& message,
// There are unknown fields that could be extensions, thus this call fails.
if (reflection->GetUnknownFields(message).field_count() > 0) return false;
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
reflection->ListFields(message, &fields);
for (int i = 0; i < fields.size(); i++) {
@@ -541,8 +541,8 @@ static void GenerateSibling(const string& package_dir,
const string& java_package,
const DescriptorClass* descriptor,
GeneratorContext* context,
- vector<string>* file_list, bool annotate_code,
- vector<string>* annotation_list,
+ std::vector<string>* file_list, bool annotate_code,
+ std::vector<string>* annotation_list,
const string& name_suffix,
GeneratorClass* generator,
void (GeneratorClass::*pfn)(io::Printer* printer)) {
@@ -581,8 +581,8 @@ static void GenerateSibling(const string& package_dir,
void FileGenerator::GenerateSiblings(const string& package_dir,
GeneratorContext* context,
- vector<string>* file_list,
- vector<string>* annotation_list) {
+ std::vector<string>* file_list,
+ std::vector<string>* annotation_list) {
if (MultipleJavaFiles(file_, immutable_api_)) {
for (int i = 0; i < file_->enum_type_count(); i++) {
if (HasDescriptorMethods(file_, context_->EnforceLite())) {
diff --git a/src/google/protobuf/compiler/java/java_file.h b/src/google/protobuf/compiler/java/java_file.h
index 1e643f79..e95aef09 100644
--- a/src/google/protobuf/compiler/java/java_file.h
+++ b/src/google/protobuf/compiler/java/java_file.h
@@ -84,8 +84,8 @@ class FileGenerator {
// service type).
void GenerateSiblings(const string& package_dir,
GeneratorContext* generator_context,
- vector<string>* file_list,
- vector<string>* annotation_list);
+ std::vector<string>* file_list,
+ std::vector<string>* annotation_list);
const string& java_package() { return java_package_; }
const string& classname() { return classname_; }
diff --git a/src/google/protobuf/compiler/java/java_generator.cc b/src/google/protobuf/compiler/java/java_generator.cc
index b1ab4043..2c02d996 100644
--- a/src/google/protobuf/compiler/java/java_generator.cc
+++ b/src/google/protobuf/compiler/java/java_generator.cc
@@ -66,7 +66,7 @@ bool JavaGenerator::Generate(const FileDescriptor* file,
// parse generator options
- vector<pair<string, string> > options;
+ std::vector<std::pair<string, string> > options;
ParseGeneratorParameter(parameter, &options);
Options file_options;
@@ -105,11 +105,11 @@ bool JavaGenerator::Generate(const FileDescriptor* file,
// -----------------------------------------------------------------
- vector<string> all_files;
- vector<string> all_annotations;
+ std::vector<string> all_files;
+ std::vector<string> all_annotations;
- vector<FileGenerator*> file_generators;
+ std::vector<FileGenerator*> file_generators;
if (file_options.generate_immutable_code) {
file_generators.push_back(new FileGenerator(file, file_options,
/* immutable = */ true));
diff --git a/src/google/protobuf/compiler/java/java_helpers.cc b/src/google/protobuf/compiler/java/java_helpers.cc
index c31df265..efb5fd45 100644
--- a/src/google/protobuf/compiler/java/java_helpers.cc
+++ b/src/google/protobuf/compiler/java/java_helpers.cc
@@ -360,6 +360,7 @@ const char* BoxedPrimitiveTypeName(JavaType type) {
return NULL;
}
+
const char* FieldTypeName(FieldDescriptor::Type field_type) {
switch (field_type) {
case FieldDescriptor::TYPE_INT32 : return "INT32";
@@ -415,9 +416,9 @@ string DefaultValue(const FieldDescriptor* field, bool immutable,
"L";
case FieldDescriptor::CPPTYPE_DOUBLE: {
double value = field->default_value_double();
- if (value == numeric_limits<double>::infinity()) {
+ if (value == std::numeric_limits<double>::infinity()) {
return "Double.POSITIVE_INFINITY";
- } else if (value == -numeric_limits<double>::infinity()) {
+ } else if (value == -std::numeric_limits<double>::infinity()) {
return "Double.NEGATIVE_INFINITY";
} else if (value != value) {
return "Double.NaN";
@@ -427,9 +428,9 @@ string DefaultValue(const FieldDescriptor* field, bool immutable,
}
case FieldDescriptor::CPPTYPE_FLOAT: {
float value = field->default_value_float();
- if (value == numeric_limits<float>::infinity()) {
+ if (value == std::numeric_limits<float>::infinity()) {
return "Float.POSITIVE_INFINITY";
- } else if (value == -numeric_limits<float>::infinity()) {
+ } else if (value == -std::numeric_limits<float>::infinity()) {
return "Float.NEGATIVE_INFINITY";
} else if (value != value) {
return "Float.NaN";
diff --git a/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc b/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc
index dac1b51f..49070ba0 100644
--- a/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc
+++ b/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc
@@ -446,8 +446,7 @@ GenerateMembers(io::Printer* printer) const {
" for (com.google.protobuf.LazyFieldLite lf : $name$_) {\n"
" list.add(($type$) lf.getValue($type$.getDefaultInstance()));\n"
" }\n"
- // TODO(dweis): Make this list immutable?
- " return list;\n"
+ " return java.util.Collections.unmodifiableList(list);\n"
"}\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
diff --git a/src/google/protobuf/compiler/java/java_map_field.cc b/src/google/protobuf/compiler/java/java_map_field.cc
index 07aa3565..3fe68ae3 100644
--- a/src/google/protobuf/compiler/java/java_map_field.cc
+++ b/src/google/protobuf/compiler/java/java_map_field.cc
@@ -80,7 +80,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor,
int builderBitIndex,
const FieldGeneratorInfo* info,
Context* context,
- map<string, string>* variables) {
+ std::map<string, string>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
ClassNameResolver* name_resolver = context->GetNameResolver();
@@ -308,6 +308,16 @@ GenerateMembers(io::Printer* printer) const {
" com.google.protobuf.Internal.MapAdapter.newEnumConverter(\n"
" $value_enum_type$.internalGetValueMap(),\n"
" $unrecognized_value$);\n");
+ printer->Print(
+ variables_,
+ "private static final java.util.Map<$boxed_key_type$, "
+ "$value_enum_type$>\n"
+ "internalGetAdapted$capitalized_name$Map(\n"
+ " java.util.Map<$boxed_key_type$, $boxed_value_type$> map) {\n"
+ " return new com.google.protobuf.Internal.MapAdapter<\n"
+ " $boxed_key_type$, $value_enum_type$, java.lang.Integer>(\n"
+ " map, $name$ValueConverter);\n"
+ "}\n");
}
GenerateMapGetters(printer);
}
@@ -339,23 +349,23 @@ GenerateBuilderMembers(io::Printer* printer) const {
" return $name$_;\n"
"}\n");
GenerateMapGetters(printer);
- printer->Print(
- variables_,
- "$deprecation$\n"
- "public Builder clear$capitalized_name$() {\n"
- " getMutable$capitalized_name$().clear();\n"
- " return this;\n"
- "}\n");
+ printer->Print(variables_,
+ "$deprecation$\n"
+ "public Builder clear$capitalized_name$() {\n"
+ " internalGetMutable$capitalized_name$().getMutableMap()\n"
+ " .clear();\n"
+ " return this;\n"
+ "}\n");
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "$deprecation$\n"
- "public Builder remove$capitalized_name$(\n"
- " $key_type$ key) {\n"
- " $key_null_check$\n"
- " getMutable$capitalized_name$().remove(key);\n"
- " return this;\n"
- "}\n");
+ printer->Print(variables_,
+ "$deprecation$\n"
+ "public Builder remove$capitalized_name$(\n"
+ " $key_type$ key) {\n"
+ " $key_null_check$\n"
+ " internalGetMutable$capitalized_name$().getMutableMap()\n"
+ " .remove(key);\n"
+ " return this;\n"
+ "}\n");
if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
printer->Print(
variables_,
@@ -365,30 +375,28 @@ GenerateBuilderMembers(io::Printer* printer) const {
"@java.lang.Deprecated\n"
"public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
"getMutable$capitalized_name$() {\n"
- " return new com.google.protobuf.Internal.MapAdapter<\n"
- " $boxed_key_type$, $value_enum_type$, java.lang.Integer>(\n"
- " internalGetMutable$capitalized_name$().getMutableMap(),\n"
- " $name$ValueConverter);\n"
+ " return internalGetAdapted$capitalized_name$Map(\n"
+ " internalGetMutable$capitalized_name$().getMutableMap());\n"
"}\n");
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "$deprecation$public Builder put$capitalized_name$(\n"
- " $key_type$ key,\n"
- " $value_enum_type$ value) {\n"
- " $key_null_check$\n"
- " $value_null_check$\n"
- " getMutable$capitalized_name$().put(key, value);\n"
- " return this;\n"
- "}\n");
+ printer->Print(variables_,
+ "$deprecation$public Builder put$capitalized_name$(\n"
+ " $key_type$ key,\n"
+ " $value_enum_type$ value) {\n"
+ " $key_null_check$\n"
+ " $value_null_check$\n"
+ " internalGetMutable$capitalized_name$().getMutableMap()\n"
+ " .put(key, $name$ValueConverter.doBackward(value));\n"
+ " return this;\n"
+ "}\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
- // TODO(arielb): null check map keys/values here and everywhere else
- // related to putAll
"$deprecation$public Builder putAll$capitalized_name$(\n"
" java.util.Map<$boxed_key_type$, $value_enum_type$> values) {\n"
- " getMutable$capitalized_name$().putAll(values);\n"
+ " internalGetAdapted$capitalized_name$Map(\n"
+ " internalGetMutable$capitalized_name$().getMutableMap())\n"
+ " .putAll(values);\n"
" return this;\n"
"}\n");
if (SupportUnknownEnumValue(descriptor_->file())) {
@@ -412,7 +420,8 @@ GenerateBuilderMembers(io::Printer* printer) const {
" if ($value_enum_type$.forNumber(value) == null) {\n"
" throw new java.lang.IllegalArgumentException();\n"
" }\n"
- " getMutable$capitalized_name$Value().put(key, value);\n"
+ " internalGetMutable$capitalized_name$().getMutableMap()\n"
+ " .put(key, value);\n"
" return this;\n"
"}\n");
WriteFieldDocComment(printer, descriptor_);
@@ -420,7 +429,8 @@ GenerateBuilderMembers(io::Printer* printer) const {
variables_,
"$deprecation$public Builder putAll$capitalized_name$Value(\n"
" java.util.Map<$boxed_key_type$, $boxed_value_type$> values) {\n"
- " getMutable$capitalized_name$Value().putAll(values);\n"
+ " internalGetMutable$capitalized_name$().getMutableMap()\n"
+ " .putAll(values);\n"
" return this;\n"
"}\n");
}
@@ -436,26 +446,26 @@ GenerateBuilderMembers(io::Printer* printer) const {
" return internalGetMutable$capitalized_name$().getMutableMap();\n"
"}\n");
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "$deprecation$"
- "public Builder put$capitalized_name$(\n"
- " $key_type$ key,\n"
- " $value_type$ value) {\n"
- " $key_null_check$\n"
- " $value_null_check$\n"
- " getMutable$capitalized_name$().put(key, value);\n"
- " return this;\n"
- "}\n");
+ printer->Print(variables_,
+ "$deprecation$"
+ "public Builder put$capitalized_name$(\n"
+ " $key_type$ key,\n"
+ " $value_type$ value) {\n"
+ " $key_null_check$\n"
+ " $value_null_check$\n"
+ " internalGetMutable$capitalized_name$().getMutableMap()\n"
+ " .put(key, value);\n"
+ " return this;\n"
+ "}\n");
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "$deprecation$\n"
- "public Builder putAll$capitalized_name$(\n"
- " java.util.Map<$type_parameters$> values) {\n"
- " getMutable$capitalized_name$().putAll(values);\n"
- " return this;\n"
- "}\n");
+ printer->Print(variables_,
+ "$deprecation$\n"
+ "public Builder putAll$capitalized_name$(\n"
+ " java.util.Map<$type_parameters$> values) {\n"
+ " internalGetMutable$capitalized_name$().getMutableMap()\n"
+ " .putAll(values);\n"
+ " return this;\n"
+ "}\n");
}
}
@@ -488,16 +498,13 @@ GenerateMapGetters(io::Printer* printer) const {
" return get$capitalized_name$Map();\n"
"}\n");
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "$deprecation$\n"
- "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
- "get$capitalized_name$Map() {\n"
- " return new com.google.protobuf.Internal.MapAdapter<\n"
- " $boxed_key_type$, $value_enum_type$, java.lang.Integer>(\n"
- " internalGet$capitalized_name$().getMap(),\n"
- " $name$ValueConverter);\n"
- "}\n");
+ printer->Print(variables_,
+ "$deprecation$\n"
+ "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
+ "get$capitalized_name$Map() {\n"
+ " return internalGetAdapted$capitalized_name$Map(\n"
+ " internalGet$capitalized_name$().getMap());"
+ "}\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
diff --git a/src/google/protobuf/compiler/java/java_map_field.h b/src/google/protobuf/compiler/java/java_map_field.h
index ae7ce7c5..47021740 100644
--- a/src/google/protobuf/compiler/java/java_map_field.h
+++ b/src/google/protobuf/compiler/java/java_map_field.h
@@ -67,7 +67,7 @@ class ImmutableMapFieldGenerator : public ImmutableFieldGenerator {
private:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
ClassNameResolver* name_resolver_;
void GenerateMapGetters(io::Printer* printer) const;
};
diff --git a/src/google/protobuf/compiler/java/java_map_field_lite.cc b/src/google/protobuf/compiler/java/java_map_field_lite.cc
index 5f102e07..523052cc 100644
--- a/src/google/protobuf/compiler/java/java_map_field_lite.cc
+++ b/src/google/protobuf/compiler/java/java_map_field_lite.cc
@@ -80,7 +80,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor,
int builderBitIndex,
const FieldGeneratorInfo* info,
Context* context,
- map<string, string>* variables) {
+ std::map<string, string>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
ClassNameResolver* name_resolver = context->GetNameResolver();
diff --git a/src/google/protobuf/compiler/java/java_map_field_lite.h b/src/google/protobuf/compiler/java/java_map_field_lite.h
index 555b5c5b..63dedbc2 100644
--- a/src/google/protobuf/compiler/java/java_map_field_lite.h
+++ b/src/google/protobuf/compiler/java/java_map_field_lite.h
@@ -66,7 +66,7 @@ class ImmutableMapFieldLiteGenerator : public ImmutableFieldLiteGenerator {
private:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
ClassNameResolver* name_resolver_;
};
diff --git a/src/google/protobuf/compiler/java/java_message.cc b/src/google/protobuf/compiler/java/java_message.cc
index 68d28b05..df4db463 100644
--- a/src/google/protobuf/compiler/java/java_message.cc
+++ b/src/google/protobuf/compiler/java/java_message.cc
@@ -110,7 +110,7 @@ void ImmutableMessageGenerator::GenerateStaticVariables(
// the outermost class in the file. This way, they will be initialized in
// a deterministic order.
- map<string, string> vars;
+ std::map<string, string> vars;
vars["identifier"] = UniqueFileScopeIdentifier(descriptor_);
vars["index"] = SimpleItoa(descriptor_->index());
vars["classname"] = name_resolver_->GetImmutableClassName(descriptor_);
@@ -154,7 +154,7 @@ void ImmutableMessageGenerator::GenerateStaticVariables(
int ImmutableMessageGenerator::GenerateStaticVariableInitializers(
io::Printer* printer) {
int bytecode_estimate = 0;
- map<string, string> vars;
+ std::map<string, string> vars;
vars["identifier"] = UniqueFileScopeIdentifier(descriptor_);
vars["index"] = SimpleItoa(descriptor_->index());
vars["classname"] = name_resolver_->GetImmutableClassName(descriptor_);
@@ -191,7 +191,7 @@ int ImmutableMessageGenerator::GenerateStaticVariableInitializers(
void ImmutableMessageGenerator::
GenerateFieldAccessorTable(io::Printer* printer, int* bytecode_estimate) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars["identifier"] = UniqueFileScopeIdentifier(descriptor_);
if (MultipleJavaFiles(descriptor_->file(), /* immutable = */ true)) {
// We can only make these package-private since the classes that use them
@@ -299,7 +299,7 @@ void ImmutableMessageGenerator::GenerateInterface(io::Printer* printer) {
void ImmutableMessageGenerator::Generate(io::Printer* printer) {
bool is_own_file = IsOwnFile(descriptor_, /* immutable = */ true);
- map<string, string> variables;
+ std::map<string, string> variables;
variables["static"] = is_own_file ? " " : " static ";
variables["classname"] = descriptor_->name();
variables["extra_interfaces"] = ExtraMessageInterfaces(descriptor_);
@@ -409,7 +409,7 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
}
// oneof
- map<string, string> vars;
+ std::map<string, string> vars;
for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
vars["oneof_name"] = context_->GetOneofGeneratorInfo(
descriptor_->oneof_decl(i))->name;
@@ -561,13 +561,12 @@ GenerateMessageSerializationMethods(io::Printer* printer) {
google::protobuf::scoped_array<const FieldDescriptor * > sorted_fields(
SortFieldsByNumber(descriptor_));
- vector<const Descriptor::ExtensionRange*> sorted_extensions;
+ std::vector<const Descriptor::ExtensionRange*> sorted_extensions;
for (int i = 0; i < descriptor_->extension_range_count(); ++i) {
sorted_extensions.push_back(descriptor_->extension_range(i));
}
std::sort(sorted_extensions.begin(), sorted_extensions.end(),
ExtensionRangeOrdering());
-
printer->Print(
"public void writeTo(com.google.protobuf.CodedOutputStream output)\n"
" throws java.io.IOException {\n");
@@ -799,7 +798,7 @@ GenerateDescriptorMethods(io::Printer* printer) {
"fileclass", name_resolver_->GetImmutableClassName(descriptor_->file()),
"identifier", UniqueFileScopeIdentifier(descriptor_));
}
- vector<const FieldDescriptor*> map_fields;
+ std::vector<const FieldDescriptor*> map_fields;
for (int i = 0; i < descriptor_->field_count(); i++) {
const FieldDescriptor* field = descriptor_->field(i);
if (GetJavaType(field) == JAVATYPE_MESSAGE &&
@@ -1093,7 +1092,12 @@ GenerateEqualsAndHashCode(io::Printer* printer) {
"}\n"
"int hash = 41;\n");
- printer->Print("hash = (19 * hash) + getDescriptorForType().hashCode();\n");
+ // If we output a getDescriptor() method, use that as it is more efficient.
+ if (descriptor_->options().no_standard_descriptor_accessor()) {
+ printer->Print("hash = (19 * hash) + getDescriptorForType().hashCode();\n");
+ } else {
+ printer->Print("hash = (19 * hash) + getDescriptor().hashCode();\n");
+ }
// hashCode non-oneofs.
for (int i = 0; i < descriptor_->field_count(); i++) {
@@ -1254,7 +1258,7 @@ GenerateParsingConstructor(io::Printer* printer) {
printer->Print(
"case $tag$: {\n",
- "tag", SimpleItoa(tag));
+ "tag", SimpleItoa(static_cast<int32>(tag)));
printer->Indent();
field_generators_.get(field).GenerateParsingCode(printer);
@@ -1271,7 +1275,7 @@ GenerateParsingConstructor(io::Printer* printer) {
WireFormatLite::WIRETYPE_LENGTH_DELIMITED);
printer->Print(
"case $tag$: {\n",
- "tag", SimpleItoa(packed_tag));
+ "tag", SimpleItoa(static_cast<int32>(packed_tag)));
printer->Indent();
field_generators_.get(field).GenerateParsingCodeFromPacked(printer);
@@ -1417,7 +1421,7 @@ void ImmutableMessageGenerator::GenerateAnyMethods(io::Printer* printer) {
"}\n"
"\n"
"/**\n"
- " * Packs a message uisng the given type URL prefix. The type URL will\n"
+ " * Packs a message using the given type URL prefix. The type URL will\n"
" * be constructed by concatenating the message type's full name to the\n"
" * prefix with an optional \"/\" separator if the prefix doesn't end\n"
" * with \"/\" already.\n"
diff --git a/src/google/protobuf/compiler/java/java_message_builder.cc b/src/google/protobuf/compiler/java/java_message_builder.cc
index cd82c51a..f5643abc 100644
--- a/src/google/protobuf/compiler/java/java_message_builder.cc
+++ b/src/google/protobuf/compiler/java/java_message_builder.cc
@@ -122,7 +122,7 @@ Generate(io::Printer* printer) {
}
// oneof
- map<string, string> vars;
+ std::map<string, string> vars;
for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
vars["oneof_name"] = context_->GetOneofGeneratorInfo(
descriptor_->oneof_decl(i))->name;
@@ -225,7 +225,7 @@ GenerateDescriptorMethods(io::Printer* printer) {
"fileclass", name_resolver_->GetImmutableClassName(descriptor_->file()),
"identifier", UniqueFileScopeIdentifier(descriptor_));
}
- vector<const FieldDescriptor*> map_fields;
+ std::vector<const FieldDescriptor*> map_fields;
for (int i = 0; i < descriptor_->field_count(); i++) {
const FieldDescriptor* field = descriptor_->field(i);
if (GetJavaType(field) == JAVATYPE_MESSAGE &&
diff --git a/src/google/protobuf/compiler/java/java_message_builder_lite.cc b/src/google/protobuf/compiler/java/java_message_builder_lite.cc
index dd429dc9..7e404ba1 100644
--- a/src/google/protobuf/compiler/java/java_message_builder_lite.cc
+++ b/src/google/protobuf/compiler/java/java_message_builder_lite.cc
@@ -106,7 +106,7 @@ Generate(io::Printer* printer) {
GenerateCommonBuilderMethods(printer);
// oneof
- map<string, string> vars;
+ std::map<string, string> vars;
for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
vars["oneof_name"] = context_->GetOneofGeneratorInfo(
descriptor_->oneof_decl(i))->name;
diff --git a/src/google/protobuf/compiler/java/java_message_field.cc b/src/google/protobuf/compiler/java/java_message_field.cc
index c9865dda..ae84db1c 100644
--- a/src/google/protobuf/compiler/java/java_message_field.cc
+++ b/src/google/protobuf/compiler/java/java_message_field.cc
@@ -56,7 +56,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor,
int builderBitIndex,
const FieldGeneratorInfo* info,
ClassNameResolver* name_resolver,
- map<string, string>* variables) {
+ std::map<string, string>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
(*variables)["type"] =
diff --git a/src/google/protobuf/compiler/java/java_message_field.h b/src/google/protobuf/compiler/java/java_message_field.h
index ea8225a5..7ee0edb2 100644
--- a/src/google/protobuf/compiler/java/java_message_field.h
+++ b/src/google/protobuf/compiler/java/java_message_field.h
@@ -82,7 +82,7 @@ class ImmutableMessageFieldGenerator : public ImmutableFieldGenerator {
protected:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
@@ -148,7 +148,7 @@ class RepeatedImmutableMessageFieldGenerator : public ImmutableFieldGenerator {
protected:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
diff --git a/src/google/protobuf/compiler/java/java_message_field_lite.cc b/src/google/protobuf/compiler/java/java_message_field_lite.cc
index cba18360..0957676c 100644
--- a/src/google/protobuf/compiler/java/java_message_field_lite.cc
+++ b/src/google/protobuf/compiler/java/java_message_field_lite.cc
@@ -56,7 +56,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor,
int builderBitIndex,
const FieldGeneratorInfo* info,
ClassNameResolver* name_resolver,
- map<string, string>* variables) {
+ std::map<string, string>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
(*variables)["type"] =
@@ -70,6 +70,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor,
// by the proto compiler
(*variables)["deprecation"] = descriptor->options().deprecated()
? "@java.lang.Deprecated " : "";
+ (*variables)["required"] = descriptor->is_required() ? "true" : "false";
if (SupportFieldPresence(descriptor->file())) {
// For singular messages and builders, one bit is used for the hasField bit.
diff --git a/src/google/protobuf/compiler/java/java_message_field_lite.h b/src/google/protobuf/compiler/java/java_message_field_lite.h
index 61321547..dbb263de 100644
--- a/src/google/protobuf/compiler/java/java_message_field_lite.h
+++ b/src/google/protobuf/compiler/java/java_message_field_lite.h
@@ -81,7 +81,7 @@ class ImmutableMessageFieldLiteGenerator : public ImmutableFieldLiteGenerator {
protected:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
@@ -139,7 +139,7 @@ class RepeatedImmutableMessageFieldLiteGenerator
protected:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
diff --git a/src/google/protobuf/compiler/java/java_message_lite.cc b/src/google/protobuf/compiler/java/java_message_lite.cc
index 0c5a1f8a..048d5892 100644
--- a/src/google/protobuf/compiler/java/java_message_lite.cc
+++ b/src/google/protobuf/compiler/java/java_message_lite.cc
@@ -170,7 +170,7 @@ void ImmutableMessageLiteGenerator::GenerateInterface(io::Printer* printer) {
void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
bool is_own_file = IsOwnFile(descriptor_, /* immutable = */ true);
- map<string, string> variables;
+ std::map<string, string> variables;
variables["static"] = is_own_file ? " " : " static ";
variables["classname"] = descriptor_->name();
variables["extra_interfaces"] = ExtraMessageInterfaces(descriptor_);
@@ -236,13 +236,13 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
}
// oneof
- map<string, string> vars;
+ std::map<string, string> vars;
for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
- vars["oneof_name"] = context_->GetOneofGeneratorInfo(
- descriptor_->oneof_decl(i))->name;
+ const OneofDescriptor* oneof = descriptor_->oneof_decl(i);
+ vars["oneof_name"] = context_->GetOneofGeneratorInfo(oneof)->name;
vars["oneof_capitalized_name"] = context_->GetOneofGeneratorInfo(
- descriptor_->oneof_decl(i))->capitalized_name;
- vars["oneof_index"] = SimpleItoa(descriptor_->oneof_decl(i)->index());
+ oneof)->capitalized_name;
+ vars["oneof_index"] = SimpleItoa(oneof->index());
// oneofCase_ and oneof_
printer->Print(vars,
"private int $oneof_name$Case_ = 0;\n"
@@ -252,8 +252,8 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
"public enum $oneof_capitalized_name$Case\n"
" implements com.google.protobuf.Internal.EnumLite {\n");
printer->Indent();
- for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {
- const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);
+ for (int j = 0; j < oneof->field_count(); j++) {
+ const FieldDescriptor* field = oneof->field(j);
printer->Print(
"$field_name$($field_number$),\n",
"field_name",
@@ -281,8 +281,8 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
"\n"
"public static $oneof_capitalized_name$Case forNumber(int value) {\n"
" switch (value) {\n");
- for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {
- const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);
+ for (int j = 0; j < oneof->field_count(); j++) {
+ const FieldDescriptor* field = oneof->field(j);
printer->Print(
" case $field_number$: return $field_name$;\n",
"field_number",
@@ -467,7 +467,7 @@ GenerateMessageSerializationMethods(io::Printer* printer) {
google::protobuf::scoped_array<const FieldDescriptor * > sorted_fields(
SortFieldsByNumber(descriptor_));
- vector<const Descriptor::ExtensionRange*> sorted_extensions;
+ std::vector<const Descriptor::ExtensionRange*> sorted_extensions;
for (int i = 0; i < descriptor_->extension_range_count(); ++i) {
sorted_extensions.push_back(descriptor_->extension_range(i));
}
@@ -523,8 +523,13 @@ GenerateMessageSerializationMethods(io::Printer* printer) {
}
if (PreserveUnknownFields(descriptor_)) {
- printer->Print(
- "unknownFields.writeTo(output);\n");
+ if (descriptor_->options().message_set_wire_format()) {
+ printer->Print(
+ "unknownFields.writeAsMessageSetTo(output);\n");
+ } else {
+ printer->Print(
+ "unknownFields.writeTo(output);\n");
+ }
}
printer->Outdent();
@@ -553,8 +558,13 @@ GenerateMessageSerializationMethods(io::Printer* printer) {
}
if (PreserveUnknownFields(descriptor_)) {
- printer->Print(
- "size += unknownFields.getSerializedSize();\n");
+ if (descriptor_->options().message_set_wire_format()) {
+ printer->Print(
+ "size += unknownFields.getSerializedSizeAsMessageSet();\n");
+ } else {
+ printer->Print(
+ "size += unknownFields.getSerializedSize();\n");
+ }
}
printer->Outdent();
@@ -918,10 +928,10 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodMergeFromStream(
"com.google.protobuf.CodedInputStream input =\n"
" (com.google.protobuf.CodedInputStream) arg0;\n"
"com.google.protobuf.ExtensionRegistryLite extensionRegistry =\n"
- " (com.google.protobuf.ExtensionRegistryLite) arg1;\n"
+ " (com.google.protobuf.ExtensionRegistryLite) arg1;\n");
+ printer->Print(
"try {\n");
printer->Indent();
-
printer->Print(
"boolean done = false;\n"
"while (!done) {\n");
@@ -939,14 +949,26 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodMergeFromStream(
if (PreserveUnknownFields(descriptor_)) {
if (descriptor_->extension_range_count() > 0) {
- printer->Print(
- "default: {\n"
- " if (!parseUnknownField(getDefaultInstanceForType(),\n"
- " input, extensionRegistry, tag)) {\n"
- " done = true;\n" // it's an endgroup tag
- " }\n"
- " break;\n"
- "}\n");
+ if (descriptor_->options().message_set_wire_format()) {
+ printer->Print(
+ "default: {\n"
+ " if (!parseUnknownFieldAsMessageSet(\n"
+ " getDefaultInstanceForType(), input, extensionRegistry,\n"
+ " tag)) {\n"
+ " done = true;\n" // it's an endgroup tag
+ " }\n"
+ " break;\n"
+ "}\n");
+ } else {
+ printer->Print(
+ "default: {\n"
+ " if (!parseUnknownField(getDefaultInstanceForType(),\n"
+ " input, extensionRegistry, tag)) {\n"
+ " done = true;\n" // it's an endgroup tag
+ " }\n"
+ " break;\n"
+ "}\n");
+ }
} else {
printer->Print(
"default: {\n"
@@ -975,7 +997,7 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodMergeFromStream(
printer->Print(
"case $tag$: {\n",
- "tag", SimpleItoa(tag));
+ "tag", SimpleItoa(static_cast<int32>(tag)));
printer->Indent();
field_generators_.get(field).GenerateParsingCode(printer);
@@ -992,7 +1014,7 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodMergeFromStream(
WireFormatLite::WIRETYPE_LENGTH_DELIMITED);
printer->Print(
"case $tag$: {\n",
- "tag", SimpleItoa(packed_tag));
+ "tag", SimpleItoa(static_cast<int32>(packed_tag)));
printer->Indent();
field_generators_.get(field).GenerateParsingCodeFromPacked(printer);
diff --git a/src/google/protobuf/compiler/java/java_name_resolver.h b/src/google/protobuf/compiler/java/java_name_resolver.h
index 570d8d8f..28b049d1 100644
--- a/src/google/protobuf/compiler/java/java_name_resolver.h
+++ b/src/google/protobuf/compiler/java/java_name_resolver.h
@@ -112,7 +112,7 @@ class ClassNameResolver {
const FileDescriptor* file,
bool immutable);
// Caches the result to provide better performance.
- map<const FileDescriptor*, string> file_immutable_outer_class_names_;
+ std::map<const FileDescriptor*, string> file_immutable_outer_class_names_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ClassNameResolver);
};
diff --git a/src/google/protobuf/compiler/java/java_primitive_field.cc b/src/google/protobuf/compiler/java/java_primitive_field.cc
index 877baf0a..fa1047e8 100644
--- a/src/google/protobuf/compiler/java/java_primitive_field.cc
+++ b/src/google/protobuf/compiler/java/java_primitive_field.cc
@@ -61,7 +61,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
int builderBitIndex,
const FieldGeneratorInfo* info,
ClassNameResolver* name_resolver,
- map<string, string>* variables) {
+ std::map<string, string>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
(*variables)["type"] = PrimitiveTypeName(GetJavaType(descriptor));
@@ -75,7 +75,8 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
"" : ("= " + ImmutableDefaultValue(descriptor, name_resolver));
(*variables)["capitalized_type"] =
GetCapitalizedType(descriptor, /* immutable = */ true);
- (*variables)["tag"] = SimpleItoa(WireFormat::MakeTag(descriptor));
+ (*variables)["tag"] =
+ SimpleItoa(static_cast<int32>(WireFormat::MakeTag(descriptor)));
(*variables)["tag_size"] = SimpleItoa(
WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
if (IsReferenceType(GetJavaType(descriptor))) {
diff --git a/src/google/protobuf/compiler/java/java_primitive_field.h b/src/google/protobuf/compiler/java/java_primitive_field.h
index d0cd12d9..7ac9bbfb 100644
--- a/src/google/protobuf/compiler/java/java_primitive_field.h
+++ b/src/google/protobuf/compiler/java/java_primitive_field.h
@@ -82,7 +82,7 @@ class ImmutablePrimitiveFieldGenerator : public ImmutableFieldGenerator {
protected:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
@@ -143,7 +143,7 @@ class RepeatedImmutablePrimitiveFieldGenerator
private:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
diff --git a/src/google/protobuf/compiler/java/java_primitive_field_lite.cc b/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
index ad2db30c..b04bf1c2 100644
--- a/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
+++ b/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
@@ -61,7 +61,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
int builderBitIndex,
const FieldGeneratorInfo* info,
ClassNameResolver* name_resolver,
- map<string, string>* variables) {
+ std::map<string, string>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
JavaType javaType = GetJavaType(descriptor);
(*variables)["type"] = PrimitiveTypeName(javaType);
@@ -70,9 +70,11 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
(*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
(*variables)["capitalized_type"] =
GetCapitalizedType(descriptor, /* immutable = */ true);
- (*variables)["tag"] = SimpleItoa(WireFormat::MakeTag(descriptor));
+ (*variables)["tag"] =
+ SimpleItoa(static_cast<int32>(WireFormat::MakeTag(descriptor)));
(*variables)["tag_size"] = SimpleItoa(
WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
+ (*variables)["required"] = descriptor->is_required() ? "true" : "false";
string capitalized_type = UnderscoresToCamelCase(PrimitiveTypeName(javaType),
true /* cap_next_letter */);
diff --git a/src/google/protobuf/compiler/java/java_primitive_field_lite.h b/src/google/protobuf/compiler/java/java_primitive_field_lite.h
index 6cfbbb98..dc59f0cf 100644
--- a/src/google/protobuf/compiler/java/java_primitive_field_lite.h
+++ b/src/google/protobuf/compiler/java/java_primitive_field_lite.h
@@ -84,7 +84,7 @@ class ImmutablePrimitiveFieldLiteGenerator
protected:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
@@ -146,7 +146,7 @@ class RepeatedImmutablePrimitiveFieldLiteGenerator
private:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
diff --git a/src/google/protobuf/compiler/java/java_service.cc b/src/google/protobuf/compiler/java/java_service.cc
index cfa8295d..988e1942 100644
--- a/src/google/protobuf/compiler/java/java_service.cc
+++ b/src/google/protobuf/compiler/java/java_service.cc
@@ -208,7 +208,7 @@ void ImmutableServiceGenerator::GenerateCallMethod(io::Printer* printer) {
for (int i = 0; i < descriptor_->method_count(); i++) {
const MethodDescriptor* method = descriptor_->method(i);
- map<string, string> vars;
+ std::map<string, string> vars;
vars["index"] = SimpleItoa(i);
vars["method"] = UnderscoresToCamelCase(method);
vars["input"] = name_resolver_->GetImmutableClassName(
@@ -255,7 +255,7 @@ void ImmutableServiceGenerator::GenerateCallBlockingMethod(
for (int i = 0; i < descriptor_->method_count(); i++) {
const MethodDescriptor* method = descriptor_->method(i);
- map<string, string> vars;
+ std::map<string, string> vars;
vars["index"] = SimpleItoa(i);
vars["method"] = UnderscoresToCamelCase(method);
vars["input"] = name_resolver_->GetImmutableClassName(
@@ -301,7 +301,7 @@ void ImmutableServiceGenerator::GenerateGetPrototype(RequestOrResponse which,
for (int i = 0; i < descriptor_->method_count(); i++) {
const MethodDescriptor* method = descriptor_->method(i);
- map<string, string> vars;
+ std::map<string, string> vars;
vars["index"] = SimpleItoa(i);
vars["type"] = name_resolver_->GetImmutableClassName(
(which == REQUEST) ? method->input_type() : method->output_type());
@@ -353,7 +353,7 @@ void ImmutableServiceGenerator::GenerateStub(io::Printer* printer) {
printer->Print(" {\n");
printer->Indent();
- map<string, string> vars;
+ std::map<string, string> vars;
vars["index"] = SimpleItoa(i);
vars["output"] = GetOutput(method);
printer->Print(vars,
@@ -417,7 +417,7 @@ void ImmutableServiceGenerator::GenerateBlockingStub(io::Printer* printer) {
printer->Print(" {\n");
printer->Indent();
- map<string, string> vars;
+ std::map<string, string> vars;
vars["index"] = SimpleItoa(i);
vars["output"] = GetOutput(method);
printer->Print(vars,
@@ -440,7 +440,7 @@ void ImmutableServiceGenerator::GenerateBlockingStub(io::Printer* printer) {
void ImmutableServiceGenerator::GenerateMethodSignature(io::Printer* printer,
const MethodDescriptor* method,
IsAbstract is_abstract) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars["name"] = UnderscoresToCamelCase(method);
vars["input"] = name_resolver_->GetImmutableClassName(method->input_type());
vars["output"] = GetOutput(method);
@@ -455,7 +455,7 @@ void ImmutableServiceGenerator::GenerateMethodSignature(io::Printer* printer,
void ImmutableServiceGenerator::GenerateBlockingMethodSignature(
io::Printer* printer,
const MethodDescriptor* method) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars["method"] = UnderscoresToCamelCase(method);
vars["input"] = name_resolver_->GetImmutableClassName(method->input_type());
vars["output"] = GetOutput(method);
diff --git a/src/google/protobuf/compiler/java/java_shared_code_generator.cc b/src/google/protobuf/compiler/java/java_shared_code_generator.cc
index 18bf1f51..7bd5ad7a 100644
--- a/src/google/protobuf/compiler/java/java_shared_code_generator.cc
+++ b/src/google/protobuf/compiler/java/java_shared_code_generator.cc
@@ -59,8 +59,8 @@ SharedCodeGenerator::~SharedCodeGenerator() {
}
void SharedCodeGenerator::Generate(GeneratorContext* context,
- vector<string>* file_list,
- vector<string>* annotation_file_list) {
+ std::vector<string>* file_list,
+ std::vector<string>* annotation_file_list) {
string java_package = FileJavaPackage(file_);
string package_dir = JavaPackageToDir(java_package);
@@ -179,15 +179,13 @@ void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) {
// -----------------------------------------------------------------
// Find out all dependencies.
- vector<pair<string, string> > dependencies;
+ std::vector<std::pair<string, string> > dependencies;
for (int i = 0; i < file_->dependency_count(); i++) {
- if (ShouldIncludeDependency(file_->dependency(i))) {
- string filename = file_->dependency(i)->name();
- string classname = FileJavaPackage(file_->dependency(i)) + "." +
- name_resolver_->GetDescriptorClassName(
- file_->dependency(i));
- dependencies.push_back(std::make_pair(filename, classname));
- }
+ string filename = file_->dependency(i)->name();
+ string classname = FileJavaPackage(file_->dependency(i)) + "." +
+ name_resolver_->GetDescriptorClassName(
+ file_->dependency(i));
+ dependencies.push_back(std::make_pair(filename, classname));
}
// -----------------------------------------------------------------
@@ -209,11 +207,6 @@ void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) {
" }, assigner);\n");
}
-bool SharedCodeGenerator::ShouldIncludeDependency(
- const FileDescriptor* descriptor) {
- return true;
-}
-
} // namespace java
} // namespace compiler
} // namespace protobuf
diff --git a/src/google/protobuf/compiler/java/java_shared_code_generator.h b/src/google/protobuf/compiler/java/java_shared_code_generator.h
index 7e1e1f17..40502270 100644
--- a/src/google/protobuf/compiler/java/java_shared_code_generator.h
+++ b/src/google/protobuf/compiler/java/java_shared_code_generator.h
@@ -70,17 +70,13 @@ class SharedCodeGenerator {
SharedCodeGenerator(const FileDescriptor* file, const Options& options);
~SharedCodeGenerator();
- void Generate(GeneratorContext* generator_context, vector<string>* file_list,
- vector<string>* annotation_file_list);
+ void Generate(GeneratorContext* generator_context,
+ std::vector<string>* file_list,
+ std::vector<string>* annotation_file_list);
void GenerateDescriptors(io::Printer* printer);
private:
- // Returns whether the dependency should be included in the output file.
- // Always returns true for opensource, but used internally at Google to help
- // improve compatibility with version 1 of protocol buffers.
- bool ShouldIncludeDependency(const FileDescriptor* descriptor);
-
google::protobuf::scoped_ptr<ClassNameResolver> name_resolver_;
const FileDescriptor* file_;
const Options options_;
diff --git a/src/google/protobuf/compiler/java/java_string_field.cc b/src/google/protobuf/compiler/java/java_string_field.cc
index ff1865b1..5c2900ce 100644
--- a/src/google/protobuf/compiler/java/java_string_field.cc
+++ b/src/google/protobuf/compiler/java/java_string_field.cc
@@ -62,7 +62,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
int builderBitIndex,
const FieldGeneratorInfo* info,
ClassNameResolver* name_resolver,
- map<string, string>* variables) {
+ std::map<string, string>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
(*variables)["empty_list"] = "com.google.protobuf.LazyStringArrayList.EMPTY";
@@ -71,7 +71,8 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
(*variables)["default_init"] =
"= " + ImmutableDefaultValue(descriptor, name_resolver);
(*variables)["capitalized_type"] = "String";
- (*variables)["tag"] = SimpleItoa(WireFormat::MakeTag(descriptor));
+ (*variables)["tag"] =
+ SimpleItoa(static_cast<int32>(WireFormat::MakeTag(descriptor)));
(*variables)["tag_size"] = SimpleItoa(
WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
(*variables)["null_check"] =
diff --git a/src/google/protobuf/compiler/java/java_string_field.h b/src/google/protobuf/compiler/java/java_string_field.h
index a3b57351..0f7c705b 100644
--- a/src/google/protobuf/compiler/java/java_string_field.h
+++ b/src/google/protobuf/compiler/java/java_string_field.h
@@ -83,7 +83,7 @@ class ImmutableStringFieldGenerator : public ImmutableFieldGenerator {
protected:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
@@ -142,7 +142,7 @@ class RepeatedImmutableStringFieldGenerator : public ImmutableFieldGenerator {
private:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
diff --git a/src/google/protobuf/compiler/java/java_string_field_lite.cc b/src/google/protobuf/compiler/java/java_string_field_lite.cc
index 0b92c021..138e59b6 100644
--- a/src/google/protobuf/compiler/java/java_string_field_lite.cc
+++ b/src/google/protobuf/compiler/java/java_string_field_lite.cc
@@ -62,7 +62,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
int builderBitIndex,
const FieldGeneratorInfo* info,
ClassNameResolver* name_resolver,
- map<string, string>* variables) {
+ std::map<string, string>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
(*variables)["empty_list"] =
@@ -72,7 +72,8 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
(*variables)["default_init"] =
"= " + ImmutableDefaultValue(descriptor, name_resolver);
(*variables)["capitalized_type"] = "String";
- (*variables)["tag"] = SimpleItoa(WireFormat::MakeTag(descriptor));
+ (*variables)["tag"] =
+ SimpleItoa(static_cast<int32>(WireFormat::MakeTag(descriptor)));
(*variables)["tag_size"] = SimpleItoa(
WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
(*variables)["null_check"] =
@@ -84,6 +85,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
// by the proto compiler
(*variables)["deprecation"] = descriptor->options().deprecated()
? "@java.lang.Deprecated " : "";
+ (*variables)["required"] = descriptor->is_required() ? "true" : "false";
if (SupportFieldPresence(descriptor->file())) {
// For singular messages and builders, one bit is used for the hasField bit.
diff --git a/src/google/protobuf/compiler/java/java_string_field_lite.h b/src/google/protobuf/compiler/java/java_string_field_lite.h
index 4148aa4d..80496c87 100644
--- a/src/google/protobuf/compiler/java/java_string_field_lite.h
+++ b/src/google/protobuf/compiler/java/java_string_field_lite.h
@@ -82,7 +82,7 @@ class ImmutableStringFieldLiteGenerator : public ImmutableFieldLiteGenerator {
protected:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
@@ -140,7 +140,7 @@ class RepeatedImmutableStringFieldLiteGenerator
private:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
diff --git a/src/google/protobuf/compiler/js/embed.cc b/src/google/protobuf/compiler/js/embed.cc
new file mode 100644
index 00000000..57d38237
--- /dev/null
+++ b/src/google/protobuf/compiler/js/embed.cc
@@ -0,0 +1,112 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include <cassert>
+#include <cstdlib>
+#include <fstream>
+#include <iostream>
+#include <string>
+
+const char output_file[] = "well_known_types_embed.cc";
+
+static bool AsciiIsPrint(unsigned char c) {
+ return c >= 32 && c < 127;
+}
+
+static char ToDecimalDigit(int num) {
+ assert(num < 10);
+ return '0' + num;
+}
+
+static std::string CEscape(const std::string& str) {
+ std::string dest;
+
+ for (size_t i = 0; i < str.size(); ++i) {
+ unsigned char ch = str[i];
+ switch (ch) {
+ case '\n': dest += "\\n"; break;
+ case '\r': dest += "\\r"; break;
+ case '\t': dest += "\\t"; break;
+ case '\"': dest += "\\\""; break;
+ case '\\': dest += "\\\\"; break;
+ default:
+ if (AsciiIsPrint(ch)) {
+ dest += ch;
+ } else {
+ dest += "\\";
+ dest += ToDecimalDigit(ch / 64);
+ dest += ToDecimalDigit((ch % 64) / 8);
+ dest += ToDecimalDigit(ch % 8);
+ }
+ break;
+ }
+ }
+
+ return dest;
+}
+
+static void AddFile(const char* name, std::basic_ostream<char>* out) {
+ std::ifstream in(name);
+
+ if (!in.is_open()) {
+ std::cerr << "Couldn't open input file: " << name << "\n";
+ std::exit(EXIT_FAILURE);
+ }
+
+ // Make canonical name only include the final element.
+ for (const char *p = name; *p; p++) {
+ if (*p == '/') {
+ name = p + 1;
+ }
+ }
+
+ *out << "{\"" << CEscape(name) << "\",\n";
+
+ for (std::string line; std::getline(in, line); ) {
+ *out << " \"" << CEscape(line) << "\\n\"\n";
+ }
+
+ *out << "},\n";
+}
+
+int main(int argc, char *argv[]) {
+ std::cout << "#include "
+ "<google/protobuf/compiler/js/well_known_types_embed.h>\n";
+ std::cout << "struct FileToc well_known_types_js[] = {\n";
+
+ for (int i = 1; i < argc; i++) {
+ AddFile(argv[i], &std::cout);
+ }
+
+ std::cout << " {NULL, NULL} // Terminate the list.\n";
+ std::cout << "};\n";
+
+ return EXIT_SUCCESS;
+}
diff --git a/src/google/protobuf/compiler/js/js_generator.cc b/src/google/protobuf/compiler/js/js_generator.cc
index 58597b4c..727ed090 100755
--- a/src/google/protobuf/compiler/js/js_generator.cc
+++ b/src/google/protobuf/compiler/js/js_generator.cc
@@ -28,7 +28,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include "google/protobuf/compiler/js/js_generator.h"
+#include <google/protobuf/compiler/js/js_generator.h>
#include <assert.h>
#include <algorithm>
@@ -45,6 +45,7 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/stringprintf.h>
+#include <google/protobuf/compiler/js/well_known_types_embed.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/descriptor.pb.h>
@@ -216,8 +217,13 @@ string GetNestedMessageName(const Descriptor* descriptor) {
if (descriptor == NULL) {
return "";
}
- return StripPrefixString(descriptor->full_name(),
- descriptor->file()->package());
+ string result =
+ StripPrefixString(descriptor->full_name(), descriptor->file()->package());
+ // Add a leading dot if one is not already present.
+ if (!result.empty() && result[0] != '.') {
+ result = "." + result;
+ }
+ return result;
}
// Returns the path prefix for a message or enumeration that
@@ -225,8 +231,8 @@ string GetNestedMessageName(const Descriptor* descriptor) {
string GetPrefix(const GeneratorOptions& options,
const FileDescriptor* file_descriptor,
const Descriptor* containing_type) {
- string prefix = GetPath(options, file_descriptor) +
- GetNestedMessageName(containing_type);
+ string prefix =
+ GetPath(options, file_descriptor) + GetNestedMessageName(containing_type);
if (!prefix.empty()) {
prefix += ".";
}
@@ -278,8 +284,8 @@ string MaybeCrossFileRef(const GeneratorOptions& options,
// Cross-file ref in CommonJS needs to use the module alias instead of
// the global name.
return ModuleAlias(to_message->file()->name()) +
- GetNestedMessageName(to_message->containing_type()) +
- "." + to_message->name();
+ GetNestedMessageName(to_message->containing_type()) + "." +
+ to_message->name();
} else {
// Within a single file we use a full name.
return GetPath(options, to_message);
@@ -309,8 +315,8 @@ char ToLowerASCII(char c) {
}
}
-vector<string> ParseLowerUnderscore(const string& input) {
- vector<string> words;
+std::vector<string> ParseLowerUnderscore(const string& input) {
+ std::vector<string> words;
string running = "";
for (int i = 0; i < input.size(); i++) {
if (input[i] == '_') {
@@ -328,8 +334,8 @@ vector<string> ParseLowerUnderscore(const string& input) {
return words;
}
-vector<string> ParseUpperCamel(const string& input) {
- vector<string> words;
+std::vector<string> ParseUpperCamel(const string& input) {
+ std::vector<string> words;
string running = "";
for (int i = 0; i < input.size(); i++) {
if (input[i] >= 'A' && input[i] <= 'Z' && !running.empty()) {
@@ -344,7 +350,7 @@ vector<string> ParseUpperCamel(const string& input) {
return words;
}
-string ToLowerCamel(const vector<string>& words) {
+string ToLowerCamel(const std::vector<string>& words) {
string result;
for (int i = 0; i < words.size(); i++) {
string word = words[i];
@@ -358,7 +364,7 @@ string ToLowerCamel(const vector<string>& words) {
return result;
}
-string ToUpperCamel(const vector<string>& words) {
+string ToUpperCamel(const std::vector<string>& words) {
string result;
for (int i = 0; i < words.size(); i++) {
string word = words[i];
@@ -927,16 +933,10 @@ string JSTypeName(const GeneratorOptions& options,
}
}
+// Used inside Google only -- do not remove.
bool UseBrokenPresenceSemantics(const GeneratorOptions& options,
const FieldDescriptor* field) {
- if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3) {
- return options.broken_proto3_semantics;
- } else if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO2) {
- return false;
- } else {
- GOOGLE_LOG(FATAL) << "We can only handle syntax=proto2 and syntax=proto3.";
- return false;
- }
+ return false;
}
// Returns true for fields that return "null" from accessors when they are
@@ -1077,22 +1077,14 @@ string JSBinaryReadWriteMethodName(const FieldDescriptor* field,
string JSBinaryReaderMethodName(const GeneratorOptions& options,
const FieldDescriptor* field) {
- if (options.binary) {
- return "jspb.BinaryReader.prototype.read" +
- JSBinaryReadWriteMethodName(field, /* is_writer = */ false);
- } else {
- return "null";
- }
+ return "jspb.BinaryReader.prototype.read" +
+ JSBinaryReadWriteMethodName(field, /* is_writer = */ false);
}
string JSBinaryWriterMethodName(const GeneratorOptions& options,
const FieldDescriptor* field) {
- if (options.binary) {
- return "jspb.BinaryWriter.prototype.write" +
- JSBinaryReadWriteMethodName(field, /* is_writer = */ true);
- } else {
- return "null";
- }
+ return "jspb.BinaryWriter.prototype.write" +
+ JSBinaryReadWriteMethodName(field, /* is_writer = */ true);
}
string JSReturnClause(const FieldDescriptor* desc) {
@@ -1327,6 +1319,29 @@ bool HasExtensions(const FileDescriptor* file) {
return false;
}
+bool HasMap(const GeneratorOptions& options, const Descriptor* desc) {
+ for (int i = 0; i < desc->field_count(); i++) {
+ if (IsMap(options, desc->field(i))) {
+ return true;
+ }
+ }
+ for (int i = 0; i < desc->nested_type_count(); i++) {
+ if (HasMap(options, desc->nested_type(i))) {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool FileHasMap(const GeneratorOptions& options, const FileDescriptor* desc) {
+ for (int i = 0; i < desc->message_type_count(); i++) {
+ if (HasMap(options, desc->message_type(i))) {
+ return true;
+ }
+ }
+ return false;
+}
+
bool IsExtendable(const Descriptor* desc) {
return desc->extension_range_count() > 0;
}
@@ -1398,19 +1413,19 @@ class FileDeduplicator {
return true;
}
- void GetAllowedSet(set<const void*>* allowed_set) {
+ void GetAllowedSet(std::set<const void*>* allowed_set) {
*allowed_set = allowed_descs_;
}
private:
bool error_on_conflict_;
- map<string, const void*> descs_by_filename_;
- set<const void*> allowed_descs_;
+ std::map<string, const void*> descs_by_filename_;
+ std::set<const void*> allowed_descs_;
};
void DepthFirstSearch(const FileDescriptor* file,
- vector<const FileDescriptor*>* list,
- set<const FileDescriptor*>* seen) {
+ std::vector<const FileDescriptor*>* list,
+ std::set<const FileDescriptor*>* seen) {
if (!seen->insert(file).second) {
return;
}
@@ -1428,7 +1443,7 @@ void DepthFirstSearch(const FileDescriptor* file,
// FileDescriptor is not in the given set.
class NotInSet {
public:
- explicit NotInSet(const set<const FileDescriptor*>& file_set)
+ explicit NotInSet(const std::set<const FileDescriptor*>& file_set)
: file_set_(file_set) {}
bool operator()(const FileDescriptor* file) {
@@ -1436,21 +1451,21 @@ class NotInSet {
}
private:
- const set<const FileDescriptor*>& file_set_;
+ const std::set<const FileDescriptor*>& file_set_;
};
// This function generates an ordering of the input FileDescriptors that matches
// the logic of the old code generator. The order is significant because two
// different input files can generate the same output file, and the last one
// needs to win.
-void GenerateJspbFileOrder(const vector<const FileDescriptor*>& input,
- vector<const FileDescriptor*>* ordered) {
+void GenerateJspbFileOrder(const std::vector<const FileDescriptor*>& input,
+ std::vector<const FileDescriptor*>* ordered) {
// First generate an ordering of all reachable files (including dependencies)
// with depth-first search. This mimics the behavior of --include_imports,
// which is what the old codegen used.
ordered->clear();
- set<const FileDescriptor*> seen;
- set<const FileDescriptor*> input_set;
+ std::set<const FileDescriptor*> seen;
+ std::set<const FileDescriptor*> input_set;
for (int i = 0; i < input.size(); i++) {
DepthFirstSearch(input[i], ordered, &seen);
input_set.insert(input[i]);
@@ -1467,10 +1482,10 @@ void GenerateJspbFileOrder(const vector<const FileDescriptor*>& input,
// only those to generate code.
bool GenerateJspbAllowedSet(const GeneratorOptions& options,
- const vector<const FileDescriptor*>& files,
- set<const void*>* allowed_set,
+ const std::vector<const FileDescriptor*>& files,
+ std::set<const void*>* allowed_set,
string* error) {
- vector<const FileDescriptor*> files_ordered;
+ std::vector<const FileDescriptor*> files_ordered;
GenerateJspbFileOrder(files, &files_ordered);
// Choose the last descriptor for each filename.
@@ -1538,7 +1553,7 @@ void Generator::FindProvidesForFile(const GeneratorOptions& options,
void Generator::FindProvides(const GeneratorOptions& options,
io::Printer* printer,
- const vector<const FileDescriptor*>& files,
+ const std::vector<const FileDescriptor*>& files,
std::set<string>* provided) const {
for (int i = 0; i < files.size(); i++) {
FindProvidesForFile(options, printer, files[i], provided);
@@ -1580,7 +1595,7 @@ void Generator::FindProvidesForEnum(const GeneratorOptions& options,
void Generator::FindProvidesForFields(
const GeneratorOptions& options,
io::Printer* printer,
- const vector<const FieldDescriptor*>& fields,
+ const std::vector<const FieldDescriptor*>& fields,
std::set<string>* provided) const {
for (int i = 0; i < fields.size(); i++) {
const FieldDescriptor* field = fields[i];
@@ -1629,18 +1644,20 @@ void Generator::GenerateRequiresForMessage(const GeneratorOptions& options,
GenerateRequiresImpl(options, printer, &required, &forwards, provided,
/* require_jspb = */ have_message,
- /* require_extension = */ HasExtensions(desc));
+ /* require_extension = */ HasExtensions(desc),
+ /* require_map = */ HasMap(options, desc));
}
void Generator::GenerateRequiresForLibrary(
const GeneratorOptions& options, io::Printer* printer,
- const vector<const FileDescriptor*>& files,
+ const std::vector<const FileDescriptor*>& files,
std::set<string>* provided) const {
GOOGLE_CHECK_EQ(options.import_style, GeneratorOptions::kImportClosure);
// For Closure imports we need to import every message type individually.
std::set<string> required;
std::set<string> forwards;
bool have_extensions = false;
+ bool have_map = false;
bool have_message = false;
for (int i = 0; i < files.size(); i++) {
@@ -1656,6 +1673,10 @@ void Generator::GenerateRequiresForLibrary(
have_extensions = true;
}
+ if (!have_map && FileHasMap(options, files[i])) {
+ have_map = true;
+ }
+
for (int j = 0; j < files[i]->extension_count(); j++) {
const FieldDescriptor* extension = files[i]->extension(j);
if (IgnoreField(extension)) {
@@ -1672,12 +1693,13 @@ void Generator::GenerateRequiresForLibrary(
GenerateRequiresImpl(options, printer, &required, &forwards, provided,
/* require_jspb = */ have_message,
- /* require_extension = */ have_extensions);
+ /* require_extension = */ have_extensions,
+ /* require_map = */ have_map);
}
void Generator::GenerateRequiresForExtensions(
const GeneratorOptions& options, io::Printer* printer,
- const vector<const FieldDescriptor*>& fields,
+ const std::vector<const FieldDescriptor*>& fields,
std::set<string>* provided) const {
std::set<string> required;
std::set<string> forwards;
@@ -1691,7 +1713,8 @@ void Generator::GenerateRequiresForExtensions(
GenerateRequiresImpl(options, printer, &required, &forwards, provided,
/* require_jspb = */ false,
- /* require_extension = */ fields.size() > 0);
+ /* require_extension = */ fields.size() > 0,
+ /* require_map = */ false);
}
void Generator::GenerateRequiresImpl(const GeneratorOptions& options,
@@ -1699,25 +1722,22 @@ void Generator::GenerateRequiresImpl(const GeneratorOptions& options,
std::set<string>* required,
std::set<string>* forwards,
std::set<string>* provided,
- bool require_jspb,
- bool require_extension) const {
+ bool require_jspb, bool require_extension,
+ bool require_map) const {
if (require_jspb) {
printer->Print(
- "goog.require('jspb.Message');\n");
- if (options.binary) {
- printer->Print(
- "goog.require('jspb.BinaryReader');\n"
- "goog.require('jspb.BinaryWriter');\n");
- }
+ "goog.require('jspb.Message');\n"
+ "goog.require('jspb.BinaryReader');\n"
+ "goog.require('jspb.BinaryWriter');\n");
}
if (require_extension) {
- if (options.binary) {
- printer->Print(
- "goog.require('jspb.ExtensionFieldBinaryInfo');\n");
- }
+ printer->Print("goog.require('jspb.ExtensionFieldBinaryInfo');\n");
printer->Print(
"goog.require('jspb.ExtensionFieldInfo');\n");
}
+ if (require_map) {
+ printer->Print("goog.require('jspb.Map');\n");
+ }
std::set<string>::iterator it;
for (it = required->begin(); it != required->end(); ++it) {
@@ -1839,14 +1859,25 @@ void Generator::GenerateClass(const GeneratorOptions& options,
GenerateClassToObject(options, printer, desc);
- if (options.binary) {
- // These must come *before* the extension-field info generation in
- // GenerateClassRegistration so that references to the binary
- // serialization/deserialization functions may be placed in the extension
- // objects.
- GenerateClassDeserializeBinary(options, printer, desc);
- GenerateClassSerializeBinary(options, printer, desc);
- }
+ // These must come *before* the extension-field info generation in
+ // GenerateClassRegistration so that references to the binary
+ // serialization/deserialization functions may be placed in the extension
+ // objects.
+ GenerateClassDeserializeBinary(options, printer, desc);
+ GenerateClassSerializeBinary(options, printer, desc);
+ }
+
+ // Recurse on nested types. These must come *before* the extension-field
+ // info generation in GenerateClassRegistration so that extensions that
+ // reference nested types proceed the definitions of the nested types.
+ for (int i = 0; i < desc->enum_type_count(); i++) {
+ GenerateEnum(options, printer, desc->enum_type(i));
+ }
+ for (int i = 0; i < desc->nested_type_count(); i++) {
+ GenerateClass(options, printer, desc->nested_type(i));
+ }
+
+ if (!NamespaceOnly(desc)) {
GenerateClassRegistration(options, printer, desc);
GenerateClassFields(options, printer, desc);
if (IsExtendable(desc) && desc->full_name() != "google.protobuf.bridge.MessageSet") {
@@ -1860,13 +1891,6 @@ void Generator::GenerateClass(const GeneratorOptions& options,
}
}
- // Recurse on nested types.
- for (int i = 0; i < desc->enum_type_count(); i++) {
- GenerateEnum(options, printer, desc->enum_type(i));
- }
- for (int i = 0; i < desc->nested_type_count(); i++) {
- GenerateClass(options, printer, desc->nested_type(i));
- }
}
void Generator::GenerateClassConstructor(const GeneratorOptions& options,
@@ -2143,8 +2167,20 @@ void Generator::GenerateClassFieldToObject(const GeneratorOptions& options,
"fieldname", JSObjectFieldName(options, field));
if (IsMap(options, field)) {
- printer->Print("(f = msg.get$name$()) ? f.toArray() : []",
- "name", JSGetterName(options, field));
+ const FieldDescriptor* value_field = MapFieldValue(field);
+ // If the map values are of a message type, we must provide their static
+ // toObject() method; otherwise we pass undefined for that argument.
+ string value_to_object;
+ if (value_field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
+ value_to_object =
+ GetPath(options, value_field->message_type()) + ".toObject";
+ } else {
+ value_to_object = "undefined";
+ }
+ printer->Print(
+ "(f = msg.get$name$()) ? f.toObject(includeInstance, $valuetoobject$) "
+ ": []",
+ "name", JSGetterName(options, field), "valuetoobject", value_to_object);
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
// Message field.
if (field->is_repeated()) {
@@ -2217,14 +2253,27 @@ void Generator::GenerateClassFieldFromObject(
io::Printer* printer,
const FieldDescriptor* field) const {
if (IsMap(options, field)) {
- // `msg` is a newly-constructed message object that has not yet built any
- // map containers wrapping underlying arrays, so we can simply directly set
- // the array here without fear of a stale wrapper.
- printer->Print(
- " goog.isDef(obj.$name$) && "
- "jspb.Message.setField(msg, $index$, obj.$name$);\n",
- "name", JSObjectFieldName(options, field),
- "index", JSFieldIndex(field));
+ const FieldDescriptor* value_field = MapFieldValue(field);
+ if (value_field->type() == FieldDescriptor::TYPE_MESSAGE) {
+ // Since the map values are of message type, we have to do some extra work
+ // to recursively call fromObject() on them before setting the map field.
+ printer->Print(
+ " goog.isDef(obj.$name$) && jspb.Message.setWrapperField(\n"
+ " msg, $index$, jspb.Map.fromObject(obj.$name$, $fieldclass$, "
+ "$fieldclass$.fromObject));\n",
+ "name", JSObjectFieldName(options, field),
+ "index", JSFieldIndex(field),
+ "fieldclass", GetPath(options, value_field->message_type()));
+ } else {
+ // `msg` is a newly-constructed message object that has not yet built any
+ // map containers wrapping underlying arrays, so we can simply directly
+ // set the array here without fear of a stale wrapper.
+ printer->Print(
+ " goog.isDef(obj.$name$) && "
+ "jspb.Message.setField(msg, $index$, obj.$name$);\n",
+ "name", JSObjectFieldName(options, field),
+ "index", JSFieldIndex(field));
+ }
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
// Message field (singular or repeated)
if (field->is_repeated()) {
@@ -2358,7 +2407,7 @@ void Generator::GenerateClassField(const GeneratorOptions& options,
printer->Print(",\n"
" $messageType$",
"messageType", GetPath(options, value_field->message_type()));
- } else if (options.binary) {
+ } else {
printer->Print(",\n"
" null");
}
@@ -2711,28 +2760,26 @@ void Generator::GenerateClassExtensionFieldInfo(const GeneratorOptions& options,
"\n",
"class", GetPath(options, desc));
- if (options.binary) {
- printer->Print(
- "\n"
- "/**\n"
- " * The extensions registered with this message class. This is a "
- "map of\n"
- " * extension field number to fieldInfo object.\n"
- " *\n"
- " * For example:\n"
- " * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, "
- "ctor: proto.example.MyMessage} }\n"
- " *\n"
- " * fieldName contains the JsCompiler renamed field name property "
- "so that it\n"
- " * works in OPTIMIZED mode.\n"
- " *\n"
- " * @type {!Object.<number, jspb.ExtensionFieldBinaryInfo>}\n"
- " */\n"
- "$class$.extensionsBinary = {};\n"
- "\n",
- "class", GetPath(options, desc));
- }
+ printer->Print(
+ "\n"
+ "/**\n"
+ " * The extensions registered with this message class. This is a "
+ "map of\n"
+ " * extension field number to fieldInfo object.\n"
+ " *\n"
+ " * For example:\n"
+ " * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, "
+ "ctor: proto.example.MyMessage} }\n"
+ " *\n"
+ " * fieldName contains the JsCompiler renamed field name property "
+ "so that it\n"
+ " * works in OPTIMIZED mode.\n"
+ " *\n"
+ " * @type {!Object.<number, jspb.ExtensionFieldBinaryInfo>}\n"
+ " */\n"
+ "$class$.extensionsBinary = {};\n"
+ "\n",
+ "class", GetPath(options, desc));
}
}
@@ -2773,7 +2820,9 @@ void Generator::GenerateClassDeserializeBinary(const GeneratorOptions& options,
"class", GetPath(options, desc));
for (int i = 0; i < desc->field_count(); i++) {
- GenerateClassDeserializeBinaryField(options, printer, desc->field(i));
+ if (!IgnoreField(desc->field(i))) {
+ GenerateClassDeserializeBinaryField(options, printer, desc->field(i));
+ }
}
printer->Print(
@@ -2873,44 +2922,36 @@ void Generator::GenerateClassSerializeBinary(const GeneratorOptions& options,
const Descriptor* desc) const {
printer->Print(
"/**\n"
- " * Class method variant: serializes the given message to binary data\n"
- " * (in protobuf wire format), writing to the given BinaryWriter.\n"
- " * @param {!$class$} message\n"
- " * @param {!jspb.BinaryWriter} writer\n"
- " */\n"
- "$class$.serializeBinaryToWriter = function(message, "
- "writer) {\n"
- " message.serializeBinaryToWriter(writer);\n"
- "};\n"
- "\n"
- "\n"
- "/**\n"
" * Serializes the message to binary data (in protobuf wire format).\n"
" * @return {!Uint8Array}\n"
" */\n"
"$class$.prototype.serializeBinary = function() {\n"
" var writer = new jspb.BinaryWriter();\n"
- " this.serializeBinaryToWriter(writer);\n"
+ " $class$.serializeBinaryToWriter(this, writer);\n"
" return writer.getResultBuffer();\n"
"};\n"
"\n"
"\n"
"/**\n"
- " * Serializes the message to binary data (in protobuf wire format),\n"
- " * writing to the given BinaryWriter.\n"
+ " * Serializes the given message to binary data (in protobuf wire\n"
+ " * format), writing to the given BinaryWriter.\n"
+ " * @param {!$class$} message\n"
" * @param {!jspb.BinaryWriter} writer\n"
" */\n"
- "$class$.prototype.serializeBinaryToWriter = function (writer) {\n"
+ "$class$.serializeBinaryToWriter = function(message, "
+ "writer) {\n"
" var f = undefined;\n",
"class", GetPath(options, desc));
for (int i = 0; i < desc->field_count(); i++) {
- GenerateClassSerializeBinaryField(options, printer, desc->field(i));
+ if (!IgnoreField(desc->field(i))) {
+ GenerateClassSerializeBinaryField(options, printer, desc->field(i));
+ }
}
if (IsExtendable(desc)) {
printer->Print(
- " jspb.Message.serializeBinaryExtensions(this, writer,\n"
+ " jspb.Message.serializeBinaryExtensions(message, writer,\n"
" $extobj$Binary, $class$.prototype.getExtension);\n",
"extobj", JSExtensionsObjectName(options, desc->file(), desc),
"class", GetPath(options, desc));
@@ -2935,15 +2976,16 @@ void Generator::GenerateClassSerializeBinaryField(
/* singular_if_not_packed = */ false,
/* bytes_mode = */ BYTES_DEFAULT);
printer->Print(
- " f = /** @type {$type$} */ (jspb.Message.getField(this, $index$));\n",
+ " f = /** @type {$type$} */ "
+ "(jspb.Message.getField(message, $index$));\n",
"index", JSFieldIndex(field),
"type", typed_annotation);
} else {
printer->Print(
- " f = this.get$name$($nolazy$);\n",
+ " f = message.get$name$($nolazy$);\n",
"name", JSGetterName(options, field, BYTES_U8),
// No lazy creation for maps containers -- fastpath the empty case.
- "nolazy", (field->is_map()) ? "true" : "");
+ "nolazy", IsMap(options, field) ? "true" : "");
}
// Print an `if (condition)` statement that evaluates to true if the field
@@ -3102,35 +3144,30 @@ void Generator::GenerateExtension(const GeneratorOptions& options,
string("null")),
"repeated", (field->is_repeated() ? "1" : "0"));
- if (options.binary) {
- printer->Print(
- "\n"
- "$extendName$Binary[$index$] = new jspb.ExtensionFieldBinaryInfo(\n"
- " $class$.$name$,\n"
- " $binaryReaderFn$,\n"
- " $binaryWriterFn$,\n"
- " $binaryMessageSerializeFn$,\n"
- " $binaryMessageDeserializeFn$,\n",
- "extendName", JSExtensionsObjectName(options, field->file(),
- field->containing_type()),
- "index", SimpleItoa(field->number()),
- "class", extension_scope,
- "name", JSObjectFieldName(options, field),
- "binaryReaderFn", JSBinaryReaderMethodName(options, field),
- "binaryWriterFn", JSBinaryWriterMethodName(options, field),
- "binaryMessageSerializeFn",
- (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) ?
- (SubmessageTypeRef(options, field) +
- ".serializeBinaryToWriter") : "undefined",
- "binaryMessageDeserializeFn",
- (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) ?
- (SubmessageTypeRef(options, field) +
- ".deserializeBinaryFromReader") : "undefined");
-
- printer->Print(
- " $isPacked$);\n",
- "isPacked", (field->is_packed() ? "true" : "false"));
- }
+ printer->Print(
+ "\n"
+ "$extendName$Binary[$index$] = new jspb.ExtensionFieldBinaryInfo(\n"
+ " $class$.$name$,\n"
+ " $binaryReaderFn$,\n"
+ " $binaryWriterFn$,\n"
+ " $binaryMessageSerializeFn$,\n"
+ " $binaryMessageDeserializeFn$,\n",
+ "extendName",
+ JSExtensionsObjectName(options, field->file(), field->containing_type()),
+ "index", SimpleItoa(field->number()), "class", extension_scope, "name",
+ JSObjectFieldName(options, field), "binaryReaderFn",
+ JSBinaryReaderMethodName(options, field), "binaryWriterFn",
+ JSBinaryWriterMethodName(options, field), "binaryMessageSerializeFn",
+ (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE)
+ ? (SubmessageTypeRef(options, field) + ".serializeBinaryToWriter")
+ : "undefined",
+ "binaryMessageDeserializeFn",
+ (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE)
+ ? (SubmessageTypeRef(options, field) + ".deserializeBinaryFromReader")
+ : "undefined");
+
+ printer->Print(" $isPacked$);\n", "isPacked",
+ (field->is_packed() ? "true" : "false"));
printer->Print(
"// This registers the extension field with the extended class, so that\n"
@@ -3145,7 +3182,7 @@ void Generator::GenerateExtension(const GeneratorOptions& options,
}
bool GeneratorOptions::ParseFromOptions(
- const vector< pair< string, string > >& options,
+ const std::vector< std::pair< string, string > >& options,
string* error) {
for (int i = 0; i < options.size(); i++) {
if (options[i].first == "add_require_for_enums") {
@@ -3199,12 +3236,6 @@ bool GeneratorOptions::ParseFromOptions(
return false;
}
one_output_file_per_input_file = true;
- } else if (options[i].first == "broken_proto3_semantics") {
- if (!options[i].second.empty()) {
- *error = "Unexpected option value for broken_proto3_semantics";
- return false;
- }
- broken_proto3_semantics = true;
} else {
// Assume any other option is an output directory, as long as it is a bare
// `key` rather than a `key=value` option.
@@ -3218,13 +3249,12 @@ bool GeneratorOptions::ParseFromOptions(
if (import_style != kImportClosure &&
(add_require_for_enums || testonly || !library.empty() ||
- error_on_name_conflict || broken_proto3_semantics ||
- extension != ".js" || one_output_file_per_input_file)) {
+ error_on_name_conflict || extension != ".js" ||
+ one_output_file_per_input_file)) {
*error =
"The add_require_for_enums, testonly, library, error_on_name_conflict, "
- "broken_proto3_semantics, extension, and "
- "one_output_file_per_input_file options should only be used for "
- "import_style=closure";
+ "extension, and one_output_file_per_input_file options should only be "
+ "used for import_style=closure";
return false;
}
@@ -3250,7 +3280,7 @@ GeneratorOptions::OutputMode GeneratorOptions::output_mode() const {
void Generator::GenerateFilesInDepOrder(
const GeneratorOptions& options,
io::Printer* printer,
- const vector<const FileDescriptor*>& files) const {
+ const std::vector<const FileDescriptor*>& files) const {
// Build a std::set over all files so that the DFS can detect when it recurses
// into a dep not specified in the user's command line.
std::set<const FileDescriptor*> all_files(files.begin(), files.end());
@@ -3307,8 +3337,8 @@ void Generator::GenerateFile(const GeneratorOptions& options,
}
}
- set<string> provided;
- set<const FieldDescriptor*> extensions;
+ std::set<string> provided;
+ std::set<const FieldDescriptor*> extensions;
for (int i = 0; i < file->extension_count(); i++) {
// We honor the jspb::ignore option here only when working with
// Closure-style imports. Use of this option is discouraged and so we want
@@ -3324,7 +3354,7 @@ void Generator::GenerateFile(const GeneratorOptions& options,
FindProvidesForFile(options, printer, file, &provided);
GenerateProvides(options, printer, &provided);
- vector<const FileDescriptor*> files;
+ std::vector<const FileDescriptor*> files;
files.push_back(file);
if (options.import_style == GeneratorOptions::kImportClosure) {
GenerateRequiresForLibrary(options, printer, files, &provided);
@@ -3334,7 +3364,7 @@ void Generator::GenerateFile(const GeneratorOptions& options,
// Generate code for top-level extensions. Extensions nested inside messages
// are emitted inside GenerateClassesAndEnums().
- for (set<const FieldDescriptor*>::const_iterator it = extensions.begin();
+ for (std::set<const FieldDescriptor*>::const_iterator it = extensions.begin();
it != extensions.end(); ++it) {
GenerateExtension(options, printer, *it);
}
@@ -3343,13 +3373,21 @@ void Generator::GenerateFile(const GeneratorOptions& options,
printer->Print("goog.object.extend(exports, $package$);\n",
"package", GetPath(options, file));
}
+
+ // Emit well-known type methods.
+ for (FileToc* toc = well_known_types_js; toc->name != NULL; toc++) {
+ string name = string("google/protobuf/") + toc->name;
+ if (name == StripProto(file->name()) + ".js") {
+ printer->Print(toc->data);
+ }
+ }
}
-bool Generator::GenerateAll(const vector<const FileDescriptor*>& files,
+bool Generator::GenerateAll(const std::vector<const FileDescriptor*>& files,
const string& parameter,
GeneratorContext* context,
string* error) const {
- vector< pair< string, string > > option_pairs;
+ std::vector< std::pair< string, string > > option_pairs;
ParseGeneratorParameter(parameter, &option_pairs);
GeneratorOptions options;
if (!options.ParseFromOptions(option_pairs, error)) {
@@ -3367,7 +3405,7 @@ bool Generator::GenerateAll(const vector<const FileDescriptor*>& files,
// Pull out all extensions -- we need these to generate all
// provides/requires.
- vector<const FieldDescriptor*> extensions;
+ std::vector<const FieldDescriptor*> extensions;
for (int i = 0; i < files.size(); i++) {
for (int j = 0; j < files[i]->extension_count(); j++) {
const FieldDescriptor* extension = files[i]->extension(j);
@@ -3396,7 +3434,7 @@ bool Generator::GenerateAll(const vector<const FileDescriptor*>& files,
return false;
}
} else if (options.output_mode() == GeneratorOptions::kOneOutputFilePerType) {
- set<const void*> allowed_set;
+ std::set<const void*> allowed_set;
if (!GenerateJspbAllowedSet(options, files, &allowed_set, error)) {
return false;
}
@@ -3467,7 +3505,7 @@ bool Generator::GenerateAll(const vector<const FileDescriptor*>& files,
GenerateHeader(options, &printer);
std::set<string> provided;
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
for (int j = 0; j < files[i]->extension_count(); j++) {
if (ShouldGenerateExtension(files[i]->extension(j))) {
diff --git a/src/google/protobuf/compiler/js/js_generator.h b/src/google/protobuf/compiler/js/js_generator.h
index 4ca3493c..6e932d7f 100755
--- a/src/google/protobuf/compiler/js/js_generator.h
+++ b/src/google/protobuf/compiler/js/js_generator.h
@@ -29,7 +29,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Generates JavaScript code for a given .proto file.
-
+//
#ifndef GOOGLE_PROTOBUF_COMPILER_JS_GENERATOR_H__
#define GOOGLE_PROTOBUF_COMPILER_JS_GENERATOR_H__
@@ -78,12 +78,11 @@ struct GeneratorOptions {
testonly(false),
library(""),
error_on_name_conflict(false),
- broken_proto3_semantics(false),
extension(".js"),
one_output_file_per_input_file(false) {}
bool ParseFromOptions(
- const vector< pair< string, string > >& options,
+ const std::vector< std::pair< string, string > >& options,
string* error);
// Returns the file name extension to use for generated code.
@@ -115,10 +114,6 @@ struct GeneratorOptions {
string library;
// Error if there are two types that would generate the same output file?
bool error_on_name_conflict;
- // Preserve the broken proto3 semantics from the old codegen? This amounts
- // to using proto2 field presence semantics even for proto3 files. DO NOT
- // USE except for migrating legacy code.
- bool broken_proto3_semantics;
// The extension to use for output file names.
string extension;
// Create a separate output file for each input file?
@@ -144,7 +139,7 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator {
virtual bool HasGenerateAll() const { return true; }
- virtual bool GenerateAll(const vector<const FileDescriptor*>& files,
+ virtual bool GenerateAll(const std::vector<const FileDescriptor*>& files,
const string& parameter,
GeneratorContext* context,
string* error) const;
@@ -156,7 +151,7 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator {
// Generate goog.provides() calls.
void FindProvides(const GeneratorOptions& options,
io::Printer* printer,
- const vector<const FileDescriptor*>& file,
+ const std::vector<const FileDescriptor*>& file,
std::set<string>* provided) const;
void FindProvidesForFile(const GeneratorOptions& options,
io::Printer* printer,
@@ -173,7 +168,7 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator {
// For extension fields at file scope.
void FindProvidesForFields(const GeneratorOptions& options,
io::Printer* printer,
- const vector<const FieldDescriptor*>& fields,
+ const std::vector<const FieldDescriptor*>& fields,
std::set<string>* provided) const;
// Print the goog.provides() found by the methods above.
void GenerateProvides(const GeneratorOptions& options,
@@ -185,10 +180,10 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator {
io::Printer* printer) const;
// Generate goog.requires() calls.
- void GenerateRequiresForLibrary(const GeneratorOptions& options,
- io::Printer* printer,
- const vector<const FileDescriptor*>& files,
- std::set<string>* provided) const;
+ void GenerateRequiresForLibrary(
+ const GeneratorOptions& options, io::Printer* printer,
+ const std::vector<const FileDescriptor*>& files,
+ std::set<string>* provided) const;
void GenerateRequiresForMessage(const GeneratorOptions& options,
io::Printer* printer,
const Descriptor* desc,
@@ -196,15 +191,13 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator {
// For extension fields at file scope.
void GenerateRequiresForExtensions(
const GeneratorOptions& options, io::Printer* printer,
- const vector<const FieldDescriptor*>& fields,
+ const std::vector<const FieldDescriptor*>& fields,
std::set<string>* provided) const;
void GenerateRequiresImpl(const GeneratorOptions& options,
- io::Printer* printer,
- std::set<string>* required,
+ io::Printer* printer, std::set<string>* required,
std::set<string>* forwards,
- std::set<string>* provided,
- bool require_jspb,
- bool require_extension) const;
+ std::set<string>* provided, bool require_jspb,
+ bool require_extension, bool require_map) const;
void FindRequiresForMessage(const GeneratorOptions& options,
const Descriptor* desc,
std::set<string>* required,
@@ -225,9 +218,9 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator {
// Generate definitions for all message classes and enums in all files,
// processing the files in dependence order.
- void GenerateFilesInDepOrder(const GeneratorOptions& options,
- io::Printer* printer,
- const vector<const FileDescriptor*>& file) const;
+ void GenerateFilesInDepOrder(
+ const GeneratorOptions& options, io::Printer* printer,
+ const std::vector<const FileDescriptor*>& file) const;
// Helper for above.
void GenerateFileAndDeps(const GeneratorOptions& options,
io::Printer* printer,
diff --git a/src/google/protobuf/compiler/js/well_known_types/any.js b/src/google/protobuf/compiler/js/well_known_types/any.js
new file mode 100644
index 00000000..22f18919
--- /dev/null
+++ b/src/google/protobuf/compiler/js/well_known_types/any.js
@@ -0,0 +1,80 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+/* This code will be inserted into generated code for
+ * google/protobuf/any.proto. */
+
+/**
+ * Returns the type name contained in this instance, if any.
+ * @return {string|undefined}
+ */
+proto.google.protobuf.Any.prototype.getTypeName = function() {
+ return this.getTypeUrl().split('/').pop();
+};
+
+
+/**
+ * Packs the given message instance into this Any.
+ * @param {!Uint8Array} serialized The serialized data to pack.
+ * @param {string} name The type name of this message object.
+ * @param {string=} opt_typeUrlPrefix the type URL prefix.
+ */
+proto.google.protobuf.Any.prototype.pack = function(serialized, name,
+ opt_typeUrlPrefix) {
+ if (!opt_typeUrlPrefix) {
+ opt_typeUrlPrefix = 'type.googleapis.com/';
+ }
+
+ if (opt_typeUrlPrefix.substr(-1) != '/') {
+ this.setTypeUrl(opt_typeUrlPrefix + '/' + name);
+ } else {
+ this.setTypeUrl(opt_typeUrlPrefix + name);
+ }
+
+ this.setValue(serialized);
+};
+
+
+/**
+ * @template T
+ * Unpacks this Any into the given message object.
+ * @param {function(Uint8Array):T} deserialize Function that will deserialize
+ * the binary data properly.
+ * @param {string} name The expected type name of this message object.
+ * @return {?T} If the name matched the expected name, returns the deserialized
+ * object, otherwise returns undefined.
+ */
+proto.google.protobuf.Any.prototype.unpack = function(deserialize, name) {
+ if (this.getTypeName() == name) {
+ return deserialize(this.getValue_asU8());
+ } else {
+ return null;
+ }
+};
diff --git a/src/google/protobuf/compiler/js/well_known_types/struct.js b/src/google/protobuf/compiler/js/well_known_types/struct.js
new file mode 100644
index 00000000..30e3d02a
--- /dev/null
+++ b/src/google/protobuf/compiler/js/well_known_types/struct.js
@@ -0,0 +1,168 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+/* This code will be inserted into generated code for
+ * google/protobuf/struct.proto. */
+
+/**
+ * Typedef representing plain JavaScript values that can go into a
+ * Struct.
+ * @typedef {null|number|string|boolean|Array|Object}
+ */
+proto.google.protobuf.JavaScriptValue;
+
+
+/**
+ * Converts this Value object to a plain JavaScript value.
+ * @return {?proto.google.protobuf.JavaScriptValue} a plain JavaScript
+ * value representing this Struct.
+ */
+proto.google.protobuf.Value.prototype.toJavaScript = function() {
+ var kindCase = proto.google.protobuf.Value.KindCase;
+ switch (this.getKindCase()) {
+ case kindCase.NULL_VALUE:
+ return null;
+ case kindCase.NUMBER_VALUE:
+ return this.getNumberValue();
+ case kindCase.STRING_VALUE:
+ return this.getStringValue();
+ case kindCase.BOOL_VALUE:
+ return this.getBoolValue();
+ case kindCase.STRUCT_VALUE:
+ return this.getStructValue().toJavaScript();
+ case kindCase.LIST_VALUE:
+ return this.getListValue().toJavaScript();
+ default:
+ throw new Error('Unexpected struct type');
+ }
+};
+
+
+/**
+ * Converts this JavaScript value to a new Value proto.
+ * @param {!proto.google.protobuf.JavaScriptValue} value The value to
+ * convert.
+ * @return {!proto.google.protobuf.Value} The newly constructed value.
+ */
+proto.google.protobuf.Value.fromJavaScript = function(value) {
+ var ret = new proto.google.protobuf.Value();
+ switch (goog.typeOf(value)) {
+ case 'string':
+ ret.setStringValue(/** @type {string} */ (value));
+ break;
+ case 'number':
+ ret.setNumberValue(/** @type {number} */ (value));
+ break;
+ case 'boolean':
+ ret.setBoolValue(/** @type {boolean} */ (value));
+ break;
+ case 'null':
+ ret.setNullValue(proto.google.protobuf.NullValue.NULL_VALUE);
+ break;
+ case 'array':
+ ret.setListValue(proto.google.protobuf.ListValue.fromJavaScript(
+ /** @type{!Array} */ (value)));
+ break;
+ case 'object':
+ ret.setStructValue(proto.google.protobuf.Struct.fromJavaScript(
+ /** @type{!Object} */ (value)));
+ break;
+ default:
+ throw new Error('Unexpected struct type.');
+ }
+
+ return ret;
+};
+
+
+/**
+ * Converts this ListValue object to a plain JavaScript array.
+ * @return {!Array} a plain JavaScript array representing this List.
+ */
+proto.google.protobuf.ListValue.prototype.toJavaScript = function() {
+ var ret = [];
+ var values = this.getValuesList();
+
+ for (var i = 0; i < values.length; i++) {
+ ret[i] = values[i].toJavaScript();
+ }
+
+ return ret;
+};
+
+
+/**
+ * Constructs a ListValue protobuf from this plain JavaScript array.
+ * @param {!Array} array a plain JavaScript array
+ * @return {proto.google.protobuf.ListValue} a new ListValue object
+ */
+proto.google.protobuf.ListValue.fromJavaScript = function(array) {
+ var ret = new proto.google.protobuf.ListValue();
+
+ for (var i = 0; i < array.length; i++) {
+ ret.addValues(proto.google.protobuf.Value.fromJavaScript(array[i]));
+ }
+
+ return ret;
+};
+
+
+/**
+ * Converts this Struct object to a plain JavaScript object.
+ * @return {!Object<string, !proto.google.protobuf.JavaScriptValue>} a plain
+ * JavaScript object representing this Struct.
+ */
+proto.google.protobuf.Struct.prototype.toJavaScript = function() {
+ var ret = {};
+
+ this.getFieldsMap().forEach(function(value, key) {
+ ret[key] = value.toJavaScript();
+ });
+
+ return ret;
+};
+
+
+/**
+ * Constructs a Struct protobuf from this plain JavaScript object.
+ * @param {!Object} obj a plain JavaScript object
+ * @return {proto.google.protobuf.Struct} a new Struct object
+ */
+proto.google.protobuf.Struct.fromJavaScript = function(obj) {
+ var ret = new proto.google.protobuf.Struct();
+ var map = ret.getFieldsMap();
+
+ for (var property in obj) {
+ var val = obj[property];
+ map.set(property, proto.google.protobuf.Value.fromJavaScript(val));
+ }
+
+ return ret;
+};
diff --git a/src/google/protobuf/compiler/js/well_known_types/timestamp.js b/src/google/protobuf/compiler/js/well_known_types/timestamp.js
new file mode 100644
index 00000000..77c07bb4
--- /dev/null
+++ b/src/google/protobuf/compiler/js/well_known_types/timestamp.js
@@ -0,0 +1,54 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+/* This code will be inserted into generated code for
+ * google/protobuf/timestamp.proto. */
+
+/**
+ * Returns a JavaScript 'Date' object corresponding to this Timestamp.
+ * @return {!Date}
+ */
+proto.google.protobuf.Timestamp.prototype.toDate = function() {
+ var seconds = this.getSeconds();
+ var nanos = this.getNanos();
+
+ return new Date((seconds * 1000) + (nanos / 1000000));
+};
+
+
+/**
+ * Sets the value of this Timestamp object to be the given Date.
+ * @param {!Date} value The value to set.
+ */
+proto.google.protobuf.Timestamp.prototype.fromDate = function(value) {
+ var millis = value.getTime();
+ this.setSeconds(Math.floor(value.getTime() / 1000));
+ this.setNanos(value.getMilliseconds() * 1000000);
+};
diff --git a/src/google/protobuf/compiler/js/well_known_types_embed.h b/src/google/protobuf/compiler/js/well_known_types_embed.h
new file mode 100644
index 00000000..174c665e
--- /dev/null
+++ b/src/google/protobuf/compiler/js/well_known_types_embed.h
@@ -0,0 +1,43 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JS_WELL_KNOWN_TYPES_EMBED_H__
+#define GOOGLE_PROTOBUF_COMPILER_JS_WELL_KNOWN_TYPES_EMBED_H__
+
+#include <stddef.h>
+
+struct FileToc {
+ const char* name;
+ const char* data;
+};
+
+extern struct FileToc well_known_types_js[];
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JS_WELL_KNOWN_TYPES_EMBED_H__
diff --git a/src/google/protobuf/compiler/main.cc b/src/google/protobuf/compiler/main.cc
index aca2a5b9..680d6428 100644
--- a/src/google/protobuf/compiler/main.cc
+++ b/src/google/protobuf/compiler/main.cc
@@ -39,12 +39,12 @@
#endif // ! OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP
#ifndef OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP
+#include <google/protobuf/compiler/csharp/csharp_generator.h>
#include <google/protobuf/compiler/javanano/javanano_generator.h>
+#include <google/protobuf/compiler/js/js_generator.h>
+#include <google/protobuf/compiler/objectivec/objectivec_generator.h>
#include <google/protobuf/compiler/php/php_generator.h>
#include <google/protobuf/compiler/ruby/ruby_generator.h>
-#include <google/protobuf/compiler/csharp/csharp_generator.h>
-#include <google/protobuf/compiler/objectivec/objectivec_generator.h>
-#include <google/protobuf/compiler/js/js_generator.h>
#endif // ! OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP
int main(int argc, char* argv[]) {
@@ -60,7 +60,7 @@ int main(int argc, char* argv[]) {
#ifndef OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP
// Proto2 Java
google::protobuf::compiler::java::JavaGenerator java_generator;
- cli.RegisterGenerator("--java_out", &java_generator,
+ cli.RegisterGenerator("--java_out", "--java_opt", &java_generator,
"Generate Java source file.");
#endif // !OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP
diff --git a/src/google/protobuf/compiler/mock_code_generator.cc b/src/google/protobuf/compiler/mock_code_generator.cc
index 1cc932dd..e82e6ae1 100644
--- a/src/google/protobuf/compiler/mock_code_generator.cc
+++ b/src/google/protobuf/compiler/mock_code_generator.cc
@@ -40,6 +40,7 @@
#endif
#include <vector>
+#include <google/protobuf/compiler/plugin.pb.h>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/testing/file.h>
@@ -59,8 +60,8 @@ namespace compiler {
// Returns the list of the names of files in all_files in the form of a
// comma-separated string.
-string CommaSeparatedList(const vector<const FileDescriptor*> all_files) {
- vector<string> names;
+string CommaSeparatedList(const std::vector<const FileDescriptor*> all_files) {
+ std::vector<string> names;
for (size_t i = 0; i < all_files.size(); i++) {
names.push_back(all_files[i]->name());
}
@@ -92,7 +93,8 @@ void MockCodeGenerator::ExpectGenerated(
File::GetContents(output_directory + "/" + GetOutputFileName(name, file),
&content, true));
- vector<string> lines = Split(content, "\n", true);
+ std::vector<string> lines =
+ Split(content, "\n", true);
while (!lines.empty() && lines.back().empty()) {
lines.pop_back();
@@ -101,7 +103,7 @@ void MockCodeGenerator::ExpectGenerated(
lines[i] += "\n";
}
- vector<string> insertion_list;
+ std::vector<string> insertion_list;
if (!insertions.empty()) {
SplitStringUsing(insertions, ",", &insertion_list);
}
@@ -159,6 +161,15 @@ bool MockCodeGenerator::Generate(
std::cerr << "Saw json_name: "
<< field_descriptor_proto.has_json_name() << std::endl;
abort();
+ } else if (command == "ShowVersionNumber") {
+ Version compiler_version;
+ context->GetCompilerVersion(&compiler_version);
+ std::cerr << "Saw compiler_version: "
+ << compiler_version.major() * 1000000 +
+ compiler_version.minor() * 1000 +
+ compiler_version.patch()
+ << " " << compiler_version.suffix() << std::endl;
+ abort();
} else {
GOOGLE_LOG(FATAL) << "Unknown MockCodeGenerator command: " << command;
}
@@ -166,7 +177,7 @@ bool MockCodeGenerator::Generate(
}
if (HasPrefixString(parameter, "insert=")) {
- vector<string> insert_into;
+ std::vector<string> insert_into;
SplitStringUsing(StripPrefixString(parameter, "insert="),
",", &insert_into);
@@ -230,7 +241,7 @@ string MockCodeGenerator::GetOutputFileContent(
const string& parameter,
const FileDescriptor* file,
GeneratorContext *context) {
- vector<const FileDescriptor*> all_files;
+ std::vector<const FileDescriptor*> all_files;
context->ListParsedFiles(&all_files);
return GetOutputFileContent(
generator_name, parameter, file->name(),
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_enum.cc b/src/google/protobuf/compiler/objectivec/objectivec_enum.cc
index 34e17823..02d60b3e 100644
--- a/src/google/protobuf/compiler/objectivec/objectivec_enum.cc
+++ b/src/google/protobuf/compiler/objectivec/objectivec_enum.cc
@@ -74,7 +74,7 @@ void EnumGenerator::GenerateHeader(io::Printer* printer) {
printer->Print("$comments$typedef$deprecated_attribute$ GPB_ENUM($name$) {\n",
"comments", enum_comments,
- "deprecated_attribute", GetOptionalDeprecatedAttribute(descriptor_),
+ "deprecated_attribute", GetOptionalDeprecatedAttribute(descriptor_, descriptor_->file()),
"name", name_);
printer->Indent();
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_extension.cc b/src/google/protobuf/compiler/objectivec/objectivec_extension.cc
index d0de1eca..7073173c 100644
--- a/src/google/protobuf/compiler/objectivec/objectivec_extension.cc
+++ b/src/google/protobuf/compiler/objectivec/objectivec_extension.cc
@@ -67,9 +67,12 @@ void ExtensionGenerator::GenerateMembersHeader(io::Printer* printer) {
} else {
vars["comments"] = "";
}
+ // Unlike normal message fields, check if the file for the extension was
+ // deprecated.
+ vars["deprecated_attribute"] = GetOptionalDeprecatedAttribute(descriptor_, descriptor_->file());
printer->Print(vars,
"$comments$"
- "+ (GPBExtensionDescriptor *)$method_name$;\n");
+ "+ (GPBExtensionDescriptor *)$method_name$$deprecated_attribute$;\n");
}
void ExtensionGenerator::GenerateStaticVariablesInitialization(
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_helpers.h b/src/google/protobuf/compiler/objectivec/objectivec_helpers.h
index 316069e1..c99262a1 100644
--- a/src/google/protobuf/compiler/objectivec/objectivec_helpers.h
+++ b/src/google/protobuf/compiler/objectivec/objectivec_helpers.h
@@ -53,66 +53,66 @@ struct Options {
};
// Escape C++ trigraphs by escaping question marks to "\?".
-string EscapeTrigraphs(const string& to_escape);
+string LIBPROTOC_EXPORT EscapeTrigraphs(const string& to_escape);
// Strips ".proto" or ".protodevel" from the end of a filename.
-string StripProto(const string& filename);
+string LIBPROTOC_EXPORT StripProto(const string& filename);
// Remove white space from either end of a StringPiece.
-void StringPieceTrimWhitespace(StringPiece* input);
+void LIBPROTOC_EXPORT StringPieceTrimWhitespace(StringPiece* input);
// Returns true if the name requires a ns_returns_not_retained attribute applied
// to it.
-bool IsRetainedName(const string& name);
+bool LIBPROTOC_EXPORT IsRetainedName(const string& name);
// Returns true if the name starts with "init" and will need to have special
// handling under ARC.
-bool IsInitName(const string& name);
+bool LIBPROTOC_EXPORT IsInitName(const string& name);
// Gets the objc_class_prefix.
-string FileClassPrefix(const FileDescriptor* file);
+string LIBPROTOC_EXPORT FileClassPrefix(const FileDescriptor* file);
// Gets the path of the file we're going to generate (sans the .pb.h
// extension). The path will be dependent on the objectivec package
// declared in the proto package.
-string FilePath(const FileDescriptor* file);
+string LIBPROTOC_EXPORT FilePath(const FileDescriptor* file);
// Just like FilePath(), but without the directory part.
-string FilePathBasename(const FileDescriptor* file);
+string LIBPROTOC_EXPORT FilePathBasename(const FileDescriptor* file);
// Gets the name of the root class we'll generate in the file. This class
// is not meant for external consumption, but instead contains helpers that
// the rest of the classes need
-string FileClassName(const FileDescriptor* file);
+string LIBPROTOC_EXPORT FileClassName(const FileDescriptor* file);
// These return the fully-qualified class name corresponding to the given
// descriptor.
-string ClassName(const Descriptor* descriptor);
-string ClassName(const Descriptor* descriptor, string* out_suffix_added);
-string EnumName(const EnumDescriptor* descriptor);
+string LIBPROTOC_EXPORT ClassName(const Descriptor* descriptor);
+string LIBPROTOC_EXPORT ClassName(const Descriptor* descriptor, string* out_suffix_added);
+string LIBPROTOC_EXPORT EnumName(const EnumDescriptor* descriptor);
// Returns the fully-qualified name of the enum value corresponding to the
// the descriptor.
-string EnumValueName(const EnumValueDescriptor* descriptor);
+string LIBPROTOC_EXPORT EnumValueName(const EnumValueDescriptor* descriptor);
// Returns the name of the enum value corresponding to the descriptor.
-string EnumValueShortName(const EnumValueDescriptor* descriptor);
+string LIBPROTOC_EXPORT EnumValueShortName(const EnumValueDescriptor* descriptor);
// Reverse what an enum does.
-string UnCamelCaseEnumShortName(const string& name);
+string LIBPROTOC_EXPORT UnCamelCaseEnumShortName(const string& name);
// Returns the name to use for the extension (used as the method off the file's
// Root class).
-string ExtensionMethodName(const FieldDescriptor* descriptor);
+string LIBPROTOC_EXPORT ExtensionMethodName(const FieldDescriptor* descriptor);
// Returns the transformed field name.
-string FieldName(const FieldDescriptor* field);
-string FieldNameCapitalized(const FieldDescriptor* field);
+string LIBPROTOC_EXPORT FieldName(const FieldDescriptor* field);
+string LIBPROTOC_EXPORT FieldNameCapitalized(const FieldDescriptor* field);
// Returns the transformed oneof name.
-string OneofEnumName(const OneofDescriptor* descriptor);
-string OneofName(const OneofDescriptor* descriptor);
-string OneofNameCapitalized(const OneofDescriptor* descriptor);
+string LIBPROTOC_EXPORT OneofEnumName(const OneofDescriptor* descriptor);
+string LIBPROTOC_EXPORT OneofName(const OneofDescriptor* descriptor);
+string LIBPROTOC_EXPORT OneofNameCapitalized(const OneofDescriptor* descriptor);
inline bool HasFieldPresence(const FileDescriptor* file) {
return file->syntax() != FileDescriptor::SYNTAX_PROTO3;
@@ -127,7 +127,7 @@ inline bool IsMapEntryMessage(const Descriptor* descriptor) {
}
// Reverse of the above.
-string UnCamelCaseFieldName(const string& name, const FieldDescriptor* field);
+string LIBPROTOC_EXPORT UnCamelCaseFieldName(const string& name, const FieldDescriptor* field);
enum ObjectiveCType {
OBJECTIVECTYPE_INT32,
@@ -150,8 +150,18 @@ enum FlagType {
};
template<class TDescriptor>
-string GetOptionalDeprecatedAttribute(const TDescriptor* descriptor, bool preSpace = true, bool postNewline = false) {
- if (descriptor->options().deprecated()) {
+string GetOptionalDeprecatedAttribute(
+ const TDescriptor* descriptor,
+ const FileDescriptor* file = NULL,
+ bool preSpace = true, bool postNewline = false) {
+ bool isDeprecated = descriptor->options().deprecated();
+ // The file is only passed when checking Messages & Enums, so those types
+ // get tagged. At the moment, it doesn't seem to make sense to tag every
+ // field or enum value with when the file is deprecated.
+ if (!isDeprecated && file) {
+ isDeprecated = file->options().deprecated();
+ }
+ if (isDeprecated) {
string result = "DEPRECATED_ATTRIBUTE";
if (preSpace) {
result.insert(0, " ");
@@ -165,42 +175,42 @@ string GetOptionalDeprecatedAttribute(const TDescriptor* descriptor, bool preSpa
}
}
-string GetCapitalizedType(const FieldDescriptor* field);
+string LIBPROTOC_EXPORT GetCapitalizedType(const FieldDescriptor* field);
-ObjectiveCType GetObjectiveCType(FieldDescriptor::Type field_type);
+ObjectiveCType LIBPROTOC_EXPORT GetObjectiveCType(FieldDescriptor::Type field_type);
inline ObjectiveCType GetObjectiveCType(const FieldDescriptor* field) {
return GetObjectiveCType(field->type());
}
-bool IsPrimitiveType(const FieldDescriptor* field);
-bool IsReferenceType(const FieldDescriptor* field);
+bool LIBPROTOC_EXPORT IsPrimitiveType(const FieldDescriptor* field);
+bool LIBPROTOC_EXPORT IsReferenceType(const FieldDescriptor* field);
-string GPBGenericValueFieldName(const FieldDescriptor* field);
-string DefaultValue(const FieldDescriptor* field);
-bool HasNonZeroDefaultValue(const FieldDescriptor* field);
+string LIBPROTOC_EXPORT GPBGenericValueFieldName(const FieldDescriptor* field);
+string LIBPROTOC_EXPORT DefaultValue(const FieldDescriptor* field);
+bool LIBPROTOC_EXPORT HasNonZeroDefaultValue(const FieldDescriptor* field);
-string BuildFlagsString(const FlagType type, const vector<string>& strings);
+string LIBPROTOC_EXPORT BuildFlagsString(const FlagType type, const vector<string>& strings);
// Builds HeaderDoc/appledoc style comments out of the comments in the .proto
// file.
-string BuildCommentsString(const SourceLocation& location,
+string LIBPROTOC_EXPORT BuildCommentsString(const SourceLocation& location,
bool prefer_single_line);
// The name the commonly used by the library when built as a framework.
// This lines up to the name used in the CocoaPod.
-extern const char* const ProtobufLibraryFrameworkName;
+extern LIBPROTOC_EXPORT const char* const ProtobufLibraryFrameworkName;
// Returns the CPP symbol name to use as the gate for framework style imports
// for the given framework name to use.
-string ProtobufFrameworkImportSymbol(const string& framework_name);
+string LIBPROTOC_EXPORT ProtobufFrameworkImportSymbol(const string& framework_name);
// Checks if the file is one of the proto's bundled with the library.
-bool IsProtobufLibraryBundledProtoFile(const FileDescriptor* file);
+bool LIBPROTOC_EXPORT IsProtobufLibraryBundledProtoFile(const FileDescriptor* file);
// Checks the prefix for the given files and outputs any warnings as needed. If
// there are flat out errors, then out_error is filled in with the first error
// and the result is false.
-bool ValidateObjCClassPrefixes(const vector<const FileDescriptor*>& files,
+bool LIBPROTOC_EXPORT ValidateObjCClassPrefixes(const vector<const FileDescriptor*>& files,
const Options& generation_options,
string* out_error);
@@ -234,7 +244,7 @@ class LIBPROTOC_EXPORT LineConsumer {
virtual bool ConsumeLine(const StringPiece& line, string* out_error) = 0;
};
-bool ParseSimpleFile(
+bool LIBPROTOC_EXPORT ParseSimpleFile(
const string& path, LineConsumer* line_consumer, string* out_error);
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_message.cc b/src/google/protobuf/compiler/objectivec/objectivec_message.cc
index 4c6e1b55..e0bd3dac 100644
--- a/src/google/protobuf/compiler/objectivec/objectivec_message.cc
+++ b/src/google/protobuf/compiler/objectivec/objectivec_message.cc
@@ -180,7 +180,10 @@ MessageGenerator::MessageGenerator(const string& root_classname,
: root_classname_(root_classname),
descriptor_(descriptor),
field_generators_(descriptor, options),
- class_name_(ClassName(descriptor_)) {
+ class_name_(ClassName(descriptor_)),
+ deprecated_attribute_(
+ GetOptionalDeprecatedAttribute(descriptor, descriptor->file(), false, true)) {
+
for (int i = 0; i < descriptor_->extension_count(); i++) {
extension_generators_.push_back(
new ExtensionGenerator(class_name_, descriptor_->extension(i)));
@@ -339,7 +342,7 @@ void MessageGenerator::GenerateMessageHeader(io::Printer* printer) {
printer->Print(
"$comments$$deprecated_attribute$@interface $classname$ : GPBMessage\n\n",
"classname", class_name_,
- "deprecated_attribute", GetOptionalDeprecatedAttribute(descriptor_, false, true),
+ "deprecated_attribute", deprecated_attribute_,
"comments", message_comments);
vector<char> seen_oneofs(descriptor_->oneof_decl_count(), 0);
@@ -396,6 +399,14 @@ void MessageGenerator::GenerateSource(io::Printer* printer) {
"\n",
"classname", class_name_);
+ if (!deprecated_attribute_.empty()) {
+ // No warnings when compiling the impl of this deprecated class.
+ printer->Print(
+ "#pragma clang diagnostic push\n"
+ "#pragma clang diagnostic ignored \"-Wdeprecated-implementations\"\n"
+ "\n");
+ }
+
printer->Print("@implementation $classname$\n\n",
"classname", class_name_);
@@ -601,6 +612,12 @@ void MessageGenerator::GenerateSource(io::Printer* printer) {
"}\n\n"
"@end\n\n");
+ if (!deprecated_attribute_.empty()) {
+ printer->Print(
+ "#pragma clang diagnostic pop\n"
+ "\n");
+ }
+
for (int i = 0; i < descriptor_->field_count(); i++) {
field_generators_.get(descriptor_->field(i))
.GenerateCFunctionImplementations(printer);
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_message.h b/src/google/protobuf/compiler/objectivec/objectivec_message.h
index 910535ac..0fb78bc0 100644
--- a/src/google/protobuf/compiler/objectivec/objectivec_message.h
+++ b/src/google/protobuf/compiler/objectivec/objectivec_message.h
@@ -85,6 +85,7 @@ class MessageGenerator {
const Descriptor* descriptor_;
FieldGeneratorMap field_generators_;
const string class_name_;
+ const string deprecated_attribute_;
vector<ExtensionGenerator*> extension_generators_;
vector<EnumGenerator*> enum_generators_;
vector<MessageGenerator*> nested_message_generators_;
diff --git a/src/google/protobuf/compiler/parser.cc b/src/google/protobuf/compiler/parser.cc
index 09c7a2b6..7a03d42b 100644
--- a/src/google/protobuf/compiler/parser.cc
+++ b/src/google/protobuf/compiler/parser.cc
@@ -249,11 +249,11 @@ bool Parser::ConsumeNumber(double* output, const char* error) {
input_->Next();
return true;
} else if (LookingAt("inf")) {
- *output = numeric_limits<double>::infinity();
+ *output = std::numeric_limits<double>::infinity();
input_->Next();
return true;
} else if (LookingAt("nan")) {
- *output = numeric_limits<double>::quiet_NaN();
+ *output = std::numeric_limits<double>::quiet_NaN();
input_->Next();
return true;
} else {
@@ -282,7 +282,7 @@ bool Parser::TryConsumeEndOfDeclaration(
const char* text, const LocationRecorder* location) {
if (LookingAt(text)) {
string leading, trailing;
- vector<string> detached;
+ std::vector<string> detached;
input_->NextWithComments(&trailing, &detached, &leading);
// Save the leading comments for next time, and recall the leading comments
@@ -404,7 +404,7 @@ void Parser::LocationRecorder::RecordLegacyLocation(const Message* descriptor,
void Parser::LocationRecorder::AttachComments(
string* leading, string* trailing,
- vector<string>* detached_comments) const {
+ std::vector<string>* detached_comments) const {
GOOGLE_CHECK(!location_->has_leading_comments());
GOOGLE_CHECK(!location_->has_trailing_comments());
@@ -487,7 +487,7 @@ bool Parser::ValidateEnum(const EnumDescriptorProto* proto) {
return false;
}
- set<int> used_values;
+ std::set<int> used_values;
bool has_duplicates = false;
for (int i = 0; i < proto->value_size(); ++i) {
const EnumValueDescriptorProto enum_value = proto->value(i);
@@ -2089,7 +2089,7 @@ bool SourceLocationTable::Find(
const Message* descriptor,
DescriptorPool::ErrorCollector::ErrorLocation location,
int* line, int* column) const {
- const pair<int, int>* result =
+ const std::pair<int, int>* result =
FindOrNull(location_map_, std::make_pair(descriptor, location));
if (result == NULL) {
*line = -1;
diff --git a/src/google/protobuf/compiler/parser.h b/src/google/protobuf/compiler/parser.h
index 0f80e78b..dd8b6586 100644
--- a/src/google/protobuf/compiler/parser.h
+++ b/src/google/protobuf/compiler/parser.h
@@ -257,7 +257,7 @@ class LIBPROTOBUF_EXPORT Parser {
// TODO(kenton): See comment on TryConsumeEndOfDeclaration(), above, for
// why this is const.
void AttachComments(string* leading, string* trailing,
- vector<string>* detached_comments) const;
+ std::vector<string>* detached_comments) const;
private:
// Indexes of parent and current location in the parent
@@ -520,7 +520,7 @@ class LIBPROTOBUF_EXPORT Parser {
// detached comments will be put into the leading_detached_comments field for
// the next element (See SourceCodeInfo.Location in descriptor.proto), when
// ConsumeEndOfDeclaration() is called.
- vector<string> upcoming_detached_comments_;
+ std::vector<string> upcoming_detached_comments_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Parser);
};
@@ -556,9 +556,9 @@ class LIBPROTOBUF_EXPORT SourceLocationTable {
void Clear();
private:
- typedef map<
- pair<const Message*, DescriptorPool::ErrorCollector::ErrorLocation>,
- pair<int, int> > LocationMap;
+ typedef std::map<
+ std::pair<const Message*, DescriptorPool::ErrorCollector::ErrorLocation>,
+ std::pair<int, int> > LocationMap;
LocationMap location_map_;
};
diff --git a/src/google/protobuf/compiler/parser_unittest.cc b/src/google/protobuf/compiler/parser_unittest.cc
index 1d623dd9..20140f8e 100644
--- a/src/google/protobuf/compiler/parser_unittest.cc
+++ b/src/google/protobuf/compiler/parser_unittest.cc
@@ -2218,7 +2218,7 @@ class SourceInfoTest : public ParserTest {
const char* expected_leading_comments,
const char* expected_trailing_comments,
const char* expected_leading_detached_comments) {
- pair<SpanMap::iterator, SpanMap::iterator> range =
+ std::pair<SpanMap::iterator, SpanMap::iterator> range =
spans_.equal_range(SpanKey(descriptor_proto, field, index));
if (start_marker == '\0') {
@@ -2229,8 +2229,8 @@ class SourceInfoTest : public ParserTest {
return true;
}
} else {
- pair<int, int> start_pos = FindOrDie(markers_, start_marker);
- pair<int, int> end_pos = FindOrDie(markers_, end_marker);
+ std::pair<int, int> start_pos = FindOrDie(markers_, start_marker);
+ std::pair<int, int> end_pos = FindOrDie(markers_, end_marker);
RepeatedField<int> expected_span;
expected_span.Add(start_pos.first);
@@ -2295,9 +2295,9 @@ class SourceInfoTest : public ParserTest {
}
};
- typedef multimap<SpanKey, const SourceCodeInfo::Location*> SpanMap;
+ typedef std::multimap<SpanKey, const SourceCodeInfo::Location*> SpanMap;
SpanMap spans_;
- map<char, pair<int, int> > markers_;
+ std::map<char, std::pair<int, int> > markers_;
string text_without_markers_;
void ExtractMarkers(const char* text) {
diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc
index 75ddb405..ec9a2365 100644
--- a/src/google/protobuf/compiler/php/php_generator.cc
+++ b/src/google/protobuf/compiler/php/php_generator.cc
@@ -43,6 +43,11 @@
using google::protobuf::internal::scoped_ptr;
const std::string kDescriptorFile = "google/protobuf/descriptor.proto";
+const std::string kEmptyFile = "google/protobuf/empty.proto";
+const std::string kEmptyMetadataFile = "GPBMetadata/Google/Protobuf/GPBEmpty.php";
+const std::string kDescriptorMetadataFile =
+ "GPBMetadata/Google/Protobuf/Internal/Descriptor.php";
+const std::string kDescriptorDirName = "Google/Protobuf/Internal";
const std::string kDescriptorPackageName = "Google\\Protobuf\\Internal";
namespace google {
@@ -52,38 +57,57 @@ namespace php {
// Forward decls.
std::string PhpName(const std::string& full_name, bool is_descriptor);
-std::string DefaultForField(google::protobuf::FieldDescriptor* field);
+std::string DefaultForField(FieldDescriptor* field);
std::string IntToString(int32 value);
-std::string GeneratedFileName(const std::string& proto_file,
- bool is_descriptor);
-std::string LabelForField(google::protobuf::FieldDescriptor* field);
-std::string TypeName(google::protobuf::FieldDescriptor* field);
+std::string FilenameToClassname(const string& filename);
+std::string GeneratedMetadataFileName(const std::string& proto_file,
+ bool is_descriptor);
+std::string LabelForField(FieldDescriptor* field);
+std::string TypeName(FieldDescriptor* field);
std::string UnderscoresToCamelCase(const string& name, bool cap_first_letter);
std::string EscapeDollor(const string& to_escape);
std::string BinaryToHex(const string& binary);
-void GenerateMessage(const string& name_prefix,
- const google::protobuf::Descriptor* message,
- bool is_descriptor,
- google::protobuf::io::Printer* printer);
-void GenerateEnum(const google::protobuf::EnumDescriptor* en,
- google::protobuf::io::Printer* printer);
-void Indent(google::protobuf::io::Printer* printer);
-void Outdent(google::protobuf::io::Printer* printer);
-
-std::string MessageName(const google::protobuf::Descriptor* message,
- bool is_descriptor) {
+void Indent(io::Printer* printer);
+void Outdent(io::Printer* printer);
+void GenerateMessageDocComment(io::Printer* printer, const Descriptor* message);
+void GenerateFieldDocComment(io::Printer* printer,
+ const FieldDescriptor* field);
+void GenerateEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_);
+void GenerateEnumValueDocComment(io::Printer* printer,
+ const EnumValueDescriptor* value);
+
+std::string RenameEmpty(const std::string& name) {
+ if (name == "Empty") {
+ return "GPBEmpty";
+ } else {
+ return name;
+ }
+}
+
+std::string MessagePrefix(const Descriptor* message) {
+ // Empty cannot be php class name.
+ if (message->name() == "Empty" &&
+ message->file()->package() == "google.protobuf") {
+ return "GPB";
+ } else {
+ return "";
+ }
+}
+
+std::string MessageName(const Descriptor* message, bool is_descriptor) {
string message_name = message->name();
- const google::protobuf::Descriptor* descriptor = message->containing_type();
+ const Descriptor* descriptor = message->containing_type();
while (descriptor != NULL) {
message_name = descriptor->name() + '_' + message_name;
descriptor = descriptor->containing_type();
}
+ message_name = MessagePrefix(message) + message_name;
+
return PhpName(message->file()->package(), is_descriptor) + '\\' +
message_name;
}
-std::string MessageFullName(const google::protobuf::Descriptor* message,
- bool is_descriptor) {
+std::string MessageFullName(const Descriptor* message, bool is_descriptor) {
if (is_descriptor) {
return StringReplace(message->full_name(),
"google.protobuf",
@@ -93,8 +117,7 @@ std::string MessageFullName(const google::protobuf::Descriptor* message,
}
}
-std::string EnumFullName(const google::protobuf::EnumDescriptor* envm,
- bool is_descriptor) {
+std::string EnumFullName(const EnumDescriptor* envm, bool is_descriptor) {
if (is_descriptor) {
return StringReplace(envm->full_name(),
"google.protobuf",
@@ -104,9 +127,9 @@ std::string EnumFullName(const google::protobuf::EnumDescriptor* envm,
}
}
-std::string EnumClassName(const google::protobuf::EnumDescriptor* envm) {
+std::string EnumClassName(const EnumDescriptor* envm) {
string enum_class_name = envm->name();
- const google::protobuf::Descriptor* descriptor = envm->containing_type();
+ const Descriptor* descriptor = envm->containing_type();
while (descriptor != NULL) {
enum_class_name = descriptor->name() + '_' + enum_class_name;
descriptor = descriptor->containing_type();
@@ -114,8 +137,7 @@ std::string EnumClassName(const google::protobuf::EnumDescriptor* envm) {
return enum_class_name;
}
-std::string EnumName(const google::protobuf::EnumDescriptor* envm,
- bool is_descriptor) {
+std::string EnumName(const EnumDescriptor* envm, bool is_descriptor) {
string enum_name = EnumClassName(envm);
return PhpName(envm->file()->package(), is_descriptor) + '\\' + enum_name;
}
@@ -142,7 +164,7 @@ std::string PhpName(const std::string& full_name, bool is_descriptor) {
return result;
}
-std::string DefaultForField(const google::protobuf::FieldDescriptor* field) {
+std::string DefaultForField(const FieldDescriptor* field) {
switch (field->type()) {
case FieldDescriptor::TYPE_INT32:
case FieldDescriptor::TYPE_INT64:
@@ -166,14 +188,63 @@ std::string DefaultForField(const google::protobuf::FieldDescriptor* field) {
}
}
-std::string GeneratedFileName(const std::string& proto_file,
- bool is_descriptor) {
+std::string GeneratedMetadataFileName(const std::string& proto_file,
+ bool is_descriptor) {
+ int start_index = 0;
+ int first_index = proto_file.find_first_of("/", start_index);
+ std::string result = "GPBMetadata/";
+
+ if (proto_file == kEmptyFile) {
+ return kEmptyMetadataFile;
+ }
if (is_descriptor) {
- return "descriptor_internal.pb.php";
+ return kDescriptorMetadataFile;
+ }
+
+ // Append directory name.
+ std::string file_no_suffix;
+ int lastindex = proto_file.find_last_of(".");
+ if (proto_file == kEmptyFile) {
+ return kEmptyMetadataFile;
} else {
- int lastindex = proto_file.find_last_of(".");
- return proto_file.substr(0, lastindex) + ".pb.php";
+ file_no_suffix = proto_file.substr(0, lastindex);
+ }
+
+ while (first_index != string::npos) {
+ result += UnderscoresToCamelCase(
+ file_no_suffix.substr(start_index, first_index - start_index), true);
+ result += "/";
+ start_index = first_index + 1;
+ first_index = file_no_suffix.find_first_of("/", start_index);
+ }
+
+ // Append file name.
+ result += RenameEmpty(UnderscoresToCamelCase(
+ file_no_suffix.substr(start_index, first_index - start_index), true));
+
+ return result += ".php";
+}
+
+std::string GeneratedMessageFileName(const Descriptor* message,
+ bool is_descriptor) {
+ std::string result = MessageName(message, is_descriptor);
+ for (int i = 0; i < result.size(); i++) {
+ if (result[i] == '\\') {
+ result[i] = '/';
+ }
}
+ return result + ".php";
+}
+
+std::string GeneratedEnumFileName(const EnumDescriptor* en,
+ bool is_descriptor) {
+ std::string result = EnumName(en, is_descriptor);
+ for (int i = 0; i < result.size(); i++) {
+ if (result[i] == '\\') {
+ result[i] = '/';
+ }
+ }
+ return result + ".php";
}
std::string IntToString(int32 value) {
@@ -182,7 +253,7 @@ std::string IntToString(int32 value) {
return os.str();
}
-std::string LabelForField(const google::protobuf::FieldDescriptor* field) {
+std::string LabelForField(const FieldDescriptor* field) {
switch (field->label()) {
case FieldDescriptor::LABEL_OPTIONAL: return "optional";
case FieldDescriptor::LABEL_REQUIRED: return "required";
@@ -191,7 +262,7 @@ std::string LabelForField(const google::protobuf::FieldDescriptor* field) {
}
}
-std::string TypeName(const google::protobuf::FieldDescriptor* field) {
+std::string TypeName(const FieldDescriptor* field) {
switch (field->type()) {
case FieldDescriptor::TYPE_INT32: return "int32";
case FieldDescriptor::TYPE_INT64: return "int64";
@@ -216,7 +287,7 @@ std::string TypeName(const google::protobuf::FieldDescriptor* field) {
}
std::string EnumOrMessageSuffix(
- const google::protobuf::FieldDescriptor* field, bool is_descriptor) {
+ const FieldDescriptor* field, bool is_descriptor) {
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
return ", '" + MessageFullName(field->message_type(), is_descriptor) + "'";
}
@@ -287,74 +358,77 @@ std::string BinaryToHex(const string& src) {
return dest;
}
-void Indent(google::protobuf::io::Printer* printer) {
+void Indent(io::Printer* printer) {
printer->Indent();
printer->Indent();
}
-void Outdent(google::protobuf::io::Printer* printer) {
+void Outdent(io::Printer* printer) {
printer->Outdent();
printer->Outdent();
}
-void GenerateField(const google::protobuf::FieldDescriptor* field,
- google::protobuf::io::Printer* printer, bool is_descriptor) {
+void GenerateField(const FieldDescriptor* field, io::Printer* printer,
+ bool is_descriptor) {
if (field->is_repeated()) {
+ GenerateFieldDocComment(printer, field);
printer->Print(
- "private $@name@;\n",
+ "private $^name^;\n",
"name", field->name());
} else if (field->containing_oneof()) {
// Oneof fields are handled by GenerateOneofField.
return;
} else {
+ GenerateFieldDocComment(printer, field);
printer->Print(
- "private $@name@ = @default@;\n",
+ "private $^name^ = ^default^;\n",
"name", field->name(),
"default", DefaultForField(field));
}
if (is_descriptor) {
printer->Print(
- "private $has_@name@ = false;\n",
+ "private $has_^name^ = false;\n",
"name", field->name());
}
}
-void GenerateOneofField(const google::protobuf::OneofDescriptor* oneof,
- google::protobuf::io::Printer* printer) {
+void GenerateOneofField(const OneofDescriptor* oneof, io::Printer* printer) {
// Oneof property needs to be protected in order to be accessed by parent
// class in implementation.
printer->Print(
- "protected $@name@;\n",
+ "protected $^name^;\n",
"name", oneof->name());
}
-void GenerateFieldAccessor(const google::protobuf::FieldDescriptor* field,
- bool is_descriptor,
- google::protobuf::io::Printer* printer) {
+void GenerateFieldAccessor(const FieldDescriptor* field, bool is_descriptor,
+ io::Printer* printer) {
const OneofDescriptor* oneof = field->containing_oneof();
// Generate getter.
if (oneof != NULL) {
+ GenerateFieldDocComment(printer, field);
printer->Print(
- "public function get@camel_name@()\n"
+ "public function get^camel_name^()\n"
"{\n"
- " return $this->readOneof(@number@);\n"
+ " return $this->readOneof(^number^);\n"
"}\n\n",
"camel_name", UnderscoresToCamelCase(field->name(), true),
"number", IntToString(field->number()));
} else {
+ GenerateFieldDocComment(printer, field);
printer->Print(
- "public function get@camel_name@()\n"
+ "public function get^camel_name^()\n"
"{\n"
- " return $this->@name@;\n"
+ " return $this->^name^;\n"
"}\n\n",
"camel_name", UnderscoresToCamelCase(field->name(), true), "name",
field->name());
}
// Generate setter.
+ GenerateFieldDocComment(printer, field);
printer->Print(
- "public function set@camel_name@(@var@)\n"
+ "public function set^camel_name^(^var^)\n"
"{\n",
"camel_name", UnderscoresToCamelCase(field->name(), true),
"var", (field->is_repeated() ||
@@ -367,16 +441,17 @@ void GenerateFieldAccessor(const google::protobuf::FieldDescriptor* field,
if (field->is_map()) {
} else if (field->is_repeated()) {
printer->Print(
- "GPBUtil::checkRepeatedField($var, GPBType::@type@",
+ "GPBUtil::checkRepeatedField($var, "
+ "\\Google\\Protobuf\\Internal\\GPBType::^type^",
"type", ToUpper(field->type_name()));
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
printer->Print(
- ", \\@class_name@);\n",
+ ", \\^class_name^);\n",
"class_name",
MessageName(field->message_type(), is_descriptor) + "::class");
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) {
printer->Print(
- ", @class_name@);\n",
+ ", ^class_name^);\n",
"class_name",
EnumName(field->enum_type(), is_descriptor) + "::class");
} else {
@@ -384,37 +459,37 @@ void GenerateFieldAccessor(const google::protobuf::FieldDescriptor* field,
}
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
printer->Print(
- "GPBUtil::checkMessage($var, \\@class_name@::class);\n",
+ "GPBUtil::checkMessage($var, \\^class_name^::class);\n",
"class_name", MessageName(field->message_type(), is_descriptor));
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) {
printer->Print(
- "GPBUtil::checkEnum($var, \\@class_name@::class);\n",
+ "GPBUtil::checkEnum($var, \\^class_name^::class);\n",
"class_name", EnumName(field->enum_type(), is_descriptor));
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) {
printer->Print(
- "GPBUtil::checkString($var, @utf8@);\n",
+ "GPBUtil::checkString($var, ^utf8^);\n",
"utf8",
field->type() == FieldDescriptor::TYPE_STRING ? "True": "False");
} else {
printer->Print(
- "GPBUtil::check@type@($var);\n",
+ "GPBUtil::check^type^($var);\n",
"type", UnderscoresToCamelCase(field->cpp_type_name(), true));
}
if (oneof != NULL) {
printer->Print(
- "$this->writeOneof(@number@, $var);\n",
+ "$this->writeOneof(^number^, $var);\n",
"number", IntToString(field->number()));
} else {
printer->Print(
- "$this->@name@ = $var;\n",
+ "$this->^name^ = $var;\n",
"name", field->name());
}
// Set has bit for proto2 only.
if (is_descriptor) {
printer->Print(
- "$this->has_@field_name@ = true;\n",
+ "$this->has_^field_name^ = true;\n",
"field_name", field->name());
}
@@ -426,125 +501,27 @@ void GenerateFieldAccessor(const google::protobuf::FieldDescriptor* field,
// Generate has method for proto2 only.
if (is_descriptor) {
printer->Print(
- "public function has@camel_name@()\n"
+ "public function has^camel_name^()\n"
"{\n"
- " return $this->has_@field_name@;\n"
+ " return $this->has_^field_name^;\n"
"}\n\n",
"camel_name", UnderscoresToCamelCase(field->name(), true),
"field_name", field->name());
}
}
-void GenerateRepeatedFieldDecode(
- const google::protobuf::FieldDescriptor* field,
- google::protobuf::io::Printer* printer) {
- printer->Print(
- "if ($input->read@cap_wire_type@($var)) return False;\n"
- "$this->get@cap_field_name@() []= $var;\n",
- "cap_field_name", UnderscoresToCamelCase(field->name(), true),
- "cap_wire_type", UnderscoresToCamelCase(field->type_name(), true));
-}
-
-void GeneratePrimitiveFieldDecode(
- const google::protobuf::FieldDescriptor* field,
- google::protobuf::io::Printer* printer) {
- printer->Print(
- "if ($input->read@cap_wire_type@($var)) return False;\n"
- "$this->set@cap_field_name@($var);\n",
- "cap_field_name", UnderscoresToCamelCase(field->name(), true),
- "cap_wire_type", UnderscoresToCamelCase(field->type_name(), true));
-}
-
-void GenerateFieldDecode(const google::protobuf::FieldDescriptor* field,
- google::protobuf::io::Printer* printer) {
- printer->Print(
- "case @number@:\n",
- "number", IntToString(field->number()));
- Indent(printer);
-
- if (field->is_repeated()) {
- GenerateRepeatedFieldDecode(field, printer);
- } else {
- GeneratePrimitiveFieldDecode(field, printer);
- }
-
- printer->Print(
- "break;\n");
- Outdent(printer);
-}
-
-void GenerateMessage(const string& name_prefix,
- const google::protobuf::Descriptor* message,
- bool is_descriptor,
- google::protobuf::io::Printer* printer) {
- // Don't generate MapEntry messages -- we use the PHP extension's native
- // support for map fields instead.
- if (message->options().map_entry()) {
- return;
- }
-
- string message_name = name_prefix.empty()?
- message->name() : name_prefix + "_" + message->name();
-
+void GenerateEnumToPool(const EnumDescriptor* en, io::Printer* printer) {
printer->Print(
- "class @name@ extends \\Google\\Protobuf\\Internal\\Message\n"
- "{\n",
- "name", message_name);
- Indent(printer);
-
- // Field and oneof definitions.
- for (int i = 0; i < message->field_count(); i++) {
- const FieldDescriptor* field = message->field(i);
- GenerateField(field, printer, is_descriptor);
- }
- for (int i = 0; i < message->oneof_decl_count(); i++) {
- const OneofDescriptor* oneof = message->oneof_decl(i);
- GenerateOneofField(oneof, printer);
- }
- printer->Print("\n");
-
- // Field and oneof accessors.
- for (int i = 0; i < message->field_count(); i++) {
- const FieldDescriptor* field = message->field(i);
- GenerateFieldAccessor(field, is_descriptor, printer);
- }
- for (int i = 0; i < message->oneof_decl_count(); i++) {
- const google::protobuf::OneofDescriptor* oneof = message->oneof_decl(i);
- printer->Print(
- "public function get@camel_name@()\n"
- "{\n"
- " return $this->@name@;\n"
- "}\n\n",
- "camel_name", UnderscoresToCamelCase(oneof->name(), true), "name",
- oneof->name());
- }
-
- Outdent(printer);
- printer->Print("}\n\n");
-
- // Nested messages and enums.
- for (int i = 0; i < message->nested_type_count(); i++) {
- GenerateMessage(message_name, message->nested_type(i), is_descriptor,
- printer);
- }
- for (int i = 0; i < message->enum_type_count(); i++) {
- GenerateEnum(message->enum_type(i), printer);
- }
-}
-
-void GenerateEnumToPool(const google::protobuf::EnumDescriptor* en,
- bool is_descriptor,
- google::protobuf::io::Printer* printer) {
- printer->Print(
- "$pool->addEnum('@name@', @class_name@::class)\n",
- "name", EnumFullName(en, is_descriptor),
+ "$pool->addEnum('^name^', "
+ "\\Google\\Protobuf\\Internal\\^class_name^::class)\n",
+ "name", EnumFullName(en, true),
"class_name", en->name());
Indent(printer);
for (int i = 0; i < en->value_count(); i++) {
const EnumValueDescriptor* value = en->value(i);
printer->Print(
- "->value(\"@name@\", @number@)\n",
+ "->value(\"^name^\", ^number^)\n",
"name", value->name(),
"number", IntToString(value->number()));
}
@@ -552,10 +529,8 @@ void GenerateEnumToPool(const google::protobuf::EnumDescriptor* en,
Outdent(printer);
}
-void GenerateMessageToPool(const string& name_prefix,
- const google::protobuf::Descriptor* message,
- bool is_descriptor,
- google::protobuf::io::Printer* printer) {
+void GenerateMessageToPool(const string& name_prefix, const Descriptor* message,
+ io::Printer* printer) {
// Don't generate MapEntry messages -- we use the PHP extension's native
// support for map fields instead.
if (message->options().map_entry()) {
@@ -565,8 +540,9 @@ void GenerateMessageToPool(const string& name_prefix,
message->name() : name_prefix + "_" + message->name();
printer->Print(
- "$pool->addMessage('@message@', @class_name@::class)\n",
- "message", MessageFullName(message, is_descriptor),
+ "$pool->addMessage('^message^', "
+ "\\Google\\Protobuf\\Internal\\^class_name^::class)\n",
+ "message", MessageFullName(message, true),
"class_name", class_name);
Indent(printer);
@@ -579,38 +555,40 @@ void GenerateMessageToPool(const string& name_prefix,
const FieldDescriptor* val =
field->message_type()->FindFieldByName("value");
printer->Print(
- "->map('@field@', GPBType::@key@, "
- "GPBType::@value@, @number@@other@)\n",
+ "->map('^field^', \\Google\\Protobuf\\Internal\\GPBType::^key^, "
+ "\\Google\\Protobuf\\Internal\\GPBType::^value^, ^number^^other^)\n",
"field", field->name(),
"key", ToUpper(key->type_name()),
"value", ToUpper(val->type_name()),
"number", SimpleItoa(field->number()),
- "other", EnumOrMessageSuffix(val, is_descriptor));
+ "other", EnumOrMessageSuffix(val, true));
} else if (!field->containing_oneof()) {
printer->Print(
- "->@label@('@field@', GPBType::@type@, @number@@other@)\n",
+ "->^label^('^field^', "
+ "\\Google\\Protobuf\\Internal\\GPBType::^type^, ^number^^other^)\n",
"field", field->name(),
"label", LabelForField(field),
"type", ToUpper(field->type_name()),
"number", SimpleItoa(field->number()),
- "other", EnumOrMessageSuffix(field, is_descriptor));
+ "other", EnumOrMessageSuffix(field, true));
}
}
// oneofs.
for (int i = 0; i < message->oneof_decl_count(); i++) {
const OneofDescriptor* oneof = message->oneof_decl(i);
- printer->Print("->oneof(@name@)\n",
+ printer->Print("->oneof(^name^)\n",
"name", oneof->name());
Indent(printer);
for (int index = 0; index < oneof->field_count(); index++) {
const FieldDescriptor* field = oneof->field(index);
printer->Print(
- "->value('@field@', GPBType::@type@, @number@@other@)\n",
+ "->value('^field^', "
+ "\\Google\\Protobuf\\Internal\\GPBType::^type^, ^number^^other^)\n",
"field", field->name(),
"type", ToUpper(field->type_name()),
"number", SimpleItoa(field->number()),
- "other", EnumOrMessageSuffix(field, is_descriptor));
+ "other", EnumOrMessageSuffix(field, true));
}
printer->Print("->finish()\n");
Outdent(printer);
@@ -625,33 +603,48 @@ void GenerateMessageToPool(const string& name_prefix,
"\n");
for (int i = 0; i < message->nested_type_count(); i++) {
- GenerateMessageToPool(class_name, message->nested_type(i), is_descriptor,
- printer);
+ GenerateMessageToPool(class_name, message->nested_type(i), printer);
}
for (int i = 0; i < message->enum_type_count(); i++) {
- GenerateEnumToPool(message->enum_type(i), is_descriptor, printer);
+ GenerateEnumToPool(message->enum_type(i), printer);
}
}
-void GenerateAddFileToPool(const google::protobuf::FileDescriptor* file,
- bool is_descriptor,
- google::protobuf::io::Printer* printer) {
- if (is_descriptor) {
- printer->Print("$pool = DescriptorPool::getGeneratedPool();\n\n");
+void GenerateAddFileToPool(const FileDescriptor* file, bool is_descriptor,
+ io::Printer* printer) {
+ printer->Print(
+ "public static $is_initialized = false;\n\n"
+ "public static function initOnce() {\n");
+ Indent(printer);
+
+ printer->Print(
+ "$pool = \\Google\\Protobuf\\Internal\\"
+ "DescriptorPool::getGeneratedPool();\n\n"
+ "if (static::$is_initialized == true) {\n"
+ " return;\n"
+ "}\n");
+ if (is_descriptor) {
for (int i = 0; i < file->message_type_count(); i++) {
- GenerateMessageToPool("", file->message_type(i), is_descriptor, printer);
+ GenerateMessageToPool("", file->message_type(i), printer);
}
for (int i = 0; i < file->enum_type_count(); i++) {
- GenerateEnumToPool(file->enum_type(i), is_descriptor, printer);
+ GenerateEnumToPool(file->enum_type(i), printer);
}
printer->Print(
"$pool->finish();\n");
} else {
- // Add messages and enums to descriptor pool.
- printer->Print("$pool = DescriptorPool::getGeneratedPool();\n\n");
+ for (int i = 0; i < file->dependency_count(); i++) {
+ const std::string& name = file->dependency(i)->name();
+ std::string dependency_filename =
+ GeneratedMetadataFileName(name, is_descriptor);
+ printer->Print(
+ "\\^name^::initOnce();\n",
+ "name", FilenameToClassname(dependency_filename));
+ }
+ // Add messages and enums to descriptor pool.
FileDescriptorSet files;
FileDescriptorProto* file_proto = files.add_file();
file->CopyTo(file_proto);
@@ -665,7 +658,7 @@ void GenerateAddFileToPool(const google::protobuf::FileDescriptor* file,
static const int kBytesPerLine = 30;
for (int i = 0; i < files_data.size(); i += kBytesPerLine) {
printer->Print(
- "\"@data@\"@dot@\n",
+ "\"^data^\"^dot^\n",
"data", BinaryToHex(files_data.substr(i, kBytesPerLine)),
"dot", i + kBytesPerLine < files_data.size() ? " ." : "");
}
@@ -674,38 +667,20 @@ void GenerateAddFileToPool(const google::protobuf::FileDescriptor* file,
printer->Print(
"));\n\n");
}
-
-}
-
-void GenerateEnum(const google::protobuf::EnumDescriptor* en,
- google::protobuf::io::Printer* printer) {
printer->Print(
- "class @name@\n"
- "{\n",
- "name", EnumClassName(en));
- Indent(printer);
-
- for (int i = 0; i < en->value_count(); i++) {
- const EnumValueDescriptor* value = en->value(i);
- printer->Print("const @name@ = @number@;\n",
- "name", value->name(),
- "number", IntToString(value->number()));
- }
+ "static::$is_initialized = true;\n");
Outdent(printer);
- printer->Print("}\n\n");
+ printer->Print("}\n");
}
-void GenerateUseDeclaration(bool is_descriptor,
- google::protobuf::io::Printer* printer) {
+void GenerateUseDeclaration(bool is_descriptor, io::Printer* printer) {
if (!is_descriptor) {
printer->Print(
- "use Google\\Protobuf\\Internal\\DescriptorPool;\n"
"use Google\\Protobuf\\Internal\\GPBType;\n"
"use Google\\Protobuf\\Internal\\RepeatedField;\n"
"use Google\\Protobuf\\Internal\\GPBUtil;\n\n");
} else {
printer->Print(
- "use Google\\Protobuf\\Internal\\DescriptorPool;\n"
"use Google\\Protobuf\\Internal\\GPBType;\n"
"use Google\\Protobuf\\Internal\\GPBWire;\n"
"use Google\\Protobuf\\Internal\\RepeatedField;\n"
@@ -714,42 +689,380 @@ void GenerateUseDeclaration(bool is_descriptor,
}
}
-void GenerateFile(const google::protobuf::FileDescriptor* file,
- bool is_descriptor, google::protobuf::io::Printer* printer) {
+void GenerateHead(const FileDescriptor* file, io::Printer* printer) {
printer->Print(
"<?php\n"
"# Generated by the protocol buffer compiler. DO NOT EDIT!\n"
- "# source: @filename@\n"
+ "# source: ^filename^\n"
"\n",
"filename", file->name());
+}
+
+std::string FilenameToClassname(const string& filename) {
+ int lastindex = filename.find_last_of(".");
+ std::string result = filename.substr(0, lastindex);
+ for (int i = 0; i < result.size(); i++) {
+ if (result[i] == '/') {
+ result[i] = '\\';
+ }
+ }
+ return result;
+}
+
+void GenerateMetadataFile(const FileDescriptor* file,
+ bool is_descriptor,
+ GeneratorContext* generator_context) {
+ std::string filename = GeneratedMetadataFileName(file->name(), is_descriptor);
+ scoped_ptr<io::ZeroCopyOutputStream> output(
+ generator_context->Open(filename));
+ io::Printer printer(output.get(), '^');
+
+ GenerateHead(file, &printer);
+
+ std::string fullname = FilenameToClassname(filename);
+ int lastindex = fullname.find_last_of("\\");
+
+ printer.Print(
+ "namespace ^name^;\n\n",
+ "name", fullname.substr(0, lastindex));
+
+ if (lastindex != string::npos) {
+ printer.Print(
+ "class ^name^\n"
+ "{\n",
+ "name", fullname.substr(lastindex + 1));
+ } else {
+ printer.Print(
+ "class ^name^\n"
+ "{\n",
+ "name", fullname);
+ }
+ Indent(&printer);
+
+ GenerateAddFileToPool(file, is_descriptor, &printer);
+
+ Outdent(&printer);
+ printer.Print("}\n\n");
+}
+
+void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en,
+ bool is_descriptor, GeneratorContext* generator_context) {
+ std::string filename = GeneratedEnumFileName(en, is_descriptor);
+ scoped_ptr<io::ZeroCopyOutputStream> output(
+ generator_context->Open(filename));
+ io::Printer printer(output.get(), '^');
+
+ GenerateHead(file, &printer);
+
+ std::string fullname = FilenameToClassname(filename);
+ int lastindex = fullname.find_last_of("\\");
+
if (!file->package().empty()) {
- printer->Print("namespace @name@;\n\n",
- "name", PhpName(file->package(), is_descriptor));
+ printer.Print(
+ "namespace ^name^;\n\n",
+ "name", fullname.substr(0, lastindex));
+ }
+
+ GenerateEnumDocComment(&printer, en);
+
+ if (lastindex != string::npos) {
+ printer.Print(
+ "class ^name^\n"
+ "{\n",
+ "name", fullname.substr(lastindex + 1));
+ } else {
+ printer.Print(
+ "class ^name^\n"
+ "{\n",
+ "name", fullname);
+ }
+ Indent(&printer);
+
+ for (int i = 0; i < en->value_count(); i++) {
+ const EnumValueDescriptor* value = en->value(i);
+ GenerateEnumValueDocComment(&printer, value);
+ printer.Print("const ^name^ = ^number^;\n",
+ "name", value->name(),
+ "number", IntToString(value->number()));
}
- for (int i = 0; i < file->dependency_count(); i++) {
- const std::string& name = file->dependency(i)->name();
- printer->Print("require_once('@name@');\n", "name",
- GeneratedFileName(name, is_descriptor));
+ Outdent(&printer);
+ printer.Print("}\n\n");
+}
+
+void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message,
+ bool is_descriptor,
+ GeneratorContext* generator_context) {
+ // Don't generate MapEntry messages -- we use the PHP extension's native
+ // support for map fields instead.
+ if (message->options().map_entry()) {
+ return;
+ }
+
+ std::string filename = GeneratedMessageFileName(message, is_descriptor);
+ scoped_ptr<io::ZeroCopyOutputStream> output(
+ generator_context->Open(filename));
+ io::Printer printer(output.get(), '^');
+
+ GenerateHead(file, &printer);
+
+ std::string fullname = FilenameToClassname(filename);
+ int lastindex = fullname.find_last_of("\\");
+
+ if (!file->package().empty()) {
+ printer.Print(
+ "namespace ^name^;\n\n",
+ "name", fullname.substr(0, lastindex));
+ }
+
+ GenerateUseDeclaration(is_descriptor, &printer);
+
+ GenerateMessageDocComment(&printer, message);
+ if (lastindex != string::npos) {
+ printer.Print(
+ "class ^name^ extends \\Google\\Protobuf\\Internal\\Message\n"
+ "{\n",
+ "name", fullname.substr(lastindex + 1));
+ } else {
+ printer.Print(
+ "class ^name^ extends \\Google\\Protobuf\\Internal\\Message\n"
+ "{\n",
+ "name", fullname);
+ }
+ Indent(&printer);
+
+ // Field and oneof definitions.
+ for (int i = 0; i < message->field_count(); i++) {
+ const FieldDescriptor* field = message->field(i);
+ GenerateField(field, &printer, is_descriptor);
+ }
+ for (int i = 0; i < message->oneof_decl_count(); i++) {
+ const OneofDescriptor* oneof = message->oneof_decl(i);
+ GenerateOneofField(oneof, &printer);
+ }
+ printer.Print("\n");
+
+ printer.Print(
+ "public function __construct() {\n");
+ Indent(&printer);
+
+ std::string metadata_filename =
+ GeneratedMetadataFileName(file->name(), is_descriptor);
+ std::string metadata_fullname = FilenameToClassname(metadata_filename);
+ printer.Print(
+ "\\^fullname^::initOnce();\n"
+ "parent::__construct();\n",
+ "fullname", metadata_fullname);
+
+ Outdent(&printer);
+ printer.Print("}\n\n");
+
+ // Field and oneof accessors.
+ for (int i = 0; i < message->field_count(); i++) {
+ const FieldDescriptor* field = message->field(i);
+ GenerateFieldAccessor(field, is_descriptor, &printer);
+ }
+ for (int i = 0; i < message->oneof_decl_count(); i++) {
+ const OneofDescriptor* oneof = message->oneof_decl(i);
+ printer.Print(
+ "public function get^camel_name^()\n"
+ "{\n"
+ " return $this->whichOneof(\"^name^\");\n"
+ "}\n\n",
+ "camel_name", UnderscoresToCamelCase(oneof->name(), true), "name",
+ oneof->name());
}
- GenerateUseDeclaration(is_descriptor, printer);
+ Outdent(&printer);
+ printer.Print("}\n\n");
+
+ // Nested messages and enums.
+ for (int i = 0; i < message->nested_type_count(); i++) {
+ GenerateMessageFile(file, message->nested_type(i), is_descriptor,
+ generator_context);
+ }
+ for (int i = 0; i < message->enum_type_count(); i++) {
+ GenerateEnumFile(file, message->enum_type(i), is_descriptor,
+ generator_context);
+ }
+}
+void GenerateFile(const FileDescriptor* file, bool is_descriptor,
+ GeneratorContext* generator_context) {
+ GenerateMetadataFile(file, is_descriptor, generator_context);
for (int i = 0; i < file->message_type_count(); i++) {
- GenerateMessage("", file->message_type(i), is_descriptor, printer);
+ GenerateMessageFile(file, file->message_type(i), is_descriptor,
+ generator_context);
}
for (int i = 0; i < file->enum_type_count(); i++) {
- GenerateEnum(file->enum_type(i), printer);
+ GenerateEnumFile(file, file->enum_type(i), is_descriptor,
+ generator_context);
+ }
+}
+
+static string EscapePhpdoc(const string& input) {
+ string result;
+ result.reserve(input.size() * 2);
+
+ char prev = '*';
+
+ for (string::size_type i = 0; i < input.size(); i++) {
+ char c = input[i];
+ switch (c) {
+ case '*':
+ // Avoid "/*".
+ if (prev == '/') {
+ result.append("&#42;");
+ } else {
+ result.push_back(c);
+ }
+ break;
+ case '/':
+ // Avoid "*/".
+ if (prev == '*') {
+ result.append("&#47;");
+ } else {
+ result.push_back(c);
+ }
+ break;
+ case '@':
+ // '@' starts phpdoc tags including the @deprecated tag, which will
+ // cause a compile-time error if inserted before a declaration that
+ // does not have a corresponding @Deprecated annotation.
+ result.append("&#64;");
+ break;
+ case '<':
+ // Avoid interpretation as HTML.
+ result.append("&lt;");
+ break;
+ case '>':
+ // Avoid interpretation as HTML.
+ result.append("&gt;");
+ break;
+ case '&':
+ // Avoid interpretation as HTML.
+ result.append("&amp;");
+ break;
+ case '\\':
+ // Java interprets Unicode escape sequences anywhere!
+ result.append("&#92;");
+ break;
+ default:
+ result.push_back(c);
+ break;
+ }
+
+ prev = c;
}
- GenerateAddFileToPool(file, is_descriptor, printer);
+ return result;
}
-bool Generator::Generate(
- const FileDescriptor* file,
- const string& parameter,
- GeneratorContext* generator_context,
- string* error) const {
+static void GenerateDocCommentBodyForLocation(
+ io::Printer* printer, const SourceLocation& location) {
+ string comments = location.leading_comments.empty() ?
+ location.trailing_comments : location.leading_comments;
+ if (!comments.empty()) {
+ // TODO(teboring): Ideally we should parse the comment text as Markdown and
+ // write it back as HTML, but this requires a Markdown parser. For now
+ // we just use <pre> to get fixed-width text formatting.
+
+ // If the comment itself contains block comment start or end markers,
+ // HTML-escape them so that they don't accidentally close the doc comment.
+ comments = EscapePhpdoc(comments);
+
+ vector<string> lines = Split(comments, "\n");
+ while (!lines.empty() && lines.back().empty()) {
+ lines.pop_back();
+ }
+
+ printer->Print(" * <pre>\n");
+ for (int i = 0; i < lines.size(); i++) {
+ // Most lines should start with a space. Watch out for lines that start
+ // with a /, since putting that right after the leading asterisk will
+ // close the comment.
+ if (!lines[i].empty() && lines[i][0] == '/') {
+ printer->Print(" * ^line^\n", "line", lines[i]);
+ } else {
+ printer->Print(" *^line^\n", "line", lines[i]);
+ }
+ }
+ printer->Print(
+ " * </pre>\n"
+ " *\n");
+ }
+}
+
+template <typename DescriptorType>
+static void GenerateDocCommentBody(
+ io::Printer* printer, const DescriptorType* descriptor) {
+ SourceLocation location;
+ if (descriptor->GetSourceLocation(&location)) {
+ GenerateDocCommentBodyForLocation(printer, location);
+ }
+}
+
+static string FirstLineOf(const string& value) {
+ string result = value;
+
+ string::size_type pos = result.find_first_of('\n');
+ if (pos != string::npos) {
+ result.erase(pos);
+ }
+
+ return result;
+}
+
+void GenerateMessageDocComment(io::Printer* printer,
+ const Descriptor* message) {
+ printer->Print("/**\n");
+ GenerateDocCommentBody(printer, message);
+ printer->Print(
+ " * Protobuf type <code>^fullname^</code>\n"
+ " */\n",
+ "fullname", EscapePhpdoc(message->full_name()));
+}
+
+void GenerateFieldDocComment(io::Printer* printer,
+ const FieldDescriptor* field) {
+ // In theory we should have slightly different comments for setters, getters,
+ // etc., but in practice everyone already knows the difference between these
+ // so it's redundant information.
+
+ // We start the comment with the main body based on the comments from the
+ // .proto file (if present). We then end with the field declaration, e.g.:
+ // optional string foo = 5;
+ // If the field is a group, the debug string might end with {.
+ printer->Print("/**\n");
+ GenerateDocCommentBody(printer, field);
+ printer->Print(
+ " * <code>^def^</code>\n",
+ "def", EscapePhpdoc(FirstLineOf(field->DebugString())));
+ printer->Print(" */\n");
+}
+
+void GenerateEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_) {
+ printer->Print("/**\n");
+ GenerateDocCommentBody(printer, enum_);
+ printer->Print(
+ " * Protobuf enum <code>^fullname^</code>\n"
+ " */\n",
+ "fullname", EscapePhpdoc(enum_->full_name()));
+}
+
+void GenerateEnumValueDocComment(io::Printer* printer,
+ const EnumValueDescriptor* value) {
+ printer->Print("/**\n");
+ GenerateDocCommentBody(printer, value);
+ printer->Print(
+ " * <code>^def^</code>\n"
+ " */\n",
+ "def", EscapePhpdoc(FirstLineOf(value->DebugString())));
+}
+
+bool Generator::Generate(const FileDescriptor* file, const string& parameter,
+ GeneratorContext* generator_context,
+ string* error) const {
bool is_descriptor = parameter == "internal";
if (is_descriptor && file->name() != kDescriptorFile) {
@@ -765,12 +1078,7 @@ bool Generator::Generate(
return false;
}
- std::string filename = GeneratedFileName(file->name(), is_descriptor);
- scoped_ptr<io::ZeroCopyOutputStream> output(
- generator_context->Open(filename));
- io::Printer printer(output.get(), '@');
-
- GenerateFile(file, is_descriptor, &printer);
+ GenerateFile(file, is_descriptor, generator_context);
return true;
}
diff --git a/src/google/protobuf/compiler/plugin.cc b/src/google/protobuf/compiler/plugin.cc
index e1087601..3848101d 100644
--- a/src/google/protobuf/compiler/plugin.cc
+++ b/src/google/protobuf/compiler/plugin.cc
@@ -62,9 +62,12 @@ namespace compiler {
class GeneratorResponseContext : public GeneratorContext {
public:
- GeneratorResponseContext(CodeGeneratorResponse* response,
- const vector<const FileDescriptor*>& parsed_files)
- : response_(response),
+ GeneratorResponseContext(
+ const Version& compiler_version,
+ CodeGeneratorResponse* response,
+ const std::vector<const FileDescriptor*>& parsed_files)
+ : compiler_version_(compiler_version),
+ response_(response),
parsed_files_(parsed_files) {}
virtual ~GeneratorResponseContext() {}
@@ -84,13 +87,18 @@ class GeneratorResponseContext : public GeneratorContext {
return new io::StringOutputStream(file->mutable_content());
}
- void ListParsedFiles(vector<const FileDescriptor*>* output) {
+ void ListParsedFiles(std::vector<const FileDescriptor*>* output) {
*output = parsed_files_;
}
+ void GetCompilerVersion(Version* version) const {
+ *version = compiler_version_;
+ }
+
private:
+ Version compiler_version_;
CodeGeneratorResponse* response_;
- const vector<const FileDescriptor*>& parsed_files_;
+ const std::vector<const FileDescriptor*>& parsed_files_;
};
bool GenerateCode(const CodeGeneratorRequest& request,
@@ -105,7 +113,7 @@ bool GenerateCode(const CodeGeneratorRequest& request,
}
}
- vector<const FileDescriptor*> parsed_files;
+ std::vector<const FileDescriptor*> parsed_files;
for (int i = 0; i < request.file_to_generate_size(); i++) {
parsed_files.push_back(pool.FindFileByName(request.file_to_generate(i)));
if (parsed_files.back() == NULL) {
@@ -116,7 +124,8 @@ bool GenerateCode(const CodeGeneratorRequest& request,
}
}
- GeneratorResponseContext context(response, parsed_files);
+ GeneratorResponseContext context(
+ request.compiler_version(), response, parsed_files);
string error;
bool succeeded = generator.GenerateAll(
diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc
index a4d4a530..686ee477 100644
--- a/src/google/protobuf/compiler/plugin.pb.cc
+++ b/src/google/protobuf/compiler/plugin.pb.cc
@@ -20,172 +20,681 @@
namespace google {
namespace protobuf {
namespace compiler {
+class VersionDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Version> {
+} _Version_default_instance_;
+class CodeGeneratorRequestDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorRequest> {
+} _CodeGeneratorRequest_default_instance_;
+class CodeGeneratorResponse_FileDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse_File> {
+} _CodeGeneratorResponse_File_default_instance_;
+class CodeGeneratorResponseDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse> {
+} _CodeGeneratorResponse_default_instance_;
+
+namespace protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto {
+
namespace {
-const ::google::protobuf::Descriptor* CodeGeneratorRequest_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- CodeGeneratorRequest_reflection_ = NULL;
-const ::google::protobuf::Descriptor* CodeGeneratorResponse_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- CodeGeneratorResponse_reflection_ = NULL;
-const ::google::protobuf::Descriptor* CodeGeneratorResponse_File_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- CodeGeneratorResponse_File_reflection_ = NULL;
+::google::protobuf::Metadata file_level_metadata[4];
} // namespace
-
-void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() GOOGLE_ATTRIBUTE_COLD;
-void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() {
- protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
- const ::google::protobuf::FileDescriptor* file =
- ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
- "google/protobuf/compiler/plugin.proto");
- GOOGLE_CHECK(file != NULL);
- CodeGeneratorRequest_descriptor_ = file->message_type(0);
- static const int CodeGeneratorRequest_offsets_[3] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, file_to_generate_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, parameter_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, proto_file_),
- };
- CodeGeneratorRequest_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- CodeGeneratorRequest_descriptor_,
- CodeGeneratorRequest::internal_default_instance(),
- CodeGeneratorRequest_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _has_bits_),
- -1,
- -1,
- sizeof(CodeGeneratorRequest),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _internal_metadata_));
- CodeGeneratorResponse_descriptor_ = file->message_type(1);
- static const int CodeGeneratorResponse_offsets_[2] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, error_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, file_),
- };
- CodeGeneratorResponse_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- CodeGeneratorResponse_descriptor_,
- CodeGeneratorResponse::internal_default_instance(),
- CodeGeneratorResponse_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _has_bits_),
- -1,
- -1,
- sizeof(CodeGeneratorResponse),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _internal_metadata_));
- CodeGeneratorResponse_File_descriptor_ = CodeGeneratorResponse_descriptor_->nested_type(0);
- static const int CodeGeneratorResponse_File_offsets_[3] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, insertion_point_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, content_),
- };
- CodeGeneratorResponse_File_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- CodeGeneratorResponse_File_descriptor_,
- CodeGeneratorResponse_File::internal_default_instance(),
- CodeGeneratorResponse_File_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _has_bits_),
- -1,
- -1,
- sizeof(CodeGeneratorResponse_File),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _internal_metadata_));
-}
+const ::google::protobuf::uint32 TableStruct::offsets[] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, major_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, minor_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, patch_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, suffix_),
+ 1,
+ 2,
+ 3,
+ 0,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, file_to_generate_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, parameter_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, proto_file_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, compiler_version_),
+ ~0u,
+ 0,
+ ~0u,
+ 1,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, insertion_point_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, content_),
+ 0,
+ 1,
+ 2,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, error_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, file_),
+ 0,
+ ~0u,
+};
+
+static const ::google::protobuf::internal::MigrationSchema schemas[] = {
+ { 0, 8, sizeof(Version)},
+ { 12, 20, sizeof(CodeGeneratorRequest)},
+ { 24, 31, sizeof(CodeGeneratorResponse_File)},
+ { 34, 40, sizeof(CodeGeneratorResponse)},
+};
+
+static ::google::protobuf::Message const * const file_default_instances[] = {
+ reinterpret_cast<const ::google::protobuf::Message*>(&_Version_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_CodeGeneratorRequest_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_CodeGeneratorResponse_File_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_CodeGeneratorResponse_default_instance_),
+};
namespace {
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
+void protobuf_AssignDescriptors() {
+ AddDescriptors();
+ ::google::protobuf::MessageFactory* factory = NULL;
+ AssignDescriptors(
+ "google/protobuf/compiler/plugin.proto", schemas, file_default_instances, TableStruct::offsets, factory,
+ file_level_metadata, NULL, NULL);
+}
+
void protobuf_AssignDescriptorsOnce() {
- ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
- &protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto);
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);
}
void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;
void protobuf_RegisterTypes(const ::std::string&) {
protobuf_AssignDescriptorsOnce();
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- CodeGeneratorRequest_descriptor_, CodeGeneratorRequest::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- CodeGeneratorResponse_descriptor_, CodeGeneratorResponse::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- CodeGeneratorResponse_File_descriptor_, CodeGeneratorResponse_File::internal_default_instance());
+ ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 4);
}
} // namespace
-void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto() {
- CodeGeneratorRequest_default_instance_.Shutdown();
- delete CodeGeneratorRequest_reflection_;
- CodeGeneratorResponse_default_instance_.Shutdown();
- delete CodeGeneratorResponse_reflection_;
- CodeGeneratorResponse_File_default_instance_.Shutdown();
- delete CodeGeneratorResponse_File_reflection_;
-}
-
-void protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl() {
- GOOGLE_PROTOBUF_VERIFY_VERSION;
-
- ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
- ::google::protobuf::internal::GetEmptyString();
- CodeGeneratorRequest_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- CodeGeneratorResponse_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- CodeGeneratorResponse_File_default_instance_.DefaultConstruct();
- CodeGeneratorRequest_default_instance_.get_mutable()->InitAsDefaultInstance();
- CodeGeneratorResponse_default_instance_.get_mutable()->InitAsDefaultInstance();
- CodeGeneratorResponse_File_default_instance_.get_mutable()->InitAsDefaultInstance();
+void TableStruct::Shutdown() {
+ _Version_default_instance_.Shutdown();
+ delete file_level_metadata[0].reflection;
+ _CodeGeneratorRequest_default_instance_.Shutdown();
+ delete file_level_metadata[1].reflection;
+ _CodeGeneratorResponse_File_default_instance_.Shutdown();
+ delete file_level_metadata[2].reflection;
+ _CodeGeneratorResponse_default_instance_.Shutdown();
+ delete file_level_metadata[3].reflection;
}
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once_);
-void protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto() {
- ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once_,
- &protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl);
-}
-void protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl() {
+void TableStruct::InitDefaultsImpl() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
- protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
+ ::google::protobuf::internal::InitProtobufDefaults();
+ ::google::protobuf::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
+ _Version_default_instance_.DefaultConstruct();
+ _CodeGeneratorRequest_default_instance_.DefaultConstruct();
+ _CodeGeneratorResponse_File_default_instance_.DefaultConstruct();
+ _CodeGeneratorResponse_default_instance_.DefaultConstruct();
+ _CodeGeneratorRequest_default_instance_.get_mutable()->compiler_version_ = const_cast< ::google::protobuf::compiler::Version*>(
+ ::google::protobuf::compiler::Version::internal_default_instance());
+}
+
+void InitDefaults() {
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);
+}
+void AddDescriptorsImpl() {
+ InitDefaults();
+ static const char descriptor[] = {
+ "\n%google/protobuf/compiler/plugin.proto\022"
+ "\030google.protobuf.compiler\032 google/protob"
+ "uf/descriptor.proto\"F\n\007Version\022\r\n\005major\030"
+ "\001 \001(\005\022\r\n\005minor\030\002 \001(\005\022\r\n\005patch\030\003 \001(\005\022\016\n\006s"
+ "uffix\030\004 \001(\t\"\272\001\n\024CodeGeneratorRequest\022\030\n\020"
+ "file_to_generate\030\001 \003(\t\022\021\n\tparameter\030\002 \001("
+ "\t\0228\n\nproto_file\030\017 \003(\0132$.google.protobuf."
+ "FileDescriptorProto\022;\n\020compiler_version\030"
+ "\003 \001(\0132!.google.protobuf.compiler.Version"
+ "\"\252\001\n\025CodeGeneratorResponse\022\r\n\005error\030\001 \001("
+ "\t\022B\n\004file\030\017 \003(\01324.google.protobuf.compil"
+ "er.CodeGeneratorResponse.File\032>\n\004File\022\014\n"
+ "\004name\030\001 \001(\t\022\027\n\017insertion_point\030\002 \001(\t\022\017\n\007"
+ "content\030\017 \001(\tB7\n\034com.google.protobuf.com"
+ "pilerB\014PluginProtosZ\tplugin_go"
+ };
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
- "\n%google/protobuf/compiler/plugin.proto\022"
- "\030google.protobuf.compiler\032 google/protob"
- "uf/descriptor.proto\"}\n\024CodeGeneratorRequ"
- "est\022\030\n\020file_to_generate\030\001 \003(\t\022\021\n\tparamet"
- "er\030\002 \001(\t\0228\n\nproto_file\030\017 \003(\0132$.google.pr"
- "otobuf.FileDescriptorProto\"\252\001\n\025CodeGener"
- "atorResponse\022\r\n\005error\030\001 \001(\t\022B\n\004file\030\017 \003("
- "\01324.google.protobuf.compiler.CodeGenerat"
- "orResponse.File\032>\n\004File\022\014\n\004name\030\001 \001(\t\022\027\n"
- "\017insertion_point\030\002 \001(\t\022\017\n\007content\030\017 \001(\tB"
- "7\n\034com.google.protobuf.compilerB\014PluginP"
- "rotosZ\tplugin_go", 456);
+ descriptor, 590);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"google/protobuf/compiler/plugin.proto", &protobuf_RegisterTypes);
- ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();
- ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto);
+ ::google::protobuf::protobuf_google_2fprotobuf_2fdescriptor_2eproto::AddDescriptors();
+ ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);
}
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once_);
-void protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() {
- ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once_,
- &protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl);
+void AddDescriptors() {
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
}
// Force AddDescriptors() to be called at static initialization time.
-struct StaticDescriptorInitializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto {
- StaticDescriptorInitializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto() {
- protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
+struct StaticDescriptorInitializer {
+ StaticDescriptorInitializer() {
+ AddDescriptors();
}
-} static_descriptor_initializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto_;
+} static_descriptor_initializer;
-namespace {
+} // namespace protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto
+
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int Version::kMajorFieldNumber;
+const int Version::kMinorFieldNumber;
+const int Version::kPatchFieldNumber;
+const int Version::kSuffixFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+Version::Version()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults();
+ }
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:google.protobuf.compiler.Version)
+}
+Version::Version(const Version& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ suffix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_suffix()) {
+ suffix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.suffix_);
+ }
+ ::memcpy(&major_, &from.major_,
+ reinterpret_cast<char*>(&patch_) -
+ reinterpret_cast<char*>(&major_) + sizeof(patch_));
+ // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.Version)
+}
-static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN;
-static void MergeFromFail(int line) {
- ::google::protobuf::internal::MergeFromFail(__FILE__, line);
+void Version::SharedCtor() {
+ _cached_size_ = 0;
+ suffix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ ::memset(&major_, 0, reinterpret_cast<char*>(&patch_) -
+ reinterpret_cast<char*>(&major_) + sizeof(patch_));
}
-} // namespace
+Version::~Version() {
+ // @@protoc_insertion_point(destructor:google.protobuf.compiler.Version)
+ SharedDtor();
+}
+
+void Version::SharedDtor() {
+ suffix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+
+void Version::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* Version::descriptor() {
+ protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[0].descriptor;
+}
+
+const Version& Version::default_instance() {
+ protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults();
+ return *internal_default_instance();
+}
+
+Version* Version::New(::google::protobuf::Arena* arena) const {
+ Version* n = new Version;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void Version::Clear() {
+// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.Version)
+ if (has_suffix()) {
+ GOOGLE_DCHECK(!suffix_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*suffix_.UnsafeRawStringPointer())->clear();
+ }
+ if (_has_bits_[0 / 32] & 14u) {
+ ::memset(&major_, 0, reinterpret_cast<char*>(&patch_) -
+ reinterpret_cast<char*>(&major_) + sizeof(patch_));
+ }
+ _has_bits_.Clear();
+ _internal_metadata_.Clear();
+}
+
+bool Version::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:google.protobuf.compiler.Version)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional int32 major = 1;
+ case 1: {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(8u)) {
+ set_has_major();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &major_)));
+ } else {
+ goto handle_unusual;
+ }
+ break;
+ }
+
+ // optional int32 minor = 2;
+ case 2: {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(16u)) {
+ set_has_minor();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &minor_)));
+ } else {
+ goto handle_unusual;
+ }
+ break;
+ }
+
+ // optional int32 patch = 3;
+ case 3: {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(24u)) {
+ set_has_patch();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &patch_)));
+ } else {
+ goto handle_unusual;
+ }
+ break;
+ }
+
+ // optional string suffix = 4;
+ case 4: {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(34u)) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_suffix()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->suffix().data(), this->suffix().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "google.protobuf.compiler.Version.suffix");
+ } else {
+ goto handle_unusual;
+ }
+ break;
+ }
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:google.protobuf.compiler.Version)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:google.protobuf.compiler.Version)
+ return false;
+#undef DO_
+}
+
+void Version::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:google.protobuf.compiler.Version)
+ // optional int32 major = 1;
+ if (has_major()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->major(), output);
+ }
+
+ // optional int32 minor = 2;
+ if (has_minor()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->minor(), output);
+ }
+
+ // optional int32 patch = 3;
+ if (has_patch()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->patch(), output);
+ }
+
+ // optional string suffix = 4;
+ if (has_suffix()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->suffix().data(), this->suffix().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "google.protobuf.compiler.Version.suffix");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 4, this->suffix(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:google.protobuf.compiler.Version)
+}
+
+::google::protobuf::uint8* Version::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.Version)
+ // optional int32 major = 1;
+ if (has_major()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->major(), target);
+ }
+
+ // optional int32 minor = 2;
+ if (has_minor()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->minor(), target);
+ }
+
+ // optional int32 patch = 3;
+ if (has_patch()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->patch(), target);
+ }
+
+ // optional string suffix = 4;
+ if (has_suffix()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->suffix().data(), this->suffix().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "google.protobuf.compiler.Version.suffix");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 4, this->suffix(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.Version)
+ return target;
+}
+
+size_t Version::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.Version)
+ size_t total_size = 0;
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ if (_has_bits_[0 / 32] & 15u) {
+ // optional string suffix = 4;
+ if (has_suffix()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->suffix());
+ }
+
+ // optional int32 major = 1;
+ if (has_major()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->major());
+ }
+
+ // optional int32 minor = 2;
+ if (has_minor()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->minor());
+ }
+
+ // optional int32 patch = 3;
+ if (has_patch()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->patch());
+ }
+
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void Version::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.compiler.Version)
+ GOOGLE_DCHECK_NE(&from, this);
+ const Version* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const Version>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.compiler.Version)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.compiler.Version)
+ MergeFrom(*source);
+ }
+}
+
+void Version::MergeFrom(const Version& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.Version)
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ if (from._has_bits_[0 / 32] & 15u) {
+ if (from.has_suffix()) {
+ set_has_suffix();
+ suffix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.suffix_);
+ }
+ if (from.has_major()) {
+ set_major(from.major());
+ }
+ if (from.has_minor()) {
+ set_minor(from.minor());
+ }
+ if (from.has_patch()) {
+ set_patch(from.patch());
+ }
+ }
+}
+
+void Version::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.compiler.Version)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void Version::CopyFrom(const Version& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.Version)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+bool Version::IsInitialized() const {
+ return true;
+}
+
+void Version::Swap(Version* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void Version::InternalSwap(Version* other) {
+ suffix_.Swap(&other->suffix_);
+ std::swap(major_, other->major_);
+ std::swap(minor_, other->minor_);
+ std::swap(patch_, other->patch_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata Version::GetMetadata() const {
+ protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[0];
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// Version
+
+// optional int32 major = 1;
+bool Version::has_major() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void Version::set_has_major() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void Version::clear_has_major() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void Version::clear_major() {
+ major_ = 0;
+ clear_has_major();
+}
+::google::protobuf::int32 Version::major() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.major)
+ return major_;
+}
+void Version::set_major(::google::protobuf::int32 value) {
+ set_has_major();
+ major_ = value;
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.major)
+}
+
+// optional int32 minor = 2;
+bool Version::has_minor() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void Version::set_has_minor() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void Version::clear_has_minor() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void Version::clear_minor() {
+ minor_ = 0;
+ clear_has_minor();
+}
+::google::protobuf::int32 Version::minor() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.minor)
+ return minor_;
+}
+void Version::set_minor(::google::protobuf::int32 value) {
+ set_has_minor();
+ minor_ = value;
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.minor)
+}
+
+// optional int32 patch = 3;
+bool Version::has_patch() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+void Version::set_has_patch() {
+ _has_bits_[0] |= 0x00000008u;
+}
+void Version::clear_has_patch() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+void Version::clear_patch() {
+ patch_ = 0;
+ clear_has_patch();
+}
+::google::protobuf::int32 Version::patch() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.patch)
+ return patch_;
+}
+void Version::set_patch(::google::protobuf::int32 value) {
+ set_has_patch();
+ patch_ = value;
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.patch)
+}
+
+// optional string suffix = 4;
+bool Version::has_suffix() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void Version::set_has_suffix() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void Version::clear_has_suffix() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void Version::clear_suffix() {
+ suffix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_suffix();
+}
+const ::std::string& Version::suffix() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.suffix)
+ return suffix_.GetNoArena();
+}
+void Version::set_suffix(const ::std::string& value) {
+ set_has_suffix();
+ suffix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.suffix)
+}
+#if LANG_CXX11
+void Version::set_suffix(::std::string&& value) {
+ set_has_suffix();
+ suffix_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.Version.suffix)
+}
+#endif
+void Version::set_suffix(const char* value) {
+ set_has_suffix();
+ suffix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.Version.suffix)
+}
+void Version::set_suffix(const char* value, size_t size) {
+ set_has_suffix();
+ suffix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.Version.suffix)
+}
+::std::string* Version::mutable_suffix() {
+ set_has_suffix();
+ // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.Version.suffix)
+ return suffix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* Version::release_suffix() {
+ // @@protoc_insertion_point(field_release:google.protobuf.compiler.Version.suffix)
+ clear_has_suffix();
+ return suffix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void Version::set_allocated_suffix(::std::string* suffix) {
+ if (suffix != NULL) {
+ set_has_suffix();
+ } else {
+ clear_has_suffix();
+ }
+ suffix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), suffix);
+ // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.Version.suffix)
+}
+
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -193,29 +702,41 @@ static void MergeFromFail(int line) {
const int CodeGeneratorRequest::kFileToGenerateFieldNumber;
const int CodeGeneratorRequest::kParameterFieldNumber;
const int CodeGeneratorRequest::kProtoFileFieldNumber;
+const int CodeGeneratorRequest::kCompilerVersionFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
CodeGeneratorRequest::CodeGeneratorRequest()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorRequest)
}
-
-void CodeGeneratorRequest::InitAsDefaultInstance() {
-}
-
CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0),
+ file_to_generate_(from.file_to_generate_),
+ proto_file_(from.proto_file_) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ parameter_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_parameter()) {
+ parameter_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.parameter_);
+ }
+ if (from.has_compiler_version()) {
+ compiler_version_ = new ::google::protobuf::compiler::Version(*from.compiler_version_);
+ } else {
+ compiler_version_ = NULL;
+ }
// @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorRequest)
}
void CodeGeneratorRequest::SharedCtor() {
_cached_size_ = 0;
parameter_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ compiler_version_ = NULL;
}
CodeGeneratorRequest::~CodeGeneratorRequest() {
@@ -225,6 +746,9 @@ CodeGeneratorRequest::~CodeGeneratorRequest() {
void CodeGeneratorRequest::SharedDtor() {
parameter_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (this != internal_default_instance()) {
+ delete compiler_version_;
+ }
}
void CodeGeneratorRequest::SetCachedSize(int size) const {
@@ -233,17 +757,15 @@ void CodeGeneratorRequest::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* CodeGeneratorRequest::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return CodeGeneratorRequest_descriptor_;
+ protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[1].descriptor;
}
const CodeGeneratorRequest& CodeGeneratorRequest::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
+ protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorRequest> CodeGeneratorRequest_default_instance_;
-
CodeGeneratorRequest* CodeGeneratorRequest::New(::google::protobuf::Arena* arena) const {
CodeGeneratorRequest* n = new CodeGeneratorRequest;
if (arena != NULL) {
@@ -254,15 +776,20 @@ CodeGeneratorRequest* CodeGeneratorRequest::New(::google::protobuf::Arena* arena
void CodeGeneratorRequest::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorRequest)
- if (has_parameter()) {
- parameter_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
file_to_generate_.Clear();
proto_file_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
+ if (_has_bits_[0 / 32] & 3u) {
+ if (has_parameter()) {
+ GOOGLE_DCHECK(!parameter_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*parameter_.UnsafeRawStringPointer())->clear();
+ }
+ if (has_compiler_version()) {
+ GOOGLE_DCHECK(compiler_version_ != NULL);
+ compiler_version_->::google::protobuf::compiler::Version::Clear();
+ }
}
+ _has_bits_.Clear();
+ _internal_metadata_.Clear();
}
bool CodeGeneratorRequest::MergePartialFromCodedStream(
@@ -271,14 +798,14 @@ bool CodeGeneratorRequest::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.compiler.CodeGeneratorRequest)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// repeated string file_to_generate = 1;
case 1: {
- if (tag == 10) {
- parse_file_to_generate:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->add_file_to_generate()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -289,15 +816,13 @@ bool CodeGeneratorRequest::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(10)) goto parse_file_to_generate;
- if (input->ExpectTag(18)) goto parse_parameter;
break;
}
// optional string parameter = 2;
case 2: {
- if (tag == 18) {
- parse_parameter:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(18u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_parameter()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -307,24 +832,32 @@ bool CodeGeneratorRequest::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(122)) goto parse_proto_file;
+ break;
+ }
+
+ // optional .google.protobuf.compiler.Version compiler_version = 3;
+ case 3: {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(26u)) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_compiler_version()));
+ } else {
+ goto handle_unusual;
+ }
break;
}
// repeated .google.protobuf.FileDescriptorProto proto_file = 15;
case 15: {
- if (tag == 122) {
- parse_proto_file:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(122u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_proto_file:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_proto_file()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(122)) goto parse_loop_proto_file;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -354,7 +887,7 @@ void CodeGeneratorRequest::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.compiler.CodeGeneratorRequest)
// repeated string file_to_generate = 1;
- for (int i = 0; i < this->file_to_generate_size(); i++) {
+ for (int i = 0, n = this->file_to_generate_size(); i < n; i++) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->file_to_generate(i).data(), this->file_to_generate(i).length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
@@ -373,6 +906,12 @@ void CodeGeneratorRequest::SerializeWithCachedSizes(
2, this->parameter(), output);
}
+ // optional .google.protobuf.compiler.Version compiler_version = 3;
+ if (has_compiler_version()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 3, *this->compiler_version_, output);
+ }
+
// repeated .google.protobuf.FileDescriptorProto proto_file = 15;
for (unsigned int i = 0, n = this->proto_file_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
@@ -388,10 +927,10 @@ void CodeGeneratorRequest::SerializeWithCachedSizes(
::google::protobuf::uint8* CodeGeneratorRequest::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorRequest)
// repeated string file_to_generate = 1;
- for (int i = 0; i < this->file_to_generate_size(); i++) {
+ for (int i = 0, n = this->file_to_generate_size(); i < n; i++) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->file_to_generate(i).data(), this->file_to_generate(i).length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
@@ -411,6 +950,13 @@ void CodeGeneratorRequest::SerializeWithCachedSizes(
2, this->parameter(), target);
}
+ // optional .google.protobuf.compiler.Version compiler_version = 3;
+ if (has_compiler_version()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 3, *this->compiler_version_, false, target);
+ }
+
// repeated .google.protobuf.FileDescriptorProto proto_file = 15;
for (unsigned int i = 0, n = this->proto_file_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
@@ -430,17 +976,15 @@ size_t CodeGeneratorRequest::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorRequest)
size_t total_size = 0;
- // optional string parameter = 2;
- if (has_parameter()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->parameter());
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
}
-
// repeated string file_to_generate = 1;
total_size += 1 *
::google::protobuf::internal::FromIntSize(this->file_to_generate_size());
- for (int i = 0; i < this->file_to_generate_size(); i++) {
+ for (int i = 0, n = this->file_to_generate_size(); i < n; i++) {
total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
this->file_to_generate(i));
}
@@ -456,10 +1000,21 @@ size_t CodeGeneratorRequest::ByteSizeLong() const {
}
}
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
+ if (_has_bits_[0 / 32] & 3u) {
+ // optional string parameter = 2;
+ if (has_parameter()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->parameter());
+ }
+
+ // optional .google.protobuf.compiler.Version compiler_version = 3;
+ if (has_compiler_version()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->compiler_version_);
+ }
+
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
@@ -470,7 +1025,7 @@ size_t CodeGeneratorRequest::ByteSizeLong() const {
void CodeGeneratorRequest::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.compiler.CodeGeneratorRequest)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const CodeGeneratorRequest* source =
::google::protobuf::internal::DynamicCastToGenerated<const CodeGeneratorRequest>(
&from);
@@ -479,32 +1034,24 @@ void CodeGeneratorRequest::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.compiler.CodeGeneratorRequest)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void CodeGeneratorRequest::MergeFrom(const CodeGeneratorRequest& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorRequest)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void CodeGeneratorRequest::UnsafeMergeFrom(const CodeGeneratorRequest& from) {
- GOOGLE_DCHECK(&from != this);
- file_to_generate_.UnsafeMergeFrom(from.file_to_generate_);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ file_to_generate_.MergeFrom(from.file_to_generate_);
proto_file_.MergeFrom(from.proto_file_);
- if (from._has_bits_[1 / 32] & (0xffu << (1 % 32))) {
+ if (from._has_bits_[0 / 32] & 3u) {
if (from.has_parameter()) {
set_has_parameter();
parameter_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.parameter_);
}
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
+ if (from.has_compiler_version()) {
+ mutable_compiler_version()->::google::protobuf::compiler::Version::MergeFrom(from.compiler_version());
+ }
}
}
@@ -519,11 +1066,10 @@ void CodeGeneratorRequest::CopyFrom(const CodeGeneratorRequest& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.CodeGeneratorRequest)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool CodeGeneratorRequest::IsInitialized() const {
-
if (!::google::protobuf::internal::AllAreInitialized(this->proto_file())) return false;
return true;
}
@@ -534,19 +1080,17 @@ void CodeGeneratorRequest::Swap(CodeGeneratorRequest* other) {
}
void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) {
file_to_generate_.UnsafeArenaSwap(&other->file_to_generate_);
- parameter_.Swap(&other->parameter_);
proto_file_.UnsafeArenaSwap(&other->proto_file_);
+ parameter_.Swap(&other->parameter_);
+ std::swap(compiler_version_, other->compiler_version_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata CodeGeneratorRequest::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = CodeGeneratorRequest_descriptor_;
- metadata.reflection = CodeGeneratorRequest_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[1];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -571,6 +1115,12 @@ void CodeGeneratorRequest::set_file_to_generate(int index, const ::std::string&
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
file_to_generate_.Mutable(index)->assign(value);
}
+#if LANG_CXX11
+void CodeGeneratorRequest::set_file_to_generate(int index, ::std::string&& value) {
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
+ file_to_generate_.Mutable(index)->assign(std::move(value));
+}
+#endif
void CodeGeneratorRequest::set_file_to_generate(int index, const char* value) {
file_to_generate_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
@@ -588,6 +1138,12 @@ void CodeGeneratorRequest::add_file_to_generate(const ::std::string& value) {
file_to_generate_.Add()->assign(value);
// @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
}
+#if LANG_CXX11
+void CodeGeneratorRequest::add_file_to_generate(::std::string&& value) {
+ file_to_generate_.Add()->assign(std::move(value));
+ // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
+}
+#endif
void CodeGeneratorRequest::add_file_to_generate(const char* value) {
file_to_generate_.Add()->assign(value);
// @@protoc_insertion_point(field_add_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
@@ -609,13 +1165,13 @@ CodeGeneratorRequest::mutable_file_to_generate() {
// optional string parameter = 2;
bool CodeGeneratorRequest::has_parameter() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
+ return (_has_bits_[0] & 0x00000001u) != 0;
}
void CodeGeneratorRequest::set_has_parameter() {
- _has_bits_[0] |= 0x00000002u;
+ _has_bits_[0] |= 0x00000001u;
}
void CodeGeneratorRequest::clear_has_parameter() {
- _has_bits_[0] &= ~0x00000002u;
+ _has_bits_[0] &= ~0x00000001u;
}
void CodeGeneratorRequest::clear_parameter() {
parameter_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -623,13 +1179,21 @@ void CodeGeneratorRequest::clear_parameter() {
}
const ::std::string& CodeGeneratorRequest::parameter() const {
// @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.parameter)
- return parameter_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return parameter_.GetNoArena();
}
void CodeGeneratorRequest::set_parameter(const ::std::string& value) {
set_has_parameter();
parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.parameter)
}
+#if LANG_CXX11
+void CodeGeneratorRequest::set_parameter(::std::string&& value) {
+ set_has_parameter();
+ parameter_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorRequest.parameter)
+}
+#endif
void CodeGeneratorRequest::set_parameter(const char* value) {
set_has_parameter();
parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -691,9 +1255,51 @@ CodeGeneratorRequest::proto_file() const {
return proto_file_;
}
-inline const CodeGeneratorRequest* CodeGeneratorRequest::internal_default_instance() {
- return &CodeGeneratorRequest_default_instance_.get();
+// optional .google.protobuf.compiler.Version compiler_version = 3;
+bool CodeGeneratorRequest::has_compiler_version() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void CodeGeneratorRequest::set_has_compiler_version() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void CodeGeneratorRequest::clear_has_compiler_version() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void CodeGeneratorRequest::clear_compiler_version() {
+ if (compiler_version_ != NULL) compiler_version_->::google::protobuf::compiler::Version::Clear();
+ clear_has_compiler_version();
+}
+const ::google::protobuf::compiler::Version& CodeGeneratorRequest::compiler_version() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.compiler_version)
+ return compiler_version_ != NULL ? *compiler_version_
+ : *::google::protobuf::compiler::Version::internal_default_instance();
+}
+::google::protobuf::compiler::Version* CodeGeneratorRequest::mutable_compiler_version() {
+ set_has_compiler_version();
+ if (compiler_version_ == NULL) {
+ compiler_version_ = new ::google::protobuf::compiler::Version;
+ }
+ // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.compiler_version)
+ return compiler_version_;
+}
+::google::protobuf::compiler::Version* CodeGeneratorRequest::release_compiler_version() {
+ // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.compiler_version)
+ clear_has_compiler_version();
+ ::google::protobuf::compiler::Version* temp = compiler_version_;
+ compiler_version_ = NULL;
+ return temp;
+}
+void CodeGeneratorRequest::set_allocated_compiler_version(::google::protobuf::compiler::Version* compiler_version) {
+ delete compiler_version_;
+ compiler_version_ = compiler_version;
+ if (compiler_version) {
+ set_has_compiler_version();
+ } else {
+ clear_has_compiler_version();
+ }
+ // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.compiler_version)
}
+
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -706,19 +1312,30 @@ const int CodeGeneratorResponse_File::kContentFieldNumber;
CodeGeneratorResponse_File::CodeGeneratorResponse_File()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorResponse.File)
}
-
-void CodeGeneratorResponse_File::InitAsDefaultInstance() {
-}
-
CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorResponse_File& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_name()) {
+ name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
+ }
+ insertion_point_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_insertion_point()) {
+ insertion_point_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.insertion_point_);
+ }
+ content_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_content()) {
+ content_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.content_);
+ }
// @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse.File)
}
@@ -746,17 +1363,15 @@ void CodeGeneratorResponse_File::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* CodeGeneratorResponse_File::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return CodeGeneratorResponse_File_descriptor_;
+ protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[2].descriptor;
}
const CodeGeneratorResponse_File& CodeGeneratorResponse_File::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
+ protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse_File> CodeGeneratorResponse_File_default_instance_;
-
CodeGeneratorResponse_File* CodeGeneratorResponse_File::New(::google::protobuf::Arena* arena) const {
CodeGeneratorResponse_File* n = new CodeGeneratorResponse_File;
if (arena != NULL) {
@@ -769,19 +1384,20 @@ void CodeGeneratorResponse_File::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorResponse.File)
if (_has_bits_[0 / 32] & 7u) {
if (has_name()) {
- name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*name_.UnsafeRawStringPointer())->clear();
}
if (has_insertion_point()) {
- insertion_point_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!insertion_point_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*insertion_point_.UnsafeRawStringPointer())->clear();
}
if (has_content()) {
- content_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!content_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*content_.UnsafeRawStringPointer())->clear();
}
}
_has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
+ _internal_metadata_.Clear();
}
bool CodeGeneratorResponse_File::MergePartialFromCodedStream(
@@ -790,13 +1406,14 @@ bool CodeGeneratorResponse_File::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.compiler.CodeGeneratorResponse.File)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional string name = 1;
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -806,14 +1423,13 @@ bool CodeGeneratorResponse_File::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(18)) goto parse_insertion_point;
break;
}
// optional string insertion_point = 2;
case 2: {
- if (tag == 18) {
- parse_insertion_point:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(18u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_insertion_point()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -823,14 +1439,13 @@ bool CodeGeneratorResponse_File::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(122)) goto parse_content;
break;
}
// optional string content = 15;
case 15: {
- if (tag == 122) {
- parse_content:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(122u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_content()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -840,7 +1455,6 @@ bool CodeGeneratorResponse_File::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -908,7 +1522,7 @@ void CodeGeneratorResponse_File::SerializeWithCachedSizes(
::google::protobuf::uint8* CodeGeneratorResponse_File::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorResponse.File)
// optional string name = 1;
if (has_name()) {
@@ -955,6 +1569,11 @@ size_t CodeGeneratorResponse_File::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorResponse.File)
size_t total_size = 0;
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
if (_has_bits_[0 / 32] & 7u) {
// optional string name = 1;
if (has_name()) {
@@ -978,11 +1597,6 @@ size_t CodeGeneratorResponse_File::ByteSizeLong() const {
}
}
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
@@ -992,7 +1606,7 @@ size_t CodeGeneratorResponse_File::ByteSizeLong() const {
void CodeGeneratorResponse_File::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse.File)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const CodeGeneratorResponse_File* source =
::google::protobuf::internal::DynamicCastToGenerated<const CodeGeneratorResponse_File>(
&from);
@@ -1001,22 +1615,15 @@ void CodeGeneratorResponse_File::MergeFrom(const ::google::protobuf::Message& fr
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.compiler.CodeGeneratorResponse.File)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void CodeGeneratorResponse_File::MergeFrom(const CodeGeneratorResponse_File& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse.File)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void CodeGeneratorResponse_File::UnsafeMergeFrom(const CodeGeneratorResponse_File& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ if (from._has_bits_[0 / 32] & 7u) {
if (from.has_name()) {
set_has_name();
name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
@@ -1030,10 +1637,6 @@ void CodeGeneratorResponse_File::UnsafeMergeFrom(const CodeGeneratorResponse_Fil
content_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.content_);
}
}
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
}
void CodeGeneratorResponse_File::CopyFrom(const ::google::protobuf::Message& from) {
@@ -1047,11 +1650,10 @@ void CodeGeneratorResponse_File::CopyFrom(const CodeGeneratorResponse_File& from
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.CodeGeneratorResponse.File)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool CodeGeneratorResponse_File::IsInitialized() const {
-
return true;
}
@@ -1069,15 +1671,202 @@ void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other)
}
::google::protobuf::Metadata CodeGeneratorResponse_File::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = CodeGeneratorResponse_File_descriptor_;
- metadata.reflection = CodeGeneratorResponse_File_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[2];
}
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// CodeGeneratorResponse_File
+
+// optional string name = 1;
+bool CodeGeneratorResponse_File::has_name() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void CodeGeneratorResponse_File::set_has_name() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void CodeGeneratorResponse_File::clear_has_name() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void CodeGeneratorResponse_File::clear_name() {
+ name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_name();
+}
+const ::std::string& CodeGeneratorResponse_File::name() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.name)
+ return name_.GetNoArena();
+}
+void CodeGeneratorResponse_File::set_name(const ::std::string& value) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name)
+}
+#if LANG_CXX11
+void CodeGeneratorResponse_File::set_name(::std::string&& value) {
+ set_has_name();
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.name)
+}
+#endif
+void CodeGeneratorResponse_File::set_name(const char* value) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.name)
+}
+void CodeGeneratorResponse_File::set_name(const char* value, size_t size) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.name)
+}
+::std::string* CodeGeneratorResponse_File::mutable_name() {
+ set_has_name();
+ // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.name)
+ return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* CodeGeneratorResponse_File::release_name() {
+ // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.name)
+ clear_has_name();
+ return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void CodeGeneratorResponse_File::set_allocated_name(::std::string* name) {
+ if (name != NULL) {
+ set_has_name();
+ } else {
+ clear_has_name();
+ }
+ name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
+ // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.name)
+}
+
+// optional string insertion_point = 2;
+bool CodeGeneratorResponse_File::has_insertion_point() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void CodeGeneratorResponse_File::set_has_insertion_point() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void CodeGeneratorResponse_File::clear_has_insertion_point() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void CodeGeneratorResponse_File::clear_insertion_point() {
+ insertion_point_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_insertion_point();
+}
+const ::std::string& CodeGeneratorResponse_File::insertion_point() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
+ return insertion_point_.GetNoArena();
+}
+void CodeGeneratorResponse_File::set_insertion_point(const ::std::string& value) {
+ set_has_insertion_point();
+ insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
+}
+#if LANG_CXX11
+void CodeGeneratorResponse_File::set_insertion_point(::std::string&& value) {
+ set_has_insertion_point();
+ insertion_point_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
+}
+#endif
+void CodeGeneratorResponse_File::set_insertion_point(const char* value) {
+ set_has_insertion_point();
+ insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
+}
+void CodeGeneratorResponse_File::set_insertion_point(const char* value, size_t size) {
+ set_has_insertion_point();
+ insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
+}
+::std::string* CodeGeneratorResponse_File::mutable_insertion_point() {
+ set_has_insertion_point();
+ // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
+ return insertion_point_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* CodeGeneratorResponse_File::release_insertion_point() {
+ // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
+ clear_has_insertion_point();
+ return insertion_point_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void CodeGeneratorResponse_File::set_allocated_insertion_point(::std::string* insertion_point) {
+ if (insertion_point != NULL) {
+ set_has_insertion_point();
+ } else {
+ clear_has_insertion_point();
+ }
+ insertion_point_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), insertion_point);
+ // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
+}
-// -------------------------------------------------------------------
+// optional string content = 15;
+bool CodeGeneratorResponse_File::has_content() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void CodeGeneratorResponse_File::set_has_content() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void CodeGeneratorResponse_File::clear_has_content() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void CodeGeneratorResponse_File::clear_content() {
+ content_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_content();
+}
+const ::std::string& CodeGeneratorResponse_File::content() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.content)
+ return content_.GetNoArena();
+}
+void CodeGeneratorResponse_File::set_content(const ::std::string& value) {
+ set_has_content();
+ content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content)
+}
+#if LANG_CXX11
+void CodeGeneratorResponse_File::set_content(::std::string&& value) {
+ set_has_content();
+ content_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.content)
+}
+#endif
+void CodeGeneratorResponse_File::set_content(const char* value) {
+ set_has_content();
+ content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.content)
+}
+void CodeGeneratorResponse_File::set_content(const char* value, size_t size) {
+ set_has_content();
+ content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.content)
+}
+::std::string* CodeGeneratorResponse_File::mutable_content() {
+ set_has_content();
+ // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.content)
+ return content_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* CodeGeneratorResponse_File::release_content() {
+ // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.content)
+ clear_has_content();
+ return content_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void CodeGeneratorResponse_File::set_allocated_content(::std::string* content) {
+ if (content != NULL) {
+ set_has_content();
+ } else {
+ clear_has_content();
+ }
+ content_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), content);
+ // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content)
+}
+
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int CodeGeneratorResponse::kErrorFieldNumber;
@@ -1086,19 +1875,23 @@ const int CodeGeneratorResponse::kFileFieldNumber;
CodeGeneratorResponse::CodeGeneratorResponse()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorResponse)
}
-
-void CodeGeneratorResponse::InitAsDefaultInstance() {
-}
-
CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0),
+ file_(from.file_) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ error_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_error()) {
+ error_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.error_);
+ }
// @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse)
}
@@ -1122,17 +1915,15 @@ void CodeGeneratorResponse::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* CodeGeneratorResponse::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return CodeGeneratorResponse_descriptor_;
+ protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[3].descriptor;
}
const CodeGeneratorResponse& CodeGeneratorResponse::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
+ protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse> CodeGeneratorResponse_default_instance_;
-
CodeGeneratorResponse* CodeGeneratorResponse::New(::google::protobuf::Arena* arena) const {
CodeGeneratorResponse* n = new CodeGeneratorResponse;
if (arena != NULL) {
@@ -1143,14 +1934,13 @@ CodeGeneratorResponse* CodeGeneratorResponse::New(::google::protobuf::Arena* are
void CodeGeneratorResponse::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorResponse)
+ file_.Clear();
if (has_error()) {
- error_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!error_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*error_.UnsafeRawStringPointer())->clear();
}
- file_.Clear();
_has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
+ _internal_metadata_.Clear();
}
bool CodeGeneratorResponse::MergePartialFromCodedStream(
@@ -1159,13 +1949,14 @@ bool CodeGeneratorResponse::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.compiler.CodeGeneratorResponse)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional string error = 1;
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_error()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -1175,24 +1966,20 @@ bool CodeGeneratorResponse::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(122)) goto parse_file;
break;
}
// repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15;
case 15: {
- if (tag == 122) {
- parse_file:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(122u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_file:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_file()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(122)) goto parse_loop_file;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -1246,7 +2033,7 @@ void CodeGeneratorResponse::SerializeWithCachedSizes(
::google::protobuf::uint8* CodeGeneratorResponse::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorResponse)
// optional string error = 1;
if (has_error()) {
@@ -1278,13 +2065,11 @@ size_t CodeGeneratorResponse::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorResponse)
size_t total_size = 0;
- // optional string error = 1;
- if (has_error()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->error());
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
}
-
// repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15;
{
unsigned int count = this->file_size();
@@ -1296,11 +2081,13 @@ size_t CodeGeneratorResponse::ByteSizeLong() const {
}
}
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
+ // optional string error = 1;
+ if (has_error()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->error());
}
+
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
@@ -1310,7 +2097,7 @@ size_t CodeGeneratorResponse::ByteSizeLong() const {
void CodeGeneratorResponse::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const CodeGeneratorResponse* source =
::google::protobuf::internal::DynamicCastToGenerated<const CodeGeneratorResponse>(
&from);
@@ -1319,31 +2106,18 @@ void CodeGeneratorResponse::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.compiler.CodeGeneratorResponse)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void CodeGeneratorResponse::MergeFrom(const CodeGeneratorResponse& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void CodeGeneratorResponse::UnsafeMergeFrom(const CodeGeneratorResponse& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
file_.MergeFrom(from.file_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_error()) {
- set_has_error();
- error_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.error_);
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
+ if (from.has_error()) {
+ set_has_error();
+ error_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.error_);
}
}
@@ -1358,11 +2132,10 @@ void CodeGeneratorResponse::CopyFrom(const CodeGeneratorResponse& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.CodeGeneratorResponse)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool CodeGeneratorResponse::IsInitialized() const {
-
return true;
}
@@ -1371,191 +2144,19 @@ void CodeGeneratorResponse::Swap(CodeGeneratorResponse* other) {
InternalSwap(other);
}
void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) {
- error_.Swap(&other->error_);
file_.UnsafeArenaSwap(&other->file_);
+ error_.Swap(&other->error_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata CodeGeneratorResponse::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = CodeGeneratorResponse_descriptor_;
- metadata.reflection = CodeGeneratorResponse_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[3];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// CodeGeneratorResponse_File
-
-// optional string name = 1;
-bool CodeGeneratorResponse_File::has_name() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void CodeGeneratorResponse_File::set_has_name() {
- _has_bits_[0] |= 0x00000001u;
-}
-void CodeGeneratorResponse_File::clear_has_name() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void CodeGeneratorResponse_File::clear_name() {
- name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_name();
-}
-const ::std::string& CodeGeneratorResponse_File::name() const {
- // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void CodeGeneratorResponse_File::set_name(const ::std::string& value) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name)
-}
-void CodeGeneratorResponse_File::set_name(const char* value) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.name)
-}
-void CodeGeneratorResponse_File::set_name(const char* value, size_t size) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.name)
-}
-::std::string* CodeGeneratorResponse_File::mutable_name() {
- set_has_name();
- // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.name)
- return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* CodeGeneratorResponse_File::release_name() {
- // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.name)
- clear_has_name();
- return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void CodeGeneratorResponse_File::set_allocated_name(::std::string* name) {
- if (name != NULL) {
- set_has_name();
- } else {
- clear_has_name();
- }
- name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
- // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.name)
-}
-
-// optional string insertion_point = 2;
-bool CodeGeneratorResponse_File::has_insertion_point() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void CodeGeneratorResponse_File::set_has_insertion_point() {
- _has_bits_[0] |= 0x00000002u;
-}
-void CodeGeneratorResponse_File::clear_has_insertion_point() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void CodeGeneratorResponse_File::clear_insertion_point() {
- insertion_point_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_insertion_point();
-}
-const ::std::string& CodeGeneratorResponse_File::insertion_point() const {
- // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
- return insertion_point_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void CodeGeneratorResponse_File::set_insertion_point(const ::std::string& value) {
- set_has_insertion_point();
- insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
-}
-void CodeGeneratorResponse_File::set_insertion_point(const char* value) {
- set_has_insertion_point();
- insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
-}
-void CodeGeneratorResponse_File::set_insertion_point(const char* value, size_t size) {
- set_has_insertion_point();
- insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
-}
-::std::string* CodeGeneratorResponse_File::mutable_insertion_point() {
- set_has_insertion_point();
- // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
- return insertion_point_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* CodeGeneratorResponse_File::release_insertion_point() {
- // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
- clear_has_insertion_point();
- return insertion_point_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void CodeGeneratorResponse_File::set_allocated_insertion_point(::std::string* insertion_point) {
- if (insertion_point != NULL) {
- set_has_insertion_point();
- } else {
- clear_has_insertion_point();
- }
- insertion_point_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), insertion_point);
- // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
-}
-
-// optional string content = 15;
-bool CodeGeneratorResponse_File::has_content() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void CodeGeneratorResponse_File::set_has_content() {
- _has_bits_[0] |= 0x00000004u;
-}
-void CodeGeneratorResponse_File::clear_has_content() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void CodeGeneratorResponse_File::clear_content() {
- content_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_content();
-}
-const ::std::string& CodeGeneratorResponse_File::content() const {
- // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.content)
- return content_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void CodeGeneratorResponse_File::set_content(const ::std::string& value) {
- set_has_content();
- content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content)
-}
-void CodeGeneratorResponse_File::set_content(const char* value) {
- set_has_content();
- content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.content)
-}
-void CodeGeneratorResponse_File::set_content(const char* value, size_t size) {
- set_has_content();
- content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.content)
-}
-::std::string* CodeGeneratorResponse_File::mutable_content() {
- set_has_content();
- // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.content)
- return content_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* CodeGeneratorResponse_File::release_content() {
- // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.content)
- clear_has_content();
- return content_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void CodeGeneratorResponse_File::set_allocated_content(::std::string* content) {
- if (content != NULL) {
- set_has_content();
- } else {
- clear_has_content();
- }
- content_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), content);
- // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content)
-}
-
-inline const CodeGeneratorResponse_File* CodeGeneratorResponse_File::internal_default_instance() {
- return &CodeGeneratorResponse_File_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
// CodeGeneratorResponse
// optional string error = 1;
@@ -1574,13 +2175,21 @@ void CodeGeneratorResponse::clear_error() {
}
const ::std::string& CodeGeneratorResponse::error() const {
// @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.error)
- return error_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return error_.GetNoArena();
}
void CodeGeneratorResponse::set_error(const ::std::string& value) {
set_has_error();
error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.error)
}
+#if LANG_CXX11
+void CodeGeneratorResponse::set_error(::std::string&& value) {
+ set_has_error();
+ error_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.error)
+}
+#endif
void CodeGeneratorResponse::set_error(const char* value) {
set_has_error();
error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -1642,9 +2251,6 @@ CodeGeneratorResponse::file() const {
return file_;
}
-inline const CodeGeneratorResponse* CodeGeneratorResponse::internal_default_instance() {
- return &CodeGeneratorResponse_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// @@protoc_insertion_point(namespace_scope)
diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h
index f9a99e75..1b91daca 100644
--- a/src/google/protobuf/compiler/plugin.pb.h
+++ b/src/google/protobuf/compiler/plugin.pb.h
@@ -8,44 +8,272 @@
#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3001000
+#if GOOGLE_PROTOBUF_VERSION < 3002000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
#endif
+#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata.h>
#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/extension_set.h>
+#include <google/protobuf/repeated_field.h> // IWYU pragma: export
+#include <google/protobuf/extension_set.h> // IWYU pragma: export
#include <google/protobuf/unknown_field_set.h>
#include <google/protobuf/descriptor.pb.h>
// @@protoc_insertion_point(includes)
-
namespace google {
namespace protobuf {
+class DescriptorProto;
+class DescriptorProtoDefaultTypeInternal;
+LIBPROTOC_EXPORT extern DescriptorProtoDefaultTypeInternal _DescriptorProto_default_instance_;
+class DescriptorProto_ExtensionRange;
+class DescriptorProto_ExtensionRangeDefaultTypeInternal;
+LIBPROTOC_EXPORT extern DescriptorProto_ExtensionRangeDefaultTypeInternal _DescriptorProto_ExtensionRange_default_instance_;
+class DescriptorProto_ReservedRange;
+class DescriptorProto_ReservedRangeDefaultTypeInternal;
+LIBPROTOC_EXPORT extern DescriptorProto_ReservedRangeDefaultTypeInternal _DescriptorProto_ReservedRange_default_instance_;
+class EnumDescriptorProto;
+class EnumDescriptorProtoDefaultTypeInternal;
+LIBPROTOC_EXPORT extern EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_;
+class EnumOptions;
+class EnumOptionsDefaultTypeInternal;
+LIBPROTOC_EXPORT extern EnumOptionsDefaultTypeInternal _EnumOptions_default_instance_;
+class EnumValueDescriptorProto;
+class EnumValueDescriptorProtoDefaultTypeInternal;
+LIBPROTOC_EXPORT extern EnumValueDescriptorProtoDefaultTypeInternal _EnumValueDescriptorProto_default_instance_;
+class EnumValueOptions;
+class EnumValueOptionsDefaultTypeInternal;
+LIBPROTOC_EXPORT extern EnumValueOptionsDefaultTypeInternal _EnumValueOptions_default_instance_;
+class FieldDescriptorProto;
+class FieldDescriptorProtoDefaultTypeInternal;
+LIBPROTOC_EXPORT extern FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_;
+class FieldOptions;
+class FieldOptionsDefaultTypeInternal;
+LIBPROTOC_EXPORT extern FieldOptionsDefaultTypeInternal _FieldOptions_default_instance_;
+class FileDescriptorProto;
+class FileDescriptorProtoDefaultTypeInternal;
+LIBPROTOC_EXPORT extern FileDescriptorProtoDefaultTypeInternal _FileDescriptorProto_default_instance_;
+class FileDescriptorSet;
+class FileDescriptorSetDefaultTypeInternal;
+LIBPROTOC_EXPORT extern FileDescriptorSetDefaultTypeInternal _FileDescriptorSet_default_instance_;
+class FileOptions;
+class FileOptionsDefaultTypeInternal;
+LIBPROTOC_EXPORT extern FileOptionsDefaultTypeInternal _FileOptions_default_instance_;
+class GeneratedCodeInfo;
+class GeneratedCodeInfoDefaultTypeInternal;
+LIBPROTOC_EXPORT extern GeneratedCodeInfoDefaultTypeInternal _GeneratedCodeInfo_default_instance_;
+class GeneratedCodeInfo_Annotation;
+class GeneratedCodeInfo_AnnotationDefaultTypeInternal;
+LIBPROTOC_EXPORT extern GeneratedCodeInfo_AnnotationDefaultTypeInternal _GeneratedCodeInfo_Annotation_default_instance_;
+class MessageOptions;
+class MessageOptionsDefaultTypeInternal;
+LIBPROTOC_EXPORT extern MessageOptionsDefaultTypeInternal _MessageOptions_default_instance_;
+class MethodDescriptorProto;
+class MethodDescriptorProtoDefaultTypeInternal;
+LIBPROTOC_EXPORT extern MethodDescriptorProtoDefaultTypeInternal _MethodDescriptorProto_default_instance_;
+class MethodOptions;
+class MethodOptionsDefaultTypeInternal;
+LIBPROTOC_EXPORT extern MethodOptionsDefaultTypeInternal _MethodOptions_default_instance_;
+class OneofDescriptorProto;
+class OneofDescriptorProtoDefaultTypeInternal;
+LIBPROTOC_EXPORT extern OneofDescriptorProtoDefaultTypeInternal _OneofDescriptorProto_default_instance_;
+class OneofOptions;
+class OneofOptionsDefaultTypeInternal;
+LIBPROTOC_EXPORT extern OneofOptionsDefaultTypeInternal _OneofOptions_default_instance_;
+class ServiceDescriptorProto;
+class ServiceDescriptorProtoDefaultTypeInternal;
+LIBPROTOC_EXPORT extern ServiceDescriptorProtoDefaultTypeInternal _ServiceDescriptorProto_default_instance_;
+class ServiceOptions;
+class ServiceOptionsDefaultTypeInternal;
+LIBPROTOC_EXPORT extern ServiceOptionsDefaultTypeInternal _ServiceOptions_default_instance_;
+class SourceCodeInfo;
+class SourceCodeInfoDefaultTypeInternal;
+LIBPROTOC_EXPORT extern SourceCodeInfoDefaultTypeInternal _SourceCodeInfo_default_instance_;
+class SourceCodeInfo_Location;
+class SourceCodeInfo_LocationDefaultTypeInternal;
+LIBPROTOC_EXPORT extern SourceCodeInfo_LocationDefaultTypeInternal _SourceCodeInfo_Location_default_instance_;
+class UninterpretedOption;
+class UninterpretedOptionDefaultTypeInternal;
+LIBPROTOC_EXPORT extern UninterpretedOptionDefaultTypeInternal _UninterpretedOption_default_instance_;
+class UninterpretedOption_NamePart;
+class UninterpretedOption_NamePartDefaultTypeInternal;
+LIBPROTOC_EXPORT extern UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_;
namespace compiler {
-
-// Internal implementation detail -- do not call these.
-void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
-void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
-void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
-void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
-
class CodeGeneratorRequest;
+class CodeGeneratorRequestDefaultTypeInternal;
+LIBPROTOC_EXPORT extern CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_;
class CodeGeneratorResponse;
+class CodeGeneratorResponseDefaultTypeInternal;
+LIBPROTOC_EXPORT extern CodeGeneratorResponseDefaultTypeInternal _CodeGeneratorResponse_default_instance_;
class CodeGeneratorResponse_File;
+class CodeGeneratorResponse_FileDefaultTypeInternal;
+LIBPROTOC_EXPORT extern CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_;
+class Version;
+class VersionDefaultTypeInternal;
+LIBPROTOC_EXPORT extern VersionDefaultTypeInternal _Version_default_instance_;
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+
+namespace protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto {
+// Internal implementation detail -- do not call these.
+struct LIBPROTOC_EXPORT TableStruct {
+ static const ::google::protobuf::uint32 offsets[];
+ static void InitDefaultsImpl();
+ static void Shutdown();
+};
+void LIBPROTOC_EXPORT AddDescriptors();
+void LIBPROTOC_EXPORT InitDefaults();
+} // namespace protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto
// ===================================================================
+class LIBPROTOC_EXPORT Version : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.Version) */ {
+ public:
+ Version();
+ virtual ~Version();
+
+ Version(const Version& from);
+
+ inline Version& operator=(const Version& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const Version& default_instance();
+
+ static inline const Version* internal_default_instance() {
+ return reinterpret_cast<const Version*>(
+ &_Version_default_instance_);
+ }
+
+ void Swap(Version* other);
+
+ // implements Message ----------------------------------------------
+
+ inline Version* New() const PROTOBUF_FINAL { return New(NULL); }
+
+ Version* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void CopyFrom(const Version& from);
+ void MergeFrom(const Version& from);
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
+
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
+ }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
+ void InternalSwap(Version* other);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return NULL;
+ }
+ inline void* MaybeArenaPtr() const {
+ return NULL;
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional string suffix = 4;
+ bool has_suffix() const;
+ void clear_suffix();
+ static const int kSuffixFieldNumber = 4;
+ const ::std::string& suffix() const;
+ void set_suffix(const ::std::string& value);
+ #if LANG_CXX11
+ void set_suffix(::std::string&& value);
+ #endif
+ void set_suffix(const char* value);
+ void set_suffix(const char* value, size_t size);
+ ::std::string* mutable_suffix();
+ ::std::string* release_suffix();
+ void set_allocated_suffix(::std::string* suffix);
+
+ // optional int32 major = 1;
+ bool has_major() const;
+ void clear_major();
+ static const int kMajorFieldNumber = 1;
+ ::google::protobuf::int32 major() const;
+ void set_major(::google::protobuf::int32 value);
+
+ // optional int32 minor = 2;
+ bool has_minor() const;
+ void clear_minor();
+ static const int kMinorFieldNumber = 2;
+ ::google::protobuf::int32 minor() const;
+ void set_minor(::google::protobuf::int32 value);
+
+ // optional int32 patch = 3;
+ bool has_patch() const;
+ void clear_patch();
+ static const int kPatchFieldNumber = 3;
+ ::google::protobuf::int32 patch() const;
+ void set_patch(::google::protobuf::int32 value);
+
+ // @@protoc_insertion_point(class_scope:google.protobuf.compiler.Version)
+ private:
+ void set_has_major();
+ void clear_has_major();
+ void set_has_minor();
+ void clear_has_minor();
+ void set_has_patch();
+ void clear_has_patch();
+ void set_has_suffix();
+ void clear_has_suffix();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::internal::ArenaStringPtr suffix_;
+ ::google::protobuf::int32 major_;
+ ::google::protobuf::int32 minor_;
+ ::google::protobuf::int32 patch_;
+ friend struct LIBPROTOC_EXPORT protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct;
+};
+// -------------------------------------------------------------------
+
class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorRequest) */ {
public:
CodeGeneratorRequest();
@@ -69,49 +297,53 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message
static const ::google::protobuf::Descriptor* descriptor();
static const CodeGeneratorRequest& default_instance();
- static const CodeGeneratorRequest* internal_default_instance();
+ static inline const CodeGeneratorRequest* internal_default_instance() {
+ return reinterpret_cast<const CodeGeneratorRequest*>(
+ &_CodeGeneratorRequest_default_instance_);
+ }
void Swap(CodeGeneratorRequest* other);
// implements Message ----------------------------------------------
- inline CodeGeneratorRequest* New() const { return New(NULL); }
+ inline CodeGeneratorRequest* New() const PROTOBUF_FINAL { return New(NULL); }
- CodeGeneratorRequest* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ CodeGeneratorRequest* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const CodeGeneratorRequest& from);
void MergeFrom(const CodeGeneratorRequest& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(CodeGeneratorRequest* other);
- void UnsafeMergeFrom(const CodeGeneratorRequest& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
@@ -124,43 +356,63 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message
const ::std::string& file_to_generate(int index) const;
::std::string* mutable_file_to_generate(int index);
void set_file_to_generate(int index, const ::std::string& value);
+ #if LANG_CXX11
+ void set_file_to_generate(int index, ::std::string&& value);
+ #endif
void set_file_to_generate(int index, const char* value);
void set_file_to_generate(int index, const char* value, size_t size);
::std::string* add_file_to_generate();
void add_file_to_generate(const ::std::string& value);
+ #if LANG_CXX11
+ void add_file_to_generate(::std::string&& value);
+ #endif
void add_file_to_generate(const char* value);
void add_file_to_generate(const char* value, size_t size);
const ::google::protobuf::RepeatedPtrField< ::std::string>& file_to_generate() const;
::google::protobuf::RepeatedPtrField< ::std::string>* mutable_file_to_generate();
+ // repeated .google.protobuf.FileDescriptorProto proto_file = 15;
+ int proto_file_size() const;
+ void clear_proto_file();
+ static const int kProtoFileFieldNumber = 15;
+ const ::google::protobuf::FileDescriptorProto& proto_file(int index) const;
+ ::google::protobuf::FileDescriptorProto* mutable_proto_file(int index);
+ ::google::protobuf::FileDescriptorProto* add_proto_file();
+ ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >*
+ mutable_proto_file();
+ const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >&
+ proto_file() const;
+
// optional string parameter = 2;
bool has_parameter() const;
void clear_parameter();
static const int kParameterFieldNumber = 2;
const ::std::string& parameter() const;
void set_parameter(const ::std::string& value);
+ #if LANG_CXX11
+ void set_parameter(::std::string&& value);
+ #endif
void set_parameter(const char* value);
void set_parameter(const char* value, size_t size);
::std::string* mutable_parameter();
::std::string* release_parameter();
void set_allocated_parameter(::std::string* parameter);
- // repeated .google.protobuf.FileDescriptorProto proto_file = 15;
- int proto_file_size() const;
- void clear_proto_file();
- static const int kProtoFileFieldNumber = 15;
- const ::google::protobuf::FileDescriptorProto& proto_file(int index) const;
- ::google::protobuf::FileDescriptorProto* mutable_proto_file(int index);
- ::google::protobuf::FileDescriptorProto* add_proto_file();
- ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >*
- mutable_proto_file();
- const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >&
- proto_file() const;
+ // optional .google.protobuf.compiler.Version compiler_version = 3;
+ bool has_compiler_version() const;
+ void clear_compiler_version();
+ static const int kCompilerVersionFieldNumber = 3;
+ const ::google::protobuf::compiler::Version& compiler_version() const;
+ ::google::protobuf::compiler::Version* mutable_compiler_version();
+ ::google::protobuf::compiler::Version* release_compiler_version();
+ void set_allocated_compiler_version(::google::protobuf::compiler::Version* compiler_version);
// @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorRequest)
private:
- inline void set_has_parameter();
- inline void clear_has_parameter();
+ void set_has_parameter();
+ void clear_has_parameter();
+ void set_has_compiler_version();
+ void clear_has_compiler_version();
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::google::protobuf::internal::HasBits<1> _has_bits_;
@@ -168,15 +420,9 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message
::google::protobuf::RepeatedPtrField< ::std::string> file_to_generate_;
::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto > proto_file_;
::google::protobuf::internal::ArenaStringPtr parameter_;
- friend void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl();
- friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
-
- void InitAsDefaultInstance();
+ ::google::protobuf::compiler::Version* compiler_version_;
+ friend struct LIBPROTOC_EXPORT protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorRequest> CodeGeneratorRequest_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse.File) */ {
@@ -202,49 +448,53 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M
static const ::google::protobuf::Descriptor* descriptor();
static const CodeGeneratorResponse_File& default_instance();
- static const CodeGeneratorResponse_File* internal_default_instance();
+ static inline const CodeGeneratorResponse_File* internal_default_instance() {
+ return reinterpret_cast<const CodeGeneratorResponse_File*>(
+ &_CodeGeneratorResponse_File_default_instance_);
+ }
void Swap(CodeGeneratorResponse_File* other);
// implements Message ----------------------------------------------
- inline CodeGeneratorResponse_File* New() const { return New(NULL); }
+ inline CodeGeneratorResponse_File* New() const PROTOBUF_FINAL { return New(NULL); }
- CodeGeneratorResponse_File* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ CodeGeneratorResponse_File* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const CodeGeneratorResponse_File& from);
void MergeFrom(const CodeGeneratorResponse_File& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(CodeGeneratorResponse_File* other);
- void UnsafeMergeFrom(const CodeGeneratorResponse_File& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
@@ -256,6 +506,9 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M
static const int kNameFieldNumber = 1;
const ::std::string& name() const;
void set_name(const ::std::string& value);
+ #if LANG_CXX11
+ void set_name(::std::string&& value);
+ #endif
void set_name(const char* value);
void set_name(const char* value, size_t size);
::std::string* mutable_name();
@@ -268,6 +521,9 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M
static const int kInsertionPointFieldNumber = 2;
const ::std::string& insertion_point() const;
void set_insertion_point(const ::std::string& value);
+ #if LANG_CXX11
+ void set_insertion_point(::std::string&& value);
+ #endif
void set_insertion_point(const char* value);
void set_insertion_point(const char* value, size_t size);
::std::string* mutable_insertion_point();
@@ -280,6 +536,9 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M
static const int kContentFieldNumber = 15;
const ::std::string& content() const;
void set_content(const ::std::string& value);
+ #if LANG_CXX11
+ void set_content(::std::string&& value);
+ #endif
void set_content(const char* value);
void set_content(const char* value, size_t size);
::std::string* mutable_content();
@@ -288,12 +547,12 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M
// @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse.File)
private:
- inline void set_has_name();
- inline void clear_has_name();
- inline void set_has_insertion_point();
- inline void clear_has_insertion_point();
- inline void set_has_content();
- inline void clear_has_content();
+ void set_has_name();
+ void clear_has_name();
+ void set_has_insertion_point();
+ void clear_has_insertion_point();
+ void set_has_content();
+ void clear_has_content();
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::google::protobuf::internal::HasBits<1> _has_bits_;
@@ -301,15 +560,8 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M
::google::protobuf::internal::ArenaStringPtr name_;
::google::protobuf::internal::ArenaStringPtr insertion_point_;
::google::protobuf::internal::ArenaStringPtr content_;
- friend void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl();
- friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOC_EXPORT protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse_File> CodeGeneratorResponse_File_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse) */ {
@@ -335,49 +587,53 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag
static const ::google::protobuf::Descriptor* descriptor();
static const CodeGeneratorResponse& default_instance();
- static const CodeGeneratorResponse* internal_default_instance();
+ static inline const CodeGeneratorResponse* internal_default_instance() {
+ return reinterpret_cast<const CodeGeneratorResponse*>(
+ &_CodeGeneratorResponse_default_instance_);
+ }
void Swap(CodeGeneratorResponse* other);
// implements Message ----------------------------------------------
- inline CodeGeneratorResponse* New() const { return New(NULL); }
+ inline CodeGeneratorResponse* New() const PROTOBUF_FINAL { return New(NULL); }
- CodeGeneratorResponse* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ CodeGeneratorResponse* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const CodeGeneratorResponse& from);
void MergeFrom(const CodeGeneratorResponse& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(CodeGeneratorResponse* other);
- void UnsafeMergeFrom(const CodeGeneratorResponse& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
@@ -385,18 +641,6 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag
// accessors -------------------------------------------------------
- // optional string error = 1;
- bool has_error() const;
- void clear_error();
- static const int kErrorFieldNumber = 1;
- const ::std::string& error() const;
- void set_error(const ::std::string& value);
- void set_error(const char* value);
- void set_error(const char* value, size_t size);
- ::std::string* mutable_error();
- ::std::string* release_error();
- void set_allocated_error(::std::string* error);
-
// repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15;
int file_size() const;
void clear_file();
@@ -409,31 +653,177 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File >&
file() const;
+ // optional string error = 1;
+ bool has_error() const;
+ void clear_error();
+ static const int kErrorFieldNumber = 1;
+ const ::std::string& error() const;
+ void set_error(const ::std::string& value);
+ #if LANG_CXX11
+ void set_error(::std::string&& value);
+ #endif
+ void set_error(const char* value);
+ void set_error(const char* value, size_t size);
+ ::std::string* mutable_error();
+ ::std::string* release_error();
+ void set_allocated_error(::std::string* error);
+
// @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse)
private:
- inline void set_has_error();
- inline void clear_has_error();
+ void set_has_error();
+ void clear_has_error();
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::google::protobuf::internal::HasBits<1> _has_bits_;
mutable int _cached_size_;
::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File > file_;
::google::protobuf::internal::ArenaStringPtr error_;
- friend void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl();
- friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOC_EXPORT protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse> CodeGeneratorResponse_default_instance_;
-
// ===================================================================
// ===================================================================
#if !PROTOBUF_INLINE_NOT_IN_HEADERS
+// Version
+
+// optional int32 major = 1;
+inline bool Version::has_major() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void Version::set_has_major() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void Version::clear_has_major() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void Version::clear_major() {
+ major_ = 0;
+ clear_has_major();
+}
+inline ::google::protobuf::int32 Version::major() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.major)
+ return major_;
+}
+inline void Version::set_major(::google::protobuf::int32 value) {
+ set_has_major();
+ major_ = value;
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.major)
+}
+
+// optional int32 minor = 2;
+inline bool Version::has_minor() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void Version::set_has_minor() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void Version::clear_has_minor() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void Version::clear_minor() {
+ minor_ = 0;
+ clear_has_minor();
+}
+inline ::google::protobuf::int32 Version::minor() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.minor)
+ return minor_;
+}
+inline void Version::set_minor(::google::protobuf::int32 value) {
+ set_has_minor();
+ minor_ = value;
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.minor)
+}
+
+// optional int32 patch = 3;
+inline bool Version::has_patch() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+inline void Version::set_has_patch() {
+ _has_bits_[0] |= 0x00000008u;
+}
+inline void Version::clear_has_patch() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+inline void Version::clear_patch() {
+ patch_ = 0;
+ clear_has_patch();
+}
+inline ::google::protobuf::int32 Version::patch() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.patch)
+ return patch_;
+}
+inline void Version::set_patch(::google::protobuf::int32 value) {
+ set_has_patch();
+ patch_ = value;
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.patch)
+}
+
+// optional string suffix = 4;
+inline bool Version::has_suffix() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void Version::set_has_suffix() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void Version::clear_has_suffix() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void Version::clear_suffix() {
+ suffix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_suffix();
+}
+inline const ::std::string& Version::suffix() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.suffix)
+ return suffix_.GetNoArena();
+}
+inline void Version::set_suffix(const ::std::string& value) {
+ set_has_suffix();
+ suffix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.suffix)
+}
+#if LANG_CXX11
+inline void Version::set_suffix(::std::string&& value) {
+ set_has_suffix();
+ suffix_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.Version.suffix)
+}
+#endif
+inline void Version::set_suffix(const char* value) {
+ set_has_suffix();
+ suffix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.Version.suffix)
+}
+inline void Version::set_suffix(const char* value, size_t size) {
+ set_has_suffix();
+ suffix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.Version.suffix)
+}
+inline ::std::string* Version::mutable_suffix() {
+ set_has_suffix();
+ // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.Version.suffix)
+ return suffix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* Version::release_suffix() {
+ // @@protoc_insertion_point(field_release:google.protobuf.compiler.Version.suffix)
+ clear_has_suffix();
+ return suffix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void Version::set_allocated_suffix(::std::string* suffix) {
+ if (suffix != NULL) {
+ set_has_suffix();
+ } else {
+ clear_has_suffix();
+ }
+ suffix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), suffix);
+ // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.Version.suffix)
+}
+
+// -------------------------------------------------------------------
+
// CodeGeneratorRequest
// repeated string file_to_generate = 1;
@@ -455,6 +845,12 @@ inline void CodeGeneratorRequest::set_file_to_generate(int index, const ::std::s
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
file_to_generate_.Mutable(index)->assign(value);
}
+#if LANG_CXX11
+inline void CodeGeneratorRequest::set_file_to_generate(int index, ::std::string&& value) {
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
+ file_to_generate_.Mutable(index)->assign(std::move(value));
+}
+#endif
inline void CodeGeneratorRequest::set_file_to_generate(int index, const char* value) {
file_to_generate_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
@@ -472,6 +868,12 @@ inline void CodeGeneratorRequest::add_file_to_generate(const ::std::string& valu
file_to_generate_.Add()->assign(value);
// @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
}
+#if LANG_CXX11
+inline void CodeGeneratorRequest::add_file_to_generate(::std::string&& value) {
+ file_to_generate_.Add()->assign(std::move(value));
+ // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
+}
+#endif
inline void CodeGeneratorRequest::add_file_to_generate(const char* value) {
file_to_generate_.Add()->assign(value);
// @@protoc_insertion_point(field_add_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
@@ -493,13 +895,13 @@ CodeGeneratorRequest::mutable_file_to_generate() {
// optional string parameter = 2;
inline bool CodeGeneratorRequest::has_parameter() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
+ return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void CodeGeneratorRequest::set_has_parameter() {
- _has_bits_[0] |= 0x00000002u;
+ _has_bits_[0] |= 0x00000001u;
}
inline void CodeGeneratorRequest::clear_has_parameter() {
- _has_bits_[0] &= ~0x00000002u;
+ _has_bits_[0] &= ~0x00000001u;
}
inline void CodeGeneratorRequest::clear_parameter() {
parameter_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -507,13 +909,21 @@ inline void CodeGeneratorRequest::clear_parameter() {
}
inline const ::std::string& CodeGeneratorRequest::parameter() const {
// @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.parameter)
- return parameter_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return parameter_.GetNoArena();
}
inline void CodeGeneratorRequest::set_parameter(const ::std::string& value) {
set_has_parameter();
parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.parameter)
}
+#if LANG_CXX11
+inline void CodeGeneratorRequest::set_parameter(::std::string&& value) {
+ set_has_parameter();
+ parameter_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorRequest.parameter)
+}
+#endif
inline void CodeGeneratorRequest::set_parameter(const char* value) {
set_has_parameter();
parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -575,9 +985,51 @@ CodeGeneratorRequest::proto_file() const {
return proto_file_;
}
-inline const CodeGeneratorRequest* CodeGeneratorRequest::internal_default_instance() {
- return &CodeGeneratorRequest_default_instance_.get();
+// optional .google.protobuf.compiler.Version compiler_version = 3;
+inline bool CodeGeneratorRequest::has_compiler_version() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void CodeGeneratorRequest::set_has_compiler_version() {
+ _has_bits_[0] |= 0x00000002u;
}
+inline void CodeGeneratorRequest::clear_has_compiler_version() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void CodeGeneratorRequest::clear_compiler_version() {
+ if (compiler_version_ != NULL) compiler_version_->::google::protobuf::compiler::Version::Clear();
+ clear_has_compiler_version();
+}
+inline const ::google::protobuf::compiler::Version& CodeGeneratorRequest::compiler_version() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.compiler_version)
+ return compiler_version_ != NULL ? *compiler_version_
+ : *::google::protobuf::compiler::Version::internal_default_instance();
+}
+inline ::google::protobuf::compiler::Version* CodeGeneratorRequest::mutable_compiler_version() {
+ set_has_compiler_version();
+ if (compiler_version_ == NULL) {
+ compiler_version_ = new ::google::protobuf::compiler::Version;
+ }
+ // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.compiler_version)
+ return compiler_version_;
+}
+inline ::google::protobuf::compiler::Version* CodeGeneratorRequest::release_compiler_version() {
+ // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.compiler_version)
+ clear_has_compiler_version();
+ ::google::protobuf::compiler::Version* temp = compiler_version_;
+ compiler_version_ = NULL;
+ return temp;
+}
+inline void CodeGeneratorRequest::set_allocated_compiler_version(::google::protobuf::compiler::Version* compiler_version) {
+ delete compiler_version_;
+ compiler_version_ = compiler_version;
+ if (compiler_version) {
+ set_has_compiler_version();
+ } else {
+ clear_has_compiler_version();
+ }
+ // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.compiler_version)
+}
+
// -------------------------------------------------------------------
// CodeGeneratorResponse_File
@@ -598,13 +1050,21 @@ inline void CodeGeneratorResponse_File::clear_name() {
}
inline const ::std::string& CodeGeneratorResponse_File::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.GetNoArena();
}
inline void CodeGeneratorResponse_File::set_name(const ::std::string& value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name)
}
+#if LANG_CXX11
+inline void CodeGeneratorResponse_File::set_name(::std::string&& value) {
+ set_has_name();
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.name)
+}
+#endif
inline void CodeGeneratorResponse_File::set_name(const char* value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -652,13 +1112,21 @@ inline void CodeGeneratorResponse_File::clear_insertion_point() {
}
inline const ::std::string& CodeGeneratorResponse_File::insertion_point() const {
// @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
- return insertion_point_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return insertion_point_.GetNoArena();
}
inline void CodeGeneratorResponse_File::set_insertion_point(const ::std::string& value) {
set_has_insertion_point();
insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
}
+#if LANG_CXX11
+inline void CodeGeneratorResponse_File::set_insertion_point(::std::string&& value) {
+ set_has_insertion_point();
+ insertion_point_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
+}
+#endif
inline void CodeGeneratorResponse_File::set_insertion_point(const char* value) {
set_has_insertion_point();
insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -706,13 +1174,21 @@ inline void CodeGeneratorResponse_File::clear_content() {
}
inline const ::std::string& CodeGeneratorResponse_File::content() const {
// @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.content)
- return content_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return content_.GetNoArena();
}
inline void CodeGeneratorResponse_File::set_content(const ::std::string& value) {
set_has_content();
content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content)
}
+#if LANG_CXX11
+inline void CodeGeneratorResponse_File::set_content(::std::string&& value) {
+ set_has_content();
+ content_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.File.content)
+}
+#endif
inline void CodeGeneratorResponse_File::set_content(const char* value) {
set_has_content();
content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -744,9 +1220,6 @@ inline void CodeGeneratorResponse_File::set_allocated_content(::std::string* con
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content)
}
-inline const CodeGeneratorResponse_File* CodeGeneratorResponse_File::internal_default_instance() {
- return &CodeGeneratorResponse_File_default_instance_.get();
-}
// -------------------------------------------------------------------
// CodeGeneratorResponse
@@ -767,13 +1240,21 @@ inline void CodeGeneratorResponse::clear_error() {
}
inline const ::std::string& CodeGeneratorResponse::error() const {
// @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.error)
- return error_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return error_.GetNoArena();
}
inline void CodeGeneratorResponse::set_error(const ::std::string& value) {
set_has_error();
error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.error)
}
+#if LANG_CXX11
+inline void CodeGeneratorResponse::set_error(::std::string&& value) {
+ set_has_error();
+ error_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.CodeGeneratorResponse.error)
+}
+#endif
inline void CodeGeneratorResponse::set_error(const char* value) {
set_has_error();
error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -835,17 +1316,17 @@ CodeGeneratorResponse::file() const {
return file_;
}
-inline const CodeGeneratorResponse* CodeGeneratorResponse::internal_default_instance() {
- return &CodeGeneratorResponse_default_instance_.get();
-}
#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS
// -------------------------------------------------------------------
// -------------------------------------------------------------------
+// -------------------------------------------------------------------
+
// @@protoc_insertion_point(namespace_scope)
+
} // namespace compiler
} // namespace protobuf
} // namespace google
diff --git a/src/google/protobuf/compiler/plugin.proto b/src/google/protobuf/compiler/plugin.proto
index acaee1f4..6e4da2c1 100644
--- a/src/google/protobuf/compiler/plugin.proto
+++ b/src/google/protobuf/compiler/plugin.proto
@@ -53,6 +53,16 @@ option go_package = "plugin_go";
import "google/protobuf/descriptor.proto";
+// The version number of protocol compiler.
+message Version {
+ optional int32 major = 1;
+ optional int32 minor = 2;
+ optional int32 patch = 3;
+ // A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should
+ // be empty for mainline stable releases.
+ optional string suffix = 4;
+}
+
// An encoded CodeGeneratorRequest is written to the plugin's stdin.
message CodeGeneratorRequest {
// The .proto files that were explicitly listed on the command-line. The
@@ -75,6 +85,9 @@ message CodeGeneratorRequest {
// is not similarly optimized on protoc's end -- it will store all fields in
// memory at once before sending them to the plugin.
repeated FileDescriptorProto proto_file = 15;
+
+ // The version number of protocol compiler.
+ optional Version compiler_version = 3;
}
// The plugin writes an encoded CodeGeneratorResponse to stdout.
diff --git a/src/google/protobuf/compiler/python/python_generator.cc b/src/google/protobuf/compiler/python/python_generator.cc
index 3b1b0d1d..f83f155a 100644
--- a/src/google/protobuf/compiler/python/python_generator.cc
+++ b/src/google/protobuf/compiler/python/python_generator.cc
@@ -120,7 +120,7 @@ const char* const* kKeywordsEnd =
kKeywords + (sizeof(kKeywords) / sizeof(kKeywords[0]));
bool ContainsPythonKeyword(const string& module_name) {
- vector<string> tokens = Split(module_name, ".");
+ std::vector<string> tokens = Split(module_name, ".");
for (int i = 0; i < tokens.size(); ++i) {
if (std::find(kKeywords, kKeywordsEnd, tokens[i]) != kKeywordsEnd) {
return true;
@@ -230,11 +230,11 @@ string StringifyDefaultValue(const FieldDescriptor& field) {
return SimpleItoa(field.default_value_uint64());
case FieldDescriptor::CPPTYPE_DOUBLE: {
double value = field.default_value_double();
- if (value == numeric_limits<double>::infinity()) {
+ if (value == std::numeric_limits<double>::infinity()) {
// Python pre-2.6 on Windows does not parse "inf" correctly. However,
// a numeric literal that is too big for a double will become infinity.
return "1e10000";
- } else if (value == -numeric_limits<double>::infinity()) {
+ } else if (value == -std::numeric_limits<double>::infinity()) {
// See above.
return "-1e10000";
} else if (value != value) {
@@ -246,11 +246,11 @@ string StringifyDefaultValue(const FieldDescriptor& field) {
}
case FieldDescriptor::CPPTYPE_FLOAT: {
float value = field.default_value_float();
- if (value == numeric_limits<float>::infinity()) {
+ if (value == std::numeric_limits<float>::infinity()) {
// Python pre-2.6 on Windows does not parse "inf" correctly. However,
// a numeric literal that is too big for a double will become infinity.
return "1e10000";
- } else if (value == -numeric_limits<float>::infinity()) {
+ } else if (value == -std::numeric_limits<float>::infinity()) {
// See above.
return "-1e10000";
} else if (value != value) {
@@ -405,7 +405,7 @@ void Generator::PrintImports() const {
// Prints the single file descriptor for this file.
void Generator::PrintFileDescriptor() const {
- map<string, string> m;
+ std::map<string, string> m;
m["descriptor_name"] = kDescriptorKey;
m["name"] = file_->name();
m["package"] = file_->package();
@@ -453,7 +453,7 @@ void Generator::PrintFileDescriptor() const {
// Prints descriptors and module-level constants for all top-level
// enums defined in |file|.
void Generator::PrintTopLevelEnums() const {
- vector<pair<string, int> > top_level_enum_values;
+ std::vector<std::pair<string, int> > top_level_enum_values;
for (int i = 0; i < file_->enum_type_count(); ++i) {
const EnumDescriptor& enum_descriptor = *file_->enum_type(i);
PrintEnum(enum_descriptor);
@@ -490,7 +490,7 @@ void Generator::PrintAllNestedEnumsInFile() const {
// enum name to a Python EnumDescriptor object equivalent to
// enum_descriptor.
void Generator::PrintEnum(const EnumDescriptor& enum_descriptor) const {
- map<string, string> m;
+ std::map<string, string> m;
string module_level_descriptor_name =
ModuleLevelDescriptorName(enum_descriptor);
m["descriptor_name"] = module_level_descriptor_name;
@@ -584,7 +584,7 @@ void Generator::PrintServiceDescriptor(
"$service_name$ = _descriptor.ServiceDescriptor(\n",
"service_name", service_name);
printer_->Indent();
- map<string, string> m;
+ std::map<string, string> m;
m["name"] = descriptor.name();
m["full_name"] = descriptor.full_name();
m["file"] = kDescriptorKey;
@@ -680,7 +680,7 @@ void Generator::PrintDescriptor(const Descriptor& message_descriptor) const {
"descriptor_name",
ModuleLevelDescriptorName(message_descriptor));
printer_->Indent();
- map<string, string> m;
+ std::map<string, string> m;
m["name"] = message_descriptor.name();
m["full_name"] = message_descriptor.full_name();
m["file"] = kDescriptorKey;
@@ -740,7 +740,7 @@ void Generator::PrintDescriptor(const Descriptor& message_descriptor) const {
printer_->Indent();
for (int i = 0; i < message_descriptor.oneof_decl_count(); ++i) {
const OneofDescriptor* desc = message_descriptor.oneof_decl(i);
- map<string, string> m;
+ std::map<string, string> m;
m["name"] = desc->name();
m["full_name"] = desc->full_name();
m["index"] = SimpleItoa(desc->index());
@@ -781,7 +781,7 @@ void Generator::PrintNestedDescriptors(
// Prints all messages in |file|.
void Generator::PrintMessages() const {
for (int i = 0; i < file_->message_type_count(); ++i) {
- vector<string> to_register;
+ std::vector<string> to_register;
PrintMessage(*file_->message_type(i), "", &to_register);
for (int j = 0; j < to_register.size(); ++j) {
printer_->Print("_sym_db.RegisterMessage($name$)\n", "name",
@@ -801,7 +801,7 @@ void Generator::PrintMessages() const {
// Collect nested message names to_register for the symbol_database.
void Generator::PrintMessage(const Descriptor& message_descriptor,
const string& prefix,
- vector<string>* to_register) const {
+ std::vector<string>* to_register) const {
string qualified_name(prefix + message_descriptor.name());
to_register->push_back(qualified_name);
printer_->Print(
@@ -811,7 +811,7 @@ void Generator::PrintMessage(const Descriptor& message_descriptor,
printer_->Indent();
PrintNestedMessages(message_descriptor, qualified_name + ".", to_register);
- map<string, string> m;
+ std::map<string, string> m;
m["descriptor_key"] = kDescriptorKey;
m["descriptor_name"] = ModuleLevelDescriptorName(message_descriptor);
printer_->Print(m, "$descriptor_key$ = $descriptor_name$,\n");
@@ -827,7 +827,7 @@ void Generator::PrintMessage(const Descriptor& message_descriptor,
// Mutually recursive with PrintMessage().
void Generator::PrintNestedMessages(const Descriptor& containing_descriptor,
const string& prefix,
- vector<string>* to_register) const {
+ std::vector<string>* to_register) const {
for (int i = 0; i < containing_descriptor.nested_type_count(); ++i) {
printer_->Print("\n");
PrintMessage(*containing_descriptor.nested_type(i), prefix, to_register);
@@ -860,7 +860,7 @@ void Generator::FixForeignFieldsInDescriptor(
FixContainingTypeInDescriptor(enum_descriptor, &descriptor);
}
for (int i = 0; i < descriptor.oneof_decl_count(); ++i) {
- map<string, string> m;
+ std::map<string, string> m;
const OneofDescriptor* oneof = descriptor.oneof_decl(i);
m["descriptor_name"] = ModuleLevelDescriptorName(descriptor);
m["oneof_name"] = oneof->name();
@@ -879,7 +879,7 @@ void Generator::FixForeignFieldsInDescriptor(
}
void Generator::AddMessageToFileDescriptor(const Descriptor& descriptor) const {
- map<string, string> m;
+ std::map<string, string> m;
m["descriptor_name"] = kDescriptorKey;
m["message_name"] = descriptor.name();
m["message_descriptor_name"] = ModuleLevelDescriptorName(descriptor);
@@ -891,7 +891,7 @@ void Generator::AddMessageToFileDescriptor(const Descriptor& descriptor) const {
void Generator::AddEnumToFileDescriptor(
const EnumDescriptor& descriptor) const {
- map<string, string> m;
+ std::map<string, string> m;
m["descriptor_name"] = kDescriptorKey;
m["enum_name"] = descriptor.name();
m["enum_descriptor_name"] = ModuleLevelDescriptorName(descriptor);
@@ -903,7 +903,7 @@ void Generator::AddEnumToFileDescriptor(
void Generator::AddExtensionToFileDescriptor(
const FieldDescriptor& descriptor) const {
- map<string, string> m;
+ std::map<string, string> m;
m["descriptor_name"] = kDescriptorKey;
m["field_name"] = descriptor.name();
const char file_descriptor_template[] =
@@ -926,7 +926,7 @@ void Generator::FixForeignFieldsInField(const Descriptor* containing_type,
const string& python_dict_name) const {
const string field_referencing_expression = FieldReferencingExpression(
containing_type, field, python_dict_name);
- map<string, string> m;
+ std::map<string, string> m;
m["field_ref"] = field_referencing_expression;
const Descriptor* foreign_message_type = field.message_type();
if (foreign_message_type) {
@@ -1025,7 +1025,7 @@ void Generator::FixForeignFieldsInExtension(
FixForeignFieldsInField(extension_field.extension_scope(), extension_field,
"extensions_by_name");
- map<string, string> m;
+ std::map<string, string> m;
// Confusingly, for FieldDescriptors that happen to be extensions,
// containing_type() means "extended type."
// On the other hand, extension_scope() will give us what we normally
@@ -1058,7 +1058,7 @@ void Generator::PrintEnumValueDescriptor(
// More circular references. ::sigh::
string options_string;
descriptor.options().SerializeToString(&options_string);
- map<string, string> m;
+ std::map<string, string> m;
m["name"] = descriptor.name();
m["index"] = SimpleItoa(descriptor.index());
m["number"] = SimpleItoa(descriptor.number());
@@ -1091,7 +1091,7 @@ void Generator::PrintFieldDescriptor(
const FieldDescriptor& field, bool is_extension) const {
string options_string;
field.options().SerializeToString(&options_string);
- map<string, string> m;
+ std::map<string, string> m;
m["name"] = field.name();
m["full_name"] = field.full_name();
m["index"] = SimpleItoa(field.index());
@@ -1380,8 +1380,17 @@ void Generator::FixOptionsForMessage(const Descriptor& descriptor) const {
void Generator::CopyPublicDependenciesAliases(
const string& copy_from, const FileDescriptor* file) const {
for (int i = 0; i < file->public_dependency_count(); ++i) {
+ string module_name = ModuleName(file->public_dependency(i)->name());
string module_alias = ModuleAlias(file->public_dependency(i)->name());
- printer_->Print("$alias$ = $copy_from$.$alias$\n", "alias", module_alias,
+ // There's no module alias in the dependent file if it was generated by
+ // an old protoc (less than 3.0.0-alpha-1). Use module name in this
+ // situation.
+ printer_->Print("try:\n"
+ " $alias$ = $copy_from$.$alias$\n"
+ "except AttributeError:\n"
+ " $alias$ = $copy_from$.$module$\n",
+ "alias", module_alias,
+ "module", module_name,
"copy_from", copy_from);
CopyPublicDependenciesAliases(copy_from, file->public_dependency(i));
}
diff --git a/src/google/protobuf/compiler/python/python_generator.h b/src/google/protobuf/compiler/python/python_generator.h
index 7583aa65..594260af 100644
--- a/src/google/protobuf/compiler/python/python_generator.h
+++ b/src/google/protobuf/compiler/python/python_generator.h
@@ -97,10 +97,10 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator {
void PrintMessages() const;
void PrintMessage(const Descriptor& message_descriptor, const string& prefix,
- vector<string>* to_register) const;
+ std::vector<string>* to_register) const;
void PrintNestedMessages(const Descriptor& containing_descriptor,
const string& prefix,
- vector<string>* to_register) const;
+ std::vector<string>* to_register) const;
void FixForeignFieldsInDescriptors() const;
void FixForeignFieldsInDescriptor(
diff --git a/src/google/protobuf/compiler/subprocess.cc b/src/google/protobuf/compiler/subprocess.cc
index e929e4fb..933450fa 100644
--- a/src/google/protobuf/compiler/subprocess.cc
+++ b/src/google/protobuf/compiler/subprocess.cc
@@ -261,9 +261,8 @@ string Subprocess::Win32ErrorMessage(DWORD error_code) {
char* message;
// WTF?
- FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
+ FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, error_code, 0,
(LPSTR)&message, // NOT A BUG!
0, NULL);
diff --git a/src/google/protobuf/compiler/zip_writer.h b/src/google/protobuf/compiler/zip_writer.h
index 602e508e..03db4d57 100644
--- a/src/google/protobuf/compiler/zip_writer.h
+++ b/src/google/protobuf/compiler/zip_writer.h
@@ -85,7 +85,7 @@ class ZipWriter {
};
io::ZeroCopyOutputStream* raw_output_;
- vector<FileInfo> files_;
+ std::vector<FileInfo> files_;
};
} // namespace compiler
diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc
index be1e1d69..c87327ce 100644
--- a/src/google/protobuf/descriptor.cc
+++ b/src/google/protobuf/descriptor.cc
@@ -315,7 +315,7 @@ class PrefixRemover {
// be a lot cleaner but we'd just have to convert it back to const char*
// for the open source release.
-typedef pair<const void*, const char*> PointerStringPair;
+typedef std::pair<const void*, const char*> PointerStringPair;
struct PointerStringPairEqual {
inline bool operator()(const PointerStringPair& a,
@@ -343,8 +343,8 @@ struct PointerIntegerPairHash {
}
};
-typedef pair<const Descriptor*, int> DescriptorIntPair;
-typedef pair<const EnumDescriptor*, int> EnumIntPair;
+typedef std::pair<const Descriptor*, int> DescriptorIntPair;
+typedef std::pair<const EnumDescriptor*, int> EnumIntPair;
struct PointerStringPairHash {
size_t operator()(const PointerStringPair& p) const {
@@ -452,11 +452,11 @@ typedef hash_map<EnumIntPair, const EnumValueDescriptor*,
// through all the extensions that extend a given Descriptor, and an
// ordered data structure that implements lower_bound is convenient
// for that.
-typedef map<DescriptorIntPair, const FieldDescriptor*>
+typedef std::map<DescriptorIntPair, const FieldDescriptor*>
ExtensionsGroupedByDescriptorMap;
typedef hash_map<string, const SourceCodeInfo_Location*> LocationsByPathMap;
-set<string>* allowed_proto3_extendees_ = NULL;
+std::set<string>* allowed_proto3_extendees_ = NULL;
GOOGLE_PROTOBUF_DECLARE_ONCE(allowed_proto3_extendees_init_);
void DeleteAllowedProto3Extendee() {
@@ -464,10 +464,10 @@ void DeleteAllowedProto3Extendee() {
}
void InitAllowedProto3Extendee() {
- allowed_proto3_extendees_ = new set<string>;
+ allowed_proto3_extendees_ = new std::set<string>;
const char* kOptionNames[] = {
"FileOptions", "MessageOptions", "FieldOptions", "EnumOptions",
- "EnumValueOptions", "ServiceOptions", "MethodOptions"};
+ "EnumValueOptions", "ServiceOptions", "MethodOptions", "OneofOptions"};
for (int i = 0; i < GOOGLE_ARRAYSIZE(kOptionNames); ++i) {
// descriptor.proto has a different package name in opensource. We allow
// both so the opensource protocol compiler can also compile internal
@@ -542,7 +542,7 @@ class DescriptorPool::Tables {
// The stack of files which are currently being built. Used to detect
// cyclic dependencies when loading files from a DescriptorDatabase. Not
// used when fallback_database_ == NULL.
- vector<string> pending_files_;
+ std::vector<string> pending_files_;
// A set of files which we have tried to load from the fallback database
// and encountered errors. We will not attempt to load them again during
@@ -580,7 +580,7 @@ class DescriptorPool::Tables {
inline const FieldDescriptor* FindExtension(const Descriptor* extendee,
int number);
inline void FindAllExtensions(const Descriptor* extendee,
- vector<const FieldDescriptor*>* out) const;
+ std::vector<const FieldDescriptor*>* out) const;
// -----------------------------------------------------------------
// Adding items.
@@ -620,10 +620,11 @@ class DescriptorPool::Tables {
FileDescriptorTables* AllocateFileTables();
private:
- vector<string*> strings_; // All strings in the pool.
- vector<Message*> messages_; // All messages in the pool.
- vector<FileDescriptorTables*> file_tables_; // All file tables in the pool.
- vector<void*> allocations_; // All other memory allocated in the pool.
+ std::vector<string*> strings_; // All strings in the pool.
+ std::vector<Message*> messages_; // All messages in the pool.
+ std::vector<FileDescriptorTables*>
+ file_tables_; // All file tables in the pool.
+ std::vector<void*> allocations_; // All other memory allocated in the pool.
SymbolsByNameMap symbols_by_name_;
FilesByNameMap files_by_name_;
@@ -650,10 +651,10 @@ class DescriptorPool::Tables {
int pending_files_before_checkpoint;
int pending_extensions_before_checkpoint;
};
- vector<CheckPoint> checkpoints_;
- vector<const char* > symbols_after_checkpoint_;
- vector<const char* > files_after_checkpoint_;
- vector<DescriptorIntPair> extensions_after_checkpoint_;
+ std::vector<CheckPoint> checkpoints_;
+ std::vector<const char* > symbols_after_checkpoint_;
+ std::vector<const char* > files_after_checkpoint_;
+ std::vector<DescriptorIntPair> extensions_after_checkpoint_;
// Allocate some bytes which will be reclaimed when the pool is
// destroyed.
@@ -720,14 +721,14 @@ class FileDescriptorTables {
// Populates p->first->locations_by_path_ from p->second.
// Unusual signature dictated by GoogleOnceDynamic.
static void BuildLocationsByPath(
- pair<const FileDescriptorTables*, const SourceCodeInfo*>* p);
+ std::pair<const FileDescriptorTables*, const SourceCodeInfo*>* p);
// Returns the location denoted by the specified path through info,
// or NULL if not found.
// The value of info must be that of the corresponding FileDescriptor.
// (Conceptually a pure function, but stateful as an optimisation.)
const SourceCodeInfo_Location* GetSourceLocation(
- const vector<int>& path, const SourceCodeInfo* info) const;
+ const std::vector<int>& path, const SourceCodeInfo* info) const;
private:
SymbolsByParentMap symbols_by_parent_;
@@ -1008,7 +1009,8 @@ inline const FieldDescriptor* DescriptorPool::Tables::FindExtension(
}
inline void DescriptorPool::Tables::FindAllExtensions(
- const Descriptor* extendee, vector<const FieldDescriptor*>* out) const {
+ const Descriptor* extendee,
+ std::vector<const FieldDescriptor*>* out) const {
ExtensionsGroupedByDescriptorMap::const_iterator it =
extensions_.lower_bound(std::make_pair(extendee, 0));
for (; it != extensions_.end() && it->first.first == extendee; ++it) {
@@ -1128,7 +1130,7 @@ void* DescriptorPool::Tables::AllocateBytes(int size) {
}
void FileDescriptorTables::BuildLocationsByPath(
- pair<const FileDescriptorTables*, const SourceCodeInfo*>* p) {
+ std::pair<const FileDescriptorTables*, const SourceCodeInfo*>* p) {
for (int i = 0, len = p->second->location_size(); i < len; ++i) {
const SourceCodeInfo_Location* loc = &p->second->location().Get(i);
p->first->locations_by_path_[Join(loc->path(), ",")] = loc;
@@ -1136,8 +1138,8 @@ void FileDescriptorTables::BuildLocationsByPath(
}
const SourceCodeInfo_Location* FileDescriptorTables::GetSourceLocation(
- const vector<int>& path, const SourceCodeInfo* info) const {
- pair<const FileDescriptorTables*, const SourceCodeInfo*> p(
+ const std::vector<int>& path, const SourceCodeInfo* info) const {
+ std::pair<const FileDescriptorTables*, const SourceCodeInfo*> p(
std::make_pair(this, info));
locations_by_path_once_.Init(&FileDescriptorTables::BuildLocationsByPath, &p);
return FindPtrOrNull(locations_by_path_, Join(path, ","));
@@ -1239,6 +1241,7 @@ const DescriptorPool* DescriptorPool::generated_pool() {
}
+
DescriptorPool* DescriptorPool::internal_generated_pool() {
InitGeneratedPoolOnce();
return generated_pool_;
@@ -1397,7 +1400,8 @@ const FieldDescriptor* DescriptorPool::FindExtensionByNumber(
}
void DescriptorPool::FindAllExtensions(
- const Descriptor* extendee, vector<const FieldDescriptor*>* out) const {
+ const Descriptor* extendee,
+ std::vector<const FieldDescriptor*>* out) const {
MutexLockMaybe lock(mutex_);
tables_->known_bad_symbols_.clear();
tables_->known_bad_files_.clear();
@@ -1406,7 +1410,7 @@ void DescriptorPool::FindAllExtensions(
// (but do this only once per descriptor).
if (fallback_database_ != NULL &&
tables_->extensions_loaded_from_db_.count(extendee) == 0) {
- vector<int> numbers;
+ std::vector<int> numbers;
if (fallback_database_->FindAllExtensionNumbers(extendee->full_name(),
&numbers)) {
for (int i = 0; i < numbers.size(); ++i) {
@@ -2071,13 +2075,11 @@ void MethodDescriptor::CopyTo(MethodDescriptorProto* proto) const {
namespace {
-// Used by each of the option formatters.
-bool RetrieveOptions(int depth,
- const Message &options,
- vector<string> *option_entries) {
+bool RetrieveOptionsAssumingRightPool(int depth, const Message& options,
+ std::vector<string>* option_entries) {
option_entries->clear();
const Reflection* reflection = options.GetReflection();
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
reflection->ListFields(options, &fields);
for (int i = 0; i < fields.size(); i++) {
int count = 1;
@@ -2114,21 +2116,56 @@ bool RetrieveOptions(int depth,
return !option_entries->empty();
}
+// Used by each of the option formatters.
+bool RetrieveOptions(int depth, const Message& options,
+ const DescriptorPool* pool,
+ std::vector<string>* option_entries) {
+ // When printing custom options for a descriptor, we must use an options
+ // message built on top of the same DescriptorPool where the descriptor
+ // is coming from. This is to ensure we are interpreting custom options
+ // against the right pool.
+ if (options.GetDescriptor()->file()->pool() == pool) {
+ return RetrieveOptionsAssumingRightPool(depth, options, option_entries);
+ } else {
+ const Descriptor* option_descriptor =
+ pool->FindMessageTypeByName(options.GetDescriptor()->full_name());
+ if (option_descriptor == NULL) {
+ // google/protobuf/descriptor.proto is not in the pool. This means no
+ // custom options are used so we are safe to proceed with the compiled
+ // options message type.
+ return RetrieveOptionsAssumingRightPool(depth, options, option_entries);
+ }
+ DynamicMessageFactory factory;
+ google::protobuf::scoped_ptr<Message> dynamic_options(
+ factory.GetPrototype(option_descriptor)->New());
+ if (dynamic_options->ParseFromString(options.SerializeAsString())) {
+ return RetrieveOptionsAssumingRightPool(depth, *dynamic_options,
+ option_entries);
+ } else {
+ GOOGLE_LOG(ERROR) << "Found invalid proto option data for: "
+ << options.GetDescriptor()->full_name();
+ return RetrieveOptionsAssumingRightPool(depth, options, option_entries);
+ }
+ }
+}
+
// Formats options that all appear together in brackets. Does not include
// brackets.
-bool FormatBracketedOptions(int depth, const Message &options, string *output) {
- vector<string> all_options;
- if (RetrieveOptions(depth, options, &all_options)) {
+bool FormatBracketedOptions(int depth, const Message& options,
+ const DescriptorPool* pool, string* output) {
+ std::vector<string> all_options;
+ if (RetrieveOptions(depth, options, pool, &all_options)) {
output->append(Join(all_options, ", "));
}
return !all_options.empty();
}
// Formats options one per line
-bool FormatLineOptions(int depth, const Message &options, string *output) {
+bool FormatLineOptions(int depth, const Message& options,
+ const DescriptorPool* pool, string* output) {
string prefix(depth * 2, ' ');
- vector<string> all_options;
- if (RetrieveOptions(depth, options, &all_options)) {
+ std::vector<string> all_options;
+ if (RetrieveOptions(depth, options, pool, &all_options)) {
for (int i = 0; i < all_options.size(); i++) {
strings::SubstituteAndAppend(output, "$0option $1;\n",
prefix, all_options[i]);
@@ -2150,7 +2187,7 @@ class SourceLocationCommentPrinter {
desc->GetSourceLocation(&source_loc_);
}
SourceLocationCommentPrinter(const FileDescriptor* file,
- const vector<int>& path,
+ const std::vector<int>& path,
const string& prefix,
const DebugStringOptions& options)
: options_(options), prefix_(prefix) {
@@ -2183,7 +2220,7 @@ class SourceLocationCommentPrinter {
string FormatComment(const string& comment_text) {
string stripped_comment = comment_text;
StripWhitespace(&stripped_comment);
- vector<string> lines = Split(stripped_comment, "\n");
+ std::vector<string> lines = Split(stripped_comment, "\n");
string output;
for (int i = 0; i < lines.size(); ++i) {
const string& line = lines[i];
@@ -2211,7 +2248,7 @@ string FileDescriptor::DebugStringWithOptions(
const DebugStringOptions& debug_string_options) const {
string contents;
{
- vector<int> path;
+ std::vector<int> path;
path.push_back(FileDescriptorProto::kSyntaxFieldNumber);
SourceLocationCommentPrinter syntax_comment(
this, path, "", debug_string_options);
@@ -2225,8 +2262,8 @@ string FileDescriptor::DebugStringWithOptions(
comment_printer(this, "", debug_string_options);
comment_printer.AddPreComment(&contents);
- set<int> public_dependencies;
- set<int> weak_dependencies;
+ std::set<int> public_dependencies;
+ std::set<int> weak_dependencies;
public_dependencies.insert(public_dependencies_,
public_dependencies_ + public_dependency_count_);
weak_dependencies.insert(weak_dependencies_,
@@ -2246,7 +2283,7 @@ string FileDescriptor::DebugStringWithOptions(
}
if (!package().empty()) {
- vector<int> path;
+ std::vector<int> path;
path.push_back(FileDescriptorProto::kPackageFieldNumber);
SourceLocationCommentPrinter package_comment(
this, path, "", debug_string_options);
@@ -2255,7 +2292,7 @@ string FileDescriptor::DebugStringWithOptions(
package_comment.AddPostComment(&contents);
}
- if (FormatLineOptions(0, options(), &contents)) {
+ if (FormatLineOptions(0, options(), pool(), &contents)) {
contents.append("\n"); // add some space if we had options
}
@@ -2266,7 +2303,7 @@ string FileDescriptor::DebugStringWithOptions(
// Find all the 'group' type extensions; we will not output their nested
// definitions (those will be done with their group field descriptor).
- set<const Descriptor*> groups;
+ std::set<const Descriptor*> groups;
for (int i = 0; i < extension_count(); i++) {
if (extension(i)->type() == FieldDescriptor::TYPE_GROUP) {
groups.insert(extension(i)->message_type());
@@ -2336,12 +2373,12 @@ void Descriptor::DebugString(int depth, string *contents,
}
contents->append(" {\n");
- FormatLineOptions(depth, options(), contents);
+ FormatLineOptions(depth, options(), file()->pool(), contents);
// Find all the 'group' types for fields and extensions; we will not output
// their nested definitions (those will be done with their group field
// descriptor).
- set<const Descriptor*> groups;
+ std::set<const Descriptor*> groups;
for (int i = 0; i < field_count(); i++) {
if (field(i)->type() == FieldDescriptor::TYPE_GROUP) {
groups.insert(field(i)->message_type());
@@ -2474,8 +2511,18 @@ void FieldDescriptor::DebugString(int depth,
field_type = FieldTypeNameDebugString();
}
+ bool print_label = true;
+ // Determine whether to omit label:
+ // 1. For an optional field, omit label if it's in oneof or in proto3.
+ // 2. For a repeated field, omit label if it's a map.
+ if (is_optional() && (print_label_flag == OMIT_LABEL ||
+ file()->syntax() == FileDescriptor::SYNTAX_PROTO3)) {
+ print_label = false;
+ } else if (is_map()) {
+ print_label = false;
+ }
string label;
- if (print_label_flag == PRINT_LABEL && !is_map()) {
+ if (print_label) {
label = kLabelToName[this->label()];
label.push_back(' ');
}
@@ -2511,7 +2558,8 @@ void FieldDescriptor::DebugString(int depth,
}
string formatted_options;
- if (FormatBracketedOptions(depth, options(), &formatted_options)) {
+ if (FormatBracketedOptions(depth, options(), file()->pool(),
+ &formatted_options)) {
contents->append(bracketed ? ", " : " [");
bracketed = true;
contents->append(formatted_options);
@@ -2555,14 +2603,15 @@ void OneofDescriptor::DebugString(int depth, string* contents,
SourceLocationCommentPrinter
comment_printer(this, prefix, debug_string_options);
comment_printer.AddPreComment(contents);
- strings::SubstituteAndAppend(
- contents, "$0 oneof $1 {", prefix, name());
+ strings::SubstituteAndAppend(contents, "$0oneof $1 {", prefix, name());
- FormatLineOptions(depth, options(), contents);
+ FormatLineOptions(depth, options(), containing_type()->file()->pool(),
+ contents);
if (debug_string_options.elide_oneof_body) {
contents->append(" ... }\n");
} else {
+ contents->append("\n");
for (int i = 0; i < field_count(); i++) {
field(i)->DebugString(depth, FieldDescriptor::OMIT_LABEL, contents,
debug_string_options);
@@ -2597,7 +2646,7 @@ void EnumDescriptor::DebugString(int depth, string *contents,
strings::SubstituteAndAppend(contents, "$0enum $1 {\n",
prefix, name());
- FormatLineOptions(depth, options(), contents);
+ FormatLineOptions(depth, options(), file()->pool(), contents);
for (int i = 0; i < value_count(); i++) {
value(i)->DebugString(depth, contents, debug_string_options);
@@ -2632,7 +2681,8 @@ void EnumValueDescriptor::DebugString(int depth, string *contents,
prefix, name(), number());
string formatted_options;
- if (FormatBracketedOptions(depth, options(), &formatted_options)) {
+ if (FormatBracketedOptions(depth, options(), type()->file()->pool(),
+ &formatted_options)) {
strings::SubstituteAndAppend(contents, " [$0]", formatted_options);
}
contents->append(";\n");
@@ -2661,7 +2711,7 @@ void ServiceDescriptor::DebugString(string *contents,
strings::SubstituteAndAppend(contents, "service $0 {\n", name());
- FormatLineOptions(1, options(), contents);
+ FormatLineOptions(1, options(), file()->pool(), contents);
for (int i = 0; i < method_count(); i++) {
method(i)->DebugString(1, contents, debug_string_options);
@@ -2702,7 +2752,8 @@ void MethodDescriptor::DebugString(int depth, string *contents,
server_streaming() ? "stream " : "");
string formatted_options;
- if (FormatLineOptions(depth, options(), &formatted_options)) {
+ if (FormatLineOptions(depth, options(), service()->file()->pool(),
+ &formatted_options)) {
strings::SubstituteAndAppend(contents, " {\n$0$1}\n",
formatted_options, prefix);
} else {
@@ -2715,7 +2766,7 @@ void MethodDescriptor::DebugString(int depth, string *contents,
// Location methods ===============================================
-bool FileDescriptor::GetSourceLocation(const vector<int>& path,
+bool FileDescriptor::GetSourceLocation(const std::vector<int>& path,
SourceLocation* out_location) const {
GOOGLE_CHECK_NOTNULL(out_location);
if (source_code_info_) {
@@ -2741,7 +2792,7 @@ bool FileDescriptor::GetSourceLocation(const vector<int>& path,
}
bool FileDescriptor::GetSourceLocation(SourceLocation* out_location) const {
- vector<int> path; // empty path for root FileDescriptor
+ std::vector<int> path; // empty path for root FileDescriptor
return GetSourceLocation(path, out_location);
}
@@ -2755,49 +2806,49 @@ bool FieldDescriptor::is_packed() const {
}
bool Descriptor::GetSourceLocation(SourceLocation* out_location) const {
- vector<int> path;
+ std::vector<int> path;
GetLocationPath(&path);
return file()->GetSourceLocation(path, out_location);
}
bool FieldDescriptor::GetSourceLocation(SourceLocation* out_location) const {
- vector<int> path;
+ std::vector<int> path;
GetLocationPath(&path);
return file()->GetSourceLocation(path, out_location);
}
bool OneofDescriptor::GetSourceLocation(SourceLocation* out_location) const {
- vector<int> path;
+ std::vector<int> path;
GetLocationPath(&path);
return containing_type()->file()->GetSourceLocation(path, out_location);
}
bool EnumDescriptor::GetSourceLocation(SourceLocation* out_location) const {
- vector<int> path;
+ std::vector<int> path;
GetLocationPath(&path);
return file()->GetSourceLocation(path, out_location);
}
bool MethodDescriptor::GetSourceLocation(SourceLocation* out_location) const {
- vector<int> path;
+ std::vector<int> path;
GetLocationPath(&path);
return service()->file()->GetSourceLocation(path, out_location);
}
bool ServiceDescriptor::GetSourceLocation(SourceLocation* out_location) const {
- vector<int> path;
+ std::vector<int> path;
GetLocationPath(&path);
return file()->GetSourceLocation(path, out_location);
}
bool EnumValueDescriptor::GetSourceLocation(
SourceLocation* out_location) const {
- vector<int> path;
+ std::vector<int> path;
GetLocationPath(&path);
return type()->file()->GetSourceLocation(path, out_location);
}
-void Descriptor::GetLocationPath(vector<int>* output) const {
+void Descriptor::GetLocationPath(std::vector<int>* output) const {
if (containing_type()) {
containing_type()->GetLocationPath(output);
output->push_back(DescriptorProto::kNestedTypeFieldNumber);
@@ -2808,7 +2859,7 @@ void Descriptor::GetLocationPath(vector<int>* output) const {
}
}
-void FieldDescriptor::GetLocationPath(vector<int>* output) const {
+void FieldDescriptor::GetLocationPath(std::vector<int>* output) const {
if (is_extension()) {
if (extension_scope() == NULL) {
output->push_back(FileDescriptorProto::kExtensionFieldNumber);
@@ -2825,13 +2876,13 @@ void FieldDescriptor::GetLocationPath(vector<int>* output) const {
}
}
-void OneofDescriptor::GetLocationPath(vector<int>* output) const {
+void OneofDescriptor::GetLocationPath(std::vector<int>* output) const {
containing_type()->GetLocationPath(output);
output->push_back(DescriptorProto::kOneofDeclFieldNumber);
output->push_back(index());
}
-void EnumDescriptor::GetLocationPath(vector<int>* output) const {
+void EnumDescriptor::GetLocationPath(std::vector<int>* output) const {
if (containing_type()) {
containing_type()->GetLocationPath(output);
output->push_back(DescriptorProto::kEnumTypeFieldNumber);
@@ -2842,18 +2893,18 @@ void EnumDescriptor::GetLocationPath(vector<int>* output) const {
}
}
-void EnumValueDescriptor::GetLocationPath(vector<int>* output) const {
+void EnumValueDescriptor::GetLocationPath(std::vector<int>* output) const {
type()->GetLocationPath(output);
output->push_back(EnumDescriptorProto::kValueFieldNumber);
output->push_back(index());
}
-void ServiceDescriptor::GetLocationPath(vector<int>* output) const {
+void ServiceDescriptor::GetLocationPath(std::vector<int>* output) const {
output->push_back(FileDescriptorProto::kServiceFieldNumber);
output->push_back(index());
}
-void MethodDescriptor::GetLocationPath(vector<int>* output) const {
+void MethodDescriptor::GetLocationPath(std::vector<int>* output) const {
service()->GetLocationPath(output);
output->push_back(ServiceDescriptorProto::kMethodFieldNumber);
output->push_back(index());
@@ -2908,17 +2959,17 @@ class DescriptorBuilder {
// As we build descriptors we store copies of the options messages in
// them. We put pointers to those copies in this vector, as we build, so we
// can later (after cross-linking) interpret those options.
- vector<OptionsToInterpret> options_to_interpret_;
+ std::vector<OptionsToInterpret> options_to_interpret_;
bool had_errors_;
string filename_;
FileDescriptor* file_;
FileDescriptorTables* file_tables_;
- set<const FileDescriptor*> dependencies_;
+ std::set<const FileDescriptor*> dependencies_;
// unused_dependency_ is used to record the unused imported files.
// Note: public import is not considered.
- set<const FileDescriptor*> unused_dependency_;
+ std::set<const FileDescriptor*> unused_dependency_;
// If LookupSymbol() finds a symbol that is in a file which is not a declared
// dependency of this file, it will fail, but will set
@@ -3171,8 +3222,10 @@ class DescriptorBuilder {
// in unknown_fields to check if field innermost_field is set on the
// innermost message. Returns false and sets an error if so.
bool ExamineIfOptionIsSet(
- vector<const FieldDescriptor*>::const_iterator intermediate_fields_iter,
- vector<const FieldDescriptor*>::const_iterator intermediate_fields_end,
+ std::vector<const FieldDescriptor*>::const_iterator
+ intermediate_fields_iter,
+ std::vector<const FieldDescriptor*>::const_iterator
+ intermediate_fields_end,
const FieldDescriptor* innermost_field, const string& debug_msg_name,
const UnknownFieldSet& unknown_fields);
@@ -3498,7 +3551,8 @@ Symbol DescriptorBuilder::FindSymbol(const string& name) {
// dependency also defines the same package. We can't really rule out this
// symbol unless none of the dependencies define it.
if (IsInPackage(file_, name)) return result;
- for (set<const FileDescriptor*>::const_iterator it = dependencies_.begin();
+ for (std::set<const FileDescriptor*>::const_iterator it =
+ dependencies_.begin();
it != dependencies_.end(); ++it) {
// Note: A dependency may be NULL if it was not found or had errors.
if (*it != NULL && IsInPackage(*it, name)) return result;
@@ -3717,9 +3771,13 @@ bool DescriptorBuilder::AddSymbol(
if (tables_->AddSymbol(full_name, symbol)) {
if (!file_tables_->AddAliasUnderParent(parent, name, symbol)) {
- GOOGLE_LOG(DFATAL) << "\"" << full_name << "\" not previously defined in "
- "symbols_by_name_, but was defined in symbols_by_parent_; "
- "this shouldn't be possible.";
+ // This is only possible if there was already an error adding something of
+ // the same name.
+ if (!had_errors_) {
+ GOOGLE_LOG(DFATAL) << "\"" << full_name << "\" not previously defined in "
+ "symbols_by_name_, but was defined in "
+ "symbols_by_parent_; this shouldn't be possible.";
+ }
return false;
}
return true;
@@ -4037,12 +4095,12 @@ const FileDescriptor* DescriptorBuilder::BuildFileImpl(
}
// Make sure all dependencies are loaded.
- set<string> seen_dependencies;
+ std::set<string> seen_dependencies;
result->dependency_count_ = proto.dependency_size();
result->dependencies_ =
tables_->AllocateArray<const FileDescriptor*>(proto.dependency_size());
unused_dependency_.clear();
- set<int> weak_deps;
+ std::set<int> weak_deps;
for (int i = 0; i < proto.weak_dependency_size(); ++i) {
weak_deps.insert(proto.weak_dependency(i));
}
@@ -4056,6 +4114,14 @@ const FileDescriptor* DescriptorBuilder::BuildFileImpl(
dependency = pool_->underlay_->FindFileByName(proto.dependency(i));
}
+ if (dependency == result) {
+ // Recursive import. dependency/result is not fully initialized, and it's
+ // dangerous to try to do anything with it. The recursive import error
+ // will be detected and reported in DescriptorBuilder::BuildFile().
+ tables_->RollbackToLastCheckpoint();
+ return NULL;
+ }
+
if (dependency == NULL) {
if (pool_->allow_unknown_ ||
(!pool_->enforce_weak_ && weak_deps.find(i) != weak_deps.end())) {
@@ -4141,7 +4207,7 @@ const FileDescriptor* DescriptorBuilder::BuildFileImpl(
// extension options known, so all interpretations should now succeed.
if (!had_errors_) {
OptionInterpreter option_interpreter(this);
- for (vector<OptionsToInterpret>::iterator iter =
+ for (std::vector<OptionsToInterpret>::iterator iter =
options_to_interpret_.begin();
iter != options_to_interpret_.end(); ++iter) {
option_interpreter.InterpretOptions(&(*iter));
@@ -4289,7 +4355,7 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto,
for (int j = 0; j < result->reserved_range_count(); j++) {
const Descriptor::ReservedRange* range2 = result->reserved_range(j);
if (range1->end > range2->start && range2->end > range1->start) {
- AddError(result->full_name(), proto.extension_range(j),
+ AddError(result->full_name(), proto.extension_range(i),
DescriptorPool::ErrorCollector::NUMBER,
strings::Substitute("Extension range $0 to $1 overlaps with "
"reserved range $2 to $3.",
@@ -4300,7 +4366,7 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto,
for (int j = i + 1; j < result->extension_range_count(); j++) {
const Descriptor::ExtensionRange* range2 = result->extension_range(j);
if (range1->end > range2->start && range2->end > range1->start) {
- AddError(result->full_name(), proto.extension_range(j),
+ AddError(result->full_name(), proto.extension_range(i),
DescriptorPool::ErrorCollector::NUMBER,
strings::Substitute("Extension range $0 to $1 overlaps with "
"already-defined range $2 to $3.",
@@ -4411,11 +4477,14 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto,
break;
case FieldDescriptor::CPPTYPE_FLOAT:
if (proto.default_value() == "inf") {
- result->default_value_float_ = numeric_limits<float>::infinity();
+ result->default_value_float_ =
+ std::numeric_limits<float>::infinity();
} else if (proto.default_value() == "-inf") {
- result->default_value_float_ = -numeric_limits<float>::infinity();
+ result->default_value_float_ =
+ -std::numeric_limits<float>::infinity();
} else if (proto.default_value() == "nan") {
- result->default_value_float_ = numeric_limits<float>::quiet_NaN();
+ result->default_value_float_ =
+ std::numeric_limits<float>::quiet_NaN();
} else {
result->default_value_float_ = io::SafeDoubleToFloat(
io::NoLocaleStrtod(proto.default_value().c_str(), &end_pos));
@@ -4423,11 +4492,14 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto,
break;
case FieldDescriptor::CPPTYPE_DOUBLE:
if (proto.default_value() == "inf") {
- result->default_value_double_ = numeric_limits<double>::infinity();
+ result->default_value_double_ =
+ std::numeric_limits<double>::infinity();
} else if (proto.default_value() == "-inf") {
- result->default_value_double_ = -numeric_limits<double>::infinity();
+ result->default_value_double_ =
+ -std::numeric_limits<double>::infinity();
} else if (proto.default_value() == "nan") {
- result->default_value_double_ = numeric_limits<double>::quiet_NaN();
+ result->default_value_double_ =
+ std::numeric_limits<double>::quiet_NaN();
} else {
result->default_value_double_ =
io::NoLocaleStrtod(proto.default_value().c_str(), &end_pos);
@@ -4690,12 +4762,13 @@ void DescriptorBuilder::CheckEnumValueUniqueness(
// NAME_TYPE_LAST_NAME = 2,
// }
PrefixRemover remover(result->name());
- map<string, const google::protobuf::EnumValueDescriptor*> values;
+ std::map<string, const google::protobuf::EnumValueDescriptor*> values;
for (int i = 0; i < result->value_count(); i++) {
const google::protobuf::EnumValueDescriptor* value = result->value(i);
string stripped =
EnumValueToPascalCase(remover.MaybeRemove(value->name()));
- std::pair<map<string, const google::protobuf::EnumValueDescriptor*>::iterator, bool>
+ std::pair<std::map<string, const google::protobuf::EnumValueDescriptor*>::iterator,
+ bool>
insert_result = values.insert(std::make_pair(stripped, value));
bool inserted = insert_result.second;
@@ -5170,13 +5243,16 @@ void DescriptorBuilder::CrossLinkField(
const FieldDescriptor* conflicting_field =
file_tables_->FindFieldByNumber(field->containing_type(),
field->number());
+ string containing_type_name = field->containing_type() == NULL
+ ? "unknown"
+ : field->containing_type()->full_name();
if (field->is_extension()) {
AddError(field->full_name(), proto,
DescriptorPool::ErrorCollector::NUMBER,
strings::Substitute("Extension number $0 has already been used "
"in \"$1\" by extension \"$2\".",
field->number(),
- field->containing_type()->full_name(),
+ containing_type_name,
conflicting_field->full_name()));
} else {
AddError(field->full_name(), proto,
@@ -5184,7 +5260,7 @@ void DescriptorBuilder::CrossLinkField(
strings::Substitute("Field number $0 has already been used in "
"\"$1\" by field \"$2\".",
field->number(),
- field->containing_type()->full_name(),
+ containing_type_name,
conflicting_field->name()));
}
} else {
@@ -5378,7 +5454,7 @@ void DescriptorBuilder::ValidateProto3Message(
// In proto3, we reject field names if they conflict in camelCase.
// Note that we currently enforce a stricter rule: Field names must be
// unique after being converted to lowercase with underscores removed.
- map<string, const FieldDescriptor*> name_to_field;
+ std::map<string, const FieldDescriptor*> name_to_field;
for (int i = 0; i < message->field_count(); ++i) {
string lowercase_name = ToLowercaseWithoutUnderscores(
message->field(i)->name());
@@ -5529,7 +5605,7 @@ void DescriptorBuilder::ValidateEnumOptions(EnumDescriptor* enm,
const EnumDescriptorProto& proto) {
VALIDATE_OPTIONS_FROM_ARRAY(enm, value, EnumValue);
if (!enm->options().has_allow_alias() || !enm->options().allow_alias()) {
- map<int, string> used_values;
+ std::map<int, string> used_values;
for (int i = 0; i < enm->value_count(); ++i) {
const EnumValueDescriptor* enum_value = enm->value(i);
if (used_values.find(enum_value->number()) != used_values.end()) {
@@ -5656,10 +5732,10 @@ bool DescriptorBuilder::ValidateMapEntry(FieldDescriptor* field,
void DescriptorBuilder::DetectMapConflicts(const Descriptor* message,
const DescriptorProto& proto) {
- map<string, const Descriptor*> seen_types;
+ std::map<string, const Descriptor*> seen_types;
for (int i = 0; i < message->nested_type_count(); ++i) {
const Descriptor* nested = message->nested_type(i);
- pair<map<string, const Descriptor*>::iterator, bool> result =
+ std::pair<std::map<string, const Descriptor*>::iterator, bool> result =
seen_types.insert(std::make_pair(nested->name(), nested));
if (!result.second) {
if (result.first->second->options().map_entry() ||
@@ -5676,7 +5752,7 @@ void DescriptorBuilder::DetectMapConflicts(const Descriptor* message,
// Check for conflicted field names.
for (int i = 0; i < message->field_count(); ++i) {
const FieldDescriptor* field = message->field(i);
- map<string, const Descriptor*>::iterator iter =
+ std::map<string, const Descriptor*>::iterator iter =
seen_types.find(field->name());
if (iter != seen_types.end() && iter->second->options().map_entry()) {
AddError(message->full_name(), proto,
@@ -5688,7 +5764,7 @@ void DescriptorBuilder::DetectMapConflicts(const Descriptor* message,
// Check for conflicted enum names.
for (int i = 0; i < message->enum_type_count(); ++i) {
const EnumDescriptor* enum_desc = message->enum_type(i);
- map<string, const Descriptor*>::iterator iter =
+ std::map<string, const Descriptor*>::iterator iter =
seen_types.find(enum_desc->name());
if (iter != seen_types.end() && iter->second->options().map_entry()) {
AddError(message->full_name(), proto,
@@ -5700,7 +5776,7 @@ void DescriptorBuilder::DetectMapConflicts(const Descriptor* message,
// Check for conflicted oneof names.
for (int i = 0; i < message->oneof_decl_count(); ++i) {
const OneofDescriptor* oneof_desc = message->oneof_decl(i);
- map<string, const Descriptor*>::iterator iter =
+ std::map<string, const Descriptor*>::iterator iter =
seen_types.find(oneof_desc->name());
if (iter != seen_types.end() && iter->second->options().map_entry()) {
AddError(message->full_name(), proto,
@@ -5835,7 +5911,7 @@ bool DescriptorBuilder::OptionInterpreter::InterpretSingleOption(
// name in |debug_msg_name|, for use in error messages.
const Descriptor* descriptor = options_descriptor;
const FieldDescriptor* field = NULL;
- vector<const FieldDescriptor*> intermediate_fields;
+ std::vector<const FieldDescriptor*> intermediate_fields;
string debug_msg_name = "";
for (int i = 0; i < uninterpreted_option_->name_size(); ++i) {
@@ -5943,7 +6019,7 @@ bool DescriptorBuilder::OptionInterpreter::InterpretSingleOption(
// Now wrap the UnknownFieldSet with UnknownFieldSets corresponding to all
// the intermediate messages.
- for (vector<const FieldDescriptor*>::reverse_iterator iter =
+ for (std::vector<const FieldDescriptor*>::reverse_iterator iter =
intermediate_fields.rbegin();
iter != intermediate_fields.rend(); ++iter) {
google::protobuf::scoped_ptr<UnknownFieldSet> parent_unknown_fields(
@@ -5993,8 +6069,9 @@ void DescriptorBuilder::OptionInterpreter::AddWithoutInterpreting(
}
bool DescriptorBuilder::OptionInterpreter::ExamineIfOptionIsSet(
- vector<const FieldDescriptor*>::const_iterator intermediate_fields_iter,
- vector<const FieldDescriptor*>::const_iterator intermediate_fields_end,
+ std::vector<const FieldDescriptor*>::const_iterator
+ intermediate_fields_iter,
+ std::vector<const FieldDescriptor*>::const_iterator intermediate_fields_end,
const FieldDescriptor* innermost_field, const string& debug_msg_name,
const UnknownFieldSet& unknown_fields) {
// We do linear searches of the UnknownFieldSet and its sub-groups. This
@@ -6454,7 +6531,7 @@ void DescriptorBuilder::LogUnusedDependency(const FileDescriptorProto& proto,
annotation_extensions.insert("google.protobuf.ServiceOptions");
annotation_extensions.insert("google.protobuf.MethodOptions");
annotation_extensions.insert("google.protobuf.StreamOptions");
- for (set<const FileDescriptor*>::const_iterator
+ for (std::set<const FileDescriptor*>::const_iterator
it = unused_dependency_.begin();
it != unused_dependency_.end(); ++it) {
// Do not log warnings for proto files which extend annotations.
diff --git a/src/google/protobuf/descriptor.h b/src/google/protobuf/descriptor.h
index 0151e1d9..cc099693 100644
--- a/src/google/protobuf/descriptor.h
+++ b/src/google/protobuf/descriptor.h
@@ -62,6 +62,7 @@
#include <string>
#include <vector>
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/stubs/mutex.h>
// TYPE_BOOL is defined in the MacOS's ConditionalMacros.h.
#ifdef TYPE_BOOL
diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc
index 1e21e230..15c97d0b 100644
--- a/src/google/protobuf/descriptor.pb.cc
+++ b/src/google/protobuf/descriptor.pb.cc
@@ -19,898 +19,912 @@
namespace google {
namespace protobuf {
+class FileDescriptorSetDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorSet> {
+} _FileDescriptorSet_default_instance_;
+class FileDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorProto> {
+} _FileDescriptorProto_default_instance_;
+class DescriptorProto_ExtensionRangeDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ExtensionRange> {
+} _DescriptorProto_ExtensionRange_default_instance_;
+class DescriptorProto_ReservedRangeDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ReservedRange> {
+} _DescriptorProto_ReservedRange_default_instance_;
+class DescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto> {
+} _DescriptorProto_default_instance_;
+class FieldDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FieldDescriptorProto> {
+} _FieldDescriptorProto_default_instance_;
+class OneofDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<OneofDescriptorProto> {
+} _OneofDescriptorProto_default_instance_;
+class EnumDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumDescriptorProto> {
+} _EnumDescriptorProto_default_instance_;
+class EnumValueDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumValueDescriptorProto> {
+} _EnumValueDescriptorProto_default_instance_;
+class ServiceDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<ServiceDescriptorProto> {
+} _ServiceDescriptorProto_default_instance_;
+class MethodDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<MethodDescriptorProto> {
+} _MethodDescriptorProto_default_instance_;
+class FileOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FileOptions> {
+} _FileOptions_default_instance_;
+class MessageOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<MessageOptions> {
+} _MessageOptions_default_instance_;
+class FieldOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FieldOptions> {
+} _FieldOptions_default_instance_;
+class OneofOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<OneofOptions> {
+} _OneofOptions_default_instance_;
+class EnumOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumOptions> {
+} _EnumOptions_default_instance_;
+class EnumValueOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumValueOptions> {
+} _EnumValueOptions_default_instance_;
+class ServiceOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<ServiceOptions> {
+} _ServiceOptions_default_instance_;
+class MethodOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<MethodOptions> {
+} _MethodOptions_default_instance_;
+class UninterpretedOption_NamePartDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption_NamePart> {
+} _UninterpretedOption_NamePart_default_instance_;
+class UninterpretedOptionDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption> {
+} _UninterpretedOption_default_instance_;
+class SourceCodeInfo_LocationDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo_Location> {
+} _SourceCodeInfo_Location_default_instance_;
+class SourceCodeInfoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo> {
+} _SourceCodeInfo_default_instance_;
+class GeneratedCodeInfo_AnnotationDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo_Annotation> {
+} _GeneratedCodeInfo_Annotation_default_instance_;
+class GeneratedCodeInfoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo> {
+} _GeneratedCodeInfo_default_instance_;
+
+namespace protobuf_google_2fprotobuf_2fdescriptor_2eproto {
+
namespace {
-const ::google::protobuf::Descriptor* FileDescriptorSet_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- FileDescriptorSet_reflection_ = NULL;
-const ::google::protobuf::Descriptor* FileDescriptorProto_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- FileDescriptorProto_reflection_ = NULL;
-const ::google::protobuf::Descriptor* DescriptorProto_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- DescriptorProto_reflection_ = NULL;
-const ::google::protobuf::Descriptor* DescriptorProto_ExtensionRange_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- DescriptorProto_ExtensionRange_reflection_ = NULL;
-const ::google::protobuf::Descriptor* DescriptorProto_ReservedRange_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- DescriptorProto_ReservedRange_reflection_ = NULL;
-const ::google::protobuf::Descriptor* FieldDescriptorProto_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- FieldDescriptorProto_reflection_ = NULL;
-const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Type_descriptor_ = NULL;
-const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Label_descriptor_ = NULL;
-const ::google::protobuf::Descriptor* OneofDescriptorProto_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- OneofDescriptorProto_reflection_ = NULL;
-const ::google::protobuf::Descriptor* EnumDescriptorProto_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- EnumDescriptorProto_reflection_ = NULL;
-const ::google::protobuf::Descriptor* EnumValueDescriptorProto_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- EnumValueDescriptorProto_reflection_ = NULL;
-const ::google::protobuf::Descriptor* ServiceDescriptorProto_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- ServiceDescriptorProto_reflection_ = NULL;
-const ::google::protobuf::Descriptor* MethodDescriptorProto_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- MethodDescriptorProto_reflection_ = NULL;
-const ::google::protobuf::Descriptor* FileOptions_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- FileOptions_reflection_ = NULL;
-const ::google::protobuf::EnumDescriptor* FileOptions_OptimizeMode_descriptor_ = NULL;
-const ::google::protobuf::Descriptor* MessageOptions_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- MessageOptions_reflection_ = NULL;
-const ::google::protobuf::Descriptor* FieldOptions_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- FieldOptions_reflection_ = NULL;
-const ::google::protobuf::EnumDescriptor* FieldOptions_CType_descriptor_ = NULL;
-const ::google::protobuf::EnumDescriptor* FieldOptions_JSType_descriptor_ = NULL;
-const ::google::protobuf::Descriptor* OneofOptions_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- OneofOptions_reflection_ = NULL;
-const ::google::protobuf::Descriptor* EnumOptions_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- EnumOptions_reflection_ = NULL;
-const ::google::protobuf::Descriptor* EnumValueOptions_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- EnumValueOptions_reflection_ = NULL;
-const ::google::protobuf::Descriptor* ServiceOptions_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- ServiceOptions_reflection_ = NULL;
-const ::google::protobuf::Descriptor* MethodOptions_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- MethodOptions_reflection_ = NULL;
-const ::google::protobuf::Descriptor* UninterpretedOption_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- UninterpretedOption_reflection_ = NULL;
-const ::google::protobuf::Descriptor* UninterpretedOption_NamePart_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- UninterpretedOption_NamePart_reflection_ = NULL;
-const ::google::protobuf::Descriptor* SourceCodeInfo_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- SourceCodeInfo_reflection_ = NULL;
-const ::google::protobuf::Descriptor* SourceCodeInfo_Location_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- SourceCodeInfo_Location_reflection_ = NULL;
-const ::google::protobuf::Descriptor* GeneratedCodeInfo_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- GeneratedCodeInfo_reflection_ = NULL;
-const ::google::protobuf::Descriptor* GeneratedCodeInfo_Annotation_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- GeneratedCodeInfo_Annotation_reflection_ = NULL;
+::google::protobuf::Metadata file_level_metadata[25];
+const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors[6];
} // namespace
-
-void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() GOOGLE_ATTRIBUTE_COLD;
-void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() {
- protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();
- const ::google::protobuf::FileDescriptor* file =
- ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
- "google/protobuf/descriptor.proto");
- GOOGLE_CHECK(file != NULL);
- FileDescriptorSet_descriptor_ = file->message_type(0);
- static const int FileDescriptorSet_offsets_[1] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, file_),
- };
- FileDescriptorSet_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- FileDescriptorSet_descriptor_,
- FileDescriptorSet::internal_default_instance(),
- FileDescriptorSet_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _has_bits_),
- -1,
- -1,
- sizeof(FileDescriptorSet),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _internal_metadata_));
- FileDescriptorProto_descriptor_ = file->message_type(1);
- static const int FileDescriptorProto_offsets_[12] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, package_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, dependency_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, public_dependency_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, weak_dependency_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, message_type_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, enum_type_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, service_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, extension_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, options_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, source_code_info_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, syntax_),
- };
- FileDescriptorProto_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- FileDescriptorProto_descriptor_,
- FileDescriptorProto::internal_default_instance(),
- FileDescriptorProto_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _has_bits_),
- -1,
- -1,
- sizeof(FileDescriptorProto),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _internal_metadata_));
- DescriptorProto_descriptor_ = file->message_type(2);
- static const int DescriptorProto_offsets_[10] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, field_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, extension_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, nested_type_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, enum_type_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, extension_range_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, oneof_decl_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, options_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, reserved_range_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, reserved_name_),
- };
- DescriptorProto_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- DescriptorProto_descriptor_,
- DescriptorProto::internal_default_instance(),
- DescriptorProto_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, _has_bits_),
- -1,
- -1,
- sizeof(DescriptorProto),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, _internal_metadata_));
- DescriptorProto_ExtensionRange_descriptor_ = DescriptorProto_descriptor_->nested_type(0);
- static const int DescriptorProto_ExtensionRange_offsets_[2] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, start_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, end_),
- };
- DescriptorProto_ExtensionRange_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- DescriptorProto_ExtensionRange_descriptor_,
- DescriptorProto_ExtensionRange::internal_default_instance(),
- DescriptorProto_ExtensionRange_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, _has_bits_),
- -1,
- -1,
- sizeof(DescriptorProto_ExtensionRange),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, _internal_metadata_));
- DescriptorProto_ReservedRange_descriptor_ = DescriptorProto_descriptor_->nested_type(1);
- static const int DescriptorProto_ReservedRange_offsets_[2] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, start_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, end_),
- };
- DescriptorProto_ReservedRange_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- DescriptorProto_ReservedRange_descriptor_,
- DescriptorProto_ReservedRange::internal_default_instance(),
- DescriptorProto_ReservedRange_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, _has_bits_),
- -1,
- -1,
- sizeof(DescriptorProto_ReservedRange),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, _internal_metadata_));
- FieldDescriptorProto_descriptor_ = file->message_type(3);
- static const int FieldDescriptorProto_offsets_[10] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, number_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, label_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, type_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, type_name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, extendee_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, default_value_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, oneof_index_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, json_name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, options_),
- };
- FieldDescriptorProto_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- FieldDescriptorProto_descriptor_,
- FieldDescriptorProto::internal_default_instance(),
- FieldDescriptorProto_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, _has_bits_),
- -1,
- -1,
- sizeof(FieldDescriptorProto),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, _internal_metadata_));
- FieldDescriptorProto_Type_descriptor_ = FieldDescriptorProto_descriptor_->enum_type(0);
- FieldDescriptorProto_Label_descriptor_ = FieldDescriptorProto_descriptor_->enum_type(1);
- OneofDescriptorProto_descriptor_ = file->message_type(4);
- static const int OneofDescriptorProto_offsets_[2] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, options_),
- };
- OneofDescriptorProto_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- OneofDescriptorProto_descriptor_,
- OneofDescriptorProto::internal_default_instance(),
- OneofDescriptorProto_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, _has_bits_),
- -1,
- -1,
- sizeof(OneofDescriptorProto),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, _internal_metadata_));
- EnumDescriptorProto_descriptor_ = file->message_type(5);
- static const int EnumDescriptorProto_offsets_[3] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, value_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, options_),
- };
- EnumDescriptorProto_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- EnumDescriptorProto_descriptor_,
- EnumDescriptorProto::internal_default_instance(),
- EnumDescriptorProto_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _has_bits_),
- -1,
- -1,
- sizeof(EnumDescriptorProto),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _internal_metadata_));
- EnumValueDescriptorProto_descriptor_ = file->message_type(6);
- static const int EnumValueDescriptorProto_offsets_[3] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, number_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, options_),
- };
- EnumValueDescriptorProto_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- EnumValueDescriptorProto_descriptor_,
- EnumValueDescriptorProto::internal_default_instance(),
- EnumValueDescriptorProto_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _has_bits_),
- -1,
- -1,
- sizeof(EnumValueDescriptorProto),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _internal_metadata_));
- ServiceDescriptorProto_descriptor_ = file->message_type(7);
- static const int ServiceDescriptorProto_offsets_[3] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, method_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, options_),
- };
- ServiceDescriptorProto_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- ServiceDescriptorProto_descriptor_,
- ServiceDescriptorProto::internal_default_instance(),
- ServiceDescriptorProto_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _has_bits_),
- -1,
- -1,
- sizeof(ServiceDescriptorProto),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _internal_metadata_));
- MethodDescriptorProto_descriptor_ = file->message_type(8);
- static const int MethodDescriptorProto_offsets_[6] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, input_type_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, output_type_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, options_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, client_streaming_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, server_streaming_),
- };
- MethodDescriptorProto_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- MethodDescriptorProto_descriptor_,
- MethodDescriptorProto::internal_default_instance(),
- MethodDescriptorProto_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _has_bits_),
- -1,
- -1,
- sizeof(MethodDescriptorProto),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _internal_metadata_));
- FileOptions_descriptor_ = file->message_type(9);
- static const int FileOptions_offsets_[15] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_package_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_outer_classname_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_multiple_files_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_generate_equals_and_hash_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_string_check_utf8_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, optimize_for_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, go_package_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, cc_generic_services_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_generic_services_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, py_generic_services_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, deprecated_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, cc_enable_arenas_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, objc_class_prefix_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_namespace_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, uninterpreted_option_),
- };
- FileOptions_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- FileOptions_descriptor_,
- FileOptions::internal_default_instance(),
- FileOptions_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _has_bits_),
- -1,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _extensions_),
- sizeof(FileOptions),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _internal_metadata_));
- FileOptions_OptimizeMode_descriptor_ = FileOptions_descriptor_->enum_type(0);
- MessageOptions_descriptor_ = file->message_type(10);
- static const int MessageOptions_offsets_[5] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, message_set_wire_format_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, no_standard_descriptor_accessor_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, deprecated_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, map_entry_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, uninterpreted_option_),
- };
- MessageOptions_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- MessageOptions_descriptor_,
- MessageOptions::internal_default_instance(),
- MessageOptions_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _has_bits_),
- -1,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _extensions_),
- sizeof(MessageOptions),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _internal_metadata_));
- FieldOptions_descriptor_ = file->message_type(11);
- static const int FieldOptions_offsets_[7] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, ctype_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, packed_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, jstype_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, lazy_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, deprecated_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, weak_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, uninterpreted_option_),
- };
- FieldOptions_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- FieldOptions_descriptor_,
- FieldOptions::internal_default_instance(),
- FieldOptions_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _has_bits_),
- -1,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _extensions_),
- sizeof(FieldOptions),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _internal_metadata_));
- FieldOptions_CType_descriptor_ = FieldOptions_descriptor_->enum_type(0);
- FieldOptions_JSType_descriptor_ = FieldOptions_descriptor_->enum_type(1);
- OneofOptions_descriptor_ = file->message_type(12);
- static const int OneofOptions_offsets_[1] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, uninterpreted_option_),
- };
- OneofOptions_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- OneofOptions_descriptor_,
- OneofOptions::internal_default_instance(),
- OneofOptions_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _has_bits_),
- -1,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _extensions_),
- sizeof(OneofOptions),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _internal_metadata_));
- EnumOptions_descriptor_ = file->message_type(13);
- static const int EnumOptions_offsets_[3] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, allow_alias_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, deprecated_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, uninterpreted_option_),
- };
- EnumOptions_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- EnumOptions_descriptor_,
- EnumOptions::internal_default_instance(),
- EnumOptions_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _has_bits_),
- -1,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _extensions_),
- sizeof(EnumOptions),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _internal_metadata_));
- EnumValueOptions_descriptor_ = file->message_type(14);
- static const int EnumValueOptions_offsets_[2] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, deprecated_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, uninterpreted_option_),
- };
- EnumValueOptions_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- EnumValueOptions_descriptor_,
- EnumValueOptions::internal_default_instance(),
- EnumValueOptions_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _has_bits_),
- -1,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _extensions_),
- sizeof(EnumValueOptions),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _internal_metadata_));
- ServiceOptions_descriptor_ = file->message_type(15);
- static const int ServiceOptions_offsets_[2] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, deprecated_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, uninterpreted_option_),
- };
- ServiceOptions_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- ServiceOptions_descriptor_,
- ServiceOptions::internal_default_instance(),
- ServiceOptions_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _has_bits_),
- -1,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _extensions_),
- sizeof(ServiceOptions),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _internal_metadata_));
- MethodOptions_descriptor_ = file->message_type(16);
- static const int MethodOptions_offsets_[2] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, deprecated_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, uninterpreted_option_),
- };
- MethodOptions_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- MethodOptions_descriptor_,
- MethodOptions::internal_default_instance(),
- MethodOptions_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _has_bits_),
- -1,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _extensions_),
- sizeof(MethodOptions),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _internal_metadata_));
- UninterpretedOption_descriptor_ = file->message_type(17);
- static const int UninterpretedOption_offsets_[7] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, identifier_value_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, positive_int_value_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, negative_int_value_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, double_value_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, string_value_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, aggregate_value_),
- };
- UninterpretedOption_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- UninterpretedOption_descriptor_,
- UninterpretedOption::internal_default_instance(),
- UninterpretedOption_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, _has_bits_),
- -1,
- -1,
- sizeof(UninterpretedOption),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, _internal_metadata_));
- UninterpretedOption_NamePart_descriptor_ = UninterpretedOption_descriptor_->nested_type(0);
- static const int UninterpretedOption_NamePart_offsets_[2] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, name_part_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, is_extension_),
- };
- UninterpretedOption_NamePart_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- UninterpretedOption_NamePart_descriptor_,
- UninterpretedOption_NamePart::internal_default_instance(),
- UninterpretedOption_NamePart_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, _has_bits_),
- -1,
- -1,
- sizeof(UninterpretedOption_NamePart),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, _internal_metadata_));
- SourceCodeInfo_descriptor_ = file->message_type(18);
- static const int SourceCodeInfo_offsets_[1] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, location_),
- };
- SourceCodeInfo_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- SourceCodeInfo_descriptor_,
- SourceCodeInfo::internal_default_instance(),
- SourceCodeInfo_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _has_bits_),
- -1,
- -1,
- sizeof(SourceCodeInfo),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _internal_metadata_));
- SourceCodeInfo_Location_descriptor_ = SourceCodeInfo_descriptor_->nested_type(0);
- static const int SourceCodeInfo_Location_offsets_[5] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, path_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, span_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, leading_comments_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, trailing_comments_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, leading_detached_comments_),
- };
- SourceCodeInfo_Location_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- SourceCodeInfo_Location_descriptor_,
- SourceCodeInfo_Location::internal_default_instance(),
- SourceCodeInfo_Location_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, _has_bits_),
- -1,
- -1,
- sizeof(SourceCodeInfo_Location),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, _internal_metadata_));
- GeneratedCodeInfo_descriptor_ = file->message_type(19);
- static const int GeneratedCodeInfo_offsets_[1] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, annotation_),
- };
- GeneratedCodeInfo_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- GeneratedCodeInfo_descriptor_,
- GeneratedCodeInfo::internal_default_instance(),
- GeneratedCodeInfo_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, _has_bits_),
- -1,
- -1,
- sizeof(GeneratedCodeInfo),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, _internal_metadata_));
- GeneratedCodeInfo_Annotation_descriptor_ = GeneratedCodeInfo_descriptor_->nested_type(0);
- static const int GeneratedCodeInfo_Annotation_offsets_[4] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, path_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, source_file_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, begin_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, end_),
- };
- GeneratedCodeInfo_Annotation_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- GeneratedCodeInfo_Annotation_descriptor_,
- GeneratedCodeInfo_Annotation::internal_default_instance(),
- GeneratedCodeInfo_Annotation_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _has_bits_),
- -1,
- -1,
- sizeof(GeneratedCodeInfo_Annotation),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _internal_metadata_));
-}
+const ::google::protobuf::uint32 TableStruct::offsets[] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, file_),
+ ~0u,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, package_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, dependency_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, public_dependency_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, weak_dependency_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, message_type_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, enum_type_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, service_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, extension_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, options_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, source_code_info_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, syntax_),
+ 0,
+ 1,
+ ~0u,
+ ~0u,
+ ~0u,
+ ~0u,
+ ~0u,
+ ~0u,
+ ~0u,
+ 3,
+ 4,
+ 2,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, start_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, end_),
+ 0,
+ 1,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, start_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, end_),
+ 0,
+ 1,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, field_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, extension_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, nested_type_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, enum_type_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, extension_range_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, oneof_decl_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, options_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, reserved_range_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, reserved_name_),
+ 0,
+ ~0u,
+ ~0u,
+ ~0u,
+ ~0u,
+ ~0u,
+ ~0u,
+ 1,
+ ~0u,
+ ~0u,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, number_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, label_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, type_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, type_name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, extendee_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, default_value_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, oneof_index_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, json_name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, options_),
+ 0,
+ 6,
+ 8,
+ 9,
+ 1,
+ 2,
+ 3,
+ 7,
+ 4,
+ 5,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, options_),
+ 0,
+ 1,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, value_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, options_),
+ 0,
+ ~0u,
+ 1,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, number_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, options_),
+ 0,
+ 2,
+ 1,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, method_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, options_),
+ 0,
+ ~0u,
+ 1,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, input_type_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, output_type_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, options_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, client_streaming_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, server_streaming_),
+ 0,
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _internal_metadata_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _extensions_),
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_package_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_outer_classname_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_multiple_files_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_generate_equals_and_hash_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_string_check_utf8_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, optimize_for_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, go_package_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, cc_generic_services_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_generic_services_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, py_generic_services_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, deprecated_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, cc_enable_arenas_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, objc_class_prefix_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_namespace_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, swift_prefix_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, uninterpreted_option_),
+ 0,
+ 1,
+ 6,
+ 7,
+ 8,
+ 14,
+ 2,
+ 9,
+ 10,
+ 11,
+ 12,
+ 13,
+ 3,
+ 4,
+ 5,
+ ~0u,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _internal_metadata_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _extensions_),
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, message_set_wire_format_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, no_standard_descriptor_accessor_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, deprecated_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, map_entry_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, uninterpreted_option_),
+ 0,
+ 1,
+ 2,
+ 3,
+ ~0u,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _internal_metadata_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _extensions_),
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, ctype_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, packed_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, jstype_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, lazy_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, deprecated_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, weak_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, uninterpreted_option_),
+ 0,
+ 2,
+ 1,
+ 3,
+ 4,
+ 5,
+ ~0u,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _internal_metadata_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _extensions_),
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, uninterpreted_option_),
+ ~0u,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _internal_metadata_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _extensions_),
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, allow_alias_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, deprecated_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, uninterpreted_option_),
+ 0,
+ 1,
+ ~0u,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _internal_metadata_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _extensions_),
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, deprecated_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, uninterpreted_option_),
+ 0,
+ ~0u,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _internal_metadata_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _extensions_),
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, deprecated_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, uninterpreted_option_),
+ 0,
+ ~0u,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _internal_metadata_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _extensions_),
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, deprecated_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, idempotency_level_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, uninterpreted_option_),
+ 0,
+ 1,
+ ~0u,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, name_part_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, is_extension_),
+ 0,
+ 1,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, identifier_value_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, positive_int_value_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, negative_int_value_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, double_value_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, string_value_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, aggregate_value_),
+ ~0u,
+ 0,
+ 3,
+ 4,
+ 5,
+ 1,
+ 2,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, path_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, span_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, leading_comments_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, trailing_comments_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, leading_detached_comments_),
+ ~0u,
+ ~0u,
+ 0,
+ 1,
+ ~0u,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, location_),
+ ~0u,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, path_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, source_file_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, begin_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, end_),
+ ~0u,
+ 0,
+ 1,
+ 2,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, annotation_),
+ ~0u,
+};
+
+static const ::google::protobuf::internal::MigrationSchema schemas[] = {
+ { 0, 5, sizeof(FileDescriptorSet)},
+ { 6, 22, sizeof(FileDescriptorProto)},
+ { 34, 40, sizeof(DescriptorProto_ExtensionRange)},
+ { 42, 48, sizeof(DescriptorProto_ReservedRange)},
+ { 50, 64, sizeof(DescriptorProto)},
+ { 74, 88, sizeof(FieldDescriptorProto)},
+ { 98, 104, sizeof(OneofDescriptorProto)},
+ { 106, 113, sizeof(EnumDescriptorProto)},
+ { 116, 123, sizeof(EnumValueDescriptorProto)},
+ { 126, 133, sizeof(ServiceDescriptorProto)},
+ { 136, 146, sizeof(MethodDescriptorProto)},
+ { 152, 172, sizeof(FileOptions)},
+ { 188, 197, sizeof(MessageOptions)},
+ { 202, 213, sizeof(FieldOptions)},
+ { 220, 225, sizeof(OneofOptions)},
+ { 226, 233, sizeof(EnumOptions)},
+ { 236, 242, sizeof(EnumValueOptions)},
+ { 244, 250, sizeof(ServiceOptions)},
+ { 252, 259, sizeof(MethodOptions)},
+ { 262, 268, sizeof(UninterpretedOption_NamePart)},
+ { 270, 281, sizeof(UninterpretedOption)},
+ { 288, 297, sizeof(SourceCodeInfo_Location)},
+ { 302, 307, sizeof(SourceCodeInfo)},
+ { 308, 316, sizeof(GeneratedCodeInfo_Annotation)},
+ { 320, 325, sizeof(GeneratedCodeInfo)},
+};
+
+static ::google::protobuf::Message const * const file_default_instances[] = {
+ reinterpret_cast<const ::google::protobuf::Message*>(&_FileDescriptorSet_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_FileDescriptorProto_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_DescriptorProto_ExtensionRange_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_DescriptorProto_ReservedRange_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_DescriptorProto_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_FieldDescriptorProto_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_OneofDescriptorProto_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_EnumDescriptorProto_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_EnumValueDescriptorProto_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_ServiceDescriptorProto_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_MethodDescriptorProto_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_FileOptions_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_MessageOptions_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_FieldOptions_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_OneofOptions_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_EnumOptions_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_EnumValueOptions_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_ServiceOptions_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_MethodOptions_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_UninterpretedOption_NamePart_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_UninterpretedOption_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_SourceCodeInfo_Location_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_SourceCodeInfo_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_GeneratedCodeInfo_Annotation_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_GeneratedCodeInfo_default_instance_),
+};
namespace {
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
+void protobuf_AssignDescriptors() {
+ AddDescriptors();
+ ::google::protobuf::MessageFactory* factory = NULL;
+ AssignDescriptors(
+ "google/protobuf/descriptor.proto", schemas, file_default_instances, TableStruct::offsets, factory,
+ file_level_metadata, file_level_enum_descriptors, NULL);
+}
+
void protobuf_AssignDescriptorsOnce() {
- ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
- &protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto);
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);
}
void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;
void protobuf_RegisterTypes(const ::std::string&) {
protobuf_AssignDescriptorsOnce();
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- FileDescriptorSet_descriptor_, FileDescriptorSet::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- FileDescriptorProto_descriptor_, FileDescriptorProto::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- DescriptorProto_descriptor_, DescriptorProto::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- DescriptorProto_ExtensionRange_descriptor_, DescriptorProto_ExtensionRange::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- DescriptorProto_ReservedRange_descriptor_, DescriptorProto_ReservedRange::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- FieldDescriptorProto_descriptor_, FieldDescriptorProto::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- OneofDescriptorProto_descriptor_, OneofDescriptorProto::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- EnumDescriptorProto_descriptor_, EnumDescriptorProto::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- EnumValueDescriptorProto_descriptor_, EnumValueDescriptorProto::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- ServiceDescriptorProto_descriptor_, ServiceDescriptorProto::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- MethodDescriptorProto_descriptor_, MethodDescriptorProto::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- FileOptions_descriptor_, FileOptions::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- MessageOptions_descriptor_, MessageOptions::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- FieldOptions_descriptor_, FieldOptions::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- OneofOptions_descriptor_, OneofOptions::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- EnumOptions_descriptor_, EnumOptions::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- EnumValueOptions_descriptor_, EnumValueOptions::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- ServiceOptions_descriptor_, ServiceOptions::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- MethodOptions_descriptor_, MethodOptions::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- UninterpretedOption_descriptor_, UninterpretedOption::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- UninterpretedOption_NamePart_descriptor_, UninterpretedOption_NamePart::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- SourceCodeInfo_descriptor_, SourceCodeInfo::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- SourceCodeInfo_Location_descriptor_, SourceCodeInfo_Location::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- GeneratedCodeInfo_descriptor_, GeneratedCodeInfo::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- GeneratedCodeInfo_Annotation_descriptor_, GeneratedCodeInfo_Annotation::internal_default_instance());
+ ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 25);
}
} // namespace
-void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto() {
- FileDescriptorSet_default_instance_.Shutdown();
- delete FileDescriptorSet_reflection_;
- FileDescriptorProto_default_instance_.Shutdown();
- delete FileDescriptorProto_reflection_;
- DescriptorProto_default_instance_.Shutdown();
- delete DescriptorProto_reflection_;
- DescriptorProto_ExtensionRange_default_instance_.Shutdown();
- delete DescriptorProto_ExtensionRange_reflection_;
- DescriptorProto_ReservedRange_default_instance_.Shutdown();
- delete DescriptorProto_ReservedRange_reflection_;
- FieldDescriptorProto_default_instance_.Shutdown();
- delete FieldDescriptorProto_reflection_;
- OneofDescriptorProto_default_instance_.Shutdown();
- delete OneofDescriptorProto_reflection_;
- EnumDescriptorProto_default_instance_.Shutdown();
- delete EnumDescriptorProto_reflection_;
- EnumValueDescriptorProto_default_instance_.Shutdown();
- delete EnumValueDescriptorProto_reflection_;
- ServiceDescriptorProto_default_instance_.Shutdown();
- delete ServiceDescriptorProto_reflection_;
- MethodDescriptorProto_default_instance_.Shutdown();
- delete MethodDescriptorProto_reflection_;
- FileOptions_default_instance_.Shutdown();
- delete FileOptions_reflection_;
- MessageOptions_default_instance_.Shutdown();
- delete MessageOptions_reflection_;
- FieldOptions_default_instance_.Shutdown();
- delete FieldOptions_reflection_;
- OneofOptions_default_instance_.Shutdown();
- delete OneofOptions_reflection_;
- EnumOptions_default_instance_.Shutdown();
- delete EnumOptions_reflection_;
- EnumValueOptions_default_instance_.Shutdown();
- delete EnumValueOptions_reflection_;
- ServiceOptions_default_instance_.Shutdown();
- delete ServiceOptions_reflection_;
- MethodOptions_default_instance_.Shutdown();
- delete MethodOptions_reflection_;
- UninterpretedOption_default_instance_.Shutdown();
- delete UninterpretedOption_reflection_;
- UninterpretedOption_NamePart_default_instance_.Shutdown();
- delete UninterpretedOption_NamePart_reflection_;
- SourceCodeInfo_default_instance_.Shutdown();
- delete SourceCodeInfo_reflection_;
- SourceCodeInfo_Location_default_instance_.Shutdown();
- delete SourceCodeInfo_Location_reflection_;
- GeneratedCodeInfo_default_instance_.Shutdown();
- delete GeneratedCodeInfo_reflection_;
- GeneratedCodeInfo_Annotation_default_instance_.Shutdown();
- delete GeneratedCodeInfo_Annotation_reflection_;
-}
-
-void protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl() {
+void TableStruct::Shutdown() {
+ _FileDescriptorSet_default_instance_.Shutdown();
+ delete file_level_metadata[0].reflection;
+ _FileDescriptorProto_default_instance_.Shutdown();
+ delete file_level_metadata[1].reflection;
+ _DescriptorProto_ExtensionRange_default_instance_.Shutdown();
+ delete file_level_metadata[2].reflection;
+ _DescriptorProto_ReservedRange_default_instance_.Shutdown();
+ delete file_level_metadata[3].reflection;
+ _DescriptorProto_default_instance_.Shutdown();
+ delete file_level_metadata[4].reflection;
+ _FieldDescriptorProto_default_instance_.Shutdown();
+ delete file_level_metadata[5].reflection;
+ _OneofDescriptorProto_default_instance_.Shutdown();
+ delete file_level_metadata[6].reflection;
+ _EnumDescriptorProto_default_instance_.Shutdown();
+ delete file_level_metadata[7].reflection;
+ _EnumValueDescriptorProto_default_instance_.Shutdown();
+ delete file_level_metadata[8].reflection;
+ _ServiceDescriptorProto_default_instance_.Shutdown();
+ delete file_level_metadata[9].reflection;
+ _MethodDescriptorProto_default_instance_.Shutdown();
+ delete file_level_metadata[10].reflection;
+ _FileOptions_default_instance_.Shutdown();
+ delete file_level_metadata[11].reflection;
+ _MessageOptions_default_instance_.Shutdown();
+ delete file_level_metadata[12].reflection;
+ _FieldOptions_default_instance_.Shutdown();
+ delete file_level_metadata[13].reflection;
+ _OneofOptions_default_instance_.Shutdown();
+ delete file_level_metadata[14].reflection;
+ _EnumOptions_default_instance_.Shutdown();
+ delete file_level_metadata[15].reflection;
+ _EnumValueOptions_default_instance_.Shutdown();
+ delete file_level_metadata[16].reflection;
+ _ServiceOptions_default_instance_.Shutdown();
+ delete file_level_metadata[17].reflection;
+ _MethodOptions_default_instance_.Shutdown();
+ delete file_level_metadata[18].reflection;
+ _UninterpretedOption_NamePart_default_instance_.Shutdown();
+ delete file_level_metadata[19].reflection;
+ _UninterpretedOption_default_instance_.Shutdown();
+ delete file_level_metadata[20].reflection;
+ _SourceCodeInfo_Location_default_instance_.Shutdown();
+ delete file_level_metadata[21].reflection;
+ _SourceCodeInfo_default_instance_.Shutdown();
+ delete file_level_metadata[22].reflection;
+ _GeneratedCodeInfo_Annotation_default_instance_.Shutdown();
+ delete file_level_metadata[23].reflection;
+ _GeneratedCodeInfo_default_instance_.Shutdown();
+ delete file_level_metadata[24].reflection;
+}
+
+void TableStruct::InitDefaultsImpl() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
- FileDescriptorSet_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- FileDescriptorProto_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- DescriptorProto_default_instance_.DefaultConstruct();
- DescriptorProto_ExtensionRange_default_instance_.DefaultConstruct();
- DescriptorProto_ReservedRange_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- FieldDescriptorProto_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- OneofDescriptorProto_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- EnumDescriptorProto_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- EnumValueDescriptorProto_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- ServiceDescriptorProto_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- MethodDescriptorProto_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- FileOptions_default_instance_.DefaultConstruct();
- MessageOptions_default_instance_.DefaultConstruct();
- FieldOptions_default_instance_.DefaultConstruct();
- OneofOptions_default_instance_.DefaultConstruct();
- EnumOptions_default_instance_.DefaultConstruct();
- EnumValueOptions_default_instance_.DefaultConstruct();
- ServiceOptions_default_instance_.DefaultConstruct();
- MethodOptions_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- UninterpretedOption_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- UninterpretedOption_NamePart_default_instance_.DefaultConstruct();
- SourceCodeInfo_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- SourceCodeInfo_Location_default_instance_.DefaultConstruct();
- GeneratedCodeInfo_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- GeneratedCodeInfo_Annotation_default_instance_.DefaultConstruct();
- FileDescriptorSet_default_instance_.get_mutable()->InitAsDefaultInstance();
- FileDescriptorProto_default_instance_.get_mutable()->InitAsDefaultInstance();
- DescriptorProto_default_instance_.get_mutable()->InitAsDefaultInstance();
- DescriptorProto_ExtensionRange_default_instance_.get_mutable()->InitAsDefaultInstance();
- DescriptorProto_ReservedRange_default_instance_.get_mutable()->InitAsDefaultInstance();
- FieldDescriptorProto_default_instance_.get_mutable()->InitAsDefaultInstance();
- OneofDescriptorProto_default_instance_.get_mutable()->InitAsDefaultInstance();
- EnumDescriptorProto_default_instance_.get_mutable()->InitAsDefaultInstance();
- EnumValueDescriptorProto_default_instance_.get_mutable()->InitAsDefaultInstance();
- ServiceDescriptorProto_default_instance_.get_mutable()->InitAsDefaultInstance();
- MethodDescriptorProto_default_instance_.get_mutable()->InitAsDefaultInstance();
- FileOptions_default_instance_.get_mutable()->InitAsDefaultInstance();
- MessageOptions_default_instance_.get_mutable()->InitAsDefaultInstance();
- FieldOptions_default_instance_.get_mutable()->InitAsDefaultInstance();
- OneofOptions_default_instance_.get_mutable()->InitAsDefaultInstance();
- EnumOptions_default_instance_.get_mutable()->InitAsDefaultInstance();
- EnumValueOptions_default_instance_.get_mutable()->InitAsDefaultInstance();
- ServiceOptions_default_instance_.get_mutable()->InitAsDefaultInstance();
- MethodOptions_default_instance_.get_mutable()->InitAsDefaultInstance();
- UninterpretedOption_default_instance_.get_mutable()->InitAsDefaultInstance();
- UninterpretedOption_NamePart_default_instance_.get_mutable()->InitAsDefaultInstance();
- SourceCodeInfo_default_instance_.get_mutable()->InitAsDefaultInstance();
- SourceCodeInfo_Location_default_instance_.get_mutable()->InitAsDefaultInstance();
- GeneratedCodeInfo_default_instance_.get_mutable()->InitAsDefaultInstance();
- GeneratedCodeInfo_Annotation_default_instance_.get_mutable()->InitAsDefaultInstance();
-}
-
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_once_);
-void protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto() {
- ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_once_,
- &protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl);
-}
-void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl() {
- GOOGLE_PROTOBUF_VERIFY_VERSION;
+ ::google::protobuf::internal::InitProtobufDefaults();
+ _FileDescriptorSet_default_instance_.DefaultConstruct();
+ _FileDescriptorProto_default_instance_.DefaultConstruct();
+ _DescriptorProto_ExtensionRange_default_instance_.DefaultConstruct();
+ _DescriptorProto_ReservedRange_default_instance_.DefaultConstruct();
+ _DescriptorProto_default_instance_.DefaultConstruct();
+ _FieldDescriptorProto_default_instance_.DefaultConstruct();
+ _OneofDescriptorProto_default_instance_.DefaultConstruct();
+ _EnumDescriptorProto_default_instance_.DefaultConstruct();
+ _EnumValueDescriptorProto_default_instance_.DefaultConstruct();
+ _ServiceDescriptorProto_default_instance_.DefaultConstruct();
+ _MethodDescriptorProto_default_instance_.DefaultConstruct();
+ _FileOptions_default_instance_.DefaultConstruct();
+ _MessageOptions_default_instance_.DefaultConstruct();
+ _FieldOptions_default_instance_.DefaultConstruct();
+ _OneofOptions_default_instance_.DefaultConstruct();
+ _EnumOptions_default_instance_.DefaultConstruct();
+ _EnumValueOptions_default_instance_.DefaultConstruct();
+ _ServiceOptions_default_instance_.DefaultConstruct();
+ _MethodOptions_default_instance_.DefaultConstruct();
+ _UninterpretedOption_NamePart_default_instance_.DefaultConstruct();
+ _UninterpretedOption_default_instance_.DefaultConstruct();
+ _SourceCodeInfo_Location_default_instance_.DefaultConstruct();
+ _SourceCodeInfo_default_instance_.DefaultConstruct();
+ _GeneratedCodeInfo_Annotation_default_instance_.DefaultConstruct();
+ _GeneratedCodeInfo_default_instance_.DefaultConstruct();
+ _FileDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::FileOptions*>(
+ ::google::protobuf::FileOptions::internal_default_instance());
+ _FileDescriptorProto_default_instance_.get_mutable()->source_code_info_ = const_cast< ::google::protobuf::SourceCodeInfo*>(
+ ::google::protobuf::SourceCodeInfo::internal_default_instance());
+ _DescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::MessageOptions*>(
+ ::google::protobuf::MessageOptions::internal_default_instance());
+ _FieldDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::FieldOptions*>(
+ ::google::protobuf::FieldOptions::internal_default_instance());
+ _OneofDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::OneofOptions*>(
+ ::google::protobuf::OneofOptions::internal_default_instance());
+ _EnumDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::EnumOptions*>(
+ ::google::protobuf::EnumOptions::internal_default_instance());
+ _EnumValueDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::EnumValueOptions*>(
+ ::google::protobuf::EnumValueOptions::internal_default_instance());
+ _ServiceDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::ServiceOptions*>(
+ ::google::protobuf::ServiceOptions::internal_default_instance());
+ _MethodDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::MethodOptions*>(
+ ::google::protobuf::MethodOptions::internal_default_instance());
+}
- protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+void InitDefaults() {
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);
+}
+void AddDescriptorsImpl() {
+ InitDefaults();
+ static const char descriptor[] = {
+ "\n google/protobuf/descriptor.proto\022\017goog"
+ "le.protobuf\"G\n\021FileDescriptorSet\0222\n\004file"
+ "\030\001 \003(\0132$.google.protobuf.FileDescriptorP"
+ "roto\"\333\003\n\023FileDescriptorProto\022\014\n\004name\030\001 \001"
+ "(\t\022\017\n\007package\030\002 \001(\t\022\022\n\ndependency\030\003 \003(\t\022"
+ "\031\n\021public_dependency\030\n \003(\005\022\027\n\017weak_depen"
+ "dency\030\013 \003(\005\0226\n\014message_type\030\004 \003(\0132 .goog"
+ "le.protobuf.DescriptorProto\0227\n\tenum_type"
+ "\030\005 \003(\0132$.google.protobuf.EnumDescriptorP"
+ "roto\0228\n\007service\030\006 \003(\0132\'.google.protobuf."
+ "ServiceDescriptorProto\0228\n\textension\030\007 \003("
+ "\0132%.google.protobuf.FieldDescriptorProto"
+ "\022-\n\007options\030\010 \001(\0132\034.google.protobuf.File"
+ "Options\0229\n\020source_code_info\030\t \001(\0132\037.goog"
+ "le.protobuf.SourceCodeInfo\022\016\n\006syntax\030\014 \001"
+ "(\t\"\360\004\n\017DescriptorProto\022\014\n\004name\030\001 \001(\t\0224\n\005"
+ "field\030\002 \003(\0132%.google.protobuf.FieldDescr"
+ "iptorProto\0228\n\textension\030\006 \003(\0132%.google.p"
+ "rotobuf.FieldDescriptorProto\0225\n\013nested_t"
+ "ype\030\003 \003(\0132 .google.protobuf.DescriptorPr"
+ "oto\0227\n\tenum_type\030\004 \003(\0132$.google.protobuf"
+ ".EnumDescriptorProto\022H\n\017extension_range\030"
+ "\005 \003(\0132/.google.protobuf.DescriptorProto."
+ "ExtensionRange\0229\n\noneof_decl\030\010 \003(\0132%.goo"
+ "gle.protobuf.OneofDescriptorProto\0220\n\007opt"
+ "ions\030\007 \001(\0132\037.google.protobuf.MessageOpti"
+ "ons\022F\n\016reserved_range\030\t \003(\0132..google.pro"
+ "tobuf.DescriptorProto.ReservedRange\022\025\n\rr"
+ "eserved_name\030\n \003(\t\032,\n\016ExtensionRange\022\r\n\005"
+ "start\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\032+\n\rReservedRang"
+ "e\022\r\n\005start\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\"\274\005\n\024FieldD"
+ "escriptorProto\022\014\n\004name\030\001 \001(\t\022\016\n\006number\030\003"
+ " \001(\005\022:\n\005label\030\004 \001(\0162+.google.protobuf.Fi"
+ "eldDescriptorProto.Label\0228\n\004type\030\005 \001(\0162*"
+ ".google.protobuf.FieldDescriptorProto.Ty"
+ "pe\022\021\n\ttype_name\030\006 \001(\t\022\020\n\010extendee\030\002 \001(\t\022"
+ "\025\n\rdefault_value\030\007 \001(\t\022\023\n\013oneof_index\030\t "
+ "\001(\005\022\021\n\tjson_name\030\n \001(\t\022.\n\007options\030\010 \001(\0132"
+ "\035.google.protobuf.FieldOptions\"\266\002\n\004Type\022"
+ "\017\n\013TYPE_DOUBLE\020\001\022\016\n\nTYPE_FLOAT\020\002\022\016\n\nTYPE"
+ "_INT64\020\003\022\017\n\013TYPE_UINT64\020\004\022\016\n\nTYPE_INT32\020"
+ "\005\022\020\n\014TYPE_FIXED64\020\006\022\020\n\014TYPE_FIXED32\020\007\022\r\n"
+ "\tTYPE_BOOL\020\010\022\017\n\013TYPE_STRING\020\t\022\016\n\nTYPE_GR"
+ "OUP\020\n\022\020\n\014TYPE_MESSAGE\020\013\022\016\n\nTYPE_BYTES\020\014\022"
+ "\017\n\013TYPE_UINT32\020\r\022\r\n\tTYPE_ENUM\020\016\022\021\n\rTYPE_"
+ "SFIXED32\020\017\022\021\n\rTYPE_SFIXED64\020\020\022\017\n\013TYPE_SI"
+ "NT32\020\021\022\017\n\013TYPE_SINT64\020\022\"C\n\005Label\022\022\n\016LABE"
+ "L_OPTIONAL\020\001\022\022\n\016LABEL_REQUIRED\020\002\022\022\n\016LABE"
+ "L_REPEATED\020\003\"T\n\024OneofDescriptorProto\022\014\n\004"
+ "name\030\001 \001(\t\022.\n\007options\030\002 \001(\0132\035.google.pro"
+ "tobuf.OneofOptions\"\214\001\n\023EnumDescriptorPro"
+ "to\022\014\n\004name\030\001 \001(\t\0228\n\005value\030\002 \003(\0132).google"
+ ".protobuf.EnumValueDescriptorProto\022-\n\007op"
+ "tions\030\003 \001(\0132\034.google.protobuf.EnumOption"
+ "s\"l\n\030EnumValueDescriptorProto\022\014\n\004name\030\001 "
+ "\001(\t\022\016\n\006number\030\002 \001(\005\0222\n\007options\030\003 \001(\0132!.g"
+ "oogle.protobuf.EnumValueOptions\"\220\001\n\026Serv"
+ "iceDescriptorProto\022\014\n\004name\030\001 \001(\t\0226\n\006meth"
+ "od\030\002 \003(\0132&.google.protobuf.MethodDescrip"
+ "torProto\0220\n\007options\030\003 \001(\0132\037.google.proto"
+ "buf.ServiceOptions\"\301\001\n\025MethodDescriptorP"
+ "roto\022\014\n\004name\030\001 \001(\t\022\022\n\ninput_type\030\002 \001(\t\022\023"
+ "\n\013output_type\030\003 \001(\t\022/\n\007options\030\004 \001(\0132\036.g"
+ "oogle.protobuf.MethodOptions\022\037\n\020client_s"
+ "treaming\030\005 \001(\010:\005false\022\037\n\020server_streamin"
+ "g\030\006 \001(\010:\005false\"\232\005\n\013FileOptions\022\024\n\014java_p"
+ "ackage\030\001 \001(\t\022\034\n\024java_outer_classname\030\010 \001"
+ "(\t\022\"\n\023java_multiple_files\030\n \001(\010:\005false\022)"
+ "\n\035java_generate_equals_and_hash\030\024 \001(\010B\002\030"
+ "\001\022%\n\026java_string_check_utf8\030\033 \001(\010:\005false"
+ "\022F\n\014optimize_for\030\t \001(\0162).google.protobuf"
+ ".FileOptions.OptimizeMode:\005SPEED\022\022\n\ngo_p"
+ "ackage\030\013 \001(\t\022\"\n\023cc_generic_services\030\020 \001("
+ "\010:\005false\022$\n\025java_generic_services\030\021 \001(\010:"
+ "\005false\022\"\n\023py_generic_services\030\022 \001(\010:\005fal"
+ "se\022\031\n\ndeprecated\030\027 \001(\010:\005false\022\037\n\020cc_enab"
+ "le_arenas\030\037 \001(\010:\005false\022\031\n\021objc_class_pre"
+ "fix\030$ \001(\t\022\030\n\020csharp_namespace\030% \001(\t\022\024\n\014s"
+ "wift_prefix\030\' \001(\t\022C\n\024uninterpreted_optio"
+ "n\030\347\007 \003(\0132$.google.protobuf.Uninterpreted"
+ "Option\":\n\014OptimizeMode\022\t\n\005SPEED\020\001\022\r\n\tCOD"
+ "E_SIZE\020\002\022\020\n\014LITE_RUNTIME\020\003*\t\010\350\007\020\200\200\200\200\002J\004\010"
+ "&\020\'\"\354\001\n\016MessageOptions\022&\n\027message_set_wi"
+ "re_format\030\001 \001(\010:\005false\022.\n\037no_standard_de"
+ "scriptor_accessor\030\002 \001(\010:\005false\022\031\n\ndeprec"
+ "ated\030\003 \001(\010:\005false\022\021\n\tmap_entry\030\007 \001(\010\022C\n\024"
+ "uninterpreted_option\030\347\007 \003(\0132$.google.pro"
+ "tobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002J\004\010\010"
+ "\020\t\"\236\003\n\014FieldOptions\022:\n\005ctype\030\001 \001(\0162#.goo"
+ "gle.protobuf.FieldOptions.CType:\006STRING\022"
+ "\016\n\006packed\030\002 \001(\010\022\?\n\006jstype\030\006 \001(\0162$.google"
+ ".protobuf.FieldOptions.JSType:\tJS_NORMAL"
+ "\022\023\n\004lazy\030\005 \001(\010:\005false\022\031\n\ndeprecated\030\003 \001("
+ "\010:\005false\022\023\n\004weak\030\n \001(\010:\005false\022C\n\024uninter"
+ "preted_option\030\347\007 \003(\0132$.google.protobuf.U"
+ "ninterpretedOption\"/\n\005CType\022\n\n\006STRING\020\000\022"
+ "\010\n\004CORD\020\001\022\020\n\014STRING_PIECE\020\002\"5\n\006JSType\022\r\n"
+ "\tJS_NORMAL\020\000\022\r\n\tJS_STRING\020\001\022\r\n\tJS_NUMBER"
+ "\020\002*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005\"^\n\014OneofOptions\022C\n\024u"
+ "ninterpreted_option\030\347\007 \003(\0132$.google.prot"
+ "obuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"\215\001\n\013"
+ "EnumOptions\022\023\n\013allow_alias\030\002 \001(\010\022\031\n\ndepr"
+ "ecated\030\003 \001(\010:\005false\022C\n\024uninterpreted_opt"
+ "ion\030\347\007 \003(\0132$.google.protobuf.Uninterpret"
+ "edOption*\t\010\350\007\020\200\200\200\200\002\"}\n\020EnumValueOptions\022"
+ "\031\n\ndeprecated\030\001 \001(\010:\005false\022C\n\024uninterpre"
+ "ted_option\030\347\007 \003(\0132$.google.protobuf.Unin"
+ "terpretedOption*\t\010\350\007\020\200\200\200\200\002\"{\n\016ServiceOpt"
+ "ions\022\031\n\ndeprecated\030! \001(\010:\005false\022C\n\024unint"
+ "erpreted_option\030\347\007 \003(\0132$.google.protobuf"
+ ".UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"\255\002\n\rMeth"
+ "odOptions\022\031\n\ndeprecated\030! \001(\010:\005false\022_\n\021"
+ "idempotency_level\030\" \001(\0162/.google.protobu"
+ "f.MethodOptions.IdempotencyLevel:\023IDEMPO"
+ "TENCY_UNKNOWN\022C\n\024uninterpreted_option\030\347\007"
+ " \003(\0132$.google.protobuf.UninterpretedOpti"
+ "on\"P\n\020IdempotencyLevel\022\027\n\023IDEMPOTENCY_UN"
+ "KNOWN\020\000\022\023\n\017NO_SIDE_EFFECTS\020\001\022\016\n\nIDEMPOTE"
+ "NT\020\002*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023UninterpretedOption\022"
+ ";\n\004name\030\002 \003(\0132-.google.protobuf.Uninterp"
+ "retedOption.NamePart\022\030\n\020identifier_value"
+ "\030\003 \001(\t\022\032\n\022positive_int_value\030\004 \001(\004\022\032\n\022ne"
+ "gative_int_value\030\005 \001(\003\022\024\n\014double_value\030\006"
+ " \001(\001\022\024\n\014string_value\030\007 \001(\014\022\027\n\017aggregate_"
+ "value\030\010 \001(\t\0323\n\010NamePart\022\021\n\tname_part\030\001 \002"
+ "(\t\022\024\n\014is_extension\030\002 \002(\010\"\325\001\n\016SourceCodeI"
+ "nfo\022:\n\010location\030\001 \003(\0132(.google.protobuf."
+ "SourceCodeInfo.Location\032\206\001\n\010Location\022\020\n\004"
+ "path\030\001 \003(\005B\002\020\001\022\020\n\004span\030\002 \003(\005B\002\020\001\022\030\n\020lead"
+ "ing_comments\030\003 \001(\t\022\031\n\021trailing_comments\030"
+ "\004 \001(\t\022!\n\031leading_detached_comments\030\006 \003(\t"
+ "\"\247\001\n\021GeneratedCodeInfo\022A\n\nannotation\030\001 \003"
+ "(\0132-.google.protobuf.GeneratedCodeInfo.A"
+ "nnotation\032O\n\nAnnotation\022\020\n\004path\030\001 \003(\005B\002\020"
+ "\001\022\023\n\013source_file\030\002 \001(\t\022\r\n\005begin\030\003 \001(\005\022\013\n"
+ "\003end\030\004 \001(\005B\214\001\n\023com.google.protobufB\020Desc"
+ "riptorProtosH\001Z>github.com/golang/protob"
+ "uf/protoc-gen-go/descriptor;descriptor\242\002"
+ "\003GPB\252\002\032Google.Protobuf.Reflection"
+ };
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
- "\n google/protobuf/descriptor.proto\022\017goog"
- "le.protobuf\"G\n\021FileDescriptorSet\0222\n\004file"
- "\030\001 \003(\0132$.google.protobuf.FileDescriptorP"
- "roto\"\333\003\n\023FileDescriptorProto\022\014\n\004name\030\001 \001"
- "(\t\022\017\n\007package\030\002 \001(\t\022\022\n\ndependency\030\003 \003(\t\022"
- "\031\n\021public_dependency\030\n \003(\005\022\027\n\017weak_depen"
- "dency\030\013 \003(\005\0226\n\014message_type\030\004 \003(\0132 .goog"
- "le.protobuf.DescriptorProto\0227\n\tenum_type"
- "\030\005 \003(\0132$.google.protobuf.EnumDescriptorP"
- "roto\0228\n\007service\030\006 \003(\0132\'.google.protobuf."
- "ServiceDescriptorProto\0228\n\textension\030\007 \003("
- "\0132%.google.protobuf.FieldDescriptorProto"
- "\022-\n\007options\030\010 \001(\0132\034.google.protobuf.File"
- "Options\0229\n\020source_code_info\030\t \001(\0132\037.goog"
- "le.protobuf.SourceCodeInfo\022\016\n\006syntax\030\014 \001"
- "(\t\"\360\004\n\017DescriptorProto\022\014\n\004name\030\001 \001(\t\0224\n\005"
- "field\030\002 \003(\0132%.google.protobuf.FieldDescr"
- "iptorProto\0228\n\textension\030\006 \003(\0132%.google.p"
- "rotobuf.FieldDescriptorProto\0225\n\013nested_t"
- "ype\030\003 \003(\0132 .google.protobuf.DescriptorPr"
- "oto\0227\n\tenum_type\030\004 \003(\0132$.google.protobuf"
- ".EnumDescriptorProto\022H\n\017extension_range\030"
- "\005 \003(\0132/.google.protobuf.DescriptorProto."
- "ExtensionRange\0229\n\noneof_decl\030\010 \003(\0132%.goo"
- "gle.protobuf.OneofDescriptorProto\0220\n\007opt"
- "ions\030\007 \001(\0132\037.google.protobuf.MessageOpti"
- "ons\022F\n\016reserved_range\030\t \003(\0132..google.pro"
- "tobuf.DescriptorProto.ReservedRange\022\025\n\rr"
- "eserved_name\030\n \003(\t\032,\n\016ExtensionRange\022\r\n\005"
- "start\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\032+\n\rReservedRang"
- "e\022\r\n\005start\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\"\274\005\n\024FieldD"
- "escriptorProto\022\014\n\004name\030\001 \001(\t\022\016\n\006number\030\003"
- " \001(\005\022:\n\005label\030\004 \001(\0162+.google.protobuf.Fi"
- "eldDescriptorProto.Label\0228\n\004type\030\005 \001(\0162*"
- ".google.protobuf.FieldDescriptorProto.Ty"
- "pe\022\021\n\ttype_name\030\006 \001(\t\022\020\n\010extendee\030\002 \001(\t\022"
- "\025\n\rdefault_value\030\007 \001(\t\022\023\n\013oneof_index\030\t "
- "\001(\005\022\021\n\tjson_name\030\n \001(\t\022.\n\007options\030\010 \001(\0132"
- "\035.google.protobuf.FieldOptions\"\266\002\n\004Type\022"
- "\017\n\013TYPE_DOUBLE\020\001\022\016\n\nTYPE_FLOAT\020\002\022\016\n\nTYPE"
- "_INT64\020\003\022\017\n\013TYPE_UINT64\020\004\022\016\n\nTYPE_INT32\020"
- "\005\022\020\n\014TYPE_FIXED64\020\006\022\020\n\014TYPE_FIXED32\020\007\022\r\n"
- "\tTYPE_BOOL\020\010\022\017\n\013TYPE_STRING\020\t\022\016\n\nTYPE_GR"
- "OUP\020\n\022\020\n\014TYPE_MESSAGE\020\013\022\016\n\nTYPE_BYTES\020\014\022"
- "\017\n\013TYPE_UINT32\020\r\022\r\n\tTYPE_ENUM\020\016\022\021\n\rTYPE_"
- "SFIXED32\020\017\022\021\n\rTYPE_SFIXED64\020\020\022\017\n\013TYPE_SI"
- "NT32\020\021\022\017\n\013TYPE_SINT64\020\022\"C\n\005Label\022\022\n\016LABE"
- "L_OPTIONAL\020\001\022\022\n\016LABEL_REQUIRED\020\002\022\022\n\016LABE"
- "L_REPEATED\020\003\"T\n\024OneofDescriptorProto\022\014\n\004"
- "name\030\001 \001(\t\022.\n\007options\030\002 \001(\0132\035.google.pro"
- "tobuf.OneofOptions\"\214\001\n\023EnumDescriptorPro"
- "to\022\014\n\004name\030\001 \001(\t\0228\n\005value\030\002 \003(\0132).google"
- ".protobuf.EnumValueDescriptorProto\022-\n\007op"
- "tions\030\003 \001(\0132\034.google.protobuf.EnumOption"
- "s\"l\n\030EnumValueDescriptorProto\022\014\n\004name\030\001 "
- "\001(\t\022\016\n\006number\030\002 \001(\005\0222\n\007options\030\003 \001(\0132!.g"
- "oogle.protobuf.EnumValueOptions\"\220\001\n\026Serv"
- "iceDescriptorProto\022\014\n\004name\030\001 \001(\t\0226\n\006meth"
- "od\030\002 \003(\0132&.google.protobuf.MethodDescrip"
- "torProto\0220\n\007options\030\003 \001(\0132\037.google.proto"
- "buf.ServiceOptions\"\301\001\n\025MethodDescriptorP"
- "roto\022\014\n\004name\030\001 \001(\t\022\022\n\ninput_type\030\002 \001(\t\022\023"
- "\n\013output_type\030\003 \001(\t\022/\n\007options\030\004 \001(\0132\036.g"
- "oogle.protobuf.MethodOptions\022\037\n\020client_s"
- "treaming\030\005 \001(\010:\005false\022\037\n\020server_streamin"
- "g\030\006 \001(\010:\005false\"\204\005\n\013FileOptions\022\024\n\014java_p"
- "ackage\030\001 \001(\t\022\034\n\024java_outer_classname\030\010 \001"
- "(\t\022\"\n\023java_multiple_files\030\n \001(\010:\005false\022)"
- "\n\035java_generate_equals_and_hash\030\024 \001(\010B\002\030"
- "\001\022%\n\026java_string_check_utf8\030\033 \001(\010:\005false"
- "\022F\n\014optimize_for\030\t \001(\0162).google.protobuf"
- ".FileOptions.OptimizeMode:\005SPEED\022\022\n\ngo_p"
- "ackage\030\013 \001(\t\022\"\n\023cc_generic_services\030\020 \001("
- "\010:\005false\022$\n\025java_generic_services\030\021 \001(\010:"
- "\005false\022\"\n\023py_generic_services\030\022 \001(\010:\005fal"
- "se\022\031\n\ndeprecated\030\027 \001(\010:\005false\022\037\n\020cc_enab"
- "le_arenas\030\037 \001(\010:\005false\022\031\n\021objc_class_pre"
- "fix\030$ \001(\t\022\030\n\020csharp_namespace\030% \001(\t\022C\n\024u"
- "ninterpreted_option\030\347\007 \003(\0132$.google.prot"
- "obuf.UninterpretedOption\":\n\014OptimizeMode"
- "\022\t\n\005SPEED\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014LITE_RUNTI"
- "ME\020\003*\t\010\350\007\020\200\200\200\200\002J\004\010&\020\'\"\354\001\n\016MessageOptions"
- "\022&\n\027message_set_wire_format\030\001 \001(\010:\005false"
- "\022.\n\037no_standard_descriptor_accessor\030\002 \001("
- "\010:\005false\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\021\n\tm"
- "ap_entry\030\007 \001(\010\022C\n\024uninterpreted_option\030\347"
- "\007 \003(\0132$.google.protobuf.UninterpretedOpt"
- "ion*\t\010\350\007\020\200\200\200\200\002J\004\010\010\020\t\"\236\003\n\014FieldOptions\022:\n"
- "\005ctype\030\001 \001(\0162#.google.protobuf.FieldOpti"
- "ons.CType:\006STRING\022\016\n\006packed\030\002 \001(\010\022\?\n\006jst"
- "ype\030\006 \001(\0162$.google.protobuf.FieldOptions"
- ".JSType:\tJS_NORMAL\022\023\n\004lazy\030\005 \001(\010:\005false\022"
- "\031\n\ndeprecated\030\003 \001(\010:\005false\022\023\n\004weak\030\n \001(\010"
- ":\005false\022C\n\024uninterpreted_option\030\347\007 \003(\0132$"
- ".google.protobuf.UninterpretedOption\"/\n\005"
- "CType\022\n\n\006STRING\020\000\022\010\n\004CORD\020\001\022\020\n\014STRING_PI"
- "ECE\020\002\"5\n\006JSType\022\r\n\tJS_NORMAL\020\000\022\r\n\tJS_STR"
- "ING\020\001\022\r\n\tJS_NUMBER\020\002*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005\"^\n"
- "\014OneofOptions\022C\n\024uninterpreted_option\030\347\007"
- " \003(\0132$.google.protobuf.UninterpretedOpti"
- "on*\t\010\350\007\020\200\200\200\200\002\"\215\001\n\013EnumOptions\022\023\n\013allow_a"
- "lias\030\002 \001(\010\022\031\n\ndeprecated\030\003 \001(\010:\005false\022C\n"
- "\024uninterpreted_option\030\347\007 \003(\0132$.google.pr"
- "otobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"}\n"
- "\020EnumValueOptions\022\031\n\ndeprecated\030\001 \001(\010:\005f"
- "alse\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.go"
- "ogle.protobuf.UninterpretedOption*\t\010\350\007\020\200"
- "\200\200\200\002\"{\n\016ServiceOptions\022\031\n\ndeprecated\030! \001"
- "(\010:\005false\022C\n\024uninterpreted_option\030\347\007 \003(\013"
- "2$.google.protobuf.UninterpretedOption*\t"
- "\010\350\007\020\200\200\200\200\002\"z\n\rMethodOptions\022\031\n\ndeprecated"
- "\030! \001(\010:\005false\022C\n\024uninterpreted_option\030\347\007"
- " \003(\0132$.google.protobuf.UninterpretedOpti"
- "on*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023UninterpretedOption\022;\n"
- "\004name\030\002 \003(\0132-.google.protobuf.Uninterpre"
- "tedOption.NamePart\022\030\n\020identifier_value\030\003"
- " \001(\t\022\032\n\022positive_int_value\030\004 \001(\004\022\032\n\022nega"
- "tive_int_value\030\005 \001(\003\022\024\n\014double_value\030\006 \001"
- "(\001\022\024\n\014string_value\030\007 \001(\014\022\027\n\017aggregate_va"
- "lue\030\010 \001(\t\0323\n\010NamePart\022\021\n\tname_part\030\001 \002(\t"
- "\022\024\n\014is_extension\030\002 \002(\010\"\325\001\n\016SourceCodeInf"
- "o\022:\n\010location\030\001 \003(\0132(.google.protobuf.So"
- "urceCodeInfo.Location\032\206\001\n\010Location\022\020\n\004pa"
- "th\030\001 \003(\005B\002\020\001\022\020\n\004span\030\002 \003(\005B\002\020\001\022\030\n\020leadin"
- "g_comments\030\003 \001(\t\022\031\n\021trailing_comments\030\004 "
- "\001(\t\022!\n\031leading_detached_comments\030\006 \003(\t\"\247"
- "\001\n\021GeneratedCodeInfo\022A\n\nannotation\030\001 \003(\013"
- "2-.google.protobuf.GeneratedCodeInfo.Ann"
- "otation\032O\n\nAnnotation\022\020\n\004path\030\001 \003(\005B\002\020\001\022"
- "\023\n\013source_file\030\002 \001(\t\022\r\n\005begin\030\003 \001(\005\022\013\n\003e"
- "nd\030\004 \001(\005BX\n\023com.google.protobufB\020Descrip"
- "torProtosH\001Z\ndescriptor\242\002\003GPB\252\002\032Google.P"
- "rotobuf.Reflection", 5298);
+ descriptor, 5553);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"google/protobuf/descriptor.proto", &protobuf_RegisterTypes);
- ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto);
+ ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);
}
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_once_);
-void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() {
- ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_once_,
- &protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl);
+void AddDescriptors() {
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
}
// Force AddDescriptors() to be called at static initialization time.
-struct StaticDescriptorInitializer_google_2fprotobuf_2fdescriptor_2eproto {
- StaticDescriptorInitializer_google_2fprotobuf_2fdescriptor_2eproto() {
- protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();
+struct StaticDescriptorInitializer {
+ StaticDescriptorInitializer() {
+ AddDescriptors();
}
-} static_descriptor_initializer_google_2fprotobuf_2fdescriptor_2eproto_;
+} static_descriptor_initializer;
-namespace {
+} // namespace protobuf_google_2fprotobuf_2fdescriptor_2eproto
+
+const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Type_descriptor() {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_enum_descriptors[0];
+}
+bool FieldDescriptorProto_Type_IsValid(int value) {
+ switch (value) {
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ case 10:
+ case 11:
+ case 12:
+ case 13:
+ case 14:
+ case 15:
+ case 16:
+ case 17:
+ case 18:
+ return true;
+ default:
+ return false;
+ }
+}
-static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN;
-static void MergeFromFail(int line) {
- ::google::protobuf::internal::MergeFromFail(__FILE__, line);
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_DOUBLE;
+const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FLOAT;
+const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_INT64;
+const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_UINT64;
+const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_INT32;
+const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FIXED64;
+const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FIXED32;
+const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_BOOL;
+const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_STRING;
+const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_GROUP;
+const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_MESSAGE;
+const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_BYTES;
+const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_UINT32;
+const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_ENUM;
+const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SFIXED32;
+const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SFIXED64;
+const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SINT32;
+const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SINT64;
+const FieldDescriptorProto_Type FieldDescriptorProto::Type_MIN;
+const FieldDescriptorProto_Type FieldDescriptorProto::Type_MAX;
+const int FieldDescriptorProto::Type_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Label_descriptor() {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_enum_descriptors[1];
+}
+bool FieldDescriptorProto_Label_IsValid(int value) {
+ switch (value) {
+ case 1:
+ case 2:
+ case 3:
+ return true;
+ default:
+ return false;
+ }
}
-} // namespace
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const FieldDescriptorProto_Label FieldDescriptorProto::LABEL_OPTIONAL;
+const FieldDescriptorProto_Label FieldDescriptorProto::LABEL_REQUIRED;
+const FieldDescriptorProto_Label FieldDescriptorProto::LABEL_REPEATED;
+const FieldDescriptorProto_Label FieldDescriptorProto::Label_MIN;
+const FieldDescriptorProto_Label FieldDescriptorProto::Label_MAX;
+const int FieldDescriptorProto::Label_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+const ::google::protobuf::EnumDescriptor* FileOptions_OptimizeMode_descriptor() {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_enum_descriptors[2];
+}
+bool FileOptions_OptimizeMode_IsValid(int value) {
+ switch (value) {
+ case 1:
+ case 2:
+ case 3:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const FileOptions_OptimizeMode FileOptions::SPEED;
+const FileOptions_OptimizeMode FileOptions::CODE_SIZE;
+const FileOptions_OptimizeMode FileOptions::LITE_RUNTIME;
+const FileOptions_OptimizeMode FileOptions::OptimizeMode_MIN;
+const FileOptions_OptimizeMode FileOptions::OptimizeMode_MAX;
+const int FileOptions::OptimizeMode_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+const ::google::protobuf::EnumDescriptor* FieldOptions_CType_descriptor() {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_enum_descriptors[3];
+}
+bool FieldOptions_CType_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ case 2:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const FieldOptions_CType FieldOptions::STRING;
+const FieldOptions_CType FieldOptions::CORD;
+const FieldOptions_CType FieldOptions::STRING_PIECE;
+const FieldOptions_CType FieldOptions::CType_MIN;
+const FieldOptions_CType FieldOptions::CType_MAX;
+const int FieldOptions::CType_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+const ::google::protobuf::EnumDescriptor* FieldOptions_JSType_descriptor() {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_enum_descriptors[4];
+}
+bool FieldOptions_JSType_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ case 2:
+ return true;
+ default:
+ return false;
+ }
+}
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const FieldOptions_JSType FieldOptions::JS_NORMAL;
+const FieldOptions_JSType FieldOptions::JS_STRING;
+const FieldOptions_JSType FieldOptions::JS_NUMBER;
+const FieldOptions_JSType FieldOptions::JSType_MIN;
+const FieldOptions_JSType FieldOptions::JSType_MAX;
+const int FieldOptions::JSType_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+const ::google::protobuf::EnumDescriptor* MethodOptions_IdempotencyLevel_descriptor() {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_enum_descriptors[5];
+}
+bool MethodOptions_IdempotencyLevel_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ case 2:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const MethodOptions_IdempotencyLevel MethodOptions::IDEMPOTENCY_UNKNOWN;
+const MethodOptions_IdempotencyLevel MethodOptions::NO_SIDE_EFFECTS;
+const MethodOptions_IdempotencyLevel MethodOptions::IDEMPOTENT;
+const MethodOptions_IdempotencyLevel MethodOptions::IdempotencyLevel_MIN;
+const MethodOptions_IdempotencyLevel MethodOptions::IdempotencyLevel_MAX;
+const int MethodOptions::IdempotencyLevel_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
// ===================================================================
@@ -920,19 +934,19 @@ const int FileDescriptorSet::kFileFieldNumber;
FileDescriptorSet::FileDescriptorSet()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.FileDescriptorSet)
}
-
-void FileDescriptorSet::InitAsDefaultInstance() {
-}
-
FileDescriptorSet::FileDescriptorSet(const FileDescriptorSet& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0),
+ file_(from.file_) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:google.protobuf.FileDescriptorSet)
}
@@ -954,17 +968,15 @@ void FileDescriptorSet::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* FileDescriptorSet::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return FileDescriptorSet_descriptor_;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[0].descriptor;
}
const FileDescriptorSet& FileDescriptorSet::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorSet> FileDescriptorSet_default_instance_;
-
FileDescriptorSet* FileDescriptorSet::New(::google::protobuf::Arena* arena) const {
FileDescriptorSet* n = new FileDescriptorSet;
if (arena != NULL) {
@@ -977,9 +989,7 @@ void FileDescriptorSet::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.FileDescriptorSet)
file_.Clear();
_has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
+ _internal_metadata_.Clear();
}
bool FileDescriptorSet::MergePartialFromCodedStream(
@@ -988,23 +998,21 @@ bool FileDescriptorSet::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.FileDescriptorSet)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// repeated .google.protobuf.FileDescriptorProto file = 1;
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_file:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_file()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(10)) goto parse_loop_file;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -1048,7 +1056,7 @@ void FileDescriptorSet::SerializeWithCachedSizes(
::google::protobuf::uint8* FileDescriptorSet::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FileDescriptorSet)
// repeated .google.protobuf.FileDescriptorProto file = 1;
for (unsigned int i = 0, n = this->file_size(); i < n; i++) {
@@ -1069,6 +1077,11 @@ size_t FileDescriptorSet::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileDescriptorSet)
size_t total_size = 0;
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
// repeated .google.protobuf.FileDescriptorProto file = 1;
{
unsigned int count = this->file_size();
@@ -1080,11 +1093,6 @@ size_t FileDescriptorSet::ByteSizeLong() const {
}
}
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
@@ -1094,7 +1102,7 @@ size_t FileDescriptorSet::ByteSizeLong() const {
void FileDescriptorSet::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FileDescriptorSet)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const FileDescriptorSet* source =
::google::protobuf::internal::DynamicCastToGenerated<const FileDescriptorSet>(
&from);
@@ -1103,26 +1111,15 @@ void FileDescriptorSet::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FileDescriptorSet)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void FileDescriptorSet::MergeFrom(const FileDescriptorSet& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileDescriptorSet)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void FileDescriptorSet::UnsafeMergeFrom(const FileDescriptorSet& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
file_.MergeFrom(from.file_);
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
}
void FileDescriptorSet::CopyFrom(const ::google::protobuf::Message& from) {
@@ -1136,11 +1133,10 @@ void FileDescriptorSet::CopyFrom(const FileDescriptorSet& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FileDescriptorSet)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool FileDescriptorSet::IsInitialized() const {
-
if (!::google::protobuf::internal::AllAreInitialized(this->file())) return false;
return true;
}
@@ -1157,11 +1153,8 @@ void FileDescriptorSet::InternalSwap(FileDescriptorSet* other) {
}
::google::protobuf::Metadata FileDescriptorSet::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = FileDescriptorSet_descriptor_;
- metadata.reflection = FileDescriptorSet_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[0];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -1197,9 +1190,6 @@ FileDescriptorSet::file() const {
return file_;
}
-inline const FileDescriptorSet* FileDescriptorSet::internal_default_instance() {
- return &FileDescriptorSet_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -1221,23 +1211,47 @@ const int FileDescriptorProto::kSyntaxFieldNumber;
FileDescriptorProto::FileDescriptorProto()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.FileDescriptorProto)
}
-
-void FileDescriptorProto::InitAsDefaultInstance() {
- options_ = const_cast< ::google::protobuf::FileOptions*>(
- ::google::protobuf::FileOptions::internal_default_instance());
- source_code_info_ = const_cast< ::google::protobuf::SourceCodeInfo*>(
- ::google::protobuf::SourceCodeInfo::internal_default_instance());
-}
-
FileDescriptorProto::FileDescriptorProto(const FileDescriptorProto& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0),
+ dependency_(from.dependency_),
+ public_dependency_(from.public_dependency_),
+ weak_dependency_(from.weak_dependency_),
+ message_type_(from.message_type_),
+ enum_type_(from.enum_type_),
+ service_(from.service_),
+ extension_(from.extension_) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_name()) {
+ name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
+ }
+ package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_package()) {
+ package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.package_);
+ }
+ syntax_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_syntax()) {
+ syntax_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.syntax_);
+ }
+ if (from.has_options()) {
+ options_ = new ::google::protobuf::FileOptions(*from.options_);
+ } else {
+ options_ = NULL;
+ }
+ if (from.has_source_code_info()) {
+ source_code_info_ = new ::google::protobuf::SourceCodeInfo(*from.source_code_info_);
+ } else {
+ source_code_info_ = NULL;
+ }
// @@protoc_insertion_point(copy_constructor:google.protobuf.FileDescriptorProto)
}
@@ -1246,8 +1260,8 @@ void FileDescriptorProto::SharedCtor() {
name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
syntax_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- options_ = NULL;
- source_code_info_ = NULL;
+ ::memset(&options_, 0, reinterpret_cast<char*>(&source_code_info_) -
+ reinterpret_cast<char*>(&options_) + sizeof(source_code_info_));
}
FileDescriptorProto::~FileDescriptorProto() {
@@ -1259,8 +1273,10 @@ void FileDescriptorProto::SharedDtor() {
name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
package_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
syntax_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- if (this != &FileDescriptorProto_default_instance_.get()) {
+ if (this != internal_default_instance()) {
delete options_;
+ }
+ if (this != internal_default_instance()) {
delete source_code_info_;
}
}
@@ -1271,17 +1287,15 @@ void FileDescriptorProto::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* FileDescriptorProto::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return FileDescriptorProto_descriptor_;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[1].descriptor;
}
const FileDescriptorProto& FileDescriptorProto::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorProto> FileDescriptorProto_default_instance_;
-
FileDescriptorProto* FileDescriptorProto::New(::google::protobuf::Arena* arena) const {
FileDescriptorProto* n = new FileDescriptorProto;
if (arena != NULL) {
@@ -1292,36 +1306,37 @@ FileDescriptorProto* FileDescriptorProto::New(::google::protobuf::Arena* arena)
void FileDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.FileDescriptorProto)
- if (_has_bits_[0 / 32] & 3u) {
+ dependency_.Clear();
+ public_dependency_.Clear();
+ weak_dependency_.Clear();
+ message_type_.Clear();
+ enum_type_.Clear();
+ service_.Clear();
+ extension_.Clear();
+ if (_has_bits_[0 / 32] & 31u) {
if (has_name()) {
- name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*name_.UnsafeRawStringPointer())->clear();
}
if (has_package()) {
- package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!package_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*package_.UnsafeRawStringPointer())->clear();
+ }
+ if (has_syntax()) {
+ GOOGLE_DCHECK(!syntax_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*syntax_.UnsafeRawStringPointer())->clear();
}
- }
- if (_has_bits_[8 / 32] & 3584u) {
if (has_options()) {
- if (options_ != NULL) options_->::google::protobuf::FileOptions::Clear();
+ GOOGLE_DCHECK(options_ != NULL);
+ options_->::google::protobuf::FileOptions::Clear();
}
if (has_source_code_info()) {
- if (source_code_info_ != NULL) source_code_info_->::google::protobuf::SourceCodeInfo::Clear();
- }
- if (has_syntax()) {
- syntax_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(source_code_info_ != NULL);
+ source_code_info_->::google::protobuf::SourceCodeInfo::Clear();
}
}
- dependency_.Clear();
- public_dependency_.Clear();
- weak_dependency_.Clear();
- message_type_.Clear();
- enum_type_.Clear();
- service_.Clear();
- extension_.Clear();
_has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
+ _internal_metadata_.Clear();
}
bool FileDescriptorProto::MergePartialFromCodedStream(
@@ -1330,13 +1345,14 @@ bool FileDescriptorProto::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.FileDescriptorProto)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional string name = 1;
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -1346,14 +1362,13 @@ bool FileDescriptorProto::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(18)) goto parse_package;
break;
}
// optional string package = 2;
case 2: {
- if (tag == 18) {
- parse_package:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(18u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_package()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -1363,14 +1378,13 @@ bool FileDescriptorProto::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(26)) goto parse_dependency;
break;
}
// repeated string dependency = 3;
case 3: {
- if (tag == 26) {
- parse_dependency:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(26u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->add_dependency()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -1381,144 +1395,129 @@ bool FileDescriptorProto::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(26)) goto parse_dependency;
- if (input->ExpectTag(34)) goto parse_message_type;
break;
}
// repeated .google.protobuf.DescriptorProto message_type = 4;
case 4: {
- if (tag == 34) {
- parse_message_type:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(34u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_message_type:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_message_type()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(34)) goto parse_loop_message_type;
- if (input->ExpectTag(42)) goto parse_loop_enum_type;
input->UnsafeDecrementRecursionDepth();
break;
}
// repeated .google.protobuf.EnumDescriptorProto enum_type = 5;
case 5: {
- if (tag == 42) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(42u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_enum_type:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_enum_type()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(42)) goto parse_loop_enum_type;
- if (input->ExpectTag(50)) goto parse_loop_service;
input->UnsafeDecrementRecursionDepth();
break;
}
// repeated .google.protobuf.ServiceDescriptorProto service = 6;
case 6: {
- if (tag == 50) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(50u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_service:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_service()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(50)) goto parse_loop_service;
- if (input->ExpectTag(58)) goto parse_loop_extension;
input->UnsafeDecrementRecursionDepth();
break;
}
// repeated .google.protobuf.FieldDescriptorProto extension = 7;
case 7: {
- if (tag == 58) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(58u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_extension:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_extension()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(58)) goto parse_loop_extension;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectTag(66)) goto parse_options;
break;
}
// optional .google.protobuf.FileOptions options = 8;
case 8: {
- if (tag == 66) {
- parse_options:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(66u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_options()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(74)) goto parse_source_code_info;
break;
}
// optional .google.protobuf.SourceCodeInfo source_code_info = 9;
case 9: {
- if (tag == 74) {
- parse_source_code_info:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(74u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_source_code_info()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(80)) goto parse_public_dependency;
break;
}
// repeated int32 public_dependency = 10;
case 10: {
- if (tag == 80) {
- parse_public_dependency:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(80u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- 1, 80, input, this->mutable_public_dependency())));
- } else if (tag == 82) {
+ 1, 80u, input, this->mutable_public_dependency())));
+ } else if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(82u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, this->mutable_public_dependency())));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(80)) goto parse_public_dependency;
- if (input->ExpectTag(88)) goto parse_weak_dependency;
break;
}
// repeated int32 weak_dependency = 11;
case 11: {
- if (tag == 88) {
- parse_weak_dependency:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(88u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- 1, 88, input, this->mutable_weak_dependency())));
- } else if (tag == 90) {
+ 1, 88u, input, this->mutable_weak_dependency())));
+ } else if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(90u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, this->mutable_weak_dependency())));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(88)) goto parse_weak_dependency;
- if (input->ExpectTag(98)) goto parse_syntax;
break;
}
// optional string syntax = 12;
case 12: {
- if (tag == 98) {
- parse_syntax:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(98u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_syntax()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -1528,7 +1527,6 @@ bool FileDescriptorProto::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -1578,7 +1576,7 @@ void FileDescriptorProto::SerializeWithCachedSizes(
}
// repeated string dependency = 3;
- for (int i = 0; i < this->dependency_size(); i++) {
+ for (int i = 0, n = this->dependency_size(); i < n; i++) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->dependency(i).data(), this->dependency(i).length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
@@ -1624,13 +1622,13 @@ void FileDescriptorProto::SerializeWithCachedSizes(
}
// repeated int32 public_dependency = 10;
- for (int i = 0; i < this->public_dependency_size(); i++) {
+ for (int i = 0, n = this->public_dependency_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteInt32(
10, this->public_dependency(i), output);
}
// repeated int32 weak_dependency = 11;
- for (int i = 0; i < this->weak_dependency_size(); i++) {
+ for (int i = 0, n = this->weak_dependency_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteInt32(
11, this->weak_dependency(i), output);
}
@@ -1654,7 +1652,7 @@ void FileDescriptorProto::SerializeWithCachedSizes(
::google::protobuf::uint8* FileDescriptorProto::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FileDescriptorProto)
// optional string name = 1;
if (has_name()) {
@@ -1679,7 +1677,7 @@ void FileDescriptorProto::SerializeWithCachedSizes(
}
// repeated string dependency = 3;
- for (int i = 0; i < this->dependency_size(); i++) {
+ for (int i = 0, n = this->dependency_size(); i < n; i++) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->dependency(i).data(), this->dependency(i).length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
@@ -1731,13 +1729,13 @@ void FileDescriptorProto::SerializeWithCachedSizes(
}
// repeated int32 public_dependency = 10;
- for (int i = 0; i < this->public_dependency_size(); i++) {
+ for (int i = 0, n = this->public_dependency_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
WriteInt32ToArray(10, this->public_dependency(i), target);
}
// repeated int32 weak_dependency = 11;
- for (int i = 0; i < this->weak_dependency_size(); i++) {
+ for (int i = 0, n = this->weak_dependency_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
WriteInt32ToArray(11, this->weak_dependency(i), target);
}
@@ -1765,61 +1763,23 @@ size_t FileDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileDescriptorProto)
size_t total_size = 0;
- if (_has_bits_[0 / 32] & 3u) {
- // optional string name = 1;
- if (has_name()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->name());
- }
-
- // optional string package = 2;
- if (has_package()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->package());
- }
-
- }
- if (_has_bits_[9 / 32] & 3584u) {
- // optional .google.protobuf.FileOptions options = 8;
- if (has_options()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->options_);
- }
-
- // optional .google.protobuf.SourceCodeInfo source_code_info = 9;
- if (has_source_code_info()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->source_code_info_);
- }
-
- // optional string syntax = 12;
- if (has_syntax()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->syntax());
- }
-
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
}
// repeated string dependency = 3;
total_size += 1 *
::google::protobuf::internal::FromIntSize(this->dependency_size());
- for (int i = 0; i < this->dependency_size(); i++) {
+ for (int i = 0, n = this->dependency_size(); i < n; i++) {
total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
this->dependency(i));
}
// repeated int32 public_dependency = 10;
{
- size_t data_size = 0;
- unsigned int count = this->public_dependency_size();
- for (unsigned int i = 0; i < count; i++) {
- data_size += ::google::protobuf::internal::WireFormatLite::
- Int32Size(this->public_dependency(i));
- }
+ size_t data_size = ::google::protobuf::internal::WireFormatLite::
+ Int32Size(this->public_dependency_);
total_size += 1 *
::google::protobuf::internal::FromIntSize(this->public_dependency_size());
total_size += data_size;
@@ -1827,12 +1787,8 @@ size_t FileDescriptorProto::ByteSizeLong() const {
// repeated int32 weak_dependency = 11;
{
- size_t data_size = 0;
- unsigned int count = this->weak_dependency_size();
- for (unsigned int i = 0; i < count; i++) {
- data_size += ::google::protobuf::internal::WireFormatLite::
- Int32Size(this->weak_dependency(i));
- }
+ size_t data_size = ::google::protobuf::internal::WireFormatLite::
+ Int32Size(this->weak_dependency_);
total_size += 1 *
::google::protobuf::internal::FromIntSize(this->weak_dependency_size());
total_size += data_size;
@@ -1882,10 +1838,42 @@ size_t FileDescriptorProto::ByteSizeLong() const {
}
}
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
+ if (_has_bits_[0 / 32] & 31u) {
+ // optional string name = 1;
+ if (has_name()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->name());
+ }
+
+ // optional string package = 2;
+ if (has_package()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->package());
+ }
+
+ // optional string syntax = 12;
+ if (has_syntax()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->syntax());
+ }
+
+ // optional .google.protobuf.FileOptions options = 8;
+ if (has_options()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->options_);
+ }
+
+ // optional .google.protobuf.SourceCodeInfo source_code_info = 9;
+ if (has_source_code_info()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->source_code_info_);
+ }
+
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
@@ -1896,7 +1884,7 @@ size_t FileDescriptorProto::ByteSizeLong() const {
void FileDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FileDescriptorProto)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const FileDescriptorProto* source =
::google::protobuf::internal::DynamicCastToGenerated<const FileDescriptorProto>(
&from);
@@ -1905,29 +1893,22 @@ void FileDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FileDescriptorProto)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void FileDescriptorProto::MergeFrom(const FileDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileDescriptorProto)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void FileDescriptorProto::UnsafeMergeFrom(const FileDescriptorProto& from) {
- GOOGLE_DCHECK(&from != this);
- dependency_.UnsafeMergeFrom(from.dependency_);
- public_dependency_.UnsafeMergeFrom(from.public_dependency_);
- weak_dependency_.UnsafeMergeFrom(from.weak_dependency_);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ dependency_.MergeFrom(from.dependency_);
+ public_dependency_.MergeFrom(from.public_dependency_);
+ weak_dependency_.MergeFrom(from.weak_dependency_);
message_type_.MergeFrom(from.message_type_);
enum_type_.MergeFrom(from.enum_type_);
service_.MergeFrom(from.service_);
extension_.MergeFrom(from.extension_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from._has_bits_[0 / 32] & 31u) {
if (from.has_name()) {
set_has_name();
name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
@@ -1936,22 +1917,16 @@ void FileDescriptorProto::UnsafeMergeFrom(const FileDescriptorProto& from) {
set_has_package();
package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.package_);
}
- }
- if (from._has_bits_[9 / 32] & (0xffu << (9 % 32))) {
+ if (from.has_syntax()) {
+ set_has_syntax();
+ syntax_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.syntax_);
+ }
if (from.has_options()) {
mutable_options()->::google::protobuf::FileOptions::MergeFrom(from.options());
}
if (from.has_source_code_info()) {
mutable_source_code_info()->::google::protobuf::SourceCodeInfo::MergeFrom(from.source_code_info());
}
- if (from.has_syntax()) {
- set_has_syntax();
- syntax_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.syntax_);
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
}
}
@@ -1966,11 +1941,10 @@ void FileDescriptorProto::CopyFrom(const FileDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FileDescriptorProto)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool FileDescriptorProto::IsInitialized() const {
-
if (!::google::protobuf::internal::AllAreInitialized(this->message_type())) return false;
if (!::google::protobuf::internal::AllAreInitialized(this->enum_type())) return false;
if (!::google::protobuf::internal::AllAreInitialized(this->service())) return false;
@@ -1986,8 +1960,6 @@ void FileDescriptorProto::Swap(FileDescriptorProto* other) {
InternalSwap(other);
}
void FileDescriptorProto::InternalSwap(FileDescriptorProto* other) {
- name_.Swap(&other->name_);
- package_.Swap(&other->package_);
dependency_.UnsafeArenaSwap(&other->dependency_);
public_dependency_.UnsafeArenaSwap(&other->public_dependency_);
weak_dependency_.UnsafeArenaSwap(&other->weak_dependency_);
@@ -1995,20 +1967,19 @@ void FileDescriptorProto::InternalSwap(FileDescriptorProto* other) {
enum_type_.UnsafeArenaSwap(&other->enum_type_);
service_.UnsafeArenaSwap(&other->service_);
extension_.UnsafeArenaSwap(&other->extension_);
+ name_.Swap(&other->name_);
+ package_.Swap(&other->package_);
+ syntax_.Swap(&other->syntax_);
std::swap(options_, other->options_);
std::swap(source_code_info_, other->source_code_info_);
- syntax_.Swap(&other->syntax_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata FileDescriptorProto::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = FileDescriptorProto_descriptor_;
- metadata.reflection = FileDescriptorProto_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[1];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -2030,13 +2001,21 @@ void FileDescriptorProto::clear_name() {
}
const ::std::string& FileDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.GetNoArena();
}
void FileDescriptorProto::set_name(const ::std::string& value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.name)
}
+#if LANG_CXX11
+void FileDescriptorProto::set_name(::std::string&& value) {
+ set_has_name();
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileDescriptorProto.name)
+}
+#endif
void FileDescriptorProto::set_name(const char* value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -2084,13 +2063,21 @@ void FileDescriptorProto::clear_package() {
}
const ::std::string& FileDescriptorProto::package() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.package)
- return package_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return package_.GetNoArena();
}
void FileDescriptorProto::set_package(const ::std::string& value) {
set_has_package();
package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.package)
}
+#if LANG_CXX11
+void FileDescriptorProto::set_package(::std::string&& value) {
+ set_has_package();
+ package_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileDescriptorProto.package)
+}
+#endif
void FileDescriptorProto::set_package(const char* value) {
set_has_package();
package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -2141,6 +2128,12 @@ void FileDescriptorProto::set_dependency(int index, const ::std::string& value)
// @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.dependency)
dependency_.Mutable(index)->assign(value);
}
+#if LANG_CXX11
+void FileDescriptorProto::set_dependency(int index, ::std::string&& value) {
+ // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.dependency)
+ dependency_.Mutable(index)->assign(std::move(value));
+}
+#endif
void FileDescriptorProto::set_dependency(int index, const char* value) {
dependency_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.dependency)
@@ -2158,6 +2151,12 @@ void FileDescriptorProto::add_dependency(const ::std::string& value) {
dependency_.Add()->assign(value);
// @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.dependency)
}
+#if LANG_CXX11
+void FileDescriptorProto::add_dependency(::std::string&& value) {
+ dependency_.Add()->assign(std::move(value));
+ // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.dependency)
+}
+#endif
void FileDescriptorProto::add_dependency(const char* value) {
dependency_.Add()->assign(value);
// @@protoc_insertion_point(field_add_char:google.protobuf.FileDescriptorProto.dependency)
@@ -2359,13 +2358,13 @@ FileDescriptorProto::extension() const {
// optional .google.protobuf.FileOptions options = 8;
bool FileDescriptorProto::has_options() const {
- return (_has_bits_[0] & 0x00000200u) != 0;
+ return (_has_bits_[0] & 0x00000008u) != 0;
}
void FileDescriptorProto::set_has_options() {
- _has_bits_[0] |= 0x00000200u;
+ _has_bits_[0] |= 0x00000008u;
}
void FileDescriptorProto::clear_has_options() {
- _has_bits_[0] &= ~0x00000200u;
+ _has_bits_[0] &= ~0x00000008u;
}
void FileDescriptorProto::clear_options() {
if (options_ != NULL) options_->::google::protobuf::FileOptions::Clear();
@@ -2404,13 +2403,13 @@ void FileDescriptorProto::set_allocated_options(::google::protobuf::FileOptions*
// optional .google.protobuf.SourceCodeInfo source_code_info = 9;
bool FileDescriptorProto::has_source_code_info() const {
- return (_has_bits_[0] & 0x00000400u) != 0;
+ return (_has_bits_[0] & 0x00000010u) != 0;
}
void FileDescriptorProto::set_has_source_code_info() {
- _has_bits_[0] |= 0x00000400u;
+ _has_bits_[0] |= 0x00000010u;
}
void FileDescriptorProto::clear_has_source_code_info() {
- _has_bits_[0] &= ~0x00000400u;
+ _has_bits_[0] &= ~0x00000010u;
}
void FileDescriptorProto::clear_source_code_info() {
if (source_code_info_ != NULL) source_code_info_->::google::protobuf::SourceCodeInfo::Clear();
@@ -2449,13 +2448,13 @@ void FileDescriptorProto::set_allocated_source_code_info(::google::protobuf::Sou
// optional string syntax = 12;
bool FileDescriptorProto::has_syntax() const {
- return (_has_bits_[0] & 0x00000800u) != 0;
+ return (_has_bits_[0] & 0x00000004u) != 0;
}
void FileDescriptorProto::set_has_syntax() {
- _has_bits_[0] |= 0x00000800u;
+ _has_bits_[0] |= 0x00000004u;
}
void FileDescriptorProto::clear_has_syntax() {
- _has_bits_[0] &= ~0x00000800u;
+ _has_bits_[0] &= ~0x00000004u;
}
void FileDescriptorProto::clear_syntax() {
syntax_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -2463,13 +2462,21 @@ void FileDescriptorProto::clear_syntax() {
}
const ::std::string& FileDescriptorProto::syntax() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.syntax)
- return syntax_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return syntax_.GetNoArena();
}
void FileDescriptorProto::set_syntax(const ::std::string& value) {
set_has_syntax();
syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.syntax)
}
+#if LANG_CXX11
+void FileDescriptorProto::set_syntax(::std::string&& value) {
+ set_has_syntax();
+ syntax_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileDescriptorProto.syntax)
+}
+#endif
void FileDescriptorProto::set_syntax(const char* value) {
set_has_syntax();
syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -2501,9 +2508,6 @@ void FileDescriptorProto::set_allocated_syntax(::std::string* syntax) {
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.syntax)
}
-inline const FileDescriptorProto* FileDescriptorProto::internal_default_instance() {
- return &FileDescriptorProto_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -2515,19 +2519,21 @@ const int DescriptorProto_ExtensionRange::kEndFieldNumber;
DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.DescriptorProto.ExtensionRange)
}
-
-void DescriptorProto_ExtensionRange::InitAsDefaultInstance() {
-}
-
DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(const DescriptorProto_ExtensionRange& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ ::memcpy(&start_, &from.start_,
+ reinterpret_cast<char*>(&end_) -
+ reinterpret_cast<char*>(&start_) + sizeof(end_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto.ExtensionRange)
}
@@ -2551,17 +2557,15 @@ void DescriptorProto_ExtensionRange::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* DescriptorProto_ExtensionRange::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return DescriptorProto_ExtensionRange_descriptor_;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[2].descriptor;
}
const DescriptorProto_ExtensionRange& DescriptorProto_ExtensionRange::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ExtensionRange> DescriptorProto_ExtensionRange_default_instance_;
-
DescriptorProto_ExtensionRange* DescriptorProto_ExtensionRange::New(::google::protobuf::Arena* arena) const {
DescriptorProto_ExtensionRange* n = new DescriptorProto_ExtensionRange;
if (arena != NULL) {
@@ -2572,31 +2576,12 @@ DescriptorProto_ExtensionRange* DescriptorProto_ExtensionRange::New(::google::pr
void DescriptorProto_ExtensionRange::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto.ExtensionRange)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(DescriptorProto_ExtensionRange, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<DescriptorProto_ExtensionRange*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- ZR_(start_, end_);
-
-#undef ZR_HELPER_
-#undef ZR_
-
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
+ if (_has_bits_[0 / 32] & 3u) {
+ ::memset(&start_, 0, reinterpret_cast<char*>(&end_) -
+ reinterpret_cast<char*>(&start_) + sizeof(end_));
}
+ _has_bits_.Clear();
+ _internal_metadata_.Clear();
}
bool DescriptorProto_ExtensionRange::MergePartialFromCodedStream(
@@ -2605,13 +2590,14 @@ bool DescriptorProto_ExtensionRange::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.DescriptorProto.ExtensionRange)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional int32 start = 1;
case 1: {
- if (tag == 8) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(8u)) {
set_has_start();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
@@ -2619,14 +2605,13 @@ bool DescriptorProto_ExtensionRange::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(16)) goto parse_end;
break;
}
// optional int32 end = 2;
case 2: {
- if (tag == 16) {
- parse_end:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(16u)) {
set_has_end();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
@@ -2634,7 +2619,6 @@ bool DescriptorProto_ExtensionRange::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -2682,7 +2666,7 @@ void DescriptorProto_ExtensionRange::SerializeWithCachedSizes(
::google::protobuf::uint8* DescriptorProto_ExtensionRange::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DescriptorProto.ExtensionRange)
// optional int32 start = 1;
if (has_start()) {
@@ -2706,6 +2690,11 @@ size_t DescriptorProto_ExtensionRange::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.DescriptorProto.ExtensionRange)
size_t total_size = 0;
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
if (_has_bits_[0 / 32] & 3u) {
// optional int32 start = 1;
if (has_start()) {
@@ -2722,11 +2711,6 @@ size_t DescriptorProto_ExtensionRange::ByteSizeLong() const {
}
}
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
@@ -2736,7 +2720,7 @@ size_t DescriptorProto_ExtensionRange::ByteSizeLong() const {
void DescriptorProto_ExtensionRange::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.DescriptorProto.ExtensionRange)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const DescriptorProto_ExtensionRange* source =
::google::protobuf::internal::DynamicCastToGenerated<const DescriptorProto_ExtensionRange>(
&from);
@@ -2745,22 +2729,15 @@ void DescriptorProto_ExtensionRange::MergeFrom(const ::google::protobuf::Message
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.DescriptorProto.ExtensionRange)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void DescriptorProto_ExtensionRange::MergeFrom(const DescriptorProto_ExtensionRange& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto.ExtensionRange)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void DescriptorProto_ExtensionRange::UnsafeMergeFrom(const DescriptorProto_ExtensionRange& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ if (from._has_bits_[0 / 32] & 3u) {
if (from.has_start()) {
set_start(from.start());
}
@@ -2768,10 +2745,6 @@ void DescriptorProto_ExtensionRange::UnsafeMergeFrom(const DescriptorProto_Exten
set_end(from.end());
}
}
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
}
void DescriptorProto_ExtensionRange::CopyFrom(const ::google::protobuf::Message& from) {
@@ -2785,11 +2758,10 @@ void DescriptorProto_ExtensionRange::CopyFrom(const DescriptorProto_ExtensionRan
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.DescriptorProto.ExtensionRange)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool DescriptorProto_ExtensionRange::IsInitialized() const {
-
return true;
}
@@ -2806,15 +2778,64 @@ void DescriptorProto_ExtensionRange::InternalSwap(DescriptorProto_ExtensionRange
}
::google::protobuf::Metadata DescriptorProto_ExtensionRange::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = DescriptorProto_ExtensionRange_descriptor_;
- metadata.reflection = DescriptorProto_ExtensionRange_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[2];
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// DescriptorProto_ExtensionRange
+
+// optional int32 start = 1;
+bool DescriptorProto_ExtensionRange::has_start() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void DescriptorProto_ExtensionRange::set_has_start() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void DescriptorProto_ExtensionRange::clear_has_start() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void DescriptorProto_ExtensionRange::clear_start() {
+ start_ = 0;
+ clear_has_start();
+}
+::google::protobuf::int32 DescriptorProto_ExtensionRange::start() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.start)
+ return start_;
+}
+void DescriptorProto_ExtensionRange::set_start(::google::protobuf::int32 value) {
+ set_has_start();
+ start_ = value;
+ // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.start)
+}
+
+// optional int32 end = 2;
+bool DescriptorProto_ExtensionRange::has_end() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void DescriptorProto_ExtensionRange::set_has_end() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void DescriptorProto_ExtensionRange::clear_has_end() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void DescriptorProto_ExtensionRange::clear_end() {
+ end_ = 0;
+ clear_has_end();
+}
+::google::protobuf::int32 DescriptorProto_ExtensionRange::end() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.end)
+ return end_;
+}
+void DescriptorProto_ExtensionRange::set_end(::google::protobuf::int32 value) {
+ set_has_end();
+ end_ = value;
+ // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.end)
}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-// -------------------------------------------------------------------
+// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int DescriptorProto_ReservedRange::kStartFieldNumber;
@@ -2823,19 +2844,21 @@ const int DescriptorProto_ReservedRange::kEndFieldNumber;
DescriptorProto_ReservedRange::DescriptorProto_ReservedRange()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.DescriptorProto.ReservedRange)
}
-
-void DescriptorProto_ReservedRange::InitAsDefaultInstance() {
-}
-
DescriptorProto_ReservedRange::DescriptorProto_ReservedRange(const DescriptorProto_ReservedRange& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ ::memcpy(&start_, &from.start_,
+ reinterpret_cast<char*>(&end_) -
+ reinterpret_cast<char*>(&start_) + sizeof(end_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto.ReservedRange)
}
@@ -2859,17 +2882,15 @@ void DescriptorProto_ReservedRange::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* DescriptorProto_ReservedRange::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return DescriptorProto_ReservedRange_descriptor_;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[3].descriptor;
}
const DescriptorProto_ReservedRange& DescriptorProto_ReservedRange::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ReservedRange> DescriptorProto_ReservedRange_default_instance_;
-
DescriptorProto_ReservedRange* DescriptorProto_ReservedRange::New(::google::protobuf::Arena* arena) const {
DescriptorProto_ReservedRange* n = new DescriptorProto_ReservedRange;
if (arena != NULL) {
@@ -2880,31 +2901,12 @@ DescriptorProto_ReservedRange* DescriptorProto_ReservedRange::New(::google::prot
void DescriptorProto_ReservedRange::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto.ReservedRange)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(DescriptorProto_ReservedRange, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<DescriptorProto_ReservedRange*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- ZR_(start_, end_);
-
-#undef ZR_HELPER_
-#undef ZR_
-
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
+ if (_has_bits_[0 / 32] & 3u) {
+ ::memset(&start_, 0, reinterpret_cast<char*>(&end_) -
+ reinterpret_cast<char*>(&start_) + sizeof(end_));
}
+ _has_bits_.Clear();
+ _internal_metadata_.Clear();
}
bool DescriptorProto_ReservedRange::MergePartialFromCodedStream(
@@ -2913,13 +2915,14 @@ bool DescriptorProto_ReservedRange::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.DescriptorProto.ReservedRange)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional int32 start = 1;
case 1: {
- if (tag == 8) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(8u)) {
set_has_start();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
@@ -2927,14 +2930,13 @@ bool DescriptorProto_ReservedRange::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(16)) goto parse_end;
break;
}
// optional int32 end = 2;
case 2: {
- if (tag == 16) {
- parse_end:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(16u)) {
set_has_end();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
@@ -2942,7 +2944,6 @@ bool DescriptorProto_ReservedRange::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -2990,7 +2991,7 @@ void DescriptorProto_ReservedRange::SerializeWithCachedSizes(
::google::protobuf::uint8* DescriptorProto_ReservedRange::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DescriptorProto.ReservedRange)
// optional int32 start = 1;
if (has_start()) {
@@ -3014,6 +3015,11 @@ size_t DescriptorProto_ReservedRange::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.DescriptorProto.ReservedRange)
size_t total_size = 0;
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
if (_has_bits_[0 / 32] & 3u) {
// optional int32 start = 1;
if (has_start()) {
@@ -3030,11 +3036,6 @@ size_t DescriptorProto_ReservedRange::ByteSizeLong() const {
}
}
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
@@ -3044,7 +3045,7 @@ size_t DescriptorProto_ReservedRange::ByteSizeLong() const {
void DescriptorProto_ReservedRange::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.DescriptorProto.ReservedRange)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const DescriptorProto_ReservedRange* source =
::google::protobuf::internal::DynamicCastToGenerated<const DescriptorProto_ReservedRange>(
&from);
@@ -3053,22 +3054,15 @@ void DescriptorProto_ReservedRange::MergeFrom(const ::google::protobuf::Message&
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.DescriptorProto.ReservedRange)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void DescriptorProto_ReservedRange::MergeFrom(const DescriptorProto_ReservedRange& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto.ReservedRange)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void DescriptorProto_ReservedRange::UnsafeMergeFrom(const DescriptorProto_ReservedRange& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ if (from._has_bits_[0 / 32] & 3u) {
if (from.has_start()) {
set_start(from.start());
}
@@ -3076,10 +3070,6 @@ void DescriptorProto_ReservedRange::UnsafeMergeFrom(const DescriptorProto_Reserv
set_end(from.end());
}
}
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
}
void DescriptorProto_ReservedRange::CopyFrom(const ::google::protobuf::Message& from) {
@@ -3093,11 +3083,10 @@ void DescriptorProto_ReservedRange::CopyFrom(const DescriptorProto_ReservedRange
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.DescriptorProto.ReservedRange)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool DescriptorProto_ReservedRange::IsInitialized() const {
-
return true;
}
@@ -3114,15 +3103,64 @@ void DescriptorProto_ReservedRange::InternalSwap(DescriptorProto_ReservedRange*
}
::google::protobuf::Metadata DescriptorProto_ReservedRange::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = DescriptorProto_ReservedRange_descriptor_;
- metadata.reflection = DescriptorProto_ReservedRange_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[3];
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// DescriptorProto_ReservedRange
+
+// optional int32 start = 1;
+bool DescriptorProto_ReservedRange::has_start() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void DescriptorProto_ReservedRange::set_has_start() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void DescriptorProto_ReservedRange::clear_has_start() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void DescriptorProto_ReservedRange::clear_start() {
+ start_ = 0;
+ clear_has_start();
+}
+::google::protobuf::int32 DescriptorProto_ReservedRange::start() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ReservedRange.start)
+ return start_;
+}
+void DescriptorProto_ReservedRange::set_start(::google::protobuf::int32 value) {
+ set_has_start();
+ start_ = value;
+ // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.start)
+}
+
+// optional int32 end = 2;
+bool DescriptorProto_ReservedRange::has_end() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void DescriptorProto_ReservedRange::set_has_end() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void DescriptorProto_ReservedRange::clear_has_end() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void DescriptorProto_ReservedRange::clear_end() {
+ end_ = 0;
+ clear_has_end();
+}
+::google::protobuf::int32 DescriptorProto_ReservedRange::end() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ReservedRange.end)
+ return end_;
+}
+void DescriptorProto_ReservedRange::set_end(::google::protobuf::int32 value) {
+ set_has_end();
+ end_ = value;
+ // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.end)
}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-// -------------------------------------------------------------------
+// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int DescriptorProto::kNameFieldNumber;
@@ -3139,21 +3177,35 @@ const int DescriptorProto::kReservedNameFieldNumber;
DescriptorProto::DescriptorProto()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.DescriptorProto)
}
-
-void DescriptorProto::InitAsDefaultInstance() {
- options_ = const_cast< ::google::protobuf::MessageOptions*>(
- ::google::protobuf::MessageOptions::internal_default_instance());
-}
-
DescriptorProto::DescriptorProto(const DescriptorProto& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0),
+ field_(from.field_),
+ extension_(from.extension_),
+ nested_type_(from.nested_type_),
+ enum_type_(from.enum_type_),
+ extension_range_(from.extension_range_),
+ oneof_decl_(from.oneof_decl_),
+ reserved_range_(from.reserved_range_),
+ reserved_name_(from.reserved_name_) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_name()) {
+ name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
+ }
+ if (from.has_options()) {
+ options_ = new ::google::protobuf::MessageOptions(*from.options_);
+ } else {
+ options_ = NULL;
+ }
// @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto)
}
@@ -3170,7 +3222,7 @@ DescriptorProto::~DescriptorProto() {
void DescriptorProto::SharedDtor() {
name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- if (this != &DescriptorProto_default_instance_.get()) {
+ if (this != internal_default_instance()) {
delete options_;
}
}
@@ -3181,17 +3233,15 @@ void DescriptorProto::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* DescriptorProto::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return DescriptorProto_descriptor_;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[4].descriptor;
}
const DescriptorProto& DescriptorProto::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto> DescriptorProto_default_instance_;
-
DescriptorProto* DescriptorProto::New(::google::protobuf::Arena* arena) const {
DescriptorProto* n = new DescriptorProto;
if (arena != NULL) {
@@ -3202,14 +3252,6 @@ DescriptorProto* DescriptorProto::New(::google::protobuf::Arena* arena) const {
void DescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto)
- if (_has_bits_[0 / 32] & 129u) {
- if (has_name()) {
- name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- if (has_options()) {
- if (options_ != NULL) options_->::google::protobuf::MessageOptions::Clear();
- }
- }
field_.Clear();
extension_.Clear();
nested_type_.Clear();
@@ -3218,10 +3260,18 @@ void DescriptorProto::Clear() {
oneof_decl_.Clear();
reserved_range_.Clear();
reserved_name_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
+ if (_has_bits_[0 / 32] & 3u) {
+ if (has_name()) {
+ GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*name_.UnsafeRawStringPointer())->clear();
+ }
+ if (has_options()) {
+ GOOGLE_DCHECK(options_ != NULL);
+ options_->::google::protobuf::MessageOptions::Clear();
+ }
}
+ _has_bits_.Clear();
+ _internal_metadata_.Clear();
}
bool DescriptorProto::MergePartialFromCodedStream(
@@ -3230,13 +3280,14 @@ bool DescriptorProto::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.DescriptorProto)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional string name = 1;
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -3246,141 +3297,123 @@ bool DescriptorProto::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(18)) goto parse_field;
break;
}
// repeated .google.protobuf.FieldDescriptorProto field = 2;
case 2: {
- if (tag == 18) {
- parse_field:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(18u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_field:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_field()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(18)) goto parse_loop_field;
- if (input->ExpectTag(26)) goto parse_loop_nested_type;
input->UnsafeDecrementRecursionDepth();
break;
}
// repeated .google.protobuf.DescriptorProto nested_type = 3;
case 3: {
- if (tag == 26) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(26u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_nested_type:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_nested_type()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(26)) goto parse_loop_nested_type;
- if (input->ExpectTag(34)) goto parse_loop_enum_type;
input->UnsafeDecrementRecursionDepth();
break;
}
// repeated .google.protobuf.EnumDescriptorProto enum_type = 4;
case 4: {
- if (tag == 34) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(34u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_enum_type:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_enum_type()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(34)) goto parse_loop_enum_type;
- if (input->ExpectTag(42)) goto parse_loop_extension_range;
input->UnsafeDecrementRecursionDepth();
break;
}
// repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;
case 5: {
- if (tag == 42) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(42u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_extension_range:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_extension_range()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(42)) goto parse_loop_extension_range;
- if (input->ExpectTag(50)) goto parse_loop_extension;
input->UnsafeDecrementRecursionDepth();
break;
}
// repeated .google.protobuf.FieldDescriptorProto extension = 6;
case 6: {
- if (tag == 50) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(50u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_extension:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_extension()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(50)) goto parse_loop_extension;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectTag(58)) goto parse_options;
break;
}
// optional .google.protobuf.MessageOptions options = 7;
case 7: {
- if (tag == 58) {
- parse_options:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(58u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_options()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(66)) goto parse_oneof_decl;
break;
}
// repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;
case 8: {
- if (tag == 66) {
- parse_oneof_decl:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(66u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_oneof_decl:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_oneof_decl()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(66)) goto parse_loop_oneof_decl;
- if (input->ExpectTag(74)) goto parse_loop_reserved_range;
input->UnsafeDecrementRecursionDepth();
break;
}
// repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;
case 9: {
- if (tag == 74) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(74u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_reserved_range:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_reserved_range()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(74)) goto parse_loop_reserved_range;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectTag(82)) goto parse_reserved_name;
break;
}
// repeated string reserved_name = 10;
case 10: {
- if (tag == 82) {
- parse_reserved_name:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(82u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->add_reserved_name()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -3391,8 +3424,6 @@ bool DescriptorProto::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(82)) goto parse_reserved_name;
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -3480,7 +3511,7 @@ void DescriptorProto::SerializeWithCachedSizes(
}
// repeated string reserved_name = 10;
- for (int i = 0; i < this->reserved_name_size(); i++) {
+ for (int i = 0, n = this->reserved_name_size(); i < n; i++) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->reserved_name(i).data(), this->reserved_name(i).length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
@@ -3498,7 +3529,7 @@ void DescriptorProto::SerializeWithCachedSizes(
::google::protobuf::uint8* DescriptorProto::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DescriptorProto)
// optional string name = 1;
if (has_name()) {
@@ -3568,7 +3599,7 @@ void DescriptorProto::SerializeWithCachedSizes(
}
// repeated string reserved_name = 10;
- for (int i = 0; i < this->reserved_name_size(); i++) {
+ for (int i = 0, n = this->reserved_name_size(); i < n; i++) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->reserved_name(i).data(), this->reserved_name(i).length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
@@ -3589,21 +3620,10 @@ size_t DescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.DescriptorProto)
size_t total_size = 0;
- if (_has_bits_[0 / 32] & 129u) {
- // optional string name = 1;
- if (has_name()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->name());
- }
-
- // optional .google.protobuf.MessageOptions options = 7;
- if (has_options()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->options_);
- }
-
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
}
// repeated .google.protobuf.FieldDescriptorProto field = 2;
{
@@ -3685,15 +3705,26 @@ size_t DescriptorProto::ByteSizeLong() const {
// repeated string reserved_name = 10;
total_size += 1 *
::google::protobuf::internal::FromIntSize(this->reserved_name_size());
- for (int i = 0; i < this->reserved_name_size(); i++) {
+ for (int i = 0, n = this->reserved_name_size(); i < n; i++) {
total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
this->reserved_name(i));
}
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
+ if (_has_bits_[0 / 32] & 3u) {
+ // optional string name = 1;
+ if (has_name()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->name());
+ }
+
+ // optional .google.protobuf.MessageOptions options = 7;
+ if (has_options()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->options_);
+ }
+
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
@@ -3704,7 +3735,7 @@ size_t DescriptorProto::ByteSizeLong() const {
void DescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.DescriptorProto)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const DescriptorProto* source =
::google::protobuf::internal::DynamicCastToGenerated<const DescriptorProto>(
&from);
@@ -3713,21 +3744,14 @@ void DescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.DescriptorProto)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void DescriptorProto::MergeFrom(const DescriptorProto& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void DescriptorProto::UnsafeMergeFrom(const DescriptorProto& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
field_.MergeFrom(from.field_);
extension_.MergeFrom(from.extension_);
nested_type_.MergeFrom(from.nested_type_);
@@ -3735,8 +3759,8 @@ void DescriptorProto::UnsafeMergeFrom(const DescriptorProto& from) {
extension_range_.MergeFrom(from.extension_range_);
oneof_decl_.MergeFrom(from.oneof_decl_);
reserved_range_.MergeFrom(from.reserved_range_);
- reserved_name_.UnsafeMergeFrom(from.reserved_name_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ reserved_name_.MergeFrom(from.reserved_name_);
+ if (from._has_bits_[0 / 32] & 3u) {
if (from.has_name()) {
set_has_name();
name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
@@ -3745,10 +3769,6 @@ void DescriptorProto::UnsafeMergeFrom(const DescriptorProto& from) {
mutable_options()->::google::protobuf::MessageOptions::MergeFrom(from.options());
}
}
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
}
void DescriptorProto::CopyFrom(const ::google::protobuf::Message& from) {
@@ -3762,11 +3782,10 @@ void DescriptorProto::CopyFrom(const DescriptorProto& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.DescriptorProto)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool DescriptorProto::IsInitialized() const {
-
if (!::google::protobuf::internal::AllAreInitialized(this->field())) return false;
if (!::google::protobuf::internal::AllAreInitialized(this->extension())) return false;
if (!::google::protobuf::internal::AllAreInitialized(this->nested_type())) return false;
@@ -3783,140 +3802,27 @@ void DescriptorProto::Swap(DescriptorProto* other) {
InternalSwap(other);
}
void DescriptorProto::InternalSwap(DescriptorProto* other) {
- name_.Swap(&other->name_);
field_.UnsafeArenaSwap(&other->field_);
extension_.UnsafeArenaSwap(&other->extension_);
nested_type_.UnsafeArenaSwap(&other->nested_type_);
enum_type_.UnsafeArenaSwap(&other->enum_type_);
extension_range_.UnsafeArenaSwap(&other->extension_range_);
oneof_decl_.UnsafeArenaSwap(&other->oneof_decl_);
- std::swap(options_, other->options_);
reserved_range_.UnsafeArenaSwap(&other->reserved_range_);
reserved_name_.UnsafeArenaSwap(&other->reserved_name_);
+ name_.Swap(&other->name_);
+ std::swap(options_, other->options_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata DescriptorProto::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = DescriptorProto_descriptor_;
- metadata.reflection = DescriptorProto_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[4];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// DescriptorProto_ExtensionRange
-
-// optional int32 start = 1;
-bool DescriptorProto_ExtensionRange::has_start() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void DescriptorProto_ExtensionRange::set_has_start() {
- _has_bits_[0] |= 0x00000001u;
-}
-void DescriptorProto_ExtensionRange::clear_has_start() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void DescriptorProto_ExtensionRange::clear_start() {
- start_ = 0;
- clear_has_start();
-}
-::google::protobuf::int32 DescriptorProto_ExtensionRange::start() const {
- // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.start)
- return start_;
-}
-void DescriptorProto_ExtensionRange::set_start(::google::protobuf::int32 value) {
- set_has_start();
- start_ = value;
- // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.start)
-}
-
-// optional int32 end = 2;
-bool DescriptorProto_ExtensionRange::has_end() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void DescriptorProto_ExtensionRange::set_has_end() {
- _has_bits_[0] |= 0x00000002u;
-}
-void DescriptorProto_ExtensionRange::clear_has_end() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void DescriptorProto_ExtensionRange::clear_end() {
- end_ = 0;
- clear_has_end();
-}
-::google::protobuf::int32 DescriptorProto_ExtensionRange::end() const {
- // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.end)
- return end_;
-}
-void DescriptorProto_ExtensionRange::set_end(::google::protobuf::int32 value) {
- set_has_end();
- end_ = value;
- // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.end)
-}
-
-inline const DescriptorProto_ExtensionRange* DescriptorProto_ExtensionRange::internal_default_instance() {
- return &DescriptorProto_ExtensionRange_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// DescriptorProto_ReservedRange
-
-// optional int32 start = 1;
-bool DescriptorProto_ReservedRange::has_start() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void DescriptorProto_ReservedRange::set_has_start() {
- _has_bits_[0] |= 0x00000001u;
-}
-void DescriptorProto_ReservedRange::clear_has_start() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void DescriptorProto_ReservedRange::clear_start() {
- start_ = 0;
- clear_has_start();
-}
-::google::protobuf::int32 DescriptorProto_ReservedRange::start() const {
- // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ReservedRange.start)
- return start_;
-}
-void DescriptorProto_ReservedRange::set_start(::google::protobuf::int32 value) {
- set_has_start();
- start_ = value;
- // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.start)
-}
-
-// optional int32 end = 2;
-bool DescriptorProto_ReservedRange::has_end() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void DescriptorProto_ReservedRange::set_has_end() {
- _has_bits_[0] |= 0x00000002u;
-}
-void DescriptorProto_ReservedRange::clear_has_end() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void DescriptorProto_ReservedRange::clear_end() {
- end_ = 0;
- clear_has_end();
-}
-::google::protobuf::int32 DescriptorProto_ReservedRange::end() const {
- // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ReservedRange.end)
- return end_;
-}
-void DescriptorProto_ReservedRange::set_end(::google::protobuf::int32 value) {
- set_has_end();
- end_ = value;
- // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.end)
-}
-
-inline const DescriptorProto_ReservedRange* DescriptorProto_ReservedRange::internal_default_instance() {
- return &DescriptorProto_ReservedRange_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
// DescriptorProto
// optional string name = 1;
@@ -3935,13 +3841,21 @@ void DescriptorProto::clear_name() {
}
const ::std::string& DescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.GetNoArena();
}
void DescriptorProto::set_name(const ::std::string& value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.name)
}
+#if LANG_CXX11
+void DescriptorProto::set_name(::std::string&& value) {
+ set_has_name();
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.DescriptorProto.name)
+}
+#endif
void DescriptorProto::set_name(const char* value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -4155,13 +4069,13 @@ DescriptorProto::oneof_decl() const {
// optional .google.protobuf.MessageOptions options = 7;
bool DescriptorProto::has_options() const {
- return (_has_bits_[0] & 0x00000080u) != 0;
+ return (_has_bits_[0] & 0x00000002u) != 0;
}
void DescriptorProto::set_has_options() {
- _has_bits_[0] |= 0x00000080u;
+ _has_bits_[0] |= 0x00000002u;
}
void DescriptorProto::clear_has_options() {
- _has_bits_[0] &= ~0x00000080u;
+ _has_bits_[0] &= ~0x00000002u;
}
void DescriptorProto::clear_options() {
if (options_ != NULL) options_->::google::protobuf::MessageOptions::Clear();
@@ -4247,6 +4161,12 @@ void DescriptorProto::set_reserved_name(int index, const ::std::string& value) {
// @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.reserved_name)
reserved_name_.Mutable(index)->assign(value);
}
+#if LANG_CXX11
+void DescriptorProto::set_reserved_name(int index, ::std::string&& value) {
+ // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.reserved_name)
+ reserved_name_.Mutable(index)->assign(std::move(value));
+}
+#endif
void DescriptorProto::set_reserved_name(int index, const char* value) {
reserved_name_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set_char:google.protobuf.DescriptorProto.reserved_name)
@@ -4264,6 +4184,12 @@ void DescriptorProto::add_reserved_name(const ::std::string& value) {
reserved_name_.Add()->assign(value);
// @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_name)
}
+#if LANG_CXX11
+void DescriptorProto::add_reserved_name(::std::string&& value) {
+ reserved_name_.Add()->assign(std::move(value));
+ // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_name)
+}
+#endif
void DescriptorProto::add_reserved_name(const char* value) {
reserved_name_.Add()->assign(value);
// @@protoc_insertion_point(field_add_char:google.protobuf.DescriptorProto.reserved_name)
@@ -4283,89 +4209,10 @@ DescriptorProto::mutable_reserved_name() {
return &reserved_name_;
}
-inline const DescriptorProto* DescriptorProto::internal_default_instance() {
- return &DescriptorProto_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
-const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Type_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return FieldDescriptorProto_Type_descriptor_;
-}
-bool FieldDescriptorProto_Type_IsValid(int value) {
- switch (value) {
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- case 10:
- case 11:
- case 12:
- case 13:
- case 14:
- case 15:
- case 16:
- case 17:
- case 18:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_DOUBLE;
-const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FLOAT;
-const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_INT64;
-const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_UINT64;
-const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_INT32;
-const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FIXED64;
-const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FIXED32;
-const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_BOOL;
-const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_STRING;
-const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_GROUP;
-const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_MESSAGE;
-const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_BYTES;
-const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_UINT32;
-const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_ENUM;
-const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SFIXED32;
-const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SFIXED64;
-const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SINT32;
-const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SINT64;
-const FieldDescriptorProto_Type FieldDescriptorProto::Type_MIN;
-const FieldDescriptorProto_Type FieldDescriptorProto::Type_MAX;
-const int FieldDescriptorProto::Type_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Label_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return FieldDescriptorProto_Label_descriptor_;
-}
-bool FieldDescriptorProto_Label_IsValid(int value) {
- switch (value) {
- case 1:
- case 2:
- case 3:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const FieldDescriptorProto_Label FieldDescriptorProto::LABEL_OPTIONAL;
-const FieldDescriptorProto_Label FieldDescriptorProto::LABEL_REQUIRED;
-const FieldDescriptorProto_Label FieldDescriptorProto::LABEL_REPEATED;
-const FieldDescriptorProto_Label FieldDescriptorProto::Label_MIN;
-const FieldDescriptorProto_Label FieldDescriptorProto::Label_MAX;
-const int FieldDescriptorProto::Label_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int FieldDescriptorProto::kNameFieldNumber;
const int FieldDescriptorProto::kNumberFieldNumber;
@@ -4381,21 +4228,46 @@ const int FieldDescriptorProto::kOptionsFieldNumber;
FieldDescriptorProto::FieldDescriptorProto()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.FieldDescriptorProto)
}
-
-void FieldDescriptorProto::InitAsDefaultInstance() {
- options_ = const_cast< ::google::protobuf::FieldOptions*>(
- ::google::protobuf::FieldOptions::internal_default_instance());
-}
-
FieldDescriptorProto::FieldDescriptorProto(const FieldDescriptorProto& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_name()) {
+ name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
+ }
+ type_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_type_name()) {
+ type_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_name_);
+ }
+ extendee_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_extendee()) {
+ extendee_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.extendee_);
+ }
+ default_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_default_value()) {
+ default_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.default_value_);
+ }
+ json_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_json_name()) {
+ json_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.json_name_);
+ }
+ if (from.has_options()) {
+ options_ = new ::google::protobuf::FieldOptions(*from.options_);
+ } else {
+ options_ = NULL;
+ }
+ ::memcpy(&number_, &from.number_,
+ reinterpret_cast<char*>(&type_) -
+ reinterpret_cast<char*>(&number_) + sizeof(type_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.FieldDescriptorProto)
}
@@ -4406,9 +4278,8 @@ void FieldDescriptorProto::SharedCtor() {
extendee_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
default_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
json_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- options_ = NULL;
- ::memset(&number_, 0, reinterpret_cast<char*>(&oneof_index_) -
- reinterpret_cast<char*>(&number_) + sizeof(oneof_index_));
+ ::memset(&options_, 0, reinterpret_cast<char*>(&oneof_index_) -
+ reinterpret_cast<char*>(&options_) + sizeof(oneof_index_));
label_ = 1;
type_ = 1;
}
@@ -4424,7 +4295,7 @@ void FieldDescriptorProto::SharedDtor() {
extendee_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
default_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
json_name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- if (this != &FieldDescriptorProto_default_instance_.get()) {
+ if (this != internal_default_instance()) {
delete options_;
}
}
@@ -4435,17 +4306,15 @@ void FieldDescriptorProto::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* FieldDescriptorProto::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return FieldDescriptorProto_descriptor_;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[5].descriptor;
}
const FieldDescriptorProto& FieldDescriptorProto::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<FieldDescriptorProto> FieldDescriptorProto_default_instance_;
-
FieldDescriptorProto* FieldDescriptorProto::New(::google::protobuf::Arena* arena) const {
FieldDescriptorProto* n = new FieldDescriptorProto;
if (arena != NULL) {
@@ -4456,55 +4325,42 @@ FieldDescriptorProto* FieldDescriptorProto::New(::google::protobuf::Arena* arena
void FieldDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.FieldDescriptorProto)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(FieldDescriptorProto, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<FieldDescriptorProto*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- if (_has_bits_[0 / 32] & 255u) {
- ZR_(number_, oneof_index_);
+ if (_has_bits_[0 / 32] & 63u) {
if (has_name()) {
- name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*name_.UnsafeRawStringPointer())->clear();
}
- label_ = 1;
- type_ = 1;
if (has_type_name()) {
- type_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!type_name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*type_name_.UnsafeRawStringPointer())->clear();
}
if (has_extendee()) {
- extendee_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!extendee_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*extendee_.UnsafeRawStringPointer())->clear();
}
if (has_default_value()) {
- default_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!default_value_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*default_value_.UnsafeRawStringPointer())->clear();
}
- }
- if (_has_bits_[8 / 32] & 768u) {
if (has_json_name()) {
- json_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!json_name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*json_name_.UnsafeRawStringPointer())->clear();
}
if (has_options()) {
- if (options_ != NULL) options_->::google::protobuf::FieldOptions::Clear();
+ GOOGLE_DCHECK(options_ != NULL);
+ options_->::google::protobuf::FieldOptions::Clear();
}
}
-
-#undef ZR_HELPER_
-#undef ZR_
-
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
+ if (_has_bits_[0 / 32] & 192u) {
+ ::memset(&number_, 0, reinterpret_cast<char*>(&oneof_index_) -
+ reinterpret_cast<char*>(&number_) + sizeof(oneof_index_));
}
+ if (_has_bits_[8 / 32] & 768u) {
+ label_ = 1;
+ type_ = 1;
+ }
+ _has_bits_.Clear();
+ _internal_metadata_.Clear();
}
bool FieldDescriptorProto::MergePartialFromCodedStream(
@@ -4513,13 +4369,14 @@ bool FieldDescriptorProto::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.FieldDescriptorProto)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional string name = 1;
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -4529,14 +4386,13 @@ bool FieldDescriptorProto::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(18)) goto parse_extendee;
break;
}
// optional string extendee = 2;
case 2: {
- if (tag == 18) {
- parse_extendee:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(18u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_extendee()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -4546,14 +4402,13 @@ bool FieldDescriptorProto::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(24)) goto parse_number;
break;
}
// optional int32 number = 3;
case 3: {
- if (tag == 24) {
- parse_number:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(24u)) {
set_has_number();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
@@ -4561,14 +4416,13 @@ bool FieldDescriptorProto::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(32)) goto parse_label;
break;
}
// optional .google.protobuf.FieldDescriptorProto.Label label = 4;
case 4: {
- if (tag == 32) {
- parse_label:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(32u)) {
int value;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
@@ -4581,14 +4435,13 @@ bool FieldDescriptorProto::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(40)) goto parse_type;
break;
}
// optional .google.protobuf.FieldDescriptorProto.Type type = 5;
case 5: {
- if (tag == 40) {
- parse_type:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(40u)) {
int value;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
@@ -4601,14 +4454,13 @@ bool FieldDescriptorProto::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(50)) goto parse_type_name;
break;
}
// optional string type_name = 6;
case 6: {
- if (tag == 50) {
- parse_type_name:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(50u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_type_name()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -4618,14 +4470,13 @@ bool FieldDescriptorProto::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(58)) goto parse_default_value;
break;
}
// optional string default_value = 7;
case 7: {
- if (tag == 58) {
- parse_default_value:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(58u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_default_value()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -4635,27 +4486,25 @@ bool FieldDescriptorProto::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(66)) goto parse_options;
break;
}
// optional .google.protobuf.FieldOptions options = 8;
case 8: {
- if (tag == 66) {
- parse_options:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(66u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_options()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(72)) goto parse_oneof_index;
break;
}
// optional int32 oneof_index = 9;
case 9: {
- if (tag == 72) {
- parse_oneof_index:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(72u)) {
set_has_oneof_index();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
@@ -4663,14 +4512,13 @@ bool FieldDescriptorProto::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(82)) goto parse_json_name;
break;
}
// optional string json_name = 10;
case 10: {
- if (tag == 82) {
- parse_json_name:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(82u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_json_name()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -4680,7 +4528,6 @@ bool FieldDescriptorProto::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -4796,7 +4643,7 @@ void FieldDescriptorProto::SerializeWithCachedSizes(
::google::protobuf::uint8* FieldDescriptorProto::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FieldDescriptorProto)
// optional string name = 1;
if (has_name()) {
@@ -4894,6 +4741,11 @@ size_t FieldDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FieldDescriptorProto)
size_t total_size = 0;
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
if (_has_bits_[0 / 32] & 255u) {
// optional string name = 1;
if (has_name()) {
@@ -4902,25 +4754,6 @@ size_t FieldDescriptorProto::ByteSizeLong() const {
this->name());
}
- // optional int32 number = 3;
- if (has_number()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->number());
- }
-
- // optional .google.protobuf.FieldDescriptorProto.Label label = 4;
- if (has_label()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->label());
- }
-
- // optional .google.protobuf.FieldDescriptorProto.Type type = 5;
- if (has_type()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->type());
- }
-
// optional string type_name = 6;
if (has_type_name()) {
total_size += 1 +
@@ -4942,15 +4775,6 @@ size_t FieldDescriptorProto::ByteSizeLong() const {
this->default_value());
}
- // optional int32 oneof_index = 9;
- if (has_oneof_index()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->oneof_index());
- }
-
- }
- if (_has_bits_[8 / 32] & 768u) {
// optional string json_name = 10;
if (has_json_name()) {
total_size += 1 +
@@ -4965,11 +4789,34 @@ size_t FieldDescriptorProto::ByteSizeLong() const {
*this->options_);
}
+ // optional int32 number = 3;
+ if (has_number()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->number());
+ }
+
+ // optional int32 oneof_index = 9;
+ if (has_oneof_index()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->oneof_index());
+ }
+
}
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
+ if (_has_bits_[8 / 32] & 768u) {
+ // optional .google.protobuf.FieldDescriptorProto.Label label = 4;
+ if (has_label()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->label());
+ }
+
+ // optional .google.protobuf.FieldDescriptorProto.Type type = 5;
+ if (has_type()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->type());
+ }
+
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
@@ -4980,7 +4827,7 @@ size_t FieldDescriptorProto::ByteSizeLong() const {
void FieldDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FieldDescriptorProto)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const FieldDescriptorProto* source =
::google::protobuf::internal::DynamicCastToGenerated<const FieldDescriptorProto>(
&from);
@@ -4989,35 +4836,19 @@ void FieldDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FieldDescriptorProto)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void FieldDescriptorProto::MergeFrom(const FieldDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldDescriptorProto)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void FieldDescriptorProto::UnsafeMergeFrom(const FieldDescriptorProto& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ if (from._has_bits_[0 / 32] & 255u) {
if (from.has_name()) {
set_has_name();
name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
}
- if (from.has_number()) {
- set_number(from.number());
- }
- if (from.has_label()) {
- set_label(from.label());
- }
- if (from.has_type()) {
- set_type(from.type());
- }
if (from.has_type_name()) {
set_has_type_name();
type_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_name_);
@@ -5030,11 +4861,6 @@ void FieldDescriptorProto::UnsafeMergeFrom(const FieldDescriptorProto& from) {
set_has_default_value();
default_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.default_value_);
}
- if (from.has_oneof_index()) {
- set_oneof_index(from.oneof_index());
- }
- }
- if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) {
if (from.has_json_name()) {
set_has_json_name();
json_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.json_name_);
@@ -5042,10 +4868,20 @@ void FieldDescriptorProto::UnsafeMergeFrom(const FieldDescriptorProto& from) {
if (from.has_options()) {
mutable_options()->::google::protobuf::FieldOptions::MergeFrom(from.options());
}
+ if (from.has_number()) {
+ set_number(from.number());
+ }
+ if (from.has_oneof_index()) {
+ set_oneof_index(from.oneof_index());
+ }
}
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
+ if (from._has_bits_[8 / 32] & 768u) {
+ if (from.has_label()) {
+ set_label(from.label());
+ }
+ if (from.has_type()) {
+ set_type(from.type());
+ }
}
}
@@ -5060,11 +4896,10 @@ void FieldDescriptorProto::CopyFrom(const FieldDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FieldDescriptorProto)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool FieldDescriptorProto::IsInitialized() const {
-
if (has_options()) {
if (!this->options_->IsInitialized()) return false;
}
@@ -5077,26 +4912,23 @@ void FieldDescriptorProto::Swap(FieldDescriptorProto* other) {
}
void FieldDescriptorProto::InternalSwap(FieldDescriptorProto* other) {
name_.Swap(&other->name_);
- std::swap(number_, other->number_);
- std::swap(label_, other->label_);
- std::swap(type_, other->type_);
type_name_.Swap(&other->type_name_);
extendee_.Swap(&other->extendee_);
default_value_.Swap(&other->default_value_);
- std::swap(oneof_index_, other->oneof_index_);
json_name_.Swap(&other->json_name_);
std::swap(options_, other->options_);
+ std::swap(number_, other->number_);
+ std::swap(oneof_index_, other->oneof_index_);
+ std::swap(label_, other->label_);
+ std::swap(type_, other->type_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata FieldDescriptorProto::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = FieldDescriptorProto_descriptor_;
- metadata.reflection = FieldDescriptorProto_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[5];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -5118,13 +4950,21 @@ void FieldDescriptorProto::clear_name() {
}
const ::std::string& FieldDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.GetNoArena();
}
void FieldDescriptorProto::set_name(const ::std::string& value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.name)
}
+#if LANG_CXX11
+void FieldDescriptorProto::set_name(::std::string&& value) {
+ set_has_name();
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.name)
+}
+#endif
void FieldDescriptorProto::set_name(const char* value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -5158,13 +4998,13 @@ void FieldDescriptorProto::set_allocated_name(::std::string* name) {
// optional int32 number = 3;
bool FieldDescriptorProto::has_number() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
+ return (_has_bits_[0] & 0x00000040u) != 0;
}
void FieldDescriptorProto::set_has_number() {
- _has_bits_[0] |= 0x00000002u;
+ _has_bits_[0] |= 0x00000040u;
}
void FieldDescriptorProto::clear_has_number() {
- _has_bits_[0] &= ~0x00000002u;
+ _has_bits_[0] &= ~0x00000040u;
}
void FieldDescriptorProto::clear_number() {
number_ = 0;
@@ -5182,13 +5022,13 @@ void FieldDescriptorProto::set_number(::google::protobuf::int32 value) {
// optional .google.protobuf.FieldDescriptorProto.Label label = 4;
bool FieldDescriptorProto::has_label() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
+ return (_has_bits_[0] & 0x00000100u) != 0;
}
void FieldDescriptorProto::set_has_label() {
- _has_bits_[0] |= 0x00000004u;
+ _has_bits_[0] |= 0x00000100u;
}
void FieldDescriptorProto::clear_has_label() {
- _has_bits_[0] &= ~0x00000004u;
+ _has_bits_[0] &= ~0x00000100u;
}
void FieldDescriptorProto::clear_label() {
label_ = 1;
@@ -5207,13 +5047,13 @@ void FieldDescriptorProto::set_label(::google::protobuf::FieldDescriptorProto_La
// optional .google.protobuf.FieldDescriptorProto.Type type = 5;
bool FieldDescriptorProto::has_type() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
+ return (_has_bits_[0] & 0x00000200u) != 0;
}
void FieldDescriptorProto::set_has_type() {
- _has_bits_[0] |= 0x00000008u;
+ _has_bits_[0] |= 0x00000200u;
}
void FieldDescriptorProto::clear_has_type() {
- _has_bits_[0] &= ~0x00000008u;
+ _has_bits_[0] &= ~0x00000200u;
}
void FieldDescriptorProto::clear_type() {
type_ = 1;
@@ -5232,13 +5072,13 @@ void FieldDescriptorProto::set_type(::google::protobuf::FieldDescriptorProto_Typ
// optional string type_name = 6;
bool FieldDescriptorProto::has_type_name() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
+ return (_has_bits_[0] & 0x00000002u) != 0;
}
void FieldDescriptorProto::set_has_type_name() {
- _has_bits_[0] |= 0x00000010u;
+ _has_bits_[0] |= 0x00000002u;
}
void FieldDescriptorProto::clear_has_type_name() {
- _has_bits_[0] &= ~0x00000010u;
+ _has_bits_[0] &= ~0x00000002u;
}
void FieldDescriptorProto::clear_type_name() {
type_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -5246,13 +5086,21 @@ void FieldDescriptorProto::clear_type_name() {
}
const ::std::string& FieldDescriptorProto::type_name() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.type_name)
- return type_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return type_name_.GetNoArena();
}
void FieldDescriptorProto::set_type_name(const ::std::string& value) {
set_has_type_name();
type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.type_name)
}
+#if LANG_CXX11
+void FieldDescriptorProto::set_type_name(::std::string&& value) {
+ set_has_type_name();
+ type_name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.type_name)
+}
+#endif
void FieldDescriptorProto::set_type_name(const char* value) {
set_has_type_name();
type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -5286,13 +5134,13 @@ void FieldDescriptorProto::set_allocated_type_name(::std::string* type_name) {
// optional string extendee = 2;
bool FieldDescriptorProto::has_extendee() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
+ return (_has_bits_[0] & 0x00000004u) != 0;
}
void FieldDescriptorProto::set_has_extendee() {
- _has_bits_[0] |= 0x00000020u;
+ _has_bits_[0] |= 0x00000004u;
}
void FieldDescriptorProto::clear_has_extendee() {
- _has_bits_[0] &= ~0x00000020u;
+ _has_bits_[0] &= ~0x00000004u;
}
void FieldDescriptorProto::clear_extendee() {
extendee_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -5300,13 +5148,21 @@ void FieldDescriptorProto::clear_extendee() {
}
const ::std::string& FieldDescriptorProto::extendee() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.extendee)
- return extendee_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return extendee_.GetNoArena();
}
void FieldDescriptorProto::set_extendee(const ::std::string& value) {
set_has_extendee();
extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.extendee)
}
+#if LANG_CXX11
+void FieldDescriptorProto::set_extendee(::std::string&& value) {
+ set_has_extendee();
+ extendee_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.extendee)
+}
+#endif
void FieldDescriptorProto::set_extendee(const char* value) {
set_has_extendee();
extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -5340,13 +5196,13 @@ void FieldDescriptorProto::set_allocated_extendee(::std::string* extendee) {
// optional string default_value = 7;
bool FieldDescriptorProto::has_default_value() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
+ return (_has_bits_[0] & 0x00000008u) != 0;
}
void FieldDescriptorProto::set_has_default_value() {
- _has_bits_[0] |= 0x00000040u;
+ _has_bits_[0] |= 0x00000008u;
}
void FieldDescriptorProto::clear_has_default_value() {
- _has_bits_[0] &= ~0x00000040u;
+ _has_bits_[0] &= ~0x00000008u;
}
void FieldDescriptorProto::clear_default_value() {
default_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -5354,13 +5210,21 @@ void FieldDescriptorProto::clear_default_value() {
}
const ::std::string& FieldDescriptorProto::default_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.default_value)
- return default_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return default_value_.GetNoArena();
}
void FieldDescriptorProto::set_default_value(const ::std::string& value) {
set_has_default_value();
default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.default_value)
}
+#if LANG_CXX11
+void FieldDescriptorProto::set_default_value(::std::string&& value) {
+ set_has_default_value();
+ default_value_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.default_value)
+}
+#endif
void FieldDescriptorProto::set_default_value(const char* value) {
set_has_default_value();
default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -5418,13 +5282,13 @@ void FieldDescriptorProto::set_oneof_index(::google::protobuf::int32 value) {
// optional string json_name = 10;
bool FieldDescriptorProto::has_json_name() const {
- return (_has_bits_[0] & 0x00000100u) != 0;
+ return (_has_bits_[0] & 0x00000010u) != 0;
}
void FieldDescriptorProto::set_has_json_name() {
- _has_bits_[0] |= 0x00000100u;
+ _has_bits_[0] |= 0x00000010u;
}
void FieldDescriptorProto::clear_has_json_name() {
- _has_bits_[0] &= ~0x00000100u;
+ _has_bits_[0] &= ~0x00000010u;
}
void FieldDescriptorProto::clear_json_name() {
json_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -5432,13 +5296,21 @@ void FieldDescriptorProto::clear_json_name() {
}
const ::std::string& FieldDescriptorProto::json_name() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.json_name)
- return json_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return json_name_.GetNoArena();
}
void FieldDescriptorProto::set_json_name(const ::std::string& value) {
set_has_json_name();
json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.json_name)
}
+#if LANG_CXX11
+void FieldDescriptorProto::set_json_name(::std::string&& value) {
+ set_has_json_name();
+ json_name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.json_name)
+}
+#endif
void FieldDescriptorProto::set_json_name(const char* value) {
set_has_json_name();
json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -5472,13 +5344,13 @@ void FieldDescriptorProto::set_allocated_json_name(::std::string* json_name) {
// optional .google.protobuf.FieldOptions options = 8;
bool FieldDescriptorProto::has_options() const {
- return (_has_bits_[0] & 0x00000200u) != 0;
+ return (_has_bits_[0] & 0x00000020u) != 0;
}
void FieldDescriptorProto::set_has_options() {
- _has_bits_[0] |= 0x00000200u;
+ _has_bits_[0] |= 0x00000020u;
}
void FieldDescriptorProto::clear_has_options() {
- _has_bits_[0] &= ~0x00000200u;
+ _has_bits_[0] &= ~0x00000020u;
}
void FieldDescriptorProto::clear_options() {
if (options_ != NULL) options_->::google::protobuf::FieldOptions::Clear();
@@ -5515,9 +5387,6 @@ void FieldDescriptorProto::set_allocated_options(::google::protobuf::FieldOption
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.options)
}
-inline const FieldDescriptorProto* FieldDescriptorProto::internal_default_instance() {
- return &FieldDescriptorProto_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -5529,21 +5398,27 @@ const int OneofDescriptorProto::kOptionsFieldNumber;
OneofDescriptorProto::OneofDescriptorProto()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.OneofDescriptorProto)
}
-
-void OneofDescriptorProto::InitAsDefaultInstance() {
- options_ = const_cast< ::google::protobuf::OneofOptions*>(
- ::google::protobuf::OneofOptions::internal_default_instance());
-}
-
OneofDescriptorProto::OneofDescriptorProto(const OneofDescriptorProto& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_name()) {
+ name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
+ }
+ if (from.has_options()) {
+ options_ = new ::google::protobuf::OneofOptions(*from.options_);
+ } else {
+ options_ = NULL;
+ }
// @@protoc_insertion_point(copy_constructor:google.protobuf.OneofDescriptorProto)
}
@@ -5560,7 +5435,7 @@ OneofDescriptorProto::~OneofDescriptorProto() {
void OneofDescriptorProto::SharedDtor() {
name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- if (this != &OneofDescriptorProto_default_instance_.get()) {
+ if (this != internal_default_instance()) {
delete options_;
}
}
@@ -5571,17 +5446,15 @@ void OneofDescriptorProto::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* OneofDescriptorProto::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return OneofDescriptorProto_descriptor_;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[6].descriptor;
}
const OneofDescriptorProto& OneofDescriptorProto::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<OneofDescriptorProto> OneofDescriptorProto_default_instance_;
-
OneofDescriptorProto* OneofDescriptorProto::New(::google::protobuf::Arena* arena) const {
OneofDescriptorProto* n = new OneofDescriptorProto;
if (arena != NULL) {
@@ -5594,16 +5467,16 @@ void OneofDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.OneofDescriptorProto)
if (_has_bits_[0 / 32] & 3u) {
if (has_name()) {
- name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*name_.UnsafeRawStringPointer())->clear();
}
if (has_options()) {
- if (options_ != NULL) options_->::google::protobuf::OneofOptions::Clear();
+ GOOGLE_DCHECK(options_ != NULL);
+ options_->::google::protobuf::OneofOptions::Clear();
}
}
_has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
+ _internal_metadata_.Clear();
}
bool OneofDescriptorProto::MergePartialFromCodedStream(
@@ -5612,13 +5485,14 @@ bool OneofDescriptorProto::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.OneofDescriptorProto)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional string name = 1;
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -5628,20 +5502,18 @@ bool OneofDescriptorProto::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(18)) goto parse_options;
break;
}
// optional .google.protobuf.OneofOptions options = 2;
case 2: {
- if (tag == 18) {
- parse_options:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(18u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_options()));
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -5695,7 +5567,7 @@ void OneofDescriptorProto::SerializeWithCachedSizes(
::google::protobuf::uint8* OneofDescriptorProto::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.OneofDescriptorProto)
// optional string name = 1;
if (has_name()) {
@@ -5727,6 +5599,11 @@ size_t OneofDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.OneofDescriptorProto)
size_t total_size = 0;
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
if (_has_bits_[0 / 32] & 3u) {
// optional string name = 1;
if (has_name()) {
@@ -5743,11 +5620,6 @@ size_t OneofDescriptorProto::ByteSizeLong() const {
}
}
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
@@ -5757,7 +5629,7 @@ size_t OneofDescriptorProto::ByteSizeLong() const {
void OneofDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.OneofDescriptorProto)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const OneofDescriptorProto* source =
::google::protobuf::internal::DynamicCastToGenerated<const OneofDescriptorProto>(
&from);
@@ -5766,22 +5638,15 @@ void OneofDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.OneofDescriptorProto)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void OneofDescriptorProto::MergeFrom(const OneofDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.OneofDescriptorProto)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void OneofDescriptorProto::UnsafeMergeFrom(const OneofDescriptorProto& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ if (from._has_bits_[0 / 32] & 3u) {
if (from.has_name()) {
set_has_name();
name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
@@ -5790,10 +5655,6 @@ void OneofDescriptorProto::UnsafeMergeFrom(const OneofDescriptorProto& from) {
mutable_options()->::google::protobuf::OneofOptions::MergeFrom(from.options());
}
}
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
}
void OneofDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) {
@@ -5807,11 +5668,10 @@ void OneofDescriptorProto::CopyFrom(const OneofDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.OneofDescriptorProto)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool OneofDescriptorProto::IsInitialized() const {
-
if (has_options()) {
if (!this->options_->IsInitialized()) return false;
}
@@ -5831,11 +5691,8 @@ void OneofDescriptorProto::InternalSwap(OneofDescriptorProto* other) {
}
::google::protobuf::Metadata OneofDescriptorProto::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = OneofDescriptorProto_descriptor_;
- metadata.reflection = OneofDescriptorProto_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[6];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -5857,13 +5714,21 @@ void OneofDescriptorProto::clear_name() {
}
const ::std::string& OneofDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.GetNoArena();
}
void OneofDescriptorProto::set_name(const ::std::string& value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.OneofDescriptorProto.name)
}
+#if LANG_CXX11
+void OneofDescriptorProto::set_name(::std::string&& value) {
+ set_has_name();
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.OneofDescriptorProto.name)
+}
+#endif
void OneofDescriptorProto::set_name(const char* value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -5940,9 +5805,6 @@ void OneofDescriptorProto::set_allocated_options(::google::protobuf::OneofOption
// @@protoc_insertion_point(field_set_allocated:google.protobuf.OneofDescriptorProto.options)
}
-inline const OneofDescriptorProto* OneofDescriptorProto::internal_default_instance() {
- return &OneofDescriptorProto_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -5955,21 +5817,28 @@ const int EnumDescriptorProto::kOptionsFieldNumber;
EnumDescriptorProto::EnumDescriptorProto()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.EnumDescriptorProto)
}
-
-void EnumDescriptorProto::InitAsDefaultInstance() {
- options_ = const_cast< ::google::protobuf::EnumOptions*>(
- ::google::protobuf::EnumOptions::internal_default_instance());
-}
-
EnumDescriptorProto::EnumDescriptorProto(const EnumDescriptorProto& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0),
+ value_(from.value_) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_name()) {
+ name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
+ }
+ if (from.has_options()) {
+ options_ = new ::google::protobuf::EnumOptions(*from.options_);
+ } else {
+ options_ = NULL;
+ }
// @@protoc_insertion_point(copy_constructor:google.protobuf.EnumDescriptorProto)
}
@@ -5986,7 +5855,7 @@ EnumDescriptorProto::~EnumDescriptorProto() {
void EnumDescriptorProto::SharedDtor() {
name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- if (this != &EnumDescriptorProto_default_instance_.get()) {
+ if (this != internal_default_instance()) {
delete options_;
}
}
@@ -5997,17 +5866,15 @@ void EnumDescriptorProto::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* EnumDescriptorProto::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return EnumDescriptorProto_descriptor_;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[7].descriptor;
}
const EnumDescriptorProto& EnumDescriptorProto::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<EnumDescriptorProto> EnumDescriptorProto_default_instance_;
-
EnumDescriptorProto* EnumDescriptorProto::New(::google::protobuf::Arena* arena) const {
EnumDescriptorProto* n = new EnumDescriptorProto;
if (arena != NULL) {
@@ -6018,19 +5885,19 @@ EnumDescriptorProto* EnumDescriptorProto::New(::google::protobuf::Arena* arena)
void EnumDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumDescriptorProto)
- if (_has_bits_[0 / 32] & 5u) {
+ value_.Clear();
+ if (_has_bits_[0 / 32] & 3u) {
if (has_name()) {
- name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*name_.UnsafeRawStringPointer())->clear();
}
if (has_options()) {
- if (options_ != NULL) options_->::google::protobuf::EnumOptions::Clear();
+ GOOGLE_DCHECK(options_ != NULL);
+ options_->::google::protobuf::EnumOptions::Clear();
}
}
- value_.Clear();
_has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
+ _internal_metadata_.Clear();
}
bool EnumDescriptorProto::MergePartialFromCodedStream(
@@ -6039,13 +5906,14 @@ bool EnumDescriptorProto::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.EnumDescriptorProto)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional string name = 1;
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -6055,37 +5923,32 @@ bool EnumDescriptorProto::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(18)) goto parse_value;
break;
}
// repeated .google.protobuf.EnumValueDescriptorProto value = 2;
case 2: {
- if (tag == 18) {
- parse_value:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(18u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_value:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_value()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(18)) goto parse_loop_value;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectTag(26)) goto parse_options;
break;
}
// optional .google.protobuf.EnumOptions options = 3;
case 3: {
- if (tag == 26) {
- parse_options:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(26u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_options()));
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -6145,7 +6008,7 @@ void EnumDescriptorProto::SerializeWithCachedSizes(
::google::protobuf::uint8* EnumDescriptorProto::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumDescriptorProto)
// optional string name = 1;
if (has_name()) {
@@ -6184,7 +6047,23 @@ size_t EnumDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumDescriptorProto)
size_t total_size = 0;
- if (_has_bits_[0 / 32] & 5u) {
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ // repeated .google.protobuf.EnumValueDescriptorProto value = 2;
+ {
+ unsigned int count = this->value_size();
+ total_size += 1UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->value(i));
+ }
+ }
+
+ if (_has_bits_[0 / 32] & 3u) {
// optional string name = 1;
if (has_name()) {
total_size += 1 +
@@ -6200,22 +6079,6 @@ size_t EnumDescriptorProto::ByteSizeLong() const {
}
}
- // repeated .google.protobuf.EnumValueDescriptorProto value = 2;
- {
- unsigned int count = this->value_size();
- total_size += 1UL * count;
- for (unsigned int i = 0; i < count; i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->value(i));
- }
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
@@ -6225,7 +6088,7 @@ size_t EnumDescriptorProto::ByteSizeLong() const {
void EnumDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumDescriptorProto)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const EnumDescriptorProto* source =
::google::protobuf::internal::DynamicCastToGenerated<const EnumDescriptorProto>(
&from);
@@ -6234,23 +6097,16 @@ void EnumDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumDescriptorProto)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void EnumDescriptorProto::MergeFrom(const EnumDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumDescriptorProto)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void EnumDescriptorProto::UnsafeMergeFrom(const EnumDescriptorProto& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
value_.MergeFrom(from.value_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from._has_bits_[0 / 32] & 3u) {
if (from.has_name()) {
set_has_name();
name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
@@ -6259,10 +6115,6 @@ void EnumDescriptorProto::UnsafeMergeFrom(const EnumDescriptorProto& from) {
mutable_options()->::google::protobuf::EnumOptions::MergeFrom(from.options());
}
}
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
}
void EnumDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) {
@@ -6276,11 +6128,10 @@ void EnumDescriptorProto::CopyFrom(const EnumDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumDescriptorProto)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool EnumDescriptorProto::IsInitialized() const {
-
if (!::google::protobuf::internal::AllAreInitialized(this->value())) return false;
if (has_options()) {
if (!this->options_->IsInitialized()) return false;
@@ -6293,8 +6144,8 @@ void EnumDescriptorProto::Swap(EnumDescriptorProto* other) {
InternalSwap(other);
}
void EnumDescriptorProto::InternalSwap(EnumDescriptorProto* other) {
- name_.Swap(&other->name_);
value_.UnsafeArenaSwap(&other->value_);
+ name_.Swap(&other->name_);
std::swap(options_, other->options_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
@@ -6302,11 +6153,8 @@ void EnumDescriptorProto::InternalSwap(EnumDescriptorProto* other) {
}
::google::protobuf::Metadata EnumDescriptorProto::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = EnumDescriptorProto_descriptor_;
- metadata.reflection = EnumDescriptorProto_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[7];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -6328,13 +6176,21 @@ void EnumDescriptorProto::clear_name() {
}
const ::std::string& EnumDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.GetNoArena();
}
void EnumDescriptorProto::set_name(const ::std::string& value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.name)
}
+#if LANG_CXX11
+void EnumDescriptorProto::set_name(::std::string&& value) {
+ set_has_name();
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.EnumDescriptorProto.name)
+}
+#endif
void EnumDescriptorProto::set_name(const char* value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -6398,13 +6254,13 @@ EnumDescriptorProto::value() const {
// optional .google.protobuf.EnumOptions options = 3;
bool EnumDescriptorProto::has_options() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
+ return (_has_bits_[0] & 0x00000002u) != 0;
}
void EnumDescriptorProto::set_has_options() {
- _has_bits_[0] |= 0x00000004u;
+ _has_bits_[0] |= 0x00000002u;
}
void EnumDescriptorProto::clear_has_options() {
- _has_bits_[0] &= ~0x00000004u;
+ _has_bits_[0] &= ~0x00000002u;
}
void EnumDescriptorProto::clear_options() {
if (options_ != NULL) options_->::google::protobuf::EnumOptions::Clear();
@@ -6441,9 +6297,6 @@ void EnumDescriptorProto::set_allocated_options(::google::protobuf::EnumOptions*
// @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumDescriptorProto.options)
}
-inline const EnumDescriptorProto* EnumDescriptorProto::internal_default_instance() {
- return &EnumDescriptorProto_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -6456,29 +6309,36 @@ const int EnumValueDescriptorProto::kOptionsFieldNumber;
EnumValueDescriptorProto::EnumValueDescriptorProto()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.EnumValueDescriptorProto)
}
-
-void EnumValueDescriptorProto::InitAsDefaultInstance() {
- options_ = const_cast< ::google::protobuf::EnumValueOptions*>(
- ::google::protobuf::EnumValueOptions::internal_default_instance());
-}
-
EnumValueDescriptorProto::EnumValueDescriptorProto(const EnumValueDescriptorProto& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_name()) {
+ name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
+ }
+ if (from.has_options()) {
+ options_ = new ::google::protobuf::EnumValueOptions(*from.options_);
+ } else {
+ options_ = NULL;
+ }
+ number_ = from.number_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValueDescriptorProto)
}
void EnumValueDescriptorProto::SharedCtor() {
_cached_size_ = 0;
name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- options_ = NULL;
- number_ = 0;
+ ::memset(&options_, 0, reinterpret_cast<char*>(&number_) -
+ reinterpret_cast<char*>(&options_) + sizeof(number_));
}
EnumValueDescriptorProto::~EnumValueDescriptorProto() {
@@ -6488,7 +6348,7 @@ EnumValueDescriptorProto::~EnumValueDescriptorProto() {
void EnumValueDescriptorProto::SharedDtor() {
name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- if (this != &EnumValueDescriptorProto_default_instance_.get()) {
+ if (this != internal_default_instance()) {
delete options_;
}
}
@@ -6499,17 +6359,15 @@ void EnumValueDescriptorProto::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* EnumValueDescriptorProto::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return EnumValueDescriptorProto_descriptor_;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[8].descriptor;
}
const EnumValueDescriptorProto& EnumValueDescriptorProto::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<EnumValueDescriptorProto> EnumValueDescriptorProto_default_instance_;
-
EnumValueDescriptorProto* EnumValueDescriptorProto::New(::google::protobuf::Arena* arena) const {
EnumValueDescriptorProto* n = new EnumValueDescriptorProto;
if (arena != NULL) {
@@ -6520,19 +6378,19 @@ EnumValueDescriptorProto* EnumValueDescriptorProto::New(::google::protobuf::Aren
void EnumValueDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValueDescriptorProto)
- if (_has_bits_[0 / 32] & 7u) {
+ if (_has_bits_[0 / 32] & 3u) {
if (has_name()) {
- name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*name_.UnsafeRawStringPointer())->clear();
}
- number_ = 0;
if (has_options()) {
- if (options_ != NULL) options_->::google::protobuf::EnumValueOptions::Clear();
+ GOOGLE_DCHECK(options_ != NULL);
+ options_->::google::protobuf::EnumValueOptions::Clear();
}
}
+ number_ = 0;
_has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
+ _internal_metadata_.Clear();
}
bool EnumValueDescriptorProto::MergePartialFromCodedStream(
@@ -6541,13 +6399,14 @@ bool EnumValueDescriptorProto::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.EnumValueDescriptorProto)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional string name = 1;
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -6557,14 +6416,13 @@ bool EnumValueDescriptorProto::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(16)) goto parse_number;
break;
}
// optional int32 number = 2;
case 2: {
- if (tag == 16) {
- parse_number:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(16u)) {
set_has_number();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
@@ -6572,20 +6430,18 @@ bool EnumValueDescriptorProto::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(26)) goto parse_options;
break;
}
// optional .google.protobuf.EnumValueOptions options = 3;
case 3: {
- if (tag == 26) {
- parse_options:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(26u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_options()));
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -6644,7 +6500,7 @@ void EnumValueDescriptorProto::SerializeWithCachedSizes(
::google::protobuf::uint8* EnumValueDescriptorProto::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumValueDescriptorProto)
// optional string name = 1;
if (has_name()) {
@@ -6681,6 +6537,11 @@ size_t EnumValueDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumValueDescriptorProto)
size_t total_size = 0;
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
if (_has_bits_[0 / 32] & 7u) {
// optional string name = 1;
if (has_name()) {
@@ -6689,13 +6550,6 @@ size_t EnumValueDescriptorProto::ByteSizeLong() const {
this->name());
}
- // optional int32 number = 2;
- if (has_number()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->number());
- }
-
// optional .google.protobuf.EnumValueOptions options = 3;
if (has_options()) {
total_size += 1 +
@@ -6703,11 +6557,13 @@ size_t EnumValueDescriptorProto::ByteSizeLong() const {
*this->options_);
}
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
+ // optional int32 number = 2;
+ if (has_number()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->number());
+ }
+
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
@@ -6718,7 +6574,7 @@ size_t EnumValueDescriptorProto::ByteSizeLong() const {
void EnumValueDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumValueDescriptorProto)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const EnumValueDescriptorProto* source =
::google::protobuf::internal::DynamicCastToGenerated<const EnumValueDescriptorProto>(
&from);
@@ -6727,36 +6583,25 @@ void EnumValueDescriptorProto::MergeFrom(const ::google::protobuf::Message& from
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumValueDescriptorProto)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void EnumValueDescriptorProto::MergeFrom(const EnumValueDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValueDescriptorProto)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void EnumValueDescriptorProto::UnsafeMergeFrom(const EnumValueDescriptorProto& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ if (from._has_bits_[0 / 32] & 7u) {
if (from.has_name()) {
set_has_name();
name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
}
- if (from.has_number()) {
- set_number(from.number());
- }
if (from.has_options()) {
mutable_options()->::google::protobuf::EnumValueOptions::MergeFrom(from.options());
}
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
+ if (from.has_number()) {
+ set_number(from.number());
+ }
}
}
@@ -6771,11 +6616,10 @@ void EnumValueDescriptorProto::CopyFrom(const EnumValueDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumValueDescriptorProto)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool EnumValueDescriptorProto::IsInitialized() const {
-
if (has_options()) {
if (!this->options_->IsInitialized()) return false;
}
@@ -6788,19 +6632,16 @@ void EnumValueDescriptorProto::Swap(EnumValueDescriptorProto* other) {
}
void EnumValueDescriptorProto::InternalSwap(EnumValueDescriptorProto* other) {
name_.Swap(&other->name_);
- std::swap(number_, other->number_);
std::swap(options_, other->options_);
+ std::swap(number_, other->number_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata EnumValueDescriptorProto::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = EnumValueDescriptorProto_descriptor_;
- metadata.reflection = EnumValueDescriptorProto_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[8];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -6822,13 +6663,21 @@ void EnumValueDescriptorProto::clear_name() {
}
const ::std::string& EnumValueDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.GetNoArena();
}
void EnumValueDescriptorProto::set_name(const ::std::string& value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.EnumValueDescriptorProto.name)
}
+#if LANG_CXX11
+void EnumValueDescriptorProto::set_name(::std::string&& value) {
+ set_has_name();
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.EnumValueDescriptorProto.name)
+}
+#endif
void EnumValueDescriptorProto::set_name(const char* value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -6862,13 +6711,13 @@ void EnumValueDescriptorProto::set_allocated_name(::std::string* name) {
// optional int32 number = 2;
bool EnumValueDescriptorProto::has_number() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
+ return (_has_bits_[0] & 0x00000004u) != 0;
}
void EnumValueDescriptorProto::set_has_number() {
- _has_bits_[0] |= 0x00000002u;
+ _has_bits_[0] |= 0x00000004u;
}
void EnumValueDescriptorProto::clear_has_number() {
- _has_bits_[0] &= ~0x00000002u;
+ _has_bits_[0] &= ~0x00000004u;
}
void EnumValueDescriptorProto::clear_number() {
number_ = 0;
@@ -6886,13 +6735,13 @@ void EnumValueDescriptorProto::set_number(::google::protobuf::int32 value) {
// optional .google.protobuf.EnumValueOptions options = 3;
bool EnumValueDescriptorProto::has_options() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
+ return (_has_bits_[0] & 0x00000002u) != 0;
}
void EnumValueDescriptorProto::set_has_options() {
- _has_bits_[0] |= 0x00000004u;
+ _has_bits_[0] |= 0x00000002u;
}
void EnumValueDescriptorProto::clear_has_options() {
- _has_bits_[0] &= ~0x00000004u;
+ _has_bits_[0] &= ~0x00000002u;
}
void EnumValueDescriptorProto::clear_options() {
if (options_ != NULL) options_->::google::protobuf::EnumValueOptions::Clear();
@@ -6929,9 +6778,6 @@ void EnumValueDescriptorProto::set_allocated_options(::google::protobuf::EnumVal
// @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValueDescriptorProto.options)
}
-inline const EnumValueDescriptorProto* EnumValueDescriptorProto::internal_default_instance() {
- return &EnumValueDescriptorProto_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -6944,21 +6790,28 @@ const int ServiceDescriptorProto::kOptionsFieldNumber;
ServiceDescriptorProto::ServiceDescriptorProto()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.ServiceDescriptorProto)
}
-
-void ServiceDescriptorProto::InitAsDefaultInstance() {
- options_ = const_cast< ::google::protobuf::ServiceOptions*>(
- ::google::protobuf::ServiceOptions::internal_default_instance());
-}
-
ServiceDescriptorProto::ServiceDescriptorProto(const ServiceDescriptorProto& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0),
+ method_(from.method_) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_name()) {
+ name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
+ }
+ if (from.has_options()) {
+ options_ = new ::google::protobuf::ServiceOptions(*from.options_);
+ } else {
+ options_ = NULL;
+ }
// @@protoc_insertion_point(copy_constructor:google.protobuf.ServiceDescriptorProto)
}
@@ -6975,7 +6828,7 @@ ServiceDescriptorProto::~ServiceDescriptorProto() {
void ServiceDescriptorProto::SharedDtor() {
name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- if (this != &ServiceDescriptorProto_default_instance_.get()) {
+ if (this != internal_default_instance()) {
delete options_;
}
}
@@ -6986,17 +6839,15 @@ void ServiceDescriptorProto::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* ServiceDescriptorProto::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return ServiceDescriptorProto_descriptor_;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[9].descriptor;
}
const ServiceDescriptorProto& ServiceDescriptorProto::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<ServiceDescriptorProto> ServiceDescriptorProto_default_instance_;
-
ServiceDescriptorProto* ServiceDescriptorProto::New(::google::protobuf::Arena* arena) const {
ServiceDescriptorProto* n = new ServiceDescriptorProto;
if (arena != NULL) {
@@ -7007,19 +6858,19 @@ ServiceDescriptorProto* ServiceDescriptorProto::New(::google::protobuf::Arena* a
void ServiceDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.ServiceDescriptorProto)
- if (_has_bits_[0 / 32] & 5u) {
+ method_.Clear();
+ if (_has_bits_[0 / 32] & 3u) {
if (has_name()) {
- name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*name_.UnsafeRawStringPointer())->clear();
}
if (has_options()) {
- if (options_ != NULL) options_->::google::protobuf::ServiceOptions::Clear();
+ GOOGLE_DCHECK(options_ != NULL);
+ options_->::google::protobuf::ServiceOptions::Clear();
}
}
- method_.Clear();
_has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
+ _internal_metadata_.Clear();
}
bool ServiceDescriptorProto::MergePartialFromCodedStream(
@@ -7028,13 +6879,14 @@ bool ServiceDescriptorProto::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.ServiceDescriptorProto)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional string name = 1;
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -7044,37 +6896,32 @@ bool ServiceDescriptorProto::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(18)) goto parse_method;
break;
}
// repeated .google.protobuf.MethodDescriptorProto method = 2;
case 2: {
- if (tag == 18) {
- parse_method:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(18u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_method:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_method()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(18)) goto parse_loop_method;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectTag(26)) goto parse_options;
break;
}
// optional .google.protobuf.ServiceOptions options = 3;
case 3: {
- if (tag == 26) {
- parse_options:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(26u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_options()));
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -7134,7 +6981,7 @@ void ServiceDescriptorProto::SerializeWithCachedSizes(
::google::protobuf::uint8* ServiceDescriptorProto::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.ServiceDescriptorProto)
// optional string name = 1;
if (has_name()) {
@@ -7173,7 +7020,23 @@ size_t ServiceDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.ServiceDescriptorProto)
size_t total_size = 0;
- if (_has_bits_[0 / 32] & 5u) {
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ // repeated .google.protobuf.MethodDescriptorProto method = 2;
+ {
+ unsigned int count = this->method_size();
+ total_size += 1UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->method(i));
+ }
+ }
+
+ if (_has_bits_[0 / 32] & 3u) {
// optional string name = 1;
if (has_name()) {
total_size += 1 +
@@ -7189,22 +7052,6 @@ size_t ServiceDescriptorProto::ByteSizeLong() const {
}
}
- // repeated .google.protobuf.MethodDescriptorProto method = 2;
- {
- unsigned int count = this->method_size();
- total_size += 1UL * count;
- for (unsigned int i = 0; i < count; i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->method(i));
- }
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
@@ -7214,7 +7061,7 @@ size_t ServiceDescriptorProto::ByteSizeLong() const {
void ServiceDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.ServiceDescriptorProto)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const ServiceDescriptorProto* source =
::google::protobuf::internal::DynamicCastToGenerated<const ServiceDescriptorProto>(
&from);
@@ -7223,23 +7070,16 @@ void ServiceDescriptorProto::MergeFrom(const ::google::protobuf::Message& from)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.ServiceDescriptorProto)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void ServiceDescriptorProto::MergeFrom(const ServiceDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ServiceDescriptorProto)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void ServiceDescriptorProto::UnsafeMergeFrom(const ServiceDescriptorProto& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
method_.MergeFrom(from.method_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from._has_bits_[0 / 32] & 3u) {
if (from.has_name()) {
set_has_name();
name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
@@ -7248,10 +7088,6 @@ void ServiceDescriptorProto::UnsafeMergeFrom(const ServiceDescriptorProto& from)
mutable_options()->::google::protobuf::ServiceOptions::MergeFrom(from.options());
}
}
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
}
void ServiceDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) {
@@ -7265,11 +7101,10 @@ void ServiceDescriptorProto::CopyFrom(const ServiceDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.ServiceDescriptorProto)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool ServiceDescriptorProto::IsInitialized() const {
-
if (!::google::protobuf::internal::AllAreInitialized(this->method())) return false;
if (has_options()) {
if (!this->options_->IsInitialized()) return false;
@@ -7282,8 +7117,8 @@ void ServiceDescriptorProto::Swap(ServiceDescriptorProto* other) {
InternalSwap(other);
}
void ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* other) {
- name_.Swap(&other->name_);
method_.UnsafeArenaSwap(&other->method_);
+ name_.Swap(&other->name_);
std::swap(options_, other->options_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
@@ -7291,11 +7126,8 @@ void ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* other) {
}
::google::protobuf::Metadata ServiceDescriptorProto::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = ServiceDescriptorProto_descriptor_;
- metadata.reflection = ServiceDescriptorProto_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[9];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -7317,13 +7149,21 @@ void ServiceDescriptorProto::clear_name() {
}
const ::std::string& ServiceDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.GetNoArena();
}
void ServiceDescriptorProto::set_name(const ::std::string& value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.ServiceDescriptorProto.name)
}
+#if LANG_CXX11
+void ServiceDescriptorProto::set_name(::std::string&& value) {
+ set_has_name();
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.ServiceDescriptorProto.name)
+}
+#endif
void ServiceDescriptorProto::set_name(const char* value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -7387,13 +7227,13 @@ ServiceDescriptorProto::method() const {
// optional .google.protobuf.ServiceOptions options = 3;
bool ServiceDescriptorProto::has_options() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
+ return (_has_bits_[0] & 0x00000002u) != 0;
}
void ServiceDescriptorProto::set_has_options() {
- _has_bits_[0] |= 0x00000004u;
+ _has_bits_[0] |= 0x00000002u;
}
void ServiceDescriptorProto::clear_has_options() {
- _has_bits_[0] &= ~0x00000004u;
+ _has_bits_[0] &= ~0x00000002u;
}
void ServiceDescriptorProto::clear_options() {
if (options_ != NULL) options_->::google::protobuf::ServiceOptions::Clear();
@@ -7430,9 +7270,6 @@ void ServiceDescriptorProto::set_allocated_options(::google::protobuf::ServiceOp
// @@protoc_insertion_point(field_set_allocated:google.protobuf.ServiceDescriptorProto.options)
}
-inline const ServiceDescriptorProto* ServiceDescriptorProto::internal_default_instance() {
- return &ServiceDescriptorProto_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -7448,21 +7285,38 @@ const int MethodDescriptorProto::kServerStreamingFieldNumber;
MethodDescriptorProto::MethodDescriptorProto()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.MethodDescriptorProto)
}
-
-void MethodDescriptorProto::InitAsDefaultInstance() {
- options_ = const_cast< ::google::protobuf::MethodOptions*>(
- ::google::protobuf::MethodOptions::internal_default_instance());
-}
-
MethodDescriptorProto::MethodDescriptorProto(const MethodDescriptorProto& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_name()) {
+ name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
+ }
+ input_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_input_type()) {
+ input_type_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.input_type_);
+ }
+ output_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_output_type()) {
+ output_type_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.output_type_);
+ }
+ if (from.has_options()) {
+ options_ = new ::google::protobuf::MethodOptions(*from.options_);
+ } else {
+ options_ = NULL;
+ }
+ ::memcpy(&client_streaming_, &from.client_streaming_,
+ reinterpret_cast<char*>(&server_streaming_) -
+ reinterpret_cast<char*>(&client_streaming_) + sizeof(server_streaming_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.MethodDescriptorProto)
}
@@ -7471,9 +7325,8 @@ void MethodDescriptorProto::SharedCtor() {
name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
input_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
output_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- options_ = NULL;
- ::memset(&client_streaming_, 0, reinterpret_cast<char*>(&server_streaming_) -
- reinterpret_cast<char*>(&client_streaming_) + sizeof(server_streaming_));
+ ::memset(&options_, 0, reinterpret_cast<char*>(&server_streaming_) -
+ reinterpret_cast<char*>(&options_) + sizeof(server_streaming_));
}
MethodDescriptorProto::~MethodDescriptorProto() {
@@ -7485,7 +7338,7 @@ void MethodDescriptorProto::SharedDtor() {
name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
input_type_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
output_type_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- if (this != &MethodDescriptorProto_default_instance_.get()) {
+ if (this != internal_default_instance()) {
delete options_;
}
}
@@ -7496,17 +7349,15 @@ void MethodDescriptorProto::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* MethodDescriptorProto::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return MethodDescriptorProto_descriptor_;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[10].descriptor;
}
const MethodDescriptorProto& MethodDescriptorProto::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<MethodDescriptorProto> MethodDescriptorProto_default_instance_;
-
MethodDescriptorProto* MethodDescriptorProto::New(::google::protobuf::Arena* arena) const {
MethodDescriptorProto* n = new MethodDescriptorProto;
if (arena != NULL) {
@@ -7517,45 +7368,30 @@ MethodDescriptorProto* MethodDescriptorProto::New(::google::protobuf::Arena* are
void MethodDescriptorProto::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.MethodDescriptorProto)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(MethodDescriptorProto, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<MethodDescriptorProto*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- if (_has_bits_[0 / 32] & 63u) {
- ZR_(client_streaming_, server_streaming_);
+ if (_has_bits_[0 / 32] & 15u) {
if (has_name()) {
- name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*name_.UnsafeRawStringPointer())->clear();
}
if (has_input_type()) {
- input_type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!input_type_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*input_type_.UnsafeRawStringPointer())->clear();
}
if (has_output_type()) {
- output_type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!output_type_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*output_type_.UnsafeRawStringPointer())->clear();
}
if (has_options()) {
- if (options_ != NULL) options_->::google::protobuf::MethodOptions::Clear();
+ GOOGLE_DCHECK(options_ != NULL);
+ options_->::google::protobuf::MethodOptions::Clear();
}
}
-
-#undef ZR_HELPER_
-#undef ZR_
-
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
+ if (_has_bits_[0 / 32] & 48u) {
+ ::memset(&client_streaming_, 0, reinterpret_cast<char*>(&server_streaming_) -
+ reinterpret_cast<char*>(&client_streaming_) + sizeof(server_streaming_));
}
+ _has_bits_.Clear();
+ _internal_metadata_.Clear();
}
bool MethodDescriptorProto::MergePartialFromCodedStream(
@@ -7564,13 +7400,14 @@ bool MethodDescriptorProto::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.MethodDescriptorProto)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional string name = 1;
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -7580,14 +7417,13 @@ bool MethodDescriptorProto::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(18)) goto parse_input_type;
break;
}
// optional string input_type = 2;
case 2: {
- if (tag == 18) {
- parse_input_type:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(18u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_input_type()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -7597,14 +7433,13 @@ bool MethodDescriptorProto::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(26)) goto parse_output_type;
break;
}
// optional string output_type = 3;
case 3: {
- if (tag == 26) {
- parse_output_type:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(26u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_output_type()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -7614,27 +7449,25 @@ bool MethodDescriptorProto::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(34)) goto parse_options;
break;
}
// optional .google.protobuf.MethodOptions options = 4;
case 4: {
- if (tag == 34) {
- parse_options:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(34u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_options()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(40)) goto parse_client_streaming;
break;
}
// optional bool client_streaming = 5 [default = false];
case 5: {
- if (tag == 40) {
- parse_client_streaming:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(40u)) {
set_has_client_streaming();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -7642,14 +7475,13 @@ bool MethodDescriptorProto::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(48)) goto parse_server_streaming;
break;
}
// optional bool server_streaming = 6 [default = false];
case 6: {
- if (tag == 48) {
- parse_server_streaming:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(48u)) {
set_has_server_streaming();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -7657,7 +7489,6 @@ bool MethodDescriptorProto::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -7741,7 +7572,7 @@ void MethodDescriptorProto::SerializeWithCachedSizes(
::google::protobuf::uint8* MethodDescriptorProto::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.MethodDescriptorProto)
// optional string name = 1;
if (has_name()) {
@@ -7805,6 +7636,11 @@ size_t MethodDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.MethodDescriptorProto)
size_t total_size = 0;
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
if (_has_bits_[0 / 32] & 63u) {
// optional string name = 1;
if (has_name()) {
@@ -7845,11 +7681,6 @@ size_t MethodDescriptorProto::ByteSizeLong() const {
}
}
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
@@ -7859,7 +7690,7 @@ size_t MethodDescriptorProto::ByteSizeLong() const {
void MethodDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.MethodDescriptorProto)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const MethodDescriptorProto* source =
::google::protobuf::internal::DynamicCastToGenerated<const MethodDescriptorProto>(
&from);
@@ -7868,22 +7699,15 @@ void MethodDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.MethodDescriptorProto)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void MethodDescriptorProto::MergeFrom(const MethodDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MethodDescriptorProto)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void MethodDescriptorProto::UnsafeMergeFrom(const MethodDescriptorProto& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ if (from._has_bits_[0 / 32] & 63u) {
if (from.has_name()) {
set_has_name();
name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
@@ -7906,10 +7730,6 @@ void MethodDescriptorProto::UnsafeMergeFrom(const MethodDescriptorProto& from) {
set_server_streaming(from.server_streaming());
}
}
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
}
void MethodDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) {
@@ -7923,11 +7743,10 @@ void MethodDescriptorProto::CopyFrom(const MethodDescriptorProto& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.MethodDescriptorProto)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool MethodDescriptorProto::IsInitialized() const {
-
if (has_options()) {
if (!this->options_->IsInitialized()) return false;
}
@@ -7951,11 +7770,8 @@ void MethodDescriptorProto::InternalSwap(MethodDescriptorProto* other) {
}
::google::protobuf::Metadata MethodDescriptorProto::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = MethodDescriptorProto_descriptor_;
- metadata.reflection = MethodDescriptorProto_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[10];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -7977,13 +7793,21 @@ void MethodDescriptorProto::clear_name() {
}
const ::std::string& MethodDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.GetNoArena();
}
void MethodDescriptorProto::set_name(const ::std::string& value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.name)
}
+#if LANG_CXX11
+void MethodDescriptorProto::set_name(::std::string&& value) {
+ set_has_name();
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.MethodDescriptorProto.name)
+}
+#endif
void MethodDescriptorProto::set_name(const char* value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -8031,13 +7855,21 @@ void MethodDescriptorProto::clear_input_type() {
}
const ::std::string& MethodDescriptorProto::input_type() const {
// @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.input_type)
- return input_type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return input_type_.GetNoArena();
}
void MethodDescriptorProto::set_input_type(const ::std::string& value) {
set_has_input_type();
input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.input_type)
}
+#if LANG_CXX11
+void MethodDescriptorProto::set_input_type(::std::string&& value) {
+ set_has_input_type();
+ input_type_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.MethodDescriptorProto.input_type)
+}
+#endif
void MethodDescriptorProto::set_input_type(const char* value) {
set_has_input_type();
input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -8085,13 +7917,21 @@ void MethodDescriptorProto::clear_output_type() {
}
const ::std::string& MethodDescriptorProto::output_type() const {
// @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.output_type)
- return output_type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return output_type_.GetNoArena();
}
void MethodDescriptorProto::set_output_type(const ::std::string& value) {
set_has_output_type();
output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.output_type)
}
+#if LANG_CXX11
+void MethodDescriptorProto::set_output_type(::std::string&& value) {
+ set_has_output_type();
+ output_type_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.MethodDescriptorProto.output_type)
+}
+#endif
void MethodDescriptorProto::set_output_type(const char* value) {
set_has_output_type();
output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -8216,36 +8056,10 @@ void MethodDescriptorProto::set_server_streaming(bool value) {
// @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.server_streaming)
}
-inline const MethodDescriptorProto* MethodDescriptorProto::internal_default_instance() {
- return &MethodDescriptorProto_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
-const ::google::protobuf::EnumDescriptor* FileOptions_OptimizeMode_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return FileOptions_OptimizeMode_descriptor_;
-}
-bool FileOptions_OptimizeMode_IsValid(int value) {
- switch (value) {
- case 1:
- case 2:
- case 3:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const FileOptions_OptimizeMode FileOptions::SPEED;
-const FileOptions_OptimizeMode FileOptions::CODE_SIZE;
-const FileOptions_OptimizeMode FileOptions::LITE_RUNTIME;
-const FileOptions_OptimizeMode FileOptions::OptimizeMode_MIN;
-const FileOptions_OptimizeMode FileOptions::OptimizeMode_MAX;
-const int FileOptions::OptimizeMode_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int FileOptions::kJavaPackageFieldNumber;
const int FileOptions::kJavaOuterClassnameFieldNumber;
@@ -8261,24 +8075,53 @@ const int FileOptions::kDeprecatedFieldNumber;
const int FileOptions::kCcEnableArenasFieldNumber;
const int FileOptions::kObjcClassPrefixFieldNumber;
const int FileOptions::kCsharpNamespaceFieldNumber;
+const int FileOptions::kSwiftPrefixFieldNumber;
const int FileOptions::kUninterpretedOptionFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
FileOptions::FileOptions()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.FileOptions)
}
-
-void FileOptions::InitAsDefaultInstance() {
-}
-
FileOptions::FileOptions(const FileOptions& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0),
+ uninterpreted_option_(from.uninterpreted_option_) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ _extensions_.MergeFrom(from._extensions_);
+ java_package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_java_package()) {
+ java_package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.java_package_);
+ }
+ java_outer_classname_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_java_outer_classname()) {
+ java_outer_classname_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.java_outer_classname_);
+ }
+ go_package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_go_package()) {
+ go_package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.go_package_);
+ }
+ objc_class_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_objc_class_prefix()) {
+ objc_class_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.objc_class_prefix_);
+ }
+ csharp_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_csharp_namespace()) {
+ csharp_namespace_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.csharp_namespace_);
+ }
+ swift_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_swift_prefix()) {
+ swift_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.swift_prefix_);
+ }
+ ::memcpy(&java_multiple_files_, &from.java_multiple_files_,
+ reinterpret_cast<char*>(&optimize_for_) -
+ reinterpret_cast<char*>(&java_multiple_files_) + sizeof(optimize_for_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.FileOptions)
}
@@ -8289,6 +8132,7 @@ void FileOptions::SharedCtor() {
go_package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
objc_class_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
csharp_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ swift_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
::memset(&java_multiple_files_, 0, reinterpret_cast<char*>(&cc_enable_arenas_) -
reinterpret_cast<char*>(&java_multiple_files_) + sizeof(cc_enable_arenas_));
optimize_for_ = 1;
@@ -8305,6 +8149,7 @@ void FileOptions::SharedDtor() {
go_package_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
objc_class_prefix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
csharp_namespace_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ swift_prefix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void FileOptions::SetCachedSize(int size) const {
@@ -8313,17 +8158,15 @@ void FileOptions::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* FileOptions::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return FileOptions_descriptor_;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[11].descriptor;
}
const FileOptions& FileOptions::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<FileOptions> FileOptions_default_instance_;
-
FileOptions* FileOptions::New(::google::protobuf::Arena* arena) const {
FileOptions* n = new FileOptions;
if (arena != NULL) {
@@ -8335,53 +8178,44 @@ FileOptions* FileOptions::New(::google::protobuf::Arena* arena) const {
void FileOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.FileOptions)
_extensions_.Clear();
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(FileOptions, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<FileOptions*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- if (_has_bits_[0 / 32] & 255u) {
- ZR_(java_multiple_files_, cc_generic_services_);
+ uninterpreted_option_.Clear();
+ if (_has_bits_[0 / 32] & 63u) {
if (has_java_package()) {
- java_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!java_package_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*java_package_.UnsafeRawStringPointer())->clear();
}
if (has_java_outer_classname()) {
- java_outer_classname_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!java_outer_classname_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*java_outer_classname_.UnsafeRawStringPointer())->clear();
}
- optimize_for_ = 1;
if (has_go_package()) {
- go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!go_package_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*go_package_.UnsafeRawStringPointer())->clear();
}
- }
- if (_has_bits_[8 / 32] & 16128u) {
- ZR_(java_generic_services_, cc_enable_arenas_);
if (has_objc_class_prefix()) {
- objc_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!objc_class_prefix_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*objc_class_prefix_.UnsafeRawStringPointer())->clear();
}
if (has_csharp_namespace()) {
- csharp_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!csharp_namespace_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*csharp_namespace_.UnsafeRawStringPointer())->clear();
+ }
+ if (has_swift_prefix()) {
+ GOOGLE_DCHECK(!swift_prefix_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*swift_prefix_.UnsafeRawStringPointer())->clear();
}
}
-
-#undef ZR_HELPER_
-#undef ZR_
-
- uninterpreted_option_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
+ if (_has_bits_[0 / 32] & 192u) {
+ ::memset(&java_multiple_files_, 0, reinterpret_cast<char*>(&java_generate_equals_and_hash_) -
+ reinterpret_cast<char*>(&java_multiple_files_) + sizeof(java_generate_equals_and_hash_));
+ }
+ if (_has_bits_[8 / 32] & 32512u) {
+ ::memset(&java_string_check_utf8_, 0, reinterpret_cast<char*>(&cc_enable_arenas_) -
+ reinterpret_cast<char*>(&java_string_check_utf8_) + sizeof(cc_enable_arenas_));
+ optimize_for_ = 1;
}
+ _has_bits_.Clear();
+ _internal_metadata_.Clear();
}
bool FileOptions::MergePartialFromCodedStream(
@@ -8390,13 +8224,14 @@ bool FileOptions::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.FileOptions)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional string java_package = 1;
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_java_package()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -8406,14 +8241,13 @@ bool FileOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(66)) goto parse_java_outer_classname;
break;
}
// optional string java_outer_classname = 8;
case 8: {
- if (tag == 66) {
- parse_java_outer_classname:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(66u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_java_outer_classname()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -8423,14 +8257,13 @@ bool FileOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(72)) goto parse_optimize_for;
break;
}
// optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
case 9: {
- if (tag == 72) {
- parse_optimize_for:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(72u)) {
int value;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
@@ -8443,14 +8276,13 @@ bool FileOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(80)) goto parse_java_multiple_files;
break;
}
// optional bool java_multiple_files = 10 [default = false];
case 10: {
- if (tag == 80) {
- parse_java_multiple_files:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(80u)) {
set_has_java_multiple_files();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -8458,14 +8290,13 @@ bool FileOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(90)) goto parse_go_package;
break;
}
// optional string go_package = 11;
case 11: {
- if (tag == 90) {
- parse_go_package:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(90u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_go_package()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -8475,14 +8306,13 @@ bool FileOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(128)) goto parse_cc_generic_services;
break;
}
// optional bool cc_generic_services = 16 [default = false];
case 16: {
- if (tag == 128) {
- parse_cc_generic_services:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(128u)) {
set_has_cc_generic_services();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -8490,14 +8320,13 @@ bool FileOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(136)) goto parse_java_generic_services;
break;
}
// optional bool java_generic_services = 17 [default = false];
case 17: {
- if (tag == 136) {
- parse_java_generic_services:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(136u)) {
set_has_java_generic_services();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -8505,14 +8334,13 @@ bool FileOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(144)) goto parse_py_generic_services;
break;
}
// optional bool py_generic_services = 18 [default = false];
case 18: {
- if (tag == 144) {
- parse_py_generic_services:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(144u)) {
set_has_py_generic_services();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -8520,14 +8348,13 @@ bool FileOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(160)) goto parse_java_generate_equals_and_hash;
break;
}
// optional bool java_generate_equals_and_hash = 20 [deprecated = true];
case 20: {
- if (tag == 160) {
- parse_java_generate_equals_and_hash:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(160u)) {
set_has_java_generate_equals_and_hash();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -8535,14 +8362,13 @@ bool FileOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(184)) goto parse_deprecated;
break;
}
// optional bool deprecated = 23 [default = false];
case 23: {
- if (tag == 184) {
- parse_deprecated:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(184u)) {
set_has_deprecated();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -8550,14 +8376,13 @@ bool FileOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(216)) goto parse_java_string_check_utf8;
break;
}
// optional bool java_string_check_utf8 = 27 [default = false];
case 27: {
- if (tag == 216) {
- parse_java_string_check_utf8:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(216u)) {
set_has_java_string_check_utf8();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -8565,14 +8390,13 @@ bool FileOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(248)) goto parse_cc_enable_arenas;
break;
}
// optional bool cc_enable_arenas = 31 [default = false];
case 31: {
- if (tag == 248) {
- parse_cc_enable_arenas:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(248u)) {
set_has_cc_enable_arenas();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -8580,14 +8404,13 @@ bool FileOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(290)) goto parse_objc_class_prefix;
break;
}
// optional string objc_class_prefix = 36;
case 36: {
- if (tag == 290) {
- parse_objc_class_prefix:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(290u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_objc_class_prefix()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -8597,14 +8420,13 @@ bool FileOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(298)) goto parse_csharp_namespace;
break;
}
// optional string csharp_namespace = 37;
case 37: {
- if (tag == 298) {
- parse_csharp_namespace:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(298u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_csharp_namespace()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -8614,24 +8436,36 @@ bool FileOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(7994)) goto parse_uninterpreted_option;
+ break;
+ }
+
+ // optional string swift_prefix = 39;
+ case 39: {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(314u)) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_swift_prefix()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->swift_prefix().data(), this->swift_prefix().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "google.protobuf.FileOptions.swift_prefix");
+ } else {
+ goto handle_unusual;
+ }
break;
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999: {
- if (tag == 7994) {
- parse_uninterpreted_option:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(7994u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_uninterpreted_option:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_uninterpreted_option()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -8761,6 +8595,16 @@ void FileOptions::SerializeWithCachedSizes(
37, this->csharp_namespace(), output);
}
+ // optional string swift_prefix = 39;
+ if (has_swift_prefix()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->swift_prefix().data(), this->swift_prefix().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "google.protobuf.FileOptions.swift_prefix");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 39, this->swift_prefix(), output);
+ }
+
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
@@ -8780,7 +8624,7 @@ void FileOptions::SerializeWithCachedSizes(
::google::protobuf::uint8* FileOptions::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FileOptions)
// optional string java_package = 1;
if (has_java_package()) {
@@ -8883,6 +8727,17 @@ void FileOptions::SerializeWithCachedSizes(
37, this->csharp_namespace(), target);
}
+ // optional string swift_prefix = 39;
+ if (has_swift_prefix()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->swift_prefix().data(), this->swift_prefix().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "google.protobuf.FileOptions.swift_prefix");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 39, this->swift_prefix(), target);
+ }
+
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
@@ -8892,7 +8747,7 @@ void FileOptions::SerializeWithCachedSizes(
// Extension range [1000, 536870912)
target = _extensions_.InternalSerializeWithCachedSizesToArray(
- 1000, 536870912, false, target);
+ 1000, 536870912, deterministic, target);
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
@@ -8906,6 +8761,24 @@ size_t FileOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileOptions)
size_t total_size = 0;
+ total_size += _extensions_.ByteSize();
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
+ {
+ unsigned int count = this->uninterpreted_option_size();
+ total_size += 2UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->uninterpreted_option(i));
+ }
+ }
+
if (_has_bits_[0 / 32] & 255u) {
// optional string java_package = 1;
if (has_java_package()) {
@@ -8921,6 +8794,34 @@ size_t FileOptions::ByteSizeLong() const {
this->java_outer_classname());
}
+ // optional string go_package = 11;
+ if (has_go_package()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->go_package());
+ }
+
+ // optional string objc_class_prefix = 36;
+ if (has_objc_class_prefix()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->objc_class_prefix());
+ }
+
+ // optional string csharp_namespace = 37;
+ if (has_csharp_namespace()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->csharp_namespace());
+ }
+
+ // optional string swift_prefix = 39;
+ if (has_swift_prefix()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->swift_prefix());
+ }
+
// optional bool java_multiple_files = 10 [default = false];
if (has_java_multiple_files()) {
total_size += 1 + 1;
@@ -8931,31 +8832,18 @@ size_t FileOptions::ByteSizeLong() const {
total_size += 2 + 1;
}
+ }
+ if (_has_bits_[8 / 32] & 32512u) {
// optional bool java_string_check_utf8 = 27 [default = false];
if (has_java_string_check_utf8()) {
total_size += 2 + 1;
}
- // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
- if (has_optimize_for()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->optimize_for());
- }
-
- // optional string go_package = 11;
- if (has_go_package()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->go_package());
- }
-
// optional bool cc_generic_services = 16 [default = false];
if (has_cc_generic_services()) {
total_size += 2 + 1;
}
- }
- if (_has_bits_[8 / 32] & 16128u) {
// optional bool java_generic_services = 17 [default = false];
if (has_java_generic_services()) {
total_size += 2 + 1;
@@ -8976,38 +8864,12 @@ size_t FileOptions::ByteSizeLong() const {
total_size += 2 + 1;
}
- // optional string objc_class_prefix = 36;
- if (has_objc_class_prefix()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->objc_class_prefix());
- }
-
- // optional string csharp_namespace = 37;
- if (has_csharp_namespace()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->csharp_namespace());
- }
-
- }
- // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
- {
- unsigned int count = this->uninterpreted_option_size();
- total_size += 2UL * count;
- for (unsigned int i = 0; i < count; i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->uninterpreted_option(i));
+ // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
+ if (has_optimize_for()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->optimize_for());
}
- }
- total_size += _extensions_.ByteSize();
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
@@ -9018,7 +8880,7 @@ size_t FileOptions::ByteSizeLong() const {
void FileOptions::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FileOptions)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const FileOptions* source =
::google::protobuf::internal::DynamicCastToGenerated<const FileOptions>(
&from);
@@ -9027,23 +8889,17 @@ void FileOptions::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FileOptions)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void FileOptions::MergeFrom(const FileOptions& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileOptions)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void FileOptions::UnsafeMergeFrom(const FileOptions& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _extensions_.MergeFrom(from._extensions_);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
uninterpreted_option_.MergeFrom(from.uninterpreted_option_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from._has_bits_[0 / 32] & 255u) {
if (from.has_java_package()) {
set_has_java_package();
java_package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.java_package_);
@@ -9052,27 +8908,36 @@ void FileOptions::UnsafeMergeFrom(const FileOptions& from) {
set_has_java_outer_classname();
java_outer_classname_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.java_outer_classname_);
}
+ if (from.has_go_package()) {
+ set_has_go_package();
+ go_package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.go_package_);
+ }
+ if (from.has_objc_class_prefix()) {
+ set_has_objc_class_prefix();
+ objc_class_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.objc_class_prefix_);
+ }
+ if (from.has_csharp_namespace()) {
+ set_has_csharp_namespace();
+ csharp_namespace_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.csharp_namespace_);
+ }
+ if (from.has_swift_prefix()) {
+ set_has_swift_prefix();
+ swift_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.swift_prefix_);
+ }
if (from.has_java_multiple_files()) {
set_java_multiple_files(from.java_multiple_files());
}
if (from.has_java_generate_equals_and_hash()) {
set_java_generate_equals_and_hash(from.java_generate_equals_and_hash());
}
+ }
+ if (from._has_bits_[8 / 32] & 32512u) {
if (from.has_java_string_check_utf8()) {
set_java_string_check_utf8(from.java_string_check_utf8());
}
- if (from.has_optimize_for()) {
- set_optimize_for(from.optimize_for());
- }
- if (from.has_go_package()) {
- set_has_go_package();
- go_package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.go_package_);
- }
if (from.has_cc_generic_services()) {
set_cc_generic_services(from.cc_generic_services());
}
- }
- if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) {
if (from.has_java_generic_services()) {
set_java_generic_services(from.java_generic_services());
}
@@ -9085,20 +8950,10 @@ void FileOptions::UnsafeMergeFrom(const FileOptions& from) {
if (from.has_cc_enable_arenas()) {
set_cc_enable_arenas(from.cc_enable_arenas());
}
- if (from.has_objc_class_prefix()) {
- set_has_objc_class_prefix();
- objc_class_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.objc_class_prefix_);
- }
- if (from.has_csharp_namespace()) {
- set_has_csharp_namespace();
- csharp_namespace_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.csharp_namespace_);
+ if (from.has_optimize_for()) {
+ set_optimize_for(from.optimize_for());
}
}
- _extensions_.MergeFrom(from._extensions_);
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
}
void FileOptions::CopyFrom(const ::google::protobuf::Message& from) {
@@ -9112,16 +8967,15 @@ void FileOptions::CopyFrom(const FileOptions& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FileOptions)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool FileOptions::IsInitialized() const {
-
- if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;
-
if (!_extensions_.IsInitialized()) {
return false;
}
+
+ if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;
return true;
}
@@ -9130,21 +8984,22 @@ void FileOptions::Swap(FileOptions* other) {
InternalSwap(other);
}
void FileOptions::InternalSwap(FileOptions* other) {
+ uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_);
java_package_.Swap(&other->java_package_);
java_outer_classname_.Swap(&other->java_outer_classname_);
+ go_package_.Swap(&other->go_package_);
+ objc_class_prefix_.Swap(&other->objc_class_prefix_);
+ csharp_namespace_.Swap(&other->csharp_namespace_);
+ swift_prefix_.Swap(&other->swift_prefix_);
std::swap(java_multiple_files_, other->java_multiple_files_);
std::swap(java_generate_equals_and_hash_, other->java_generate_equals_and_hash_);
std::swap(java_string_check_utf8_, other->java_string_check_utf8_);
- std::swap(optimize_for_, other->optimize_for_);
- go_package_.Swap(&other->go_package_);
std::swap(cc_generic_services_, other->cc_generic_services_);
std::swap(java_generic_services_, other->java_generic_services_);
std::swap(py_generic_services_, other->py_generic_services_);
std::swap(deprecated_, other->deprecated_);
std::swap(cc_enable_arenas_, other->cc_enable_arenas_);
- objc_class_prefix_.Swap(&other->objc_class_prefix_);
- csharp_namespace_.Swap(&other->csharp_namespace_);
- uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_);
+ std::swap(optimize_for_, other->optimize_for_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
@@ -9152,11 +9007,8 @@ void FileOptions::InternalSwap(FileOptions* other) {
}
::google::protobuf::Metadata FileOptions::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = FileOptions_descriptor_;
- metadata.reflection = FileOptions_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[11];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -9178,13 +9030,21 @@ void FileOptions::clear_java_package() {
}
const ::std::string& FileOptions::java_package() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_package)
- return java_package_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return java_package_.GetNoArena();
}
void FileOptions::set_java_package(const ::std::string& value) {
set_has_java_package();
java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_package)
}
+#if LANG_CXX11
+void FileOptions::set_java_package(::std::string&& value) {
+ set_has_java_package();
+ java_package_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.java_package)
+}
+#endif
void FileOptions::set_java_package(const char* value) {
set_has_java_package();
java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -9232,13 +9092,21 @@ void FileOptions::clear_java_outer_classname() {
}
const ::std::string& FileOptions::java_outer_classname() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_outer_classname)
- return java_outer_classname_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return java_outer_classname_.GetNoArena();
}
void FileOptions::set_java_outer_classname(const ::std::string& value) {
set_has_java_outer_classname();
java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_outer_classname)
}
+#if LANG_CXX11
+void FileOptions::set_java_outer_classname(::std::string&& value) {
+ set_has_java_outer_classname();
+ java_outer_classname_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.java_outer_classname)
+}
+#endif
void FileOptions::set_java_outer_classname(const char* value) {
set_has_java_outer_classname();
java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -9272,13 +9140,13 @@ void FileOptions::set_allocated_java_outer_classname(::std::string* java_outer_c
// optional bool java_multiple_files = 10 [default = false];
bool FileOptions::has_java_multiple_files() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
+ return (_has_bits_[0] & 0x00000040u) != 0;
}
void FileOptions::set_has_java_multiple_files() {
- _has_bits_[0] |= 0x00000004u;
+ _has_bits_[0] |= 0x00000040u;
}
void FileOptions::clear_has_java_multiple_files() {
- _has_bits_[0] &= ~0x00000004u;
+ _has_bits_[0] &= ~0x00000040u;
}
void FileOptions::clear_java_multiple_files() {
java_multiple_files_ = false;
@@ -9296,13 +9164,13 @@ void FileOptions::set_java_multiple_files(bool value) {
// optional bool java_generate_equals_and_hash = 20 [deprecated = true];
bool FileOptions::has_java_generate_equals_and_hash() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
+ return (_has_bits_[0] & 0x00000080u) != 0;
}
void FileOptions::set_has_java_generate_equals_and_hash() {
- _has_bits_[0] |= 0x00000008u;
+ _has_bits_[0] |= 0x00000080u;
}
void FileOptions::clear_has_java_generate_equals_and_hash() {
- _has_bits_[0] &= ~0x00000008u;
+ _has_bits_[0] &= ~0x00000080u;
}
void FileOptions::clear_java_generate_equals_and_hash() {
java_generate_equals_and_hash_ = false;
@@ -9320,13 +9188,13 @@ void FileOptions::set_java_generate_equals_and_hash(bool value) {
// optional bool java_string_check_utf8 = 27 [default = false];
bool FileOptions::has_java_string_check_utf8() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
+ return (_has_bits_[0] & 0x00000100u) != 0;
}
void FileOptions::set_has_java_string_check_utf8() {
- _has_bits_[0] |= 0x00000010u;
+ _has_bits_[0] |= 0x00000100u;
}
void FileOptions::clear_has_java_string_check_utf8() {
- _has_bits_[0] &= ~0x00000010u;
+ _has_bits_[0] &= ~0x00000100u;
}
void FileOptions::clear_java_string_check_utf8() {
java_string_check_utf8_ = false;
@@ -9344,13 +9212,13 @@ void FileOptions::set_java_string_check_utf8(bool value) {
// optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
bool FileOptions::has_optimize_for() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
+ return (_has_bits_[0] & 0x00004000u) != 0;
}
void FileOptions::set_has_optimize_for() {
- _has_bits_[0] |= 0x00000020u;
+ _has_bits_[0] |= 0x00004000u;
}
void FileOptions::clear_has_optimize_for() {
- _has_bits_[0] &= ~0x00000020u;
+ _has_bits_[0] &= ~0x00004000u;
}
void FileOptions::clear_optimize_for() {
optimize_for_ = 1;
@@ -9369,13 +9237,13 @@ void FileOptions::set_optimize_for(::google::protobuf::FileOptions_OptimizeMode
// optional string go_package = 11;
bool FileOptions::has_go_package() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
+ return (_has_bits_[0] & 0x00000004u) != 0;
}
void FileOptions::set_has_go_package() {
- _has_bits_[0] |= 0x00000040u;
+ _has_bits_[0] |= 0x00000004u;
}
void FileOptions::clear_has_go_package() {
- _has_bits_[0] &= ~0x00000040u;
+ _has_bits_[0] &= ~0x00000004u;
}
void FileOptions::clear_go_package() {
go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -9383,13 +9251,21 @@ void FileOptions::clear_go_package() {
}
const ::std::string& FileOptions::go_package() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.go_package)
- return go_package_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return go_package_.GetNoArena();
}
void FileOptions::set_go_package(const ::std::string& value) {
set_has_go_package();
go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.go_package)
}
+#if LANG_CXX11
+void FileOptions::set_go_package(::std::string&& value) {
+ set_has_go_package();
+ go_package_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.go_package)
+}
+#endif
void FileOptions::set_go_package(const char* value) {
set_has_go_package();
go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -9423,13 +9299,13 @@ void FileOptions::set_allocated_go_package(::std::string* go_package) {
// optional bool cc_generic_services = 16 [default = false];
bool FileOptions::has_cc_generic_services() const {
- return (_has_bits_[0] & 0x00000080u) != 0;
+ return (_has_bits_[0] & 0x00000200u) != 0;
}
void FileOptions::set_has_cc_generic_services() {
- _has_bits_[0] |= 0x00000080u;
+ _has_bits_[0] |= 0x00000200u;
}
void FileOptions::clear_has_cc_generic_services() {
- _has_bits_[0] &= ~0x00000080u;
+ _has_bits_[0] &= ~0x00000200u;
}
void FileOptions::clear_cc_generic_services() {
cc_generic_services_ = false;
@@ -9447,13 +9323,13 @@ void FileOptions::set_cc_generic_services(bool value) {
// optional bool java_generic_services = 17 [default = false];
bool FileOptions::has_java_generic_services() const {
- return (_has_bits_[0] & 0x00000100u) != 0;
+ return (_has_bits_[0] & 0x00000400u) != 0;
}
void FileOptions::set_has_java_generic_services() {
- _has_bits_[0] |= 0x00000100u;
+ _has_bits_[0] |= 0x00000400u;
}
void FileOptions::clear_has_java_generic_services() {
- _has_bits_[0] &= ~0x00000100u;
+ _has_bits_[0] &= ~0x00000400u;
}
void FileOptions::clear_java_generic_services() {
java_generic_services_ = false;
@@ -9471,13 +9347,13 @@ void FileOptions::set_java_generic_services(bool value) {
// optional bool py_generic_services = 18 [default = false];
bool FileOptions::has_py_generic_services() const {
- return (_has_bits_[0] & 0x00000200u) != 0;
+ return (_has_bits_[0] & 0x00000800u) != 0;
}
void FileOptions::set_has_py_generic_services() {
- _has_bits_[0] |= 0x00000200u;
+ _has_bits_[0] |= 0x00000800u;
}
void FileOptions::clear_has_py_generic_services() {
- _has_bits_[0] &= ~0x00000200u;
+ _has_bits_[0] &= ~0x00000800u;
}
void FileOptions::clear_py_generic_services() {
py_generic_services_ = false;
@@ -9495,13 +9371,13 @@ void FileOptions::set_py_generic_services(bool value) {
// optional bool deprecated = 23 [default = false];
bool FileOptions::has_deprecated() const {
- return (_has_bits_[0] & 0x00000400u) != 0;
+ return (_has_bits_[0] & 0x00001000u) != 0;
}
void FileOptions::set_has_deprecated() {
- _has_bits_[0] |= 0x00000400u;
+ _has_bits_[0] |= 0x00001000u;
}
void FileOptions::clear_has_deprecated() {
- _has_bits_[0] &= ~0x00000400u;
+ _has_bits_[0] &= ~0x00001000u;
}
void FileOptions::clear_deprecated() {
deprecated_ = false;
@@ -9519,13 +9395,13 @@ void FileOptions::set_deprecated(bool value) {
// optional bool cc_enable_arenas = 31 [default = false];
bool FileOptions::has_cc_enable_arenas() const {
- return (_has_bits_[0] & 0x00000800u) != 0;
+ return (_has_bits_[0] & 0x00002000u) != 0;
}
void FileOptions::set_has_cc_enable_arenas() {
- _has_bits_[0] |= 0x00000800u;
+ _has_bits_[0] |= 0x00002000u;
}
void FileOptions::clear_has_cc_enable_arenas() {
- _has_bits_[0] &= ~0x00000800u;
+ _has_bits_[0] &= ~0x00002000u;
}
void FileOptions::clear_cc_enable_arenas() {
cc_enable_arenas_ = false;
@@ -9543,13 +9419,13 @@ void FileOptions::set_cc_enable_arenas(bool value) {
// optional string objc_class_prefix = 36;
bool FileOptions::has_objc_class_prefix() const {
- return (_has_bits_[0] & 0x00001000u) != 0;
+ return (_has_bits_[0] & 0x00000008u) != 0;
}
void FileOptions::set_has_objc_class_prefix() {
- _has_bits_[0] |= 0x00001000u;
+ _has_bits_[0] |= 0x00000008u;
}
void FileOptions::clear_has_objc_class_prefix() {
- _has_bits_[0] &= ~0x00001000u;
+ _has_bits_[0] &= ~0x00000008u;
}
void FileOptions::clear_objc_class_prefix() {
objc_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -9557,13 +9433,21 @@ void FileOptions::clear_objc_class_prefix() {
}
const ::std::string& FileOptions::objc_class_prefix() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.objc_class_prefix)
- return objc_class_prefix_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return objc_class_prefix_.GetNoArena();
}
void FileOptions::set_objc_class_prefix(const ::std::string& value) {
set_has_objc_class_prefix();
objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.objc_class_prefix)
}
+#if LANG_CXX11
+void FileOptions::set_objc_class_prefix(::std::string&& value) {
+ set_has_objc_class_prefix();
+ objc_class_prefix_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.objc_class_prefix)
+}
+#endif
void FileOptions::set_objc_class_prefix(const char* value) {
set_has_objc_class_prefix();
objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -9597,13 +9481,13 @@ void FileOptions::set_allocated_objc_class_prefix(::std::string* objc_class_pref
// optional string csharp_namespace = 37;
bool FileOptions::has_csharp_namespace() const {
- return (_has_bits_[0] & 0x00002000u) != 0;
+ return (_has_bits_[0] & 0x00000010u) != 0;
}
void FileOptions::set_has_csharp_namespace() {
- _has_bits_[0] |= 0x00002000u;
+ _has_bits_[0] |= 0x00000010u;
}
void FileOptions::clear_has_csharp_namespace() {
- _has_bits_[0] &= ~0x00002000u;
+ _has_bits_[0] &= ~0x00000010u;
}
void FileOptions::clear_csharp_namespace() {
csharp_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -9611,13 +9495,21 @@ void FileOptions::clear_csharp_namespace() {
}
const ::std::string& FileOptions::csharp_namespace() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_namespace)
- return csharp_namespace_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return csharp_namespace_.GetNoArena();
}
void FileOptions::set_csharp_namespace(const ::std::string& value) {
set_has_csharp_namespace();
csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_namespace)
}
+#if LANG_CXX11
+void FileOptions::set_csharp_namespace(::std::string&& value) {
+ set_has_csharp_namespace();
+ csharp_namespace_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.csharp_namespace)
+}
+#endif
void FileOptions::set_csharp_namespace(const char* value) {
set_has_csharp_namespace();
csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -9649,6 +9541,68 @@ void FileOptions::set_allocated_csharp_namespace(::std::string* csharp_namespace
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace)
}
+// optional string swift_prefix = 39;
+bool FileOptions::has_swift_prefix() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+void FileOptions::set_has_swift_prefix() {
+ _has_bits_[0] |= 0x00000020u;
+}
+void FileOptions::clear_has_swift_prefix() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+void FileOptions::clear_swift_prefix() {
+ swift_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_swift_prefix();
+}
+const ::std::string& FileOptions::swift_prefix() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.swift_prefix)
+ return swift_prefix_.GetNoArena();
+}
+void FileOptions::set_swift_prefix(const ::std::string& value) {
+ set_has_swift_prefix();
+ swift_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.swift_prefix)
+}
+#if LANG_CXX11
+void FileOptions::set_swift_prefix(::std::string&& value) {
+ set_has_swift_prefix();
+ swift_prefix_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.swift_prefix)
+}
+#endif
+void FileOptions::set_swift_prefix(const char* value) {
+ set_has_swift_prefix();
+ swift_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.swift_prefix)
+}
+void FileOptions::set_swift_prefix(const char* value, size_t size) {
+ set_has_swift_prefix();
+ swift_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.swift_prefix)
+}
+::std::string* FileOptions::mutable_swift_prefix() {
+ set_has_swift_prefix();
+ // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.swift_prefix)
+ return swift_prefix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* FileOptions::release_swift_prefix() {
+ // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.swift_prefix)
+ clear_has_swift_prefix();
+ return swift_prefix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void FileOptions::set_allocated_swift_prefix(::std::string* swift_prefix) {
+ if (swift_prefix != NULL) {
+ set_has_swift_prefix();
+ } else {
+ clear_has_swift_prefix();
+ }
+ swift_prefix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), swift_prefix);
+ // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.swift_prefix)
+}
+
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
int FileOptions::uninterpreted_option_size() const {
return uninterpreted_option_.size();
@@ -9679,9 +9633,6 @@ FileOptions::uninterpreted_option() const {
return uninterpreted_option_;
}
-inline const FileOptions* FileOptions::internal_default_instance() {
- return &FileOptions_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -9696,19 +9647,23 @@ const int MessageOptions::kUninterpretedOptionFieldNumber;
MessageOptions::MessageOptions()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.MessageOptions)
}
-
-void MessageOptions::InitAsDefaultInstance() {
-}
-
MessageOptions::MessageOptions(const MessageOptions& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0),
+ uninterpreted_option_(from.uninterpreted_option_) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ _extensions_.MergeFrom(from._extensions_);
+ ::memcpy(&message_set_wire_format_, &from.message_set_wire_format_,
+ reinterpret_cast<char*>(&map_entry_) -
+ reinterpret_cast<char*>(&message_set_wire_format_) + sizeof(map_entry_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.MessageOptions)
}
@@ -9732,17 +9687,15 @@ void MessageOptions::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* MessageOptions::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return MessageOptions_descriptor_;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[12].descriptor;
}
const MessageOptions& MessageOptions::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<MessageOptions> MessageOptions_default_instance_;
-
MessageOptions* MessageOptions::New(::google::protobuf::Arena* arena) const {
MessageOptions* n = new MessageOptions;
if (arena != NULL) {
@@ -9754,32 +9707,13 @@ MessageOptions* MessageOptions::New(::google::protobuf::Arena* arena) const {
void MessageOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.MessageOptions)
_extensions_.Clear();
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(MessageOptions, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<MessageOptions*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- ZR_(message_set_wire_format_, map_entry_);
-
-#undef ZR_HELPER_
-#undef ZR_
-
uninterpreted_option_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
+ if (_has_bits_[0 / 32] & 15u) {
+ ::memset(&message_set_wire_format_, 0, reinterpret_cast<char*>(&map_entry_) -
+ reinterpret_cast<char*>(&message_set_wire_format_) + sizeof(map_entry_));
}
+ _has_bits_.Clear();
+ _internal_metadata_.Clear();
}
bool MessageOptions::MergePartialFromCodedStream(
@@ -9788,13 +9722,14 @@ bool MessageOptions::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.MessageOptions)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional bool message_set_wire_format = 1 [default = false];
case 1: {
- if (tag == 8) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(8u)) {
set_has_message_set_wire_format();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -9802,14 +9737,13 @@ bool MessageOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(16)) goto parse_no_standard_descriptor_accessor;
break;
}
// optional bool no_standard_descriptor_accessor = 2 [default = false];
case 2: {
- if (tag == 16) {
- parse_no_standard_descriptor_accessor:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(16u)) {
set_has_no_standard_descriptor_accessor();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -9817,14 +9751,13 @@ bool MessageOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(24)) goto parse_deprecated;
break;
}
// optional bool deprecated = 3 [default = false];
case 3: {
- if (tag == 24) {
- parse_deprecated:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(24u)) {
set_has_deprecated();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -9832,14 +9765,13 @@ bool MessageOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(56)) goto parse_map_entry;
break;
}
// optional bool map_entry = 7;
case 7: {
- if (tag == 56) {
- parse_map_entry:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(56u)) {
set_has_map_entry();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -9847,24 +9779,20 @@ bool MessageOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(7994)) goto parse_uninterpreted_option;
break;
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999: {
- if (tag == 7994) {
- parse_uninterpreted_option:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(7994u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_uninterpreted_option:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_uninterpreted_option()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -9937,7 +9865,7 @@ void MessageOptions::SerializeWithCachedSizes(
::google::protobuf::uint8* MessageOptions::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.MessageOptions)
// optional bool message_set_wire_format = 1 [default = false];
if (has_message_set_wire_format()) {
@@ -9968,7 +9896,7 @@ void MessageOptions::SerializeWithCachedSizes(
// Extension range [1000, 536870912)
target = _extensions_.InternalSerializeWithCachedSizesToArray(
- 1000, 536870912, false, target);
+ 1000, 536870912, deterministic, target);
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
@@ -9982,6 +9910,24 @@ size_t MessageOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.MessageOptions)
size_t total_size = 0;
+ total_size += _extensions_.ByteSize();
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
+ {
+ unsigned int count = this->uninterpreted_option_size();
+ total_size += 2UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->uninterpreted_option(i));
+ }
+ }
+
if (_has_bits_[0 / 32] & 15u) {
// optional bool message_set_wire_format = 1 [default = false];
if (has_message_set_wire_format()) {
@@ -10004,24 +9950,6 @@ size_t MessageOptions::ByteSizeLong() const {
}
}
- // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
- {
- unsigned int count = this->uninterpreted_option_size();
- total_size += 2UL * count;
- for (unsigned int i = 0; i < count; i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->uninterpreted_option(i));
- }
- }
-
- total_size += _extensions_.ByteSize();
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
@@ -10031,7 +9959,7 @@ size_t MessageOptions::ByteSizeLong() const {
void MessageOptions::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.MessageOptions)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const MessageOptions* source =
::google::protobuf::internal::DynamicCastToGenerated<const MessageOptions>(
&from);
@@ -10040,23 +9968,17 @@ void MessageOptions::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.MessageOptions)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void MessageOptions::MergeFrom(const MessageOptions& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MessageOptions)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void MessageOptions::UnsafeMergeFrom(const MessageOptions& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _extensions_.MergeFrom(from._extensions_);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
uninterpreted_option_.MergeFrom(from.uninterpreted_option_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from._has_bits_[0 / 32] & 15u) {
if (from.has_message_set_wire_format()) {
set_message_set_wire_format(from.message_set_wire_format());
}
@@ -10070,11 +9992,6 @@ void MessageOptions::UnsafeMergeFrom(const MessageOptions& from) {
set_map_entry(from.map_entry());
}
}
- _extensions_.MergeFrom(from._extensions_);
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
}
void MessageOptions::CopyFrom(const ::google::protobuf::Message& from) {
@@ -10088,16 +10005,15 @@ void MessageOptions::CopyFrom(const MessageOptions& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.MessageOptions)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool MessageOptions::IsInitialized() const {
-
- if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;
-
if (!_extensions_.IsInitialized()) {
return false;
}
+
+ if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;
return true;
}
@@ -10106,11 +10022,11 @@ void MessageOptions::Swap(MessageOptions* other) {
InternalSwap(other);
}
void MessageOptions::InternalSwap(MessageOptions* other) {
+ uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_);
std::swap(message_set_wire_format_, other->message_set_wire_format_);
std::swap(no_standard_descriptor_accessor_, other->no_standard_descriptor_accessor_);
std::swap(deprecated_, other->deprecated_);
std::swap(map_entry_, other->map_entry_);
- uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
@@ -10118,11 +10034,8 @@ void MessageOptions::InternalSwap(MessageOptions* other) {
}
::google::protobuf::Metadata MessageOptions::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = MessageOptions_descriptor_;
- metadata.reflection = MessageOptions_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[12];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -10254,59 +10167,10 @@ MessageOptions::uninterpreted_option() const {
return uninterpreted_option_;
}
-inline const MessageOptions* MessageOptions::internal_default_instance() {
- return &MessageOptions_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
-const ::google::protobuf::EnumDescriptor* FieldOptions_CType_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return FieldOptions_CType_descriptor_;
-}
-bool FieldOptions_CType_IsValid(int value) {
- switch (value) {
- case 0:
- case 1:
- case 2:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const FieldOptions_CType FieldOptions::STRING;
-const FieldOptions_CType FieldOptions::CORD;
-const FieldOptions_CType FieldOptions::STRING_PIECE;
-const FieldOptions_CType FieldOptions::CType_MIN;
-const FieldOptions_CType FieldOptions::CType_MAX;
-const int FieldOptions::CType_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-const ::google::protobuf::EnumDescriptor* FieldOptions_JSType_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return FieldOptions_JSType_descriptor_;
-}
-bool FieldOptions_JSType_IsValid(int value) {
- switch (value) {
- case 0:
- case 1:
- case 2:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const FieldOptions_JSType FieldOptions::JS_NORMAL;
-const FieldOptions_JSType FieldOptions::JS_STRING;
-const FieldOptions_JSType FieldOptions::JS_NUMBER;
-const FieldOptions_JSType FieldOptions::JSType_MIN;
-const FieldOptions_JSType FieldOptions::JSType_MAX;
-const int FieldOptions::JSType_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int FieldOptions::kCtypeFieldNumber;
const int FieldOptions::kPackedFieldNumber;
@@ -10319,19 +10183,23 @@ const int FieldOptions::kUninterpretedOptionFieldNumber;
FieldOptions::FieldOptions()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.FieldOptions)
}
-
-void FieldOptions::InitAsDefaultInstance() {
-}
-
FieldOptions::FieldOptions(const FieldOptions& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0),
+ uninterpreted_option_(from.uninterpreted_option_) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ _extensions_.MergeFrom(from._extensions_);
+ ::memcpy(&ctype_, &from.ctype_,
+ reinterpret_cast<char*>(&weak_) -
+ reinterpret_cast<char*>(&ctype_) + sizeof(weak_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.FieldOptions)
}
@@ -10355,17 +10223,15 @@ void FieldOptions::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* FieldOptions::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return FieldOptions_descriptor_;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[13].descriptor;
}
const FieldOptions& FieldOptions::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<FieldOptions> FieldOptions_default_instance_;
-
FieldOptions* FieldOptions::New(::google::protobuf::Arena* arena) const {
FieldOptions* n = new FieldOptions;
if (arena != NULL) {
@@ -10377,32 +10243,13 @@ FieldOptions* FieldOptions::New(::google::protobuf::Arena* arena) const {
void FieldOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.FieldOptions)
_extensions_.Clear();
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(FieldOptions, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<FieldOptions*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- ZR_(ctype_, weak_);
-
-#undef ZR_HELPER_
-#undef ZR_
-
uninterpreted_option_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
+ if (_has_bits_[0 / 32] & 63u) {
+ ::memset(&ctype_, 0, reinterpret_cast<char*>(&weak_) -
+ reinterpret_cast<char*>(&ctype_) + sizeof(weak_));
}
+ _has_bits_.Clear();
+ _internal_metadata_.Clear();
}
bool FieldOptions::MergePartialFromCodedStream(
@@ -10411,13 +10258,14 @@ bool FieldOptions::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.FieldOptions)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];
case 1: {
- if (tag == 8) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(8u)) {
int value;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
@@ -10430,14 +10278,13 @@ bool FieldOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(16)) goto parse_packed;
break;
}
// optional bool packed = 2;
case 2: {
- if (tag == 16) {
- parse_packed:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(16u)) {
set_has_packed();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -10445,14 +10292,13 @@ bool FieldOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(24)) goto parse_deprecated;
break;
}
// optional bool deprecated = 3 [default = false];
case 3: {
- if (tag == 24) {
- parse_deprecated:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(24u)) {
set_has_deprecated();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -10460,14 +10306,13 @@ bool FieldOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(40)) goto parse_lazy;
break;
}
// optional bool lazy = 5 [default = false];
case 5: {
- if (tag == 40) {
- parse_lazy:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(40u)) {
set_has_lazy();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -10475,14 +10320,13 @@ bool FieldOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(48)) goto parse_jstype;
break;
}
// optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];
case 6: {
- if (tag == 48) {
- parse_jstype:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(48u)) {
int value;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
@@ -10495,14 +10339,13 @@ bool FieldOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(80)) goto parse_weak;
break;
}
// optional bool weak = 10 [default = false];
case 10: {
- if (tag == 80) {
- parse_weak:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(80u)) {
set_has_weak();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -10510,24 +10353,20 @@ bool FieldOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(7994)) goto parse_uninterpreted_option;
break;
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999: {
- if (tag == 7994) {
- parse_uninterpreted_option:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(7994u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_uninterpreted_option:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_uninterpreted_option()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -10612,7 +10451,7 @@ void FieldOptions::SerializeWithCachedSizes(
::google::protobuf::uint8* FieldOptions::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FieldOptions)
// optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];
if (has_ctype()) {
@@ -10655,7 +10494,7 @@ void FieldOptions::SerializeWithCachedSizes(
// Extension range [1000, 536870912)
target = _extensions_.InternalSerializeWithCachedSizesToArray(
- 1000, 536870912, false, target);
+ 1000, 536870912, deterministic, target);
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
@@ -10669,6 +10508,24 @@ size_t FieldOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FieldOptions)
size_t total_size = 0;
+ total_size += _extensions_.ByteSize();
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
+ {
+ unsigned int count = this->uninterpreted_option_size();
+ total_size += 2UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->uninterpreted_option(i));
+ }
+ }
+
if (_has_bits_[0 / 32] & 63u) {
// optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];
if (has_ctype()) {
@@ -10676,17 +10533,17 @@ size_t FieldOptions::ByteSizeLong() const {
::google::protobuf::internal::WireFormatLite::EnumSize(this->ctype());
}
- // optional bool packed = 2;
- if (has_packed()) {
- total_size += 1 + 1;
- }
-
// optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];
if (has_jstype()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::EnumSize(this->jstype());
}
+ // optional bool packed = 2;
+ if (has_packed()) {
+ total_size += 1 + 1;
+ }
+
// optional bool lazy = 5 [default = false];
if (has_lazy()) {
total_size += 1 + 1;
@@ -10703,24 +10560,6 @@ size_t FieldOptions::ByteSizeLong() const {
}
}
- // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
- {
- unsigned int count = this->uninterpreted_option_size();
- total_size += 2UL * count;
- for (unsigned int i = 0; i < count; i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->uninterpreted_option(i));
- }
- }
-
- total_size += _extensions_.ByteSize();
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
@@ -10730,7 +10569,7 @@ size_t FieldOptions::ByteSizeLong() const {
void FieldOptions::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FieldOptions)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const FieldOptions* source =
::google::protobuf::internal::DynamicCastToGenerated<const FieldOptions>(
&from);
@@ -10739,32 +10578,26 @@ void FieldOptions::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FieldOptions)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void FieldOptions::MergeFrom(const FieldOptions& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldOptions)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void FieldOptions::UnsafeMergeFrom(const FieldOptions& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _extensions_.MergeFrom(from._extensions_);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
uninterpreted_option_.MergeFrom(from.uninterpreted_option_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from._has_bits_[0 / 32] & 63u) {
if (from.has_ctype()) {
set_ctype(from.ctype());
}
- if (from.has_packed()) {
- set_packed(from.packed());
- }
if (from.has_jstype()) {
set_jstype(from.jstype());
}
+ if (from.has_packed()) {
+ set_packed(from.packed());
+ }
if (from.has_lazy()) {
set_lazy(from.lazy());
}
@@ -10775,11 +10608,6 @@ void FieldOptions::UnsafeMergeFrom(const FieldOptions& from) {
set_weak(from.weak());
}
}
- _extensions_.MergeFrom(from._extensions_);
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
}
void FieldOptions::CopyFrom(const ::google::protobuf::Message& from) {
@@ -10793,16 +10621,15 @@ void FieldOptions::CopyFrom(const FieldOptions& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FieldOptions)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool FieldOptions::IsInitialized() const {
-
- if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;
-
if (!_extensions_.IsInitialized()) {
return false;
}
+
+ if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;
return true;
}
@@ -10811,13 +10638,13 @@ void FieldOptions::Swap(FieldOptions* other) {
InternalSwap(other);
}
void FieldOptions::InternalSwap(FieldOptions* other) {
+ uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_);
std::swap(ctype_, other->ctype_);
- std::swap(packed_, other->packed_);
std::swap(jstype_, other->jstype_);
+ std::swap(packed_, other->packed_);
std::swap(lazy_, other->lazy_);
std::swap(deprecated_, other->deprecated_);
std::swap(weak_, other->weak_);
- uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
@@ -10825,11 +10652,8 @@ void FieldOptions::InternalSwap(FieldOptions* other) {
}
::google::protobuf::Metadata FieldOptions::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = FieldOptions_descriptor_;
- metadata.reflection = FieldOptions_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[13];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -10862,13 +10686,13 @@ void FieldOptions::set_ctype(::google::protobuf::FieldOptions_CType value) {
// optional bool packed = 2;
bool FieldOptions::has_packed() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
+ return (_has_bits_[0] & 0x00000004u) != 0;
}
void FieldOptions::set_has_packed() {
- _has_bits_[0] |= 0x00000002u;
+ _has_bits_[0] |= 0x00000004u;
}
void FieldOptions::clear_has_packed() {
- _has_bits_[0] &= ~0x00000002u;
+ _has_bits_[0] &= ~0x00000004u;
}
void FieldOptions::clear_packed() {
packed_ = false;
@@ -10886,13 +10710,13 @@ void FieldOptions::set_packed(bool value) {
// optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];
bool FieldOptions::has_jstype() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
+ return (_has_bits_[0] & 0x00000002u) != 0;
}
void FieldOptions::set_has_jstype() {
- _has_bits_[0] |= 0x00000004u;
+ _has_bits_[0] |= 0x00000002u;
}
void FieldOptions::clear_has_jstype() {
- _has_bits_[0] &= ~0x00000004u;
+ _has_bits_[0] &= ~0x00000002u;
}
void FieldOptions::clear_jstype() {
jstype_ = 0;
@@ -11011,9 +10835,6 @@ FieldOptions::uninterpreted_option() const {
return uninterpreted_option_;
}
-inline const FieldOptions* FieldOptions::internal_default_instance() {
- return &FieldOptions_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -11024,19 +10845,20 @@ const int OneofOptions::kUninterpretedOptionFieldNumber;
OneofOptions::OneofOptions()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.OneofOptions)
}
-
-void OneofOptions::InitAsDefaultInstance() {
-}
-
OneofOptions::OneofOptions(const OneofOptions& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0),
+ uninterpreted_option_(from.uninterpreted_option_) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ _extensions_.MergeFrom(from._extensions_);
// @@protoc_insertion_point(copy_constructor:google.protobuf.OneofOptions)
}
@@ -11058,17 +10880,15 @@ void OneofOptions::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* OneofOptions::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return OneofOptions_descriptor_;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[14].descriptor;
}
const OneofOptions& OneofOptions::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<OneofOptions> OneofOptions_default_instance_;
-
OneofOptions* OneofOptions::New(::google::protobuf::Arena* arena) const {
OneofOptions* n = new OneofOptions;
if (arena != NULL) {
@@ -11082,9 +10902,7 @@ void OneofOptions::Clear() {
_extensions_.Clear();
uninterpreted_option_.Clear();
_has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
+ _internal_metadata_.Clear();
}
bool OneofOptions::MergePartialFromCodedStream(
@@ -11093,23 +10911,21 @@ bool OneofOptions::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.OneofOptions)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999: {
- if (tag == 7994) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(7994u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_uninterpreted_option:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_uninterpreted_option()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -11162,7 +10978,7 @@ void OneofOptions::SerializeWithCachedSizes(
::google::protobuf::uint8* OneofOptions::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.OneofOptions)
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {
@@ -11173,7 +10989,7 @@ void OneofOptions::SerializeWithCachedSizes(
// Extension range [1000, 536870912)
target = _extensions_.InternalSerializeWithCachedSizesToArray(
- 1000, 536870912, false, target);
+ 1000, 536870912, deterministic, target);
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
@@ -11187,6 +11003,13 @@ size_t OneofOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.OneofOptions)
size_t total_size = 0;
+ total_size += _extensions_.ByteSize();
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
{
unsigned int count = this->uninterpreted_option_size();
@@ -11198,13 +11021,6 @@ size_t OneofOptions::ByteSizeLong() const {
}
}
- total_size += _extensions_.ByteSize();
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
@@ -11214,7 +11030,7 @@ size_t OneofOptions::ByteSizeLong() const {
void OneofOptions::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.OneofOptions)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const OneofOptions* source =
::google::protobuf::internal::DynamicCastToGenerated<const OneofOptions>(
&from);
@@ -11223,27 +11039,16 @@ void OneofOptions::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.OneofOptions)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void OneofOptions::MergeFrom(const OneofOptions& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.OneofOptions)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void OneofOptions::UnsafeMergeFrom(const OneofOptions& from) {
- GOOGLE_DCHECK(&from != this);
- uninterpreted_option_.MergeFrom(from.uninterpreted_option_);
+ GOOGLE_DCHECK_NE(&from, this);
_extensions_.MergeFrom(from._extensions_);
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ uninterpreted_option_.MergeFrom(from.uninterpreted_option_);
}
void OneofOptions::CopyFrom(const ::google::protobuf::Message& from) {
@@ -11257,16 +11062,15 @@ void OneofOptions::CopyFrom(const OneofOptions& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.OneofOptions)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool OneofOptions::IsInitialized() const {
-
- if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;
-
if (!_extensions_.IsInitialized()) {
return false;
}
+
+ if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;
return true;
}
@@ -11283,11 +11087,8 @@ void OneofOptions::InternalSwap(OneofOptions* other) {
}
::google::protobuf::Metadata OneofOptions::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = OneofOptions_descriptor_;
- metadata.reflection = OneofOptions_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[14];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -11323,9 +11124,6 @@ OneofOptions::uninterpreted_option() const {
return uninterpreted_option_;
}
-inline const OneofOptions* OneofOptions::internal_default_instance() {
- return &OneofOptions_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -11338,19 +11136,23 @@ const int EnumOptions::kUninterpretedOptionFieldNumber;
EnumOptions::EnumOptions()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.EnumOptions)
}
-
-void EnumOptions::InitAsDefaultInstance() {
-}
-
EnumOptions::EnumOptions(const EnumOptions& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0),
+ uninterpreted_option_(from.uninterpreted_option_) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ _extensions_.MergeFrom(from._extensions_);
+ ::memcpy(&allow_alias_, &from.allow_alias_,
+ reinterpret_cast<char*>(&deprecated_) -
+ reinterpret_cast<char*>(&allow_alias_) + sizeof(deprecated_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.EnumOptions)
}
@@ -11374,17 +11176,15 @@ void EnumOptions::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* EnumOptions::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return EnumOptions_descriptor_;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[15].descriptor;
}
const EnumOptions& EnumOptions::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<EnumOptions> EnumOptions_default_instance_;
-
EnumOptions* EnumOptions::New(::google::protobuf::Arena* arena) const {
EnumOptions* n = new EnumOptions;
if (arena != NULL) {
@@ -11396,32 +11196,13 @@ EnumOptions* EnumOptions::New(::google::protobuf::Arena* arena) const {
void EnumOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumOptions)
_extensions_.Clear();
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(EnumOptions, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<EnumOptions*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- ZR_(allow_alias_, deprecated_);
-
-#undef ZR_HELPER_
-#undef ZR_
-
uninterpreted_option_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
+ if (_has_bits_[0 / 32] & 3u) {
+ ::memset(&allow_alias_, 0, reinterpret_cast<char*>(&deprecated_) -
+ reinterpret_cast<char*>(&allow_alias_) + sizeof(deprecated_));
}
+ _has_bits_.Clear();
+ _internal_metadata_.Clear();
}
bool EnumOptions::MergePartialFromCodedStream(
@@ -11430,13 +11211,14 @@ bool EnumOptions::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.EnumOptions)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional bool allow_alias = 2;
case 2: {
- if (tag == 16) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(16u)) {
set_has_allow_alias();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -11444,14 +11226,13 @@ bool EnumOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(24)) goto parse_deprecated;
break;
}
// optional bool deprecated = 3 [default = false];
case 3: {
- if (tag == 24) {
- parse_deprecated:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(24u)) {
set_has_deprecated();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -11459,24 +11240,20 @@ bool EnumOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(7994)) goto parse_uninterpreted_option;
break;
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999: {
- if (tag == 7994) {
- parse_uninterpreted_option:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(7994u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_uninterpreted_option:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_uninterpreted_option()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -11539,7 +11316,7 @@ void EnumOptions::SerializeWithCachedSizes(
::google::protobuf::uint8* EnumOptions::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumOptions)
// optional bool allow_alias = 2;
if (has_allow_alias()) {
@@ -11560,7 +11337,7 @@ void EnumOptions::SerializeWithCachedSizes(
// Extension range [1000, 536870912)
target = _extensions_.InternalSerializeWithCachedSizesToArray(
- 1000, 536870912, false, target);
+ 1000, 536870912, deterministic, target);
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
@@ -11574,17 +11351,12 @@ size_t EnumOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumOptions)
size_t total_size = 0;
- if (_has_bits_[0 / 32] & 3u) {
- // optional bool allow_alias = 2;
- if (has_allow_alias()) {
- total_size += 1 + 1;
- }
-
- // optional bool deprecated = 3 [default = false];
- if (has_deprecated()) {
- total_size += 1 + 1;
- }
+ total_size += _extensions_.ByteSize();
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
{
@@ -11597,12 +11369,17 @@ size_t EnumOptions::ByteSizeLong() const {
}
}
- total_size += _extensions_.ByteSize();
+ if (_has_bits_[0 / 32] & 3u) {
+ // optional bool allow_alias = 2;
+ if (has_allow_alias()) {
+ total_size += 1 + 1;
+ }
+
+ // optional bool deprecated = 3 [default = false];
+ if (has_deprecated()) {
+ total_size += 1 + 1;
+ }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
@@ -11613,7 +11390,7 @@ size_t EnumOptions::ByteSizeLong() const {
void EnumOptions::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumOptions)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const EnumOptions* source =
::google::protobuf::internal::DynamicCastToGenerated<const EnumOptions>(
&from);
@@ -11622,23 +11399,17 @@ void EnumOptions::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumOptions)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void EnumOptions::MergeFrom(const EnumOptions& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumOptions)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void EnumOptions::UnsafeMergeFrom(const EnumOptions& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _extensions_.MergeFrom(from._extensions_);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
uninterpreted_option_.MergeFrom(from.uninterpreted_option_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from._has_bits_[0 / 32] & 3u) {
if (from.has_allow_alias()) {
set_allow_alias(from.allow_alias());
}
@@ -11646,11 +11417,6 @@ void EnumOptions::UnsafeMergeFrom(const EnumOptions& from) {
set_deprecated(from.deprecated());
}
}
- _extensions_.MergeFrom(from._extensions_);
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
}
void EnumOptions::CopyFrom(const ::google::protobuf::Message& from) {
@@ -11664,16 +11430,15 @@ void EnumOptions::CopyFrom(const EnumOptions& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumOptions)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool EnumOptions::IsInitialized() const {
-
- if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;
-
if (!_extensions_.IsInitialized()) {
return false;
}
+
+ if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;
return true;
}
@@ -11682,9 +11447,9 @@ void EnumOptions::Swap(EnumOptions* other) {
InternalSwap(other);
}
void EnumOptions::InternalSwap(EnumOptions* other) {
+ uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_);
std::swap(allow_alias_, other->allow_alias_);
std::swap(deprecated_, other->deprecated_);
- uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
@@ -11692,11 +11457,8 @@ void EnumOptions::InternalSwap(EnumOptions* other) {
}
::google::protobuf::Metadata EnumOptions::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = EnumOptions_descriptor_;
- metadata.reflection = EnumOptions_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[15];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -11780,9 +11542,6 @@ EnumOptions::uninterpreted_option() const {
return uninterpreted_option_;
}
-inline const EnumOptions* EnumOptions::internal_default_instance() {
- return &EnumOptions_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -11794,19 +11553,21 @@ const int EnumValueOptions::kUninterpretedOptionFieldNumber;
EnumValueOptions::EnumValueOptions()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.EnumValueOptions)
}
-
-void EnumValueOptions::InitAsDefaultInstance() {
-}
-
EnumValueOptions::EnumValueOptions(const EnumValueOptions& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0),
+ uninterpreted_option_(from.uninterpreted_option_) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ _extensions_.MergeFrom(from._extensions_);
+ deprecated_ = from.deprecated_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValueOptions)
}
@@ -11829,17 +11590,15 @@ void EnumValueOptions::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* EnumValueOptions::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return EnumValueOptions_descriptor_;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[16].descriptor;
}
const EnumValueOptions& EnumValueOptions::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<EnumValueOptions> EnumValueOptions_default_instance_;
-
EnumValueOptions* EnumValueOptions::New(::google::protobuf::Arena* arena) const {
EnumValueOptions* n = new EnumValueOptions;
if (arena != NULL) {
@@ -11851,12 +11610,10 @@ EnumValueOptions* EnumValueOptions::New(::google::protobuf::Arena* arena) const
void EnumValueOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValueOptions)
_extensions_.Clear();
- deprecated_ = false;
uninterpreted_option_.Clear();
+ deprecated_ = false;
_has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
+ _internal_metadata_.Clear();
}
bool EnumValueOptions::MergePartialFromCodedStream(
@@ -11865,13 +11622,14 @@ bool EnumValueOptions::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.EnumValueOptions)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional bool deprecated = 1 [default = false];
case 1: {
- if (tag == 8) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(8u)) {
set_has_deprecated();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -11879,24 +11637,20 @@ bool EnumValueOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(7994)) goto parse_uninterpreted_option;
break;
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999: {
- if (tag == 7994) {
- parse_uninterpreted_option:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(7994u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_uninterpreted_option:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_uninterpreted_option()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -11954,7 +11708,7 @@ void EnumValueOptions::SerializeWithCachedSizes(
::google::protobuf::uint8* EnumValueOptions::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumValueOptions)
// optional bool deprecated = 1 [default = false];
if (has_deprecated()) {
@@ -11970,7 +11724,7 @@ void EnumValueOptions::SerializeWithCachedSizes(
// Extension range [1000, 536870912)
target = _extensions_.InternalSerializeWithCachedSizesToArray(
- 1000, 536870912, false, target);
+ 1000, 536870912, deterministic, target);
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
@@ -11984,11 +11738,13 @@ size_t EnumValueOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumValueOptions)
size_t total_size = 0;
- // optional bool deprecated = 1 [default = false];
- if (has_deprecated()) {
- total_size += 1 + 1;
- }
+ total_size += _extensions_.ByteSize();
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
{
unsigned int count = this->uninterpreted_option_size();
@@ -12000,13 +11756,11 @@ size_t EnumValueOptions::ByteSizeLong() const {
}
}
- total_size += _extensions_.ByteSize();
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
+ // optional bool deprecated = 1 [default = false];
+ if (has_deprecated()) {
+ total_size += 1 + 1;
}
+
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
@@ -12016,7 +11770,7 @@ size_t EnumValueOptions::ByteSizeLong() const {
void EnumValueOptions::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumValueOptions)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const EnumValueOptions* source =
::google::protobuf::internal::DynamicCastToGenerated<const EnumValueOptions>(
&from);
@@ -12025,31 +11779,18 @@ void EnumValueOptions::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumValueOptions)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void EnumValueOptions::MergeFrom(const EnumValueOptions& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValueOptions)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void EnumValueOptions::UnsafeMergeFrom(const EnumValueOptions& from) {
- GOOGLE_DCHECK(&from != this);
- uninterpreted_option_.MergeFrom(from.uninterpreted_option_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_deprecated()) {
- set_deprecated(from.deprecated());
- }
- }
+ GOOGLE_DCHECK_NE(&from, this);
_extensions_.MergeFrom(from._extensions_);
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ uninterpreted_option_.MergeFrom(from.uninterpreted_option_);
+ if (from.has_deprecated()) {
+ set_deprecated(from.deprecated());
}
}
@@ -12064,16 +11805,15 @@ void EnumValueOptions::CopyFrom(const EnumValueOptions& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumValueOptions)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool EnumValueOptions::IsInitialized() const {
-
- if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;
-
if (!_extensions_.IsInitialized()) {
return false;
}
+
+ if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;
return true;
}
@@ -12082,8 +11822,8 @@ void EnumValueOptions::Swap(EnumValueOptions* other) {
InternalSwap(other);
}
void EnumValueOptions::InternalSwap(EnumValueOptions* other) {
- std::swap(deprecated_, other->deprecated_);
uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_);
+ std::swap(deprecated_, other->deprecated_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
@@ -12091,11 +11831,8 @@ void EnumValueOptions::InternalSwap(EnumValueOptions* other) {
}
::google::protobuf::Metadata EnumValueOptions::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = EnumValueOptions_descriptor_;
- metadata.reflection = EnumValueOptions_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[16];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -12155,9 +11892,6 @@ EnumValueOptions::uninterpreted_option() const {
return uninterpreted_option_;
}
-inline const EnumValueOptions* EnumValueOptions::internal_default_instance() {
- return &EnumValueOptions_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -12169,19 +11903,21 @@ const int ServiceOptions::kUninterpretedOptionFieldNumber;
ServiceOptions::ServiceOptions()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.ServiceOptions)
}
-
-void ServiceOptions::InitAsDefaultInstance() {
-}
-
ServiceOptions::ServiceOptions(const ServiceOptions& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0),
+ uninterpreted_option_(from.uninterpreted_option_) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ _extensions_.MergeFrom(from._extensions_);
+ deprecated_ = from.deprecated_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.ServiceOptions)
}
@@ -12204,17 +11940,15 @@ void ServiceOptions::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* ServiceOptions::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return ServiceOptions_descriptor_;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[17].descriptor;
}
const ServiceOptions& ServiceOptions::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<ServiceOptions> ServiceOptions_default_instance_;
-
ServiceOptions* ServiceOptions::New(::google::protobuf::Arena* arena) const {
ServiceOptions* n = new ServiceOptions;
if (arena != NULL) {
@@ -12226,12 +11960,10 @@ ServiceOptions* ServiceOptions::New(::google::protobuf::Arena* arena) const {
void ServiceOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.ServiceOptions)
_extensions_.Clear();
- deprecated_ = false;
uninterpreted_option_.Clear();
+ deprecated_ = false;
_has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
+ _internal_metadata_.Clear();
}
bool ServiceOptions::MergePartialFromCodedStream(
@@ -12240,13 +11972,14 @@ bool ServiceOptions::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.ServiceOptions)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional bool deprecated = 33 [default = false];
case 33: {
- if (tag == 264) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(264u)) {
set_has_deprecated();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -12254,24 +11987,20 @@ bool ServiceOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(7994)) goto parse_uninterpreted_option;
break;
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999: {
- if (tag == 7994) {
- parse_uninterpreted_option:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(7994u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_uninterpreted_option:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_uninterpreted_option()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -12329,7 +12058,7 @@ void ServiceOptions::SerializeWithCachedSizes(
::google::protobuf::uint8* ServiceOptions::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.ServiceOptions)
// optional bool deprecated = 33 [default = false];
if (has_deprecated()) {
@@ -12345,7 +12074,7 @@ void ServiceOptions::SerializeWithCachedSizes(
// Extension range [1000, 536870912)
target = _extensions_.InternalSerializeWithCachedSizesToArray(
- 1000, 536870912, false, target);
+ 1000, 536870912, deterministic, target);
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
@@ -12359,11 +12088,13 @@ size_t ServiceOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.ServiceOptions)
size_t total_size = 0;
- // optional bool deprecated = 33 [default = false];
- if (has_deprecated()) {
- total_size += 2 + 1;
- }
+ total_size += _extensions_.ByteSize();
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
{
unsigned int count = this->uninterpreted_option_size();
@@ -12375,13 +12106,11 @@ size_t ServiceOptions::ByteSizeLong() const {
}
}
- total_size += _extensions_.ByteSize();
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
+ // optional bool deprecated = 33 [default = false];
+ if (has_deprecated()) {
+ total_size += 2 + 1;
}
+
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
@@ -12391,7 +12120,7 @@ size_t ServiceOptions::ByteSizeLong() const {
void ServiceOptions::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.ServiceOptions)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const ServiceOptions* source =
::google::protobuf::internal::DynamicCastToGenerated<const ServiceOptions>(
&from);
@@ -12400,31 +12129,18 @@ void ServiceOptions::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.ServiceOptions)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void ServiceOptions::MergeFrom(const ServiceOptions& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ServiceOptions)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void ServiceOptions::UnsafeMergeFrom(const ServiceOptions& from) {
- GOOGLE_DCHECK(&from != this);
- uninterpreted_option_.MergeFrom(from.uninterpreted_option_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_deprecated()) {
- set_deprecated(from.deprecated());
- }
- }
+ GOOGLE_DCHECK_NE(&from, this);
_extensions_.MergeFrom(from._extensions_);
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ uninterpreted_option_.MergeFrom(from.uninterpreted_option_);
+ if (from.has_deprecated()) {
+ set_deprecated(from.deprecated());
}
}
@@ -12439,16 +12155,15 @@ void ServiceOptions::CopyFrom(const ServiceOptions& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.ServiceOptions)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool ServiceOptions::IsInitialized() const {
-
- if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;
-
if (!_extensions_.IsInitialized()) {
return false;
}
+
+ if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;
return true;
}
@@ -12457,8 +12172,8 @@ void ServiceOptions::Swap(ServiceOptions* other) {
InternalSwap(other);
}
void ServiceOptions::InternalSwap(ServiceOptions* other) {
- std::swap(deprecated_, other->deprecated_);
uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_);
+ std::swap(deprecated_, other->deprecated_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
@@ -12466,11 +12181,8 @@ void ServiceOptions::InternalSwap(ServiceOptions* other) {
}
::google::protobuf::Metadata ServiceOptions::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = ServiceOptions_descriptor_;
- metadata.reflection = ServiceOptions_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[17];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -12530,39 +12242,42 @@ ServiceOptions::uninterpreted_option() const {
return uninterpreted_option_;
}
-inline const ServiceOptions* ServiceOptions::internal_default_instance() {
- return &ServiceOptions_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int MethodOptions::kDeprecatedFieldNumber;
+const int MethodOptions::kIdempotencyLevelFieldNumber;
const int MethodOptions::kUninterpretedOptionFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
MethodOptions::MethodOptions()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.MethodOptions)
}
-
-void MethodOptions::InitAsDefaultInstance() {
-}
-
MethodOptions::MethodOptions(const MethodOptions& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0),
+ uninterpreted_option_(from.uninterpreted_option_) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ _extensions_.MergeFrom(from._extensions_);
+ ::memcpy(&deprecated_, &from.deprecated_,
+ reinterpret_cast<char*>(&idempotency_level_) -
+ reinterpret_cast<char*>(&deprecated_) + sizeof(idempotency_level_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.MethodOptions)
}
void MethodOptions::SharedCtor() {
_cached_size_ = 0;
- deprecated_ = false;
+ ::memset(&deprecated_, 0, reinterpret_cast<char*>(&idempotency_level_) -
+ reinterpret_cast<char*>(&deprecated_) + sizeof(idempotency_level_));
}
MethodOptions::~MethodOptions() {
@@ -12579,17 +12294,15 @@ void MethodOptions::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* MethodOptions::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return MethodOptions_descriptor_;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[18].descriptor;
}
const MethodOptions& MethodOptions::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<MethodOptions> MethodOptions_default_instance_;
-
MethodOptions* MethodOptions::New(::google::protobuf::Arena* arena) const {
MethodOptions* n = new MethodOptions;
if (arena != NULL) {
@@ -12601,12 +12314,13 @@ MethodOptions* MethodOptions::New(::google::protobuf::Arena* arena) const {
void MethodOptions::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.MethodOptions)
_extensions_.Clear();
- deprecated_ = false;
uninterpreted_option_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
+ if (_has_bits_[0 / 32] & 3u) {
+ ::memset(&deprecated_, 0, reinterpret_cast<char*>(&idempotency_level_) -
+ reinterpret_cast<char*>(&deprecated_) + sizeof(idempotency_level_));
}
+ _has_bits_.Clear();
+ _internal_metadata_.Clear();
}
bool MethodOptions::MergePartialFromCodedStream(
@@ -12615,13 +12329,14 @@ bool MethodOptions::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.MethodOptions)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional bool deprecated = 33 [default = false];
case 33: {
- if (tag == 264) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(264u)) {
set_has_deprecated();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -12629,24 +12344,39 @@ bool MethodOptions::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(7994)) goto parse_uninterpreted_option;
+ break;
+ }
+
+ // optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];
+ case 34: {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(272u)) {
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::google::protobuf::MethodOptions_IdempotencyLevel_IsValid(value)) {
+ set_idempotency_level(static_cast< ::google::protobuf::MethodOptions_IdempotencyLevel >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(34, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
break;
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
case 999: {
- if (tag == 7994) {
- parse_uninterpreted_option:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(7994u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_uninterpreted_option:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_uninterpreted_option()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -12685,6 +12415,12 @@ void MethodOptions::SerializeWithCachedSizes(
::google::protobuf::internal::WireFormatLite::WriteBool(33, this->deprecated(), output);
}
+ // optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];
+ if (has_idempotency_level()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 34, this->idempotency_level(), output);
+ }
+
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
@@ -12704,13 +12440,19 @@ void MethodOptions::SerializeWithCachedSizes(
::google::protobuf::uint8* MethodOptions::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.MethodOptions)
// optional bool deprecated = 33 [default = false];
if (has_deprecated()) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(33, this->deprecated(), target);
}
+ // optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];
+ if (has_idempotency_level()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 34, this->idempotency_level(), target);
+ }
+
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
@@ -12720,7 +12462,7 @@ void MethodOptions::SerializeWithCachedSizes(
// Extension range [1000, 536870912)
target = _extensions_.InternalSerializeWithCachedSizesToArray(
- 1000, 536870912, false, target);
+ 1000, 536870912, deterministic, target);
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
@@ -12734,11 +12476,13 @@ size_t MethodOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.MethodOptions)
size_t total_size = 0;
- // optional bool deprecated = 33 [default = false];
- if (has_deprecated()) {
- total_size += 2 + 1;
- }
+ total_size += _extensions_.ByteSize();
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
{
unsigned int count = this->uninterpreted_option_size();
@@ -12750,12 +12494,18 @@ size_t MethodOptions::ByteSizeLong() const {
}
}
- total_size += _extensions_.ByteSize();
+ if (_has_bits_[0 / 32] & 3u) {
+ // optional bool deprecated = 33 [default = false];
+ if (has_deprecated()) {
+ total_size += 2 + 1;
+ }
+
+ // optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];
+ if (has_idempotency_level()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->idempotency_level());
+ }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
@@ -12766,7 +12516,7 @@ size_t MethodOptions::ByteSizeLong() const {
void MethodOptions::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.MethodOptions)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const MethodOptions* source =
::google::protobuf::internal::DynamicCastToGenerated<const MethodOptions>(
&from);
@@ -12775,31 +12525,23 @@ void MethodOptions::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.MethodOptions)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void MethodOptions::MergeFrom(const MethodOptions& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MethodOptions)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void MethodOptions::UnsafeMergeFrom(const MethodOptions& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _extensions_.MergeFrom(from._extensions_);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
uninterpreted_option_.MergeFrom(from.uninterpreted_option_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from._has_bits_[0 / 32] & 3u) {
if (from.has_deprecated()) {
set_deprecated(from.deprecated());
}
- }
- _extensions_.MergeFrom(from._extensions_);
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
+ if (from.has_idempotency_level()) {
+ set_idempotency_level(from.idempotency_level());
+ }
}
}
@@ -12814,16 +12556,15 @@ void MethodOptions::CopyFrom(const MethodOptions& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.MethodOptions)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool MethodOptions::IsInitialized() const {
-
- if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;
-
if (!_extensions_.IsInitialized()) {
return false;
}
+
+ if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;
return true;
}
@@ -12832,8 +12573,9 @@ void MethodOptions::Swap(MethodOptions* other) {
InternalSwap(other);
}
void MethodOptions::InternalSwap(MethodOptions* other) {
- std::swap(deprecated_, other->deprecated_);
uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_);
+ std::swap(deprecated_, other->deprecated_);
+ std::swap(idempotency_level_, other->idempotency_level_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
@@ -12841,11 +12583,8 @@ void MethodOptions::InternalSwap(MethodOptions* other) {
}
::google::protobuf::Metadata MethodOptions::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = MethodOptions_descriptor_;
- metadata.reflection = MethodOptions_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[18];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -12875,6 +12614,31 @@ void MethodOptions::set_deprecated(bool value) {
// @@protoc_insertion_point(field_set:google.protobuf.MethodOptions.deprecated)
}
+// optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];
+bool MethodOptions::has_idempotency_level() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void MethodOptions::set_has_idempotency_level() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void MethodOptions::clear_has_idempotency_level() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void MethodOptions::clear_idempotency_level() {
+ idempotency_level_ = 0;
+ clear_has_idempotency_level();
+}
+::google::protobuf::MethodOptions_IdempotencyLevel MethodOptions::idempotency_level() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.MethodOptions.idempotency_level)
+ return static_cast< ::google::protobuf::MethodOptions_IdempotencyLevel >(idempotency_level_);
+}
+void MethodOptions::set_idempotency_level(::google::protobuf::MethodOptions_IdempotencyLevel value) {
+ assert(::google::protobuf::MethodOptions_IdempotencyLevel_IsValid(value));
+ set_has_idempotency_level();
+ idempotency_level_ = value;
+ // @@protoc_insertion_point(field_set:google.protobuf.MethodOptions.idempotency_level)
+}
+
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
int MethodOptions::uninterpreted_option_size() const {
return uninterpreted_option_.size();
@@ -12905,9 +12669,6 @@ MethodOptions::uninterpreted_option() const {
return uninterpreted_option_;
}
-inline const MethodOptions* MethodOptions::internal_default_instance() {
- return &MethodOptions_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -12919,19 +12680,23 @@ const int UninterpretedOption_NamePart::kIsExtensionFieldNumber;
UninterpretedOption_NamePart::UninterpretedOption_NamePart()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.UninterpretedOption.NamePart)
}
-
-void UninterpretedOption_NamePart::InitAsDefaultInstance() {
-}
-
UninterpretedOption_NamePart::UninterpretedOption_NamePart(const UninterpretedOption_NamePart& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ name_part_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_name_part()) {
+ name_part_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_part_);
+ }
+ is_extension_ = from.is_extension_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.UninterpretedOption.NamePart)
}
@@ -12956,17 +12721,15 @@ void UninterpretedOption_NamePart::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* UninterpretedOption_NamePart::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return UninterpretedOption_NamePart_descriptor_;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[19].descriptor;
}
const UninterpretedOption_NamePart& UninterpretedOption_NamePart::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption_NamePart> UninterpretedOption_NamePart_default_instance_;
-
UninterpretedOption_NamePart* UninterpretedOption_NamePart::New(::google::protobuf::Arena* arena) const {
UninterpretedOption_NamePart* n = new UninterpretedOption_NamePart;
if (arena != NULL) {
@@ -12977,16 +12740,13 @@ UninterpretedOption_NamePart* UninterpretedOption_NamePart::New(::google::protob
void UninterpretedOption_NamePart::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.UninterpretedOption.NamePart)
- if (_has_bits_[0 / 32] & 3u) {
- if (has_name_part()) {
- name_part_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- is_extension_ = false;
+ if (has_name_part()) {
+ GOOGLE_DCHECK(!name_part_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*name_part_.UnsafeRawStringPointer())->clear();
}
+ is_extension_ = false;
_has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
+ _internal_metadata_.Clear();
}
bool UninterpretedOption_NamePart::MergePartialFromCodedStream(
@@ -12995,13 +12755,14 @@ bool UninterpretedOption_NamePart::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.UninterpretedOption.NamePart)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// required string name_part = 1;
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name_part()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -13011,14 +12772,13 @@ bool UninterpretedOption_NamePart::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(16)) goto parse_is_extension;
break;
}
// required bool is_extension = 2;
case 2: {
- if (tag == 16) {
- parse_is_extension:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(16u)) {
set_has_is_extension();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -13026,7 +12786,6 @@ bool UninterpretedOption_NamePart::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -13079,7 +12838,7 @@ void UninterpretedOption_NamePart::SerializeWithCachedSizes(
::google::protobuf::uint8* UninterpretedOption_NamePart::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UninterpretedOption.NamePart)
// required string name_part = 1;
if (has_name_part()) {
@@ -13127,6 +12886,11 @@ size_t UninterpretedOption_NamePart::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.UninterpretedOption.NamePart)
size_t total_size = 0;
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
if (((_has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present.
// required string name_part = 1;
total_size += 1 +
@@ -13139,11 +12903,6 @@ size_t UninterpretedOption_NamePart::ByteSizeLong() const {
} else {
total_size += RequiredFieldsByteSizeFallback();
}
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
@@ -13153,7 +12912,7 @@ size_t UninterpretedOption_NamePart::ByteSizeLong() const {
void UninterpretedOption_NamePart::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.UninterpretedOption.NamePart)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const UninterpretedOption_NamePart* source =
::google::protobuf::internal::DynamicCastToGenerated<const UninterpretedOption_NamePart>(
&from);
@@ -13162,22 +12921,15 @@ void UninterpretedOption_NamePart::MergeFrom(const ::google::protobuf::Message&
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.UninterpretedOption.NamePart)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void UninterpretedOption_NamePart::MergeFrom(const UninterpretedOption_NamePart& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption.NamePart)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void UninterpretedOption_NamePart::UnsafeMergeFrom(const UninterpretedOption_NamePart& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ if (from._has_bits_[0 / 32] & 3u) {
if (from.has_name_part()) {
set_has_name_part();
name_part_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_part_);
@@ -13186,10 +12938,6 @@ void UninterpretedOption_NamePart::UnsafeMergeFrom(const UninterpretedOption_Nam
set_is_extension(from.is_extension());
}
}
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
}
void UninterpretedOption_NamePart::CopyFrom(const ::google::protobuf::Message& from) {
@@ -13203,12 +12951,11 @@ void UninterpretedOption_NamePart::CopyFrom(const UninterpretedOption_NamePart&
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.UninterpretedOption.NamePart)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool UninterpretedOption_NamePart::IsInitialized() const {
if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false;
-
return true;
}
@@ -13225,15 +12972,102 @@ void UninterpretedOption_NamePart::InternalSwap(UninterpretedOption_NamePart* ot
}
::google::protobuf::Metadata UninterpretedOption_NamePart::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = UninterpretedOption_NamePart_descriptor_;
- metadata.reflection = UninterpretedOption_NamePart_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[19];
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// UninterpretedOption_NamePart
+
+// required string name_part = 1;
+bool UninterpretedOption_NamePart::has_name_part() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void UninterpretedOption_NamePart::set_has_name_part() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void UninterpretedOption_NamePart::clear_has_name_part() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void UninterpretedOption_NamePart::clear_name_part() {
+ name_part_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_name_part();
+}
+const ::std::string& UninterpretedOption_NamePart::name_part() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.name_part)
+ return name_part_.GetNoArena();
+}
+void UninterpretedOption_NamePart::set_name_part(const ::std::string& value) {
+ set_has_name_part();
+ name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.name_part)
+}
+#if LANG_CXX11
+void UninterpretedOption_NamePart::set_name_part(::std::string&& value) {
+ set_has_name_part();
+ name_part_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.NamePart.name_part)
+}
+#endif
+void UninterpretedOption_NamePart::set_name_part(const char* value) {
+ set_has_name_part();
+ name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.NamePart.name_part)
+}
+void UninterpretedOption_NamePart::set_name_part(const char* value, size_t size) {
+ set_has_name_part();
+ name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.NamePart.name_part)
+}
+::std::string* UninterpretedOption_NamePart::mutable_name_part() {
+ set_has_name_part();
+ // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.NamePart.name_part)
+ return name_part_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* UninterpretedOption_NamePart::release_name_part() {
+ // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.NamePart.name_part)
+ clear_has_name_part();
+ return name_part_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void UninterpretedOption_NamePart::set_allocated_name_part(::std::string* name_part) {
+ if (name_part != NULL) {
+ set_has_name_part();
+ } else {
+ clear_has_name_part();
+ }
+ name_part_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name_part);
+ // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.NamePart.name_part)
+}
+
+// required bool is_extension = 2;
+bool UninterpretedOption_NamePart::has_is_extension() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void UninterpretedOption_NamePart::set_has_is_extension() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void UninterpretedOption_NamePart::clear_has_is_extension() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void UninterpretedOption_NamePart::clear_is_extension() {
+ is_extension_ = false;
+ clear_has_is_extension();
+}
+bool UninterpretedOption_NamePart::is_extension() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.is_extension)
+ return is_extension_;
+}
+void UninterpretedOption_NamePart::set_is_extension(bool value) {
+ set_has_is_extension();
+ is_extension_ = value;
+ // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.is_extension)
}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-// -------------------------------------------------------------------
+// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int UninterpretedOption::kNameFieldNumber;
@@ -13247,19 +13081,34 @@ const int UninterpretedOption::kAggregateValueFieldNumber;
UninterpretedOption::UninterpretedOption()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.UninterpretedOption)
}
-
-void UninterpretedOption::InitAsDefaultInstance() {
-}
-
UninterpretedOption::UninterpretedOption(const UninterpretedOption& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0),
+ name_(from.name_) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ identifier_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_identifier_value()) {
+ identifier_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.identifier_value_);
+ }
+ string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_string_value()) {
+ string_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.string_value_);
+ }
+ aggregate_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_aggregate_value()) {
+ aggregate_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.aggregate_value_);
+ }
+ ::memcpy(&positive_int_value_, &from.positive_int_value_,
+ reinterpret_cast<char*>(&double_value_) -
+ reinterpret_cast<char*>(&positive_int_value_) + sizeof(double_value_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.UninterpretedOption)
}
@@ -13289,17 +13138,15 @@ void UninterpretedOption::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* UninterpretedOption::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return UninterpretedOption_descriptor_;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[20].descriptor;
}
const UninterpretedOption& UninterpretedOption::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption> UninterpretedOption_default_instance_;
-
UninterpretedOption* UninterpretedOption::New(::google::protobuf::Arena* arena) const {
UninterpretedOption* n = new UninterpretedOption;
if (arena != NULL) {
@@ -13310,43 +13157,27 @@ UninterpretedOption* UninterpretedOption::New(::google::protobuf::Arena* arena)
void UninterpretedOption::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.UninterpretedOption)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(UninterpretedOption, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<UninterpretedOption*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- if (_has_bits_[0 / 32] & 126u) {
- ZR_(positive_int_value_, double_value_);
+ name_.Clear();
+ if (_has_bits_[0 / 32] & 7u) {
if (has_identifier_value()) {
- identifier_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!identifier_value_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*identifier_value_.UnsafeRawStringPointer())->clear();
}
if (has_string_value()) {
- string_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!string_value_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*string_value_.UnsafeRawStringPointer())->clear();
}
if (has_aggregate_value()) {
- aggregate_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!aggregate_value_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*aggregate_value_.UnsafeRawStringPointer())->clear();
}
}
-
-#undef ZR_HELPER_
-#undef ZR_
-
- name_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
+ if (_has_bits_[0 / 32] & 56u) {
+ ::memset(&positive_int_value_, 0, reinterpret_cast<char*>(&double_value_) -
+ reinterpret_cast<char*>(&positive_int_value_) + sizeof(double_value_));
}
+ _has_bits_.Clear();
+ _internal_metadata_.Clear();
}
bool UninterpretedOption::MergePartialFromCodedStream(
@@ -13355,30 +13186,28 @@ bool UninterpretedOption::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.UninterpretedOption)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// repeated .google.protobuf.UninterpretedOption.NamePart name = 2;
case 2: {
- if (tag == 18) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(18u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_name:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_name()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(18)) goto parse_loop_name;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectTag(26)) goto parse_identifier_value;
break;
}
// optional string identifier_value = 3;
case 3: {
- if (tag == 26) {
- parse_identifier_value:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(26u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_identifier_value()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -13388,14 +13217,13 @@ bool UninterpretedOption::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(32)) goto parse_positive_int_value;
break;
}
// optional uint64 positive_int_value = 4;
case 4: {
- if (tag == 32) {
- parse_positive_int_value:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(32u)) {
set_has_positive_int_value();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>(
@@ -13403,14 +13231,13 @@ bool UninterpretedOption::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(40)) goto parse_negative_int_value;
break;
}
// optional int64 negative_int_value = 5;
case 5: {
- if (tag == 40) {
- parse_negative_int_value:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(40u)) {
set_has_negative_int_value();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(
@@ -13418,14 +13245,13 @@ bool UninterpretedOption::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(49)) goto parse_double_value;
break;
}
// optional double double_value = 6;
case 6: {
- if (tag == 49) {
- parse_double_value:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(49u)) {
set_has_double_value();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>(
@@ -13433,27 +13259,25 @@ bool UninterpretedOption::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(58)) goto parse_string_value;
break;
}
// optional bytes string_value = 7;
case 7: {
- if (tag == 58) {
- parse_string_value:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(58u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
input, this->mutable_string_value()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(66)) goto parse_aggregate_value;
break;
}
// optional string aggregate_value = 8;
case 8: {
- if (tag == 66) {
- parse_aggregate_value:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(66u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_aggregate_value()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -13463,7 +13287,6 @@ bool UninterpretedOption::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -13548,7 +13371,7 @@ void UninterpretedOption::SerializeWithCachedSizes(
::google::protobuf::uint8* UninterpretedOption::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UninterpretedOption)
// repeated .google.protobuf.UninterpretedOption.NamePart name = 2;
for (unsigned int i = 0, n = this->name_size(); i < n; i++) {
@@ -13613,7 +13436,23 @@ size_t UninterpretedOption::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.UninterpretedOption)
size_t total_size = 0;
- if (_has_bits_[1 / 32] & 126u) {
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ // repeated .google.protobuf.UninterpretedOption.NamePart name = 2;
+ {
+ unsigned int count = this->name_size();
+ total_size += 1UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->name(i));
+ }
+ }
+
+ if (_has_bits_[0 / 32] & 63u) {
// optional string identifier_value = 3;
if (has_identifier_value()) {
total_size += 1 +
@@ -13621,6 +13460,20 @@ size_t UninterpretedOption::ByteSizeLong() const {
this->identifier_value());
}
+ // optional bytes string_value = 7;
+ if (has_string_value()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::BytesSize(
+ this->string_value());
+ }
+
+ // optional string aggregate_value = 8;
+ if (has_aggregate_value()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->aggregate_value());
+ }
+
// optional uint64 positive_int_value = 4;
if (has_positive_int_value()) {
total_size += 1 +
@@ -13640,36 +13493,6 @@ size_t UninterpretedOption::ByteSizeLong() const {
total_size += 1 + 8;
}
- // optional bytes string_value = 7;
- if (has_string_value()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::BytesSize(
- this->string_value());
- }
-
- // optional string aggregate_value = 8;
- if (has_aggregate_value()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->aggregate_value());
- }
-
- }
- // repeated .google.protobuf.UninterpretedOption.NamePart name = 2;
- {
- unsigned int count = this->name_size();
- total_size += 1UL * count;
- for (unsigned int i = 0; i < count; i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->name(i));
- }
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
@@ -13680,7 +13503,7 @@ size_t UninterpretedOption::ByteSizeLong() const {
void UninterpretedOption::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.UninterpretedOption)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const UninterpretedOption* source =
::google::protobuf::internal::DynamicCastToGenerated<const UninterpretedOption>(
&from);
@@ -13689,27 +13512,28 @@ void UninterpretedOption::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.UninterpretedOption)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void UninterpretedOption::MergeFrom(const UninterpretedOption& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void UninterpretedOption::UnsafeMergeFrom(const UninterpretedOption& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
name_.MergeFrom(from.name_);
- if (from._has_bits_[1 / 32] & (0xffu << (1 % 32))) {
+ if (from._has_bits_[0 / 32] & 63u) {
if (from.has_identifier_value()) {
set_has_identifier_value();
identifier_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.identifier_value_);
}
+ if (from.has_string_value()) {
+ set_has_string_value();
+ string_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.string_value_);
+ }
+ if (from.has_aggregate_value()) {
+ set_has_aggregate_value();
+ aggregate_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.aggregate_value_);
+ }
if (from.has_positive_int_value()) {
set_positive_int_value(from.positive_int_value());
}
@@ -13719,18 +13543,6 @@ void UninterpretedOption::UnsafeMergeFrom(const UninterpretedOption& from) {
if (from.has_double_value()) {
set_double_value(from.double_value());
}
- if (from.has_string_value()) {
- set_has_string_value();
- string_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.string_value_);
- }
- if (from.has_aggregate_value()) {
- set_has_aggregate_value();
- aggregate_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.aggregate_value_);
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
}
}
@@ -13745,11 +13557,10 @@ void UninterpretedOption::CopyFrom(const UninterpretedOption& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.UninterpretedOption)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool UninterpretedOption::IsInitialized() const {
-
if (!::google::protobuf::internal::AllAreInitialized(this->name())) return false;
return true;
}
@@ -13761,110 +13572,22 @@ void UninterpretedOption::Swap(UninterpretedOption* other) {
void UninterpretedOption::InternalSwap(UninterpretedOption* other) {
name_.UnsafeArenaSwap(&other->name_);
identifier_value_.Swap(&other->identifier_value_);
+ string_value_.Swap(&other->string_value_);
+ aggregate_value_.Swap(&other->aggregate_value_);
std::swap(positive_int_value_, other->positive_int_value_);
std::swap(negative_int_value_, other->negative_int_value_);
std::swap(double_value_, other->double_value_);
- string_value_.Swap(&other->string_value_);
- aggregate_value_.Swap(&other->aggregate_value_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata UninterpretedOption::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = UninterpretedOption_descriptor_;
- metadata.reflection = UninterpretedOption_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[20];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// UninterpretedOption_NamePart
-
-// required string name_part = 1;
-bool UninterpretedOption_NamePart::has_name_part() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void UninterpretedOption_NamePart::set_has_name_part() {
- _has_bits_[0] |= 0x00000001u;
-}
-void UninterpretedOption_NamePart::clear_has_name_part() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void UninterpretedOption_NamePart::clear_name_part() {
- name_part_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_name_part();
-}
-const ::std::string& UninterpretedOption_NamePart::name_part() const {
- // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.name_part)
- return name_part_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void UninterpretedOption_NamePart::set_name_part(const ::std::string& value) {
- set_has_name_part();
- name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.name_part)
-}
-void UninterpretedOption_NamePart::set_name_part(const char* value) {
- set_has_name_part();
- name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.NamePart.name_part)
-}
-void UninterpretedOption_NamePart::set_name_part(const char* value, size_t size) {
- set_has_name_part();
- name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.NamePart.name_part)
-}
-::std::string* UninterpretedOption_NamePart::mutable_name_part() {
- set_has_name_part();
- // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.NamePart.name_part)
- return name_part_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* UninterpretedOption_NamePart::release_name_part() {
- // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.NamePart.name_part)
- clear_has_name_part();
- return name_part_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void UninterpretedOption_NamePart::set_allocated_name_part(::std::string* name_part) {
- if (name_part != NULL) {
- set_has_name_part();
- } else {
- clear_has_name_part();
- }
- name_part_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name_part);
- // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.NamePart.name_part)
-}
-
-// required bool is_extension = 2;
-bool UninterpretedOption_NamePart::has_is_extension() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void UninterpretedOption_NamePart::set_has_is_extension() {
- _has_bits_[0] |= 0x00000002u;
-}
-void UninterpretedOption_NamePart::clear_has_is_extension() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void UninterpretedOption_NamePart::clear_is_extension() {
- is_extension_ = false;
- clear_has_is_extension();
-}
-bool UninterpretedOption_NamePart::is_extension() const {
- // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.is_extension)
- return is_extension_;
-}
-void UninterpretedOption_NamePart::set_is_extension(bool value) {
- set_has_is_extension();
- is_extension_ = value;
- // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.is_extension)
-}
-
-inline const UninterpretedOption_NamePart* UninterpretedOption_NamePart::internal_default_instance() {
- return &UninterpretedOption_NamePart_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
// UninterpretedOption
// repeated .google.protobuf.UninterpretedOption.NamePart name = 2;
@@ -13899,13 +13622,13 @@ UninterpretedOption::name() const {
// optional string identifier_value = 3;
bool UninterpretedOption::has_identifier_value() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
+ return (_has_bits_[0] & 0x00000001u) != 0;
}
void UninterpretedOption::set_has_identifier_value() {
- _has_bits_[0] |= 0x00000002u;
+ _has_bits_[0] |= 0x00000001u;
}
void UninterpretedOption::clear_has_identifier_value() {
- _has_bits_[0] &= ~0x00000002u;
+ _has_bits_[0] &= ~0x00000001u;
}
void UninterpretedOption::clear_identifier_value() {
identifier_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -13913,13 +13636,21 @@ void UninterpretedOption::clear_identifier_value() {
}
const ::std::string& UninterpretedOption::identifier_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.identifier_value)
- return identifier_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return identifier_value_.GetNoArena();
}
void UninterpretedOption::set_identifier_value(const ::std::string& value) {
set_has_identifier_value();
identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.identifier_value)
}
+#if LANG_CXX11
+void UninterpretedOption::set_identifier_value(::std::string&& value) {
+ set_has_identifier_value();
+ identifier_value_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.identifier_value)
+}
+#endif
void UninterpretedOption::set_identifier_value(const char* value) {
set_has_identifier_value();
identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -13953,13 +13684,13 @@ void UninterpretedOption::set_allocated_identifier_value(::std::string* identifi
// optional uint64 positive_int_value = 4;
bool UninterpretedOption::has_positive_int_value() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
+ return (_has_bits_[0] & 0x00000008u) != 0;
}
void UninterpretedOption::set_has_positive_int_value() {
- _has_bits_[0] |= 0x00000004u;
+ _has_bits_[0] |= 0x00000008u;
}
void UninterpretedOption::clear_has_positive_int_value() {
- _has_bits_[0] &= ~0x00000004u;
+ _has_bits_[0] &= ~0x00000008u;
}
void UninterpretedOption::clear_positive_int_value() {
positive_int_value_ = GOOGLE_ULONGLONG(0);
@@ -13977,13 +13708,13 @@ void UninterpretedOption::set_positive_int_value(::google::protobuf::uint64 valu
// optional int64 negative_int_value = 5;
bool UninterpretedOption::has_negative_int_value() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
+ return (_has_bits_[0] & 0x00000010u) != 0;
}
void UninterpretedOption::set_has_negative_int_value() {
- _has_bits_[0] |= 0x00000008u;
+ _has_bits_[0] |= 0x00000010u;
}
void UninterpretedOption::clear_has_negative_int_value() {
- _has_bits_[0] &= ~0x00000008u;
+ _has_bits_[0] &= ~0x00000010u;
}
void UninterpretedOption::clear_negative_int_value() {
negative_int_value_ = GOOGLE_LONGLONG(0);
@@ -14001,13 +13732,13 @@ void UninterpretedOption::set_negative_int_value(::google::protobuf::int64 value
// optional double double_value = 6;
bool UninterpretedOption::has_double_value() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
+ return (_has_bits_[0] & 0x00000020u) != 0;
}
void UninterpretedOption::set_has_double_value() {
- _has_bits_[0] |= 0x00000010u;
+ _has_bits_[0] |= 0x00000020u;
}
void UninterpretedOption::clear_has_double_value() {
- _has_bits_[0] &= ~0x00000010u;
+ _has_bits_[0] &= ~0x00000020u;
}
void UninterpretedOption::clear_double_value() {
double_value_ = 0;
@@ -14025,13 +13756,13 @@ void UninterpretedOption::set_double_value(double value) {
// optional bytes string_value = 7;
bool UninterpretedOption::has_string_value() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
+ return (_has_bits_[0] & 0x00000002u) != 0;
}
void UninterpretedOption::set_has_string_value() {
- _has_bits_[0] |= 0x00000020u;
+ _has_bits_[0] |= 0x00000002u;
}
void UninterpretedOption::clear_has_string_value() {
- _has_bits_[0] &= ~0x00000020u;
+ _has_bits_[0] &= ~0x00000002u;
}
void UninterpretedOption::clear_string_value() {
string_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -14039,13 +13770,21 @@ void UninterpretedOption::clear_string_value() {
}
const ::std::string& UninterpretedOption::string_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.string_value)
- return string_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return string_value_.GetNoArena();
}
void UninterpretedOption::set_string_value(const ::std::string& value) {
set_has_string_value();
string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.string_value)
}
+#if LANG_CXX11
+void UninterpretedOption::set_string_value(::std::string&& value) {
+ set_has_string_value();
+ string_value_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.string_value)
+}
+#endif
void UninterpretedOption::set_string_value(const char* value) {
set_has_string_value();
string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -14079,13 +13818,13 @@ void UninterpretedOption::set_allocated_string_value(::std::string* string_value
// optional string aggregate_value = 8;
bool UninterpretedOption::has_aggregate_value() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
+ return (_has_bits_[0] & 0x00000004u) != 0;
}
void UninterpretedOption::set_has_aggregate_value() {
- _has_bits_[0] |= 0x00000040u;
+ _has_bits_[0] |= 0x00000004u;
}
void UninterpretedOption::clear_has_aggregate_value() {
- _has_bits_[0] &= ~0x00000040u;
+ _has_bits_[0] &= ~0x00000004u;
}
void UninterpretedOption::clear_aggregate_value() {
aggregate_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -14093,13 +13832,21 @@ void UninterpretedOption::clear_aggregate_value() {
}
const ::std::string& UninterpretedOption::aggregate_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.aggregate_value)
- return aggregate_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return aggregate_value_.GetNoArena();
}
void UninterpretedOption::set_aggregate_value(const ::std::string& value) {
set_has_aggregate_value();
aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.aggregate_value)
}
+#if LANG_CXX11
+void UninterpretedOption::set_aggregate_value(::std::string&& value) {
+ set_has_aggregate_value();
+ aggregate_value_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.aggregate_value)
+}
+#endif
void UninterpretedOption::set_aggregate_value(const char* value) {
set_has_aggregate_value();
aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -14131,9 +13878,6 @@ void UninterpretedOption::set_allocated_aggregate_value(::std::string* aggregate
// @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.aggregate_value)
}
-inline const UninterpretedOption* UninterpretedOption::internal_default_instance() {
- return &UninterpretedOption_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -14148,19 +13892,29 @@ const int SourceCodeInfo_Location::kLeadingDetachedCommentsFieldNumber;
SourceCodeInfo_Location::SourceCodeInfo_Location()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.SourceCodeInfo.Location)
}
-
-void SourceCodeInfo_Location::InitAsDefaultInstance() {
-}
-
SourceCodeInfo_Location::SourceCodeInfo_Location(const SourceCodeInfo_Location& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0),
+ path_(from.path_),
+ span_(from.span_),
+ leading_detached_comments_(from.leading_detached_comments_) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ leading_comments_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_leading_comments()) {
+ leading_comments_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.leading_comments_);
+ }
+ trailing_comments_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_trailing_comments()) {
+ trailing_comments_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.trailing_comments_);
+ }
// @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo.Location)
}
@@ -14186,17 +13940,15 @@ void SourceCodeInfo_Location::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* SourceCodeInfo_Location::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return SourceCodeInfo_Location_descriptor_;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[21].descriptor;
}
const SourceCodeInfo_Location& SourceCodeInfo_Location::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo_Location> SourceCodeInfo_Location_default_instance_;
-
SourceCodeInfo_Location* SourceCodeInfo_Location::New(::google::protobuf::Arena* arena) const {
SourceCodeInfo_Location* n = new SourceCodeInfo_Location;
if (arena != NULL) {
@@ -14207,21 +13959,21 @@ SourceCodeInfo_Location* SourceCodeInfo_Location::New(::google::protobuf::Arena*
void SourceCodeInfo_Location::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.SourceCodeInfo.Location)
- if (_has_bits_[0 / 32] & 12u) {
+ path_.Clear();
+ span_.Clear();
+ leading_detached_comments_.Clear();
+ if (_has_bits_[0 / 32] & 3u) {
if (has_leading_comments()) {
- leading_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!leading_comments_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*leading_comments_.UnsafeRawStringPointer())->clear();
}
if (has_trailing_comments()) {
- trailing_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ GOOGLE_DCHECK(!trailing_comments_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*trailing_comments_.UnsafeRawStringPointer())->clear();
}
}
- path_.Clear();
- span_.Clear();
- leading_detached_comments_.Clear();
_has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
+ _internal_metadata_.Clear();
}
bool SourceCodeInfo_Location::MergePartialFromCodedStream(
@@ -14230,49 +13982,50 @@ bool SourceCodeInfo_Location::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.SourceCodeInfo.Location)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// repeated int32 path = 1 [packed = true];
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, this->mutable_path())));
- } else if (tag == 8) {
+ } else if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(8u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- 1, 10, input, this->mutable_path())));
+ 1, 10u, input, this->mutable_path())));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(18)) goto parse_span;
break;
}
// repeated int32 span = 2 [packed = true];
case 2: {
- if (tag == 18) {
- parse_span:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(18u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, this->mutable_span())));
- } else if (tag == 16) {
+ } else if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(16u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- 1, 18, input, this->mutable_span())));
+ 1, 18u, input, this->mutable_span())));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(26)) goto parse_leading_comments;
break;
}
// optional string leading_comments = 3;
case 3: {
- if (tag == 26) {
- parse_leading_comments:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(26u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_leading_comments()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -14282,14 +14035,13 @@ bool SourceCodeInfo_Location::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(34)) goto parse_trailing_comments;
break;
}
// optional string trailing_comments = 4;
case 4: {
- if (tag == 34) {
- parse_trailing_comments:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(34u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_trailing_comments()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -14299,14 +14051,13 @@ bool SourceCodeInfo_Location::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(50)) goto parse_leading_detached_comments;
break;
}
// repeated string leading_detached_comments = 6;
case 6: {
- if (tag == 50) {
- parse_leading_detached_comments:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(50u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->add_leading_detached_comments()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -14317,8 +14068,6 @@ bool SourceCodeInfo_Location::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(50)) goto parse_leading_detached_comments;
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -14352,7 +14101,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes(
::google::protobuf::internal::WireFormatLite::WriteTag(1, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output);
output->WriteVarint32(_path_cached_byte_size_);
}
- for (int i = 0; i < this->path_size(); i++) {
+ for (int i = 0, n = this->path_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteInt32NoTag(
this->path(i), output);
}
@@ -14362,7 +14111,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes(
::google::protobuf::internal::WireFormatLite::WriteTag(2, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output);
output->WriteVarint32(_span_cached_byte_size_);
}
- for (int i = 0; i < this->span_size(); i++) {
+ for (int i = 0, n = this->span_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteInt32NoTag(
this->span(i), output);
}
@@ -14388,7 +14137,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes(
}
// repeated string leading_detached_comments = 6;
- for (int i = 0; i < this->leading_detached_comments_size(); i++) {
+ for (int i = 0, n = this->leading_detached_comments_size(); i < n; i++) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->leading_detached_comments(i).data(), this->leading_detached_comments(i).length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
@@ -14406,7 +14155,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes(
::google::protobuf::uint8* SourceCodeInfo_Location::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.SourceCodeInfo.Location)
// repeated int32 path = 1 [packed = true];
if (this->path_size() > 0) {
@@ -14417,7 +14166,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes(
target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(
_path_cached_byte_size_, target);
}
- for (int i = 0; i < this->path_size(); i++) {
+ for (int i = 0, n = this->path_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
WriteInt32NoTagToArray(this->path(i), target);
}
@@ -14431,7 +14180,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes(
target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(
_span_cached_byte_size_, target);
}
- for (int i = 0; i < this->span_size(); i++) {
+ for (int i = 0, n = this->span_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
WriteInt32NoTagToArray(this->span(i), target);
}
@@ -14459,7 +14208,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes(
}
// repeated string leading_detached_comments = 6;
- for (int i = 0; i < this->leading_detached_comments_size(); i++) {
+ for (int i = 0, n = this->leading_detached_comments_size(); i < n; i++) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->leading_detached_comments(i).data(), this->leading_detached_comments(i).length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
@@ -14480,30 +14229,15 @@ size_t SourceCodeInfo_Location::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceCodeInfo.Location)
size_t total_size = 0;
- if (_has_bits_[2 / 32] & 12u) {
- // optional string leading_comments = 3;
- if (has_leading_comments()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->leading_comments());
- }
-
- // optional string trailing_comments = 4;
- if (has_trailing_comments()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->trailing_comments());
- }
-
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
}
// repeated int32 path = 1 [packed = true];
{
- size_t data_size = 0;
- unsigned int count = this->path_size();
- for (unsigned int i = 0; i < count; i++) {
- data_size += ::google::protobuf::internal::WireFormatLite::
- Int32Size(this->path(i));
- }
+ size_t data_size = ::google::protobuf::internal::WireFormatLite::
+ Int32Size(this->path_);
if (data_size > 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(data_size);
@@ -14517,12 +14251,8 @@ size_t SourceCodeInfo_Location::ByteSizeLong() const {
// repeated int32 span = 2 [packed = true];
{
- size_t data_size = 0;
- unsigned int count = this->span_size();
- for (unsigned int i = 0; i < count; i++) {
- data_size += ::google::protobuf::internal::WireFormatLite::
- Int32Size(this->span(i));
- }
+ size_t data_size = ::google::protobuf::internal::WireFormatLite::
+ Int32Size(this->span_);
if (data_size > 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(data_size);
@@ -14537,15 +14267,26 @@ size_t SourceCodeInfo_Location::ByteSizeLong() const {
// repeated string leading_detached_comments = 6;
total_size += 1 *
::google::protobuf::internal::FromIntSize(this->leading_detached_comments_size());
- for (int i = 0; i < this->leading_detached_comments_size(); i++) {
+ for (int i = 0, n = this->leading_detached_comments_size(); i < n; i++) {
total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
this->leading_detached_comments(i));
}
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
+ if (_has_bits_[0 / 32] & 3u) {
+ // optional string leading_comments = 3;
+ if (has_leading_comments()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->leading_comments());
+ }
+
+ // optional string trailing_comments = 4;
+ if (has_trailing_comments()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->trailing_comments());
+ }
+
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
@@ -14556,7 +14297,7 @@ size_t SourceCodeInfo_Location::ByteSizeLong() const {
void SourceCodeInfo_Location::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.SourceCodeInfo.Location)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const SourceCodeInfo_Location* source =
::google::protobuf::internal::DynamicCastToGenerated<const SourceCodeInfo_Location>(
&from);
@@ -14565,25 +14306,18 @@ void SourceCodeInfo_Location::MergeFrom(const ::google::protobuf::Message& from)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.SourceCodeInfo.Location)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void SourceCodeInfo_Location::MergeFrom(const SourceCodeInfo_Location& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo.Location)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void SourceCodeInfo_Location::UnsafeMergeFrom(const SourceCodeInfo_Location& from) {
- GOOGLE_DCHECK(&from != this);
- path_.UnsafeMergeFrom(from.path_);
- span_.UnsafeMergeFrom(from.span_);
- leading_detached_comments_.UnsafeMergeFrom(from.leading_detached_comments_);
- if (from._has_bits_[2 / 32] & (0xffu << (2 % 32))) {
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ path_.MergeFrom(from.path_);
+ span_.MergeFrom(from.span_);
+ leading_detached_comments_.MergeFrom(from.leading_detached_comments_);
+ if (from._has_bits_[0 / 32] & 3u) {
if (from.has_leading_comments()) {
set_has_leading_comments();
leading_comments_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.leading_comments_);
@@ -14593,10 +14327,6 @@ void SourceCodeInfo_Location::UnsafeMergeFrom(const SourceCodeInfo_Location& fro
trailing_comments_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.trailing_comments_);
}
}
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
}
void SourceCodeInfo_Location::CopyFrom(const ::google::protobuf::Message& from) {
@@ -14610,11 +14340,10 @@ void SourceCodeInfo_Location::CopyFrom(const SourceCodeInfo_Location& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.SourceCodeInfo.Location)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool SourceCodeInfo_Location::IsInitialized() const {
-
return true;
}
@@ -14625,272 +14354,17 @@ void SourceCodeInfo_Location::Swap(SourceCodeInfo_Location* other) {
void SourceCodeInfo_Location::InternalSwap(SourceCodeInfo_Location* other) {
path_.UnsafeArenaSwap(&other->path_);
span_.UnsafeArenaSwap(&other->span_);
+ leading_detached_comments_.UnsafeArenaSwap(&other->leading_detached_comments_);
leading_comments_.Swap(&other->leading_comments_);
trailing_comments_.Swap(&other->trailing_comments_);
- leading_detached_comments_.UnsafeArenaSwap(&other->leading_detached_comments_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata SourceCodeInfo_Location::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = SourceCodeInfo_Location_descriptor_;
- metadata.reflection = SourceCodeInfo_Location_reflection_;
- return metadata;
-}
-
-
-// -------------------------------------------------------------------
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int SourceCodeInfo::kLocationFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-SourceCodeInfo::SourceCodeInfo()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:google.protobuf.SourceCodeInfo)
-}
-
-void SourceCodeInfo::InitAsDefaultInstance() {
-}
-
-SourceCodeInfo::SourceCodeInfo(const SourceCodeInfo& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo)
-}
-
-void SourceCodeInfo::SharedCtor() {
- _cached_size_ = 0;
-}
-
-SourceCodeInfo::~SourceCodeInfo() {
- // @@protoc_insertion_point(destructor:google.protobuf.SourceCodeInfo)
- SharedDtor();
-}
-
-void SourceCodeInfo::SharedDtor() {
-}
-
-void SourceCodeInfo::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* SourceCodeInfo::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return SourceCodeInfo_descriptor_;
-}
-
-const SourceCodeInfo& SourceCodeInfo::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo> SourceCodeInfo_default_instance_;
-
-SourceCodeInfo* SourceCodeInfo::New(::google::protobuf::Arena* arena) const {
- SourceCodeInfo* n = new SourceCodeInfo;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void SourceCodeInfo::Clear() {
-// @@protoc_insertion_point(message_clear_start:google.protobuf.SourceCodeInfo)
- location_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool SourceCodeInfo::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:google.protobuf.SourceCodeInfo)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // repeated .google.protobuf.SourceCodeInfo.Location location = 1;
- case 1: {
- if (tag == 10) {
- DO_(input->IncrementRecursionDepth());
- parse_loop_location:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
- input, add_location()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(10)) goto parse_loop_location;
- input->UnsafeDecrementRecursionDepth();
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:google.protobuf.SourceCodeInfo)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:google.protobuf.SourceCodeInfo)
- return false;
-#undef DO_
-}
-
-void SourceCodeInfo::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:google.protobuf.SourceCodeInfo)
- // repeated .google.protobuf.SourceCodeInfo.Location location = 1;
- for (unsigned int i = 0, n = this->location_size(); i < n; i++) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 1, this->location(i), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:google.protobuf.SourceCodeInfo)
-}
-
-::google::protobuf::uint8* SourceCodeInfo::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.SourceCodeInfo)
- // repeated .google.protobuf.SourceCodeInfo.Location location = 1;
- for (unsigned int i = 0, n = this->location_size(); i < n; i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 1, this->location(i), false, target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.SourceCodeInfo)
- return target;
-}
-
-size_t SourceCodeInfo::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceCodeInfo)
- size_t total_size = 0;
-
- // repeated .google.protobuf.SourceCodeInfo.Location location = 1;
- {
- unsigned int count = this->location_size();
- total_size += 1UL * count;
- for (unsigned int i = 0; i < count; i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->location(i));
- }
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void SourceCodeInfo::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.SourceCodeInfo)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const SourceCodeInfo* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const SourceCodeInfo>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.SourceCodeInfo)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.SourceCodeInfo)
- UnsafeMergeFrom(*source);
- }
-}
-
-void SourceCodeInfo::MergeFrom(const SourceCodeInfo& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void SourceCodeInfo::UnsafeMergeFrom(const SourceCodeInfo& from) {
- GOOGLE_DCHECK(&from != this);
- location_.MergeFrom(from.location_);
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void SourceCodeInfo::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.SourceCodeInfo)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void SourceCodeInfo::CopyFrom(const SourceCodeInfo& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.SourceCodeInfo)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool SourceCodeInfo::IsInitialized() const {
-
- return true;
-}
-
-void SourceCodeInfo::Swap(SourceCodeInfo* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void SourceCodeInfo::InternalSwap(SourceCodeInfo* other) {
- location_.UnsafeArenaSwap(&other->location_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata SourceCodeInfo::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = SourceCodeInfo_descriptor_;
- metadata.reflection = SourceCodeInfo_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[21];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -14958,13 +14432,13 @@ SourceCodeInfo_Location::mutable_span() {
// optional string leading_comments = 3;
bool SourceCodeInfo_Location::has_leading_comments() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
+ return (_has_bits_[0] & 0x00000001u) != 0;
}
void SourceCodeInfo_Location::set_has_leading_comments() {
- _has_bits_[0] |= 0x00000004u;
+ _has_bits_[0] |= 0x00000001u;
}
void SourceCodeInfo_Location::clear_has_leading_comments() {
- _has_bits_[0] &= ~0x00000004u;
+ _has_bits_[0] &= ~0x00000001u;
}
void SourceCodeInfo_Location::clear_leading_comments() {
leading_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -14972,13 +14446,21 @@ void SourceCodeInfo_Location::clear_leading_comments() {
}
const ::std::string& SourceCodeInfo_Location::leading_comments() const {
// @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.leading_comments)
- return leading_comments_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return leading_comments_.GetNoArena();
}
void SourceCodeInfo_Location::set_leading_comments(const ::std::string& value) {
set_has_leading_comments();
leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_comments)
}
+#if LANG_CXX11
+void SourceCodeInfo_Location::set_leading_comments(::std::string&& value) {
+ set_has_leading_comments();
+ leading_comments_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceCodeInfo.Location.leading_comments)
+}
+#endif
void SourceCodeInfo_Location::set_leading_comments(const char* value) {
set_has_leading_comments();
leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -15012,13 +14494,13 @@ void SourceCodeInfo_Location::set_allocated_leading_comments(::std::string* lead
// optional string trailing_comments = 4;
bool SourceCodeInfo_Location::has_trailing_comments() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
+ return (_has_bits_[0] & 0x00000002u) != 0;
}
void SourceCodeInfo_Location::set_has_trailing_comments() {
- _has_bits_[0] |= 0x00000008u;
+ _has_bits_[0] |= 0x00000002u;
}
void SourceCodeInfo_Location::clear_has_trailing_comments() {
- _has_bits_[0] &= ~0x00000008u;
+ _has_bits_[0] &= ~0x00000002u;
}
void SourceCodeInfo_Location::clear_trailing_comments() {
trailing_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -15026,13 +14508,21 @@ void SourceCodeInfo_Location::clear_trailing_comments() {
}
const ::std::string& SourceCodeInfo_Location::trailing_comments() const {
// @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.trailing_comments)
- return trailing_comments_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return trailing_comments_.GetNoArena();
}
void SourceCodeInfo_Location::set_trailing_comments(const ::std::string& value) {
set_has_trailing_comments();
trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.trailing_comments)
}
+#if LANG_CXX11
+void SourceCodeInfo_Location::set_trailing_comments(::std::string&& value) {
+ set_has_trailing_comments();
+ trailing_comments_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceCodeInfo.Location.trailing_comments)
+}
+#endif
void SourceCodeInfo_Location::set_trailing_comments(const char* value) {
set_has_trailing_comments();
trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -15083,6 +14573,12 @@ void SourceCodeInfo_Location::set_leading_detached_comments(int index, const ::s
// @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
leading_detached_comments_.Mutable(index)->assign(value);
}
+#if LANG_CXX11
+void SourceCodeInfo_Location::set_leading_detached_comments(int index, ::std::string&& value) {
+ // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
+ leading_detached_comments_.Mutable(index)->assign(std::move(value));
+}
+#endif
void SourceCodeInfo_Location::set_leading_detached_comments(int index, const char* value) {
leading_detached_comments_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
@@ -15100,6 +14596,12 @@ void SourceCodeInfo_Location::add_leading_detached_comments(const ::std::string&
leading_detached_comments_.Add()->assign(value);
// @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
}
+#if LANG_CXX11
+void SourceCodeInfo_Location::add_leading_detached_comments(::std::string&& value) {
+ leading_detached_comments_.Add()->assign(std::move(value));
+ // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
+}
+#endif
void SourceCodeInfo_Location::add_leading_detached_comments(const char* value) {
leading_detached_comments_.Add()->assign(value);
// @@protoc_insertion_point(field_add_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
@@ -15119,11 +14621,239 @@ SourceCodeInfo_Location::mutable_leading_detached_comments() {
return &leading_detached_comments_;
}
-inline const SourceCodeInfo_Location* SourceCodeInfo_Location::internal_default_instance() {
- return &SourceCodeInfo_Location_default_instance_.get();
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int SourceCodeInfo::kLocationFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+SourceCodeInfo::SourceCodeInfo()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
+ }
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:google.protobuf.SourceCodeInfo)
+}
+SourceCodeInfo::SourceCodeInfo(const SourceCodeInfo& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0),
+ location_(from.location_) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo)
+}
+
+void SourceCodeInfo::SharedCtor() {
+ _cached_size_ = 0;
+}
+
+SourceCodeInfo::~SourceCodeInfo() {
+ // @@protoc_insertion_point(destructor:google.protobuf.SourceCodeInfo)
+ SharedDtor();
+}
+
+void SourceCodeInfo::SharedDtor() {
+}
+
+void SourceCodeInfo::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* SourceCodeInfo::descriptor() {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[22].descriptor;
+}
+
+const SourceCodeInfo& SourceCodeInfo::default_instance() {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
+ return *internal_default_instance();
+}
+
+SourceCodeInfo* SourceCodeInfo::New(::google::protobuf::Arena* arena) const {
+ SourceCodeInfo* n = new SourceCodeInfo;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void SourceCodeInfo::Clear() {
+// @@protoc_insertion_point(message_clear_start:google.protobuf.SourceCodeInfo)
+ location_.Clear();
+ _has_bits_.Clear();
+ _internal_metadata_.Clear();
+}
+
+bool SourceCodeInfo::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:google.protobuf.SourceCodeInfo)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // repeated .google.protobuf.SourceCodeInfo.Location location = 1;
+ case 1: {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
+ DO_(input->IncrementRecursionDepth());
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
+ input, add_location()));
+ } else {
+ goto handle_unusual;
+ }
+ input->UnsafeDecrementRecursionDepth();
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:google.protobuf.SourceCodeInfo)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:google.protobuf.SourceCodeInfo)
+ return false;
+#undef DO_
+}
+
+void SourceCodeInfo::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:google.protobuf.SourceCodeInfo)
+ // repeated .google.protobuf.SourceCodeInfo.Location location = 1;
+ for (unsigned int i = 0, n = this->location_size(); i < n; i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 1, this->location(i), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:google.protobuf.SourceCodeInfo)
+}
+
+::google::protobuf::uint8* SourceCodeInfo::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.SourceCodeInfo)
+ // repeated .google.protobuf.SourceCodeInfo.Location location = 1;
+ for (unsigned int i = 0, n = this->location_size(); i < n; i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 1, this->location(i), false, target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.SourceCodeInfo)
+ return target;
}
-// -------------------------------------------------------------------
+size_t SourceCodeInfo::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceCodeInfo)
+ size_t total_size = 0;
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ // repeated .google.protobuf.SourceCodeInfo.Location location = 1;
+ {
+ unsigned int count = this->location_size();
+ total_size += 1UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->location(i));
+ }
+ }
+
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void SourceCodeInfo::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.SourceCodeInfo)
+ GOOGLE_DCHECK_NE(&from, this);
+ const SourceCodeInfo* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const SourceCodeInfo>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.SourceCodeInfo)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.SourceCodeInfo)
+ MergeFrom(*source);
+ }
+}
+
+void SourceCodeInfo::MergeFrom(const SourceCodeInfo& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo)
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ location_.MergeFrom(from.location_);
+}
+
+void SourceCodeInfo::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.SourceCodeInfo)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void SourceCodeInfo::CopyFrom(const SourceCodeInfo& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.SourceCodeInfo)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+bool SourceCodeInfo::IsInitialized() const {
+ return true;
+}
+
+void SourceCodeInfo::Swap(SourceCodeInfo* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void SourceCodeInfo::InternalSwap(SourceCodeInfo* other) {
+ location_.UnsafeArenaSwap(&other->location_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata SourceCodeInfo::GetMetadata() const {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[22];
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
// SourceCodeInfo
// repeated .google.protobuf.SourceCodeInfo.Location location = 1;
@@ -15156,9 +14886,6 @@ SourceCodeInfo::location() const {
return location_;
}
-inline const SourceCodeInfo* SourceCodeInfo::internal_default_instance() {
- return &SourceCodeInfo_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -15172,19 +14899,26 @@ const int GeneratedCodeInfo_Annotation::kEndFieldNumber;
GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.GeneratedCodeInfo.Annotation)
}
-
-void GeneratedCodeInfo_Annotation::InitAsDefaultInstance() {
-}
-
GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(const GeneratedCodeInfo_Annotation& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0),
+ path_(from.path_) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ source_file_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_source_file()) {
+ source_file_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_file_);
+ }
+ ::memcpy(&begin_, &from.begin_,
+ reinterpret_cast<char*>(&end_) -
+ reinterpret_cast<char*>(&begin_) + sizeof(end_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.GeneratedCodeInfo.Annotation)
}
@@ -15210,17 +14944,15 @@ void GeneratedCodeInfo_Annotation::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* GeneratedCodeInfo_Annotation::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return GeneratedCodeInfo_Annotation_descriptor_;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[23].descriptor;
}
const GeneratedCodeInfo_Annotation& GeneratedCodeInfo_Annotation::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo_Annotation> GeneratedCodeInfo_Annotation_default_instance_;
-
GeneratedCodeInfo_Annotation* GeneratedCodeInfo_Annotation::New(::google::protobuf::Arena* arena) const {
GeneratedCodeInfo_Annotation* n = new GeneratedCodeInfo_Annotation;
if (arena != NULL) {
@@ -15231,37 +14963,17 @@ GeneratedCodeInfo_Annotation* GeneratedCodeInfo_Annotation::New(::google::protob
void GeneratedCodeInfo_Annotation::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.GeneratedCodeInfo.Annotation)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(GeneratedCodeInfo_Annotation, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<GeneratedCodeInfo_Annotation*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- if (_has_bits_[0 / 32] & 14u) {
- ZR_(begin_, end_);
- if (has_source_file()) {
- source_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- }
-
-#undef ZR_HELPER_
-#undef ZR_
-
path_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
+ if (has_source_file()) {
+ GOOGLE_DCHECK(!source_file_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*source_file_.UnsafeRawStringPointer())->clear();
+ }
+ if (_has_bits_[0 / 32] & 6u) {
+ ::memset(&begin_, 0, reinterpret_cast<char*>(&end_) -
+ reinterpret_cast<char*>(&begin_) + sizeof(end_));
}
+ _has_bits_.Clear();
+ _internal_metadata_.Clear();
}
bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream(
@@ -15270,31 +14982,32 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.GeneratedCodeInfo.Annotation)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// repeated int32 path = 1 [packed = true];
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, this->mutable_path())));
- } else if (tag == 8) {
+ } else if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(8u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- 1, 10, input, this->mutable_path())));
+ 1, 10u, input, this->mutable_path())));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(18)) goto parse_source_file;
break;
}
// optional string source_file = 2;
case 2: {
- if (tag == 18) {
- parse_source_file:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(18u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_source_file()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -15304,14 +15017,13 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(24)) goto parse_begin;
break;
}
// optional int32 begin = 3;
case 3: {
- if (tag == 24) {
- parse_begin:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(24u)) {
set_has_begin();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
@@ -15319,14 +15031,13 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(32)) goto parse_end;
break;
}
// optional int32 end = 4;
case 4: {
- if (tag == 32) {
- parse_end:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(32u)) {
set_has_end();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
@@ -15334,7 +15045,6 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -15368,7 +15078,7 @@ void GeneratedCodeInfo_Annotation::SerializeWithCachedSizes(
::google::protobuf::internal::WireFormatLite::WriteTag(1, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output);
output->WriteVarint32(_path_cached_byte_size_);
}
- for (int i = 0; i < this->path_size(); i++) {
+ for (int i = 0, n = this->path_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteInt32NoTag(
this->path(i), output);
}
@@ -15402,7 +15112,7 @@ void GeneratedCodeInfo_Annotation::SerializeWithCachedSizes(
::google::protobuf::uint8* GeneratedCodeInfo_Annotation::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.GeneratedCodeInfo.Annotation)
// repeated int32 path = 1 [packed = true];
if (this->path_size() > 0) {
@@ -15413,7 +15123,7 @@ void GeneratedCodeInfo_Annotation::SerializeWithCachedSizes(
target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(
_path_cached_byte_size_, target);
}
- for (int i = 0; i < this->path_size(); i++) {
+ for (int i = 0, n = this->path_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
WriteInt32NoTagToArray(this->path(i), target);
}
@@ -15451,7 +15161,27 @@ size_t GeneratedCodeInfo_Annotation::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.GeneratedCodeInfo.Annotation)
size_t total_size = 0;
- if (_has_bits_[1 / 32] & 14u) {
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ // repeated int32 path = 1 [packed = true];
+ {
+ size_t data_size = ::google::protobuf::internal::WireFormatLite::
+ Int32Size(this->path_);
+ if (data_size > 0) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _path_cached_byte_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ total_size += data_size;
+ }
+
+ if (_has_bits_[0 / 32] & 7u) {
// optional string source_file = 2;
if (has_source_file()) {
total_size += 1 +
@@ -15474,30 +15204,6 @@ size_t GeneratedCodeInfo_Annotation::ByteSizeLong() const {
}
}
- // repeated int32 path = 1 [packed = true];
- {
- size_t data_size = 0;
- unsigned int count = this->path_size();
- for (unsigned int i = 0; i < count; i++) {
- data_size += ::google::protobuf::internal::WireFormatLite::
- Int32Size(this->path(i));
- }
- if (data_size > 0) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _path_cached_byte_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- total_size += data_size;
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
@@ -15507,7 +15213,7 @@ size_t GeneratedCodeInfo_Annotation::ByteSizeLong() const {
void GeneratedCodeInfo_Annotation::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.GeneratedCodeInfo.Annotation)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const GeneratedCodeInfo_Annotation* source =
::google::protobuf::internal::DynamicCastToGenerated<const GeneratedCodeInfo_Annotation>(
&from);
@@ -15516,23 +15222,16 @@ void GeneratedCodeInfo_Annotation::MergeFrom(const ::google::protobuf::Message&
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.GeneratedCodeInfo.Annotation)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void GeneratedCodeInfo_Annotation::MergeFrom(const GeneratedCodeInfo_Annotation& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo.Annotation)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void GeneratedCodeInfo_Annotation::UnsafeMergeFrom(const GeneratedCodeInfo_Annotation& from) {
- GOOGLE_DCHECK(&from != this);
- path_.UnsafeMergeFrom(from.path_);
- if (from._has_bits_[1 / 32] & (0xffu << (1 % 32))) {
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ path_.MergeFrom(from.path_);
+ if (from._has_bits_[0 / 32] & 7u) {
if (from.has_source_file()) {
set_has_source_file();
source_file_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_file_);
@@ -15544,10 +15243,6 @@ void GeneratedCodeInfo_Annotation::UnsafeMergeFrom(const GeneratedCodeInfo_Annot
set_end(from.end());
}
}
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
}
void GeneratedCodeInfo_Annotation::CopyFrom(const ::google::protobuf::Message& from) {
@@ -15561,11 +15256,10 @@ void GeneratedCodeInfo_Annotation::CopyFrom(const GeneratedCodeInfo_Annotation&
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.GeneratedCodeInfo.Annotation)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool GeneratedCodeInfo_Annotation::IsInitialized() const {
-
return true;
}
@@ -15584,15 +15278,156 @@ void GeneratedCodeInfo_Annotation::InternalSwap(GeneratedCodeInfo_Annotation* ot
}
::google::protobuf::Metadata GeneratedCodeInfo_Annotation::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = GeneratedCodeInfo_Annotation_descriptor_;
- metadata.reflection = GeneratedCodeInfo_Annotation_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[23];
}
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// GeneratedCodeInfo_Annotation
+
+// repeated int32 path = 1 [packed = true];
+int GeneratedCodeInfo_Annotation::path_size() const {
+ return path_.size();
+}
+void GeneratedCodeInfo_Annotation::clear_path() {
+ path_.Clear();
+}
+::google::protobuf::int32 GeneratedCodeInfo_Annotation::path(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.path)
+ return path_.Get(index);
+}
+void GeneratedCodeInfo_Annotation::set_path(int index, ::google::protobuf::int32 value) {
+ path_.Set(index, value);
+ // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.path)
+}
+void GeneratedCodeInfo_Annotation::add_path(::google::protobuf::int32 value) {
+ path_.Add(value);
+ // @@protoc_insertion_point(field_add:google.protobuf.GeneratedCodeInfo.Annotation.path)
+}
+const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
+GeneratedCodeInfo_Annotation::path() const {
+ // @@protoc_insertion_point(field_list:google.protobuf.GeneratedCodeInfo.Annotation.path)
+ return path_;
+}
+::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
+GeneratedCodeInfo_Annotation::mutable_path() {
+ // @@protoc_insertion_point(field_mutable_list:google.protobuf.GeneratedCodeInfo.Annotation.path)
+ return &path_;
+}
-// -------------------------------------------------------------------
+// optional string source_file = 2;
+bool GeneratedCodeInfo_Annotation::has_source_file() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void GeneratedCodeInfo_Annotation::set_has_source_file() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void GeneratedCodeInfo_Annotation::clear_has_source_file() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void GeneratedCodeInfo_Annotation::clear_source_file() {
+ source_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_source_file();
+}
+const ::std::string& GeneratedCodeInfo_Annotation::source_file() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
+ return source_file_.GetNoArena();
+}
+void GeneratedCodeInfo_Annotation::set_source_file(const ::std::string& value) {
+ set_has_source_file();
+ source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
+}
+#if LANG_CXX11
+void GeneratedCodeInfo_Annotation::set_source_file(::std::string&& value) {
+ set_has_source_file();
+ source_file_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
+}
+#endif
+void GeneratedCodeInfo_Annotation::set_source_file(const char* value) {
+ set_has_source_file();
+ source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
+}
+void GeneratedCodeInfo_Annotation::set_source_file(const char* value, size_t size) {
+ set_has_source_file();
+ source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
+}
+::std::string* GeneratedCodeInfo_Annotation::mutable_source_file() {
+ set_has_source_file();
+ // @@protoc_insertion_point(field_mutable:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
+ return source_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* GeneratedCodeInfo_Annotation::release_source_file() {
+ // @@protoc_insertion_point(field_release:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
+ clear_has_source_file();
+ return source_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void GeneratedCodeInfo_Annotation::set_allocated_source_file(::std::string* source_file) {
+ if (source_file != NULL) {
+ set_has_source_file();
+ } else {
+ clear_has_source_file();
+ }
+ source_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source_file);
+ // @@protoc_insertion_point(field_set_allocated:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
+}
+
+// optional int32 begin = 3;
+bool GeneratedCodeInfo_Annotation::has_begin() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void GeneratedCodeInfo_Annotation::set_has_begin() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void GeneratedCodeInfo_Annotation::clear_has_begin() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void GeneratedCodeInfo_Annotation::clear_begin() {
+ begin_ = 0;
+ clear_has_begin();
+}
+::google::protobuf::int32 GeneratedCodeInfo_Annotation::begin() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.begin)
+ return begin_;
+}
+void GeneratedCodeInfo_Annotation::set_begin(::google::protobuf::int32 value) {
+ set_has_begin();
+ begin_ = value;
+ // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.begin)
+}
+
+// optional int32 end = 4;
+bool GeneratedCodeInfo_Annotation::has_end() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void GeneratedCodeInfo_Annotation::set_has_end() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void GeneratedCodeInfo_Annotation::clear_has_end() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void GeneratedCodeInfo_Annotation::clear_end() {
+ end_ = 0;
+ clear_has_end();
+}
+::google::protobuf::int32 GeneratedCodeInfo_Annotation::end() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.end)
+ return end_;
+}
+void GeneratedCodeInfo_Annotation::set_end(::google::protobuf::int32 value) {
+ set_has_end();
+ end_ = value;
+ // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.end)
+}
+
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int GeneratedCodeInfo::kAnnotationFieldNumber;
@@ -15600,19 +15435,19 @@ const int GeneratedCodeInfo::kAnnotationFieldNumber;
GeneratedCodeInfo::GeneratedCodeInfo()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.GeneratedCodeInfo)
}
-
-void GeneratedCodeInfo::InitAsDefaultInstance() {
-}
-
GeneratedCodeInfo::GeneratedCodeInfo(const GeneratedCodeInfo& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0),
+ annotation_(from.annotation_) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:google.protobuf.GeneratedCodeInfo)
}
@@ -15634,17 +15469,15 @@ void GeneratedCodeInfo::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* GeneratedCodeInfo::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return GeneratedCodeInfo_descriptor_;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[24].descriptor;
}
const GeneratedCodeInfo& GeneratedCodeInfo::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo> GeneratedCodeInfo_default_instance_;
-
GeneratedCodeInfo* GeneratedCodeInfo::New(::google::protobuf::Arena* arena) const {
GeneratedCodeInfo* n = new GeneratedCodeInfo;
if (arena != NULL) {
@@ -15657,9 +15490,7 @@ void GeneratedCodeInfo::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.GeneratedCodeInfo)
annotation_.Clear();
_has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
+ _internal_metadata_.Clear();
}
bool GeneratedCodeInfo::MergePartialFromCodedStream(
@@ -15668,23 +15499,21 @@ bool GeneratedCodeInfo::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.GeneratedCodeInfo)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_annotation:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_annotation()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(10)) goto parse_loop_annotation;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -15728,7 +15557,7 @@ void GeneratedCodeInfo::SerializeWithCachedSizes(
::google::protobuf::uint8* GeneratedCodeInfo::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.GeneratedCodeInfo)
// repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;
for (unsigned int i = 0, n = this->annotation_size(); i < n; i++) {
@@ -15749,6 +15578,11 @@ size_t GeneratedCodeInfo::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.GeneratedCodeInfo)
size_t total_size = 0;
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
// repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;
{
unsigned int count = this->annotation_size();
@@ -15760,11 +15594,6 @@ size_t GeneratedCodeInfo::ByteSizeLong() const {
}
}
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
@@ -15774,7 +15603,7 @@ size_t GeneratedCodeInfo::ByteSizeLong() const {
void GeneratedCodeInfo::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.GeneratedCodeInfo)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const GeneratedCodeInfo* source =
::google::protobuf::internal::DynamicCastToGenerated<const GeneratedCodeInfo>(
&from);
@@ -15783,26 +15612,15 @@ void GeneratedCodeInfo::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.GeneratedCodeInfo)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void GeneratedCodeInfo::MergeFrom(const GeneratedCodeInfo& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void GeneratedCodeInfo::UnsafeMergeFrom(const GeneratedCodeInfo& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
annotation_.MergeFrom(from.annotation_);
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
}
void GeneratedCodeInfo::CopyFrom(const ::google::protobuf::Message& from) {
@@ -15816,11 +15634,10 @@ void GeneratedCodeInfo::CopyFrom(const GeneratedCodeInfo& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.GeneratedCodeInfo)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool GeneratedCodeInfo::IsInitialized() const {
-
return true;
}
@@ -15836,153 +15653,11 @@ void GeneratedCodeInfo::InternalSwap(GeneratedCodeInfo* other) {
}
::google::protobuf::Metadata GeneratedCodeInfo::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = GeneratedCodeInfo_descriptor_;
- metadata.reflection = GeneratedCodeInfo_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fdescriptor_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fdescriptor_2eproto::file_level_metadata[24];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// GeneratedCodeInfo_Annotation
-
-// repeated int32 path = 1 [packed = true];
-int GeneratedCodeInfo_Annotation::path_size() const {
- return path_.size();
-}
-void GeneratedCodeInfo_Annotation::clear_path() {
- path_.Clear();
-}
-::google::protobuf::int32 GeneratedCodeInfo_Annotation::path(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.path)
- return path_.Get(index);
-}
-void GeneratedCodeInfo_Annotation::set_path(int index, ::google::protobuf::int32 value) {
- path_.Set(index, value);
- // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.path)
-}
-void GeneratedCodeInfo_Annotation::add_path(::google::protobuf::int32 value) {
- path_.Add(value);
- // @@protoc_insertion_point(field_add:google.protobuf.GeneratedCodeInfo.Annotation.path)
-}
-const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
-GeneratedCodeInfo_Annotation::path() const {
- // @@protoc_insertion_point(field_list:google.protobuf.GeneratedCodeInfo.Annotation.path)
- return path_;
-}
-::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
-GeneratedCodeInfo_Annotation::mutable_path() {
- // @@protoc_insertion_point(field_mutable_list:google.protobuf.GeneratedCodeInfo.Annotation.path)
- return &path_;
-}
-
-// optional string source_file = 2;
-bool GeneratedCodeInfo_Annotation::has_source_file() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void GeneratedCodeInfo_Annotation::set_has_source_file() {
- _has_bits_[0] |= 0x00000002u;
-}
-void GeneratedCodeInfo_Annotation::clear_has_source_file() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void GeneratedCodeInfo_Annotation::clear_source_file() {
- source_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_source_file();
-}
-const ::std::string& GeneratedCodeInfo_Annotation::source_file() const {
- // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
- return source_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void GeneratedCodeInfo_Annotation::set_source_file(const ::std::string& value) {
- set_has_source_file();
- source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
-}
-void GeneratedCodeInfo_Annotation::set_source_file(const char* value) {
- set_has_source_file();
- source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
-}
-void GeneratedCodeInfo_Annotation::set_source_file(const char* value, size_t size) {
- set_has_source_file();
- source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
-}
-::std::string* GeneratedCodeInfo_Annotation::mutable_source_file() {
- set_has_source_file();
- // @@protoc_insertion_point(field_mutable:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
- return source_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* GeneratedCodeInfo_Annotation::release_source_file() {
- // @@protoc_insertion_point(field_release:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
- clear_has_source_file();
- return source_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void GeneratedCodeInfo_Annotation::set_allocated_source_file(::std::string* source_file) {
- if (source_file != NULL) {
- set_has_source_file();
- } else {
- clear_has_source_file();
- }
- source_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source_file);
- // @@protoc_insertion_point(field_set_allocated:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
-}
-
-// optional int32 begin = 3;
-bool GeneratedCodeInfo_Annotation::has_begin() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void GeneratedCodeInfo_Annotation::set_has_begin() {
- _has_bits_[0] |= 0x00000004u;
-}
-void GeneratedCodeInfo_Annotation::clear_has_begin() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void GeneratedCodeInfo_Annotation::clear_begin() {
- begin_ = 0;
- clear_has_begin();
-}
-::google::protobuf::int32 GeneratedCodeInfo_Annotation::begin() const {
- // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.begin)
- return begin_;
-}
-void GeneratedCodeInfo_Annotation::set_begin(::google::protobuf::int32 value) {
- set_has_begin();
- begin_ = value;
- // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.begin)
-}
-
-// optional int32 end = 4;
-bool GeneratedCodeInfo_Annotation::has_end() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-void GeneratedCodeInfo_Annotation::set_has_end() {
- _has_bits_[0] |= 0x00000008u;
-}
-void GeneratedCodeInfo_Annotation::clear_has_end() {
- _has_bits_[0] &= ~0x00000008u;
-}
-void GeneratedCodeInfo_Annotation::clear_end() {
- end_ = 0;
- clear_has_end();
-}
-::google::protobuf::int32 GeneratedCodeInfo_Annotation::end() const {
- // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.end)
- return end_;
-}
-void GeneratedCodeInfo_Annotation::set_end(::google::protobuf::int32 value) {
- set_has_end();
- end_ = value;
- // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.end)
-}
-
-inline const GeneratedCodeInfo_Annotation* GeneratedCodeInfo_Annotation::internal_default_instance() {
- return &GeneratedCodeInfo_Annotation_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
// GeneratedCodeInfo
// repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;
@@ -16015,9 +15690,6 @@ GeneratedCodeInfo::annotation() const {
return annotation_;
}
-inline const GeneratedCodeInfo* GeneratedCodeInfo::internal_default_instance() {
- return &GeneratedCodeInfo_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// @@protoc_insertion_point(namespace_scope)
diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h
index 257dd0f7..73b7a8dd 100644
--- a/src/google/protobuf/descriptor.pb.h
+++ b/src/google/protobuf/descriptor.pb.h
@@ -8,62 +8,121 @@
#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3001000
+#if GOOGLE_PROTOBUF_VERSION < 3002000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
#endif
+#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata.h>
#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/extension_set.h>
+#include <google/protobuf/repeated_field.h> // IWYU pragma: export
+#include <google/protobuf/extension_set.h> // IWYU pragma: export
#include <google/protobuf/generated_enum_reflection.h>
#include <google/protobuf/unknown_field_set.h>
// @@protoc_insertion_point(includes)
-
namespace google {
namespace protobuf {
-
-// Internal implementation detail -- do not call these.
-void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();
-void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto();
-void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();
-void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();
-
class DescriptorProto;
+class DescriptorProtoDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern DescriptorProtoDefaultTypeInternal _DescriptorProto_default_instance_;
class DescriptorProto_ExtensionRange;
+class DescriptorProto_ExtensionRangeDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern DescriptorProto_ExtensionRangeDefaultTypeInternal _DescriptorProto_ExtensionRange_default_instance_;
class DescriptorProto_ReservedRange;
+class DescriptorProto_ReservedRangeDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern DescriptorProto_ReservedRangeDefaultTypeInternal _DescriptorProto_ReservedRange_default_instance_;
class EnumDescriptorProto;
+class EnumDescriptorProtoDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_;
class EnumOptions;
+class EnumOptionsDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern EnumOptionsDefaultTypeInternal _EnumOptions_default_instance_;
class EnumValueDescriptorProto;
+class EnumValueDescriptorProtoDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern EnumValueDescriptorProtoDefaultTypeInternal _EnumValueDescriptorProto_default_instance_;
class EnumValueOptions;
+class EnumValueOptionsDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern EnumValueOptionsDefaultTypeInternal _EnumValueOptions_default_instance_;
class FieldDescriptorProto;
+class FieldDescriptorProtoDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_;
class FieldOptions;
+class FieldOptionsDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern FieldOptionsDefaultTypeInternal _FieldOptions_default_instance_;
class FileDescriptorProto;
+class FileDescriptorProtoDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern FileDescriptorProtoDefaultTypeInternal _FileDescriptorProto_default_instance_;
class FileDescriptorSet;
+class FileDescriptorSetDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern FileDescriptorSetDefaultTypeInternal _FileDescriptorSet_default_instance_;
class FileOptions;
+class FileOptionsDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern FileOptionsDefaultTypeInternal _FileOptions_default_instance_;
class GeneratedCodeInfo;
+class GeneratedCodeInfoDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern GeneratedCodeInfoDefaultTypeInternal _GeneratedCodeInfo_default_instance_;
class GeneratedCodeInfo_Annotation;
+class GeneratedCodeInfo_AnnotationDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern GeneratedCodeInfo_AnnotationDefaultTypeInternal _GeneratedCodeInfo_Annotation_default_instance_;
class MessageOptions;
+class MessageOptionsDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern MessageOptionsDefaultTypeInternal _MessageOptions_default_instance_;
class MethodDescriptorProto;
+class MethodDescriptorProtoDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern MethodDescriptorProtoDefaultTypeInternal _MethodDescriptorProto_default_instance_;
class MethodOptions;
+class MethodOptionsDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern MethodOptionsDefaultTypeInternal _MethodOptions_default_instance_;
class OneofDescriptorProto;
+class OneofDescriptorProtoDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern OneofDescriptorProtoDefaultTypeInternal _OneofDescriptorProto_default_instance_;
class OneofOptions;
+class OneofOptionsDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern OneofOptionsDefaultTypeInternal _OneofOptions_default_instance_;
class ServiceDescriptorProto;
+class ServiceDescriptorProtoDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern ServiceDescriptorProtoDefaultTypeInternal _ServiceDescriptorProto_default_instance_;
class ServiceOptions;
+class ServiceOptionsDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern ServiceOptionsDefaultTypeInternal _ServiceOptions_default_instance_;
class SourceCodeInfo;
+class SourceCodeInfoDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern SourceCodeInfoDefaultTypeInternal _SourceCodeInfo_default_instance_;
class SourceCodeInfo_Location;
+class SourceCodeInfo_LocationDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern SourceCodeInfo_LocationDefaultTypeInternal _SourceCodeInfo_Location_default_instance_;
class UninterpretedOption;
+class UninterpretedOptionDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern UninterpretedOptionDefaultTypeInternal _UninterpretedOption_default_instance_;
class UninterpretedOption_NamePart;
+class UninterpretedOption_NamePartDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_;
+} // namespace protobuf
+} // namespace google
+
+namespace google {
+namespace protobuf {
+
+namespace protobuf_google_2fprotobuf_2fdescriptor_2eproto {
+// Internal implementation detail -- do not call these.
+struct LIBPROTOBUF_EXPORT TableStruct {
+ static const ::google::protobuf::uint32 offsets[];
+ static void InitDefaultsImpl();
+ static void Shutdown();
+};
+void LIBPROTOBUF_EXPORT AddDescriptors();
+void LIBPROTOBUF_EXPORT InitDefaults();
+} // namespace protobuf_google_2fprotobuf_2fdescriptor_2eproto
enum FieldDescriptorProto_Type {
FieldDescriptorProto_Type_TYPE_DOUBLE = 1,
@@ -180,6 +239,26 @@ inline bool FieldOptions_JSType_Parse(
return ::google::protobuf::internal::ParseNamedEnum<FieldOptions_JSType>(
FieldOptions_JSType_descriptor(), name, value);
}
+enum MethodOptions_IdempotencyLevel {
+ MethodOptions_IdempotencyLevel_IDEMPOTENCY_UNKNOWN = 0,
+ MethodOptions_IdempotencyLevel_NO_SIDE_EFFECTS = 1,
+ MethodOptions_IdempotencyLevel_IDEMPOTENT = 2
+};
+LIBPROTOBUF_EXPORT bool MethodOptions_IdempotencyLevel_IsValid(int value);
+const MethodOptions_IdempotencyLevel MethodOptions_IdempotencyLevel_IdempotencyLevel_MIN = MethodOptions_IdempotencyLevel_IDEMPOTENCY_UNKNOWN;
+const MethodOptions_IdempotencyLevel MethodOptions_IdempotencyLevel_IdempotencyLevel_MAX = MethodOptions_IdempotencyLevel_IDEMPOTENT;
+const int MethodOptions_IdempotencyLevel_IdempotencyLevel_ARRAYSIZE = MethodOptions_IdempotencyLevel_IdempotencyLevel_MAX + 1;
+
+LIBPROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* MethodOptions_IdempotencyLevel_descriptor();
+inline const ::std::string& MethodOptions_IdempotencyLevel_Name(MethodOptions_IdempotencyLevel value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ MethodOptions_IdempotencyLevel_descriptor(), value);
+}
+inline bool MethodOptions_IdempotencyLevel_Parse(
+ const ::std::string& name, MethodOptions_IdempotencyLevel* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<MethodOptions_IdempotencyLevel>(
+ MethodOptions_IdempotencyLevel_descriptor(), name, value);
+}
// ===================================================================
class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileDescriptorSet) */ {
@@ -205,49 +284,53 @@ class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message
static const ::google::protobuf::Descriptor* descriptor();
static const FileDescriptorSet& default_instance();
- static const FileDescriptorSet* internal_default_instance();
+ static inline const FileDescriptorSet* internal_default_instance() {
+ return reinterpret_cast<const FileDescriptorSet*>(
+ &_FileDescriptorSet_default_instance_);
+ }
void Swap(FileDescriptorSet* other);
// implements Message ----------------------------------------------
- inline FileDescriptorSet* New() const { return New(NULL); }
+ inline FileDescriptorSet* New() const PROTOBUF_FINAL { return New(NULL); }
- FileDescriptorSet* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ FileDescriptorSet* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const FileDescriptorSet& from);
void MergeFrom(const FileDescriptorSet& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(FileDescriptorSet* other);
- void UnsafeMergeFrom(const FileDescriptorSet& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
@@ -272,15 +355,8 @@ class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message
::google::protobuf::internal::HasBits<1> _has_bits_;
mutable int _cached_size_;
::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto > file_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorSet> FileDescriptorSet_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileDescriptorProto) */ {
@@ -306,78 +382,58 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag
static const ::google::protobuf::Descriptor* descriptor();
static const FileDescriptorProto& default_instance();
- static const FileDescriptorProto* internal_default_instance();
+ static inline const FileDescriptorProto* internal_default_instance() {
+ return reinterpret_cast<const FileDescriptorProto*>(
+ &_FileDescriptorProto_default_instance_);
+ }
void Swap(FileDescriptorProto* other);
// implements Message ----------------------------------------------
- inline FileDescriptorProto* New() const { return New(NULL); }
+ inline FileDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); }
- FileDescriptorProto* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ FileDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const FileDescriptorProto& from);
void MergeFrom(const FileDescriptorProto& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(FileDescriptorProto* other);
- void UnsafeMergeFrom(const FileDescriptorProto& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
- // optional string name = 1;
- bool has_name() const;
- void clear_name();
- static const int kNameFieldNumber = 1;
- const ::std::string& name() const;
- void set_name(const ::std::string& value);
- void set_name(const char* value);
- void set_name(const char* value, size_t size);
- ::std::string* mutable_name();
- ::std::string* release_name();
- void set_allocated_name(::std::string* name);
-
- // optional string package = 2;
- bool has_package() const;
- void clear_package();
- static const int kPackageFieldNumber = 2;
- const ::std::string& package() const;
- void set_package(const ::std::string& value);
- void set_package(const char* value);
- void set_package(const char* value, size_t size);
- ::std::string* mutable_package();
- ::std::string* release_package();
- void set_allocated_package(::std::string* package);
-
// repeated string dependency = 3;
int dependency_size() const;
void clear_dependency();
@@ -385,10 +441,16 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag
const ::std::string& dependency(int index) const;
::std::string* mutable_dependency(int index);
void set_dependency(int index, const ::std::string& value);
+ #if LANG_CXX11
+ void set_dependency(int index, ::std::string&& value);
+ #endif
void set_dependency(int index, const char* value);
void set_dependency(int index, const char* value, size_t size);
::std::string* add_dependency();
void add_dependency(const ::std::string& value);
+ #if LANG_CXX11
+ void add_dependency(::std::string&& value);
+ #endif
void add_dependency(const char* value);
void add_dependency(const char* value, size_t size);
const ::google::protobuf::RepeatedPtrField< ::std::string>& dependency() const;
@@ -466,6 +528,51 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >&
extension() const;
+ // optional string name = 1;
+ bool has_name() const;
+ void clear_name();
+ static const int kNameFieldNumber = 1;
+ const ::std::string& name() const;
+ void set_name(const ::std::string& value);
+ #if LANG_CXX11
+ void set_name(::std::string&& value);
+ #endif
+ void set_name(const char* value);
+ void set_name(const char* value, size_t size);
+ ::std::string* mutable_name();
+ ::std::string* release_name();
+ void set_allocated_name(::std::string* name);
+
+ // optional string package = 2;
+ bool has_package() const;
+ void clear_package();
+ static const int kPackageFieldNumber = 2;
+ const ::std::string& package() const;
+ void set_package(const ::std::string& value);
+ #if LANG_CXX11
+ void set_package(::std::string&& value);
+ #endif
+ void set_package(const char* value);
+ void set_package(const char* value, size_t size);
+ ::std::string* mutable_package();
+ ::std::string* release_package();
+ void set_allocated_package(::std::string* package);
+
+ // optional string syntax = 12;
+ bool has_syntax() const;
+ void clear_syntax();
+ static const int kSyntaxFieldNumber = 12;
+ const ::std::string& syntax() const;
+ void set_syntax(const ::std::string& value);
+ #if LANG_CXX11
+ void set_syntax(::std::string&& value);
+ #endif
+ void set_syntax(const char* value);
+ void set_syntax(const char* value, size_t size);
+ ::std::string* mutable_syntax();
+ ::std::string* release_syntax();
+ void set_allocated_syntax(::std::string* syntax);
+
// optional .google.protobuf.FileOptions options = 8;
bool has_options() const;
void clear_options();
@@ -484,30 +591,18 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag
::google::protobuf::SourceCodeInfo* release_source_code_info();
void set_allocated_source_code_info(::google::protobuf::SourceCodeInfo* source_code_info);
- // optional string syntax = 12;
- bool has_syntax() const;
- void clear_syntax();
- static const int kSyntaxFieldNumber = 12;
- const ::std::string& syntax() const;
- void set_syntax(const ::std::string& value);
- void set_syntax(const char* value);
- void set_syntax(const char* value, size_t size);
- ::std::string* mutable_syntax();
- ::std::string* release_syntax();
- void set_allocated_syntax(::std::string* syntax);
-
// @@protoc_insertion_point(class_scope:google.protobuf.FileDescriptorProto)
private:
- inline void set_has_name();
- inline void clear_has_name();
- inline void set_has_package();
- inline void clear_has_package();
- inline void set_has_options();
- inline void clear_has_options();
- inline void set_has_source_code_info();
- inline void clear_has_source_code_info();
- inline void set_has_syntax();
- inline void clear_has_syntax();
+ void set_has_name();
+ void clear_has_name();
+ void set_has_package();
+ void clear_has_package();
+ void set_has_options();
+ void clear_has_options();
+ void set_has_source_code_info();
+ void clear_has_source_code_info();
+ void set_has_syntax();
+ void clear_has_syntax();
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::google::protobuf::internal::HasBits<1> _has_bits_;
@@ -524,15 +619,8 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag
::google::protobuf::internal::ArenaStringPtr syntax_;
::google::protobuf::FileOptions* options_;
::google::protobuf::SourceCodeInfo* source_code_info_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorProto> FileDescriptorProto_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto.ExtensionRange) */ {
@@ -558,49 +646,53 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::proto
static const ::google::protobuf::Descriptor* descriptor();
static const DescriptorProto_ExtensionRange& default_instance();
- static const DescriptorProto_ExtensionRange* internal_default_instance();
+ static inline const DescriptorProto_ExtensionRange* internal_default_instance() {
+ return reinterpret_cast<const DescriptorProto_ExtensionRange*>(
+ &_DescriptorProto_ExtensionRange_default_instance_);
+ }
void Swap(DescriptorProto_ExtensionRange* other);
// implements Message ----------------------------------------------
- inline DescriptorProto_ExtensionRange* New() const { return New(NULL); }
+ inline DescriptorProto_ExtensionRange* New() const PROTOBUF_FINAL { return New(NULL); }
- DescriptorProto_ExtensionRange* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ DescriptorProto_ExtensionRange* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const DescriptorProto_ExtensionRange& from);
void MergeFrom(const DescriptorProto_ExtensionRange& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(DescriptorProto_ExtensionRange* other);
- void UnsafeMergeFrom(const DescriptorProto_ExtensionRange& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
@@ -622,25 +714,18 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::proto
// @@protoc_insertion_point(class_scope:google.protobuf.DescriptorProto.ExtensionRange)
private:
- inline void set_has_start();
- inline void clear_has_start();
- inline void set_has_end();
- inline void clear_has_end();
+ void set_has_start();
+ void clear_has_start();
+ void set_has_end();
+ void clear_has_end();
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::google::protobuf::internal::HasBits<1> _has_bits_;
mutable int _cached_size_;
::google::protobuf::int32 start_;
::google::protobuf::int32 end_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ExtensionRange> DescriptorProto_ExtensionRange_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto.ReservedRange) */ {
@@ -666,49 +751,53 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protob
static const ::google::protobuf::Descriptor* descriptor();
static const DescriptorProto_ReservedRange& default_instance();
- static const DescriptorProto_ReservedRange* internal_default_instance();
+ static inline const DescriptorProto_ReservedRange* internal_default_instance() {
+ return reinterpret_cast<const DescriptorProto_ReservedRange*>(
+ &_DescriptorProto_ReservedRange_default_instance_);
+ }
void Swap(DescriptorProto_ReservedRange* other);
// implements Message ----------------------------------------------
- inline DescriptorProto_ReservedRange* New() const { return New(NULL); }
+ inline DescriptorProto_ReservedRange* New() const PROTOBUF_FINAL { return New(NULL); }
- DescriptorProto_ReservedRange* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ DescriptorProto_ReservedRange* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const DescriptorProto_ReservedRange& from);
void MergeFrom(const DescriptorProto_ReservedRange& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(DescriptorProto_ReservedRange* other);
- void UnsafeMergeFrom(const DescriptorProto_ReservedRange& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
@@ -730,25 +819,18 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protob
// @@protoc_insertion_point(class_scope:google.protobuf.DescriptorProto.ReservedRange)
private:
- inline void set_has_start();
- inline void clear_has_start();
- inline void set_has_end();
- inline void clear_has_end();
+ void set_has_start();
+ void clear_has_start();
+ void set_has_end();
+ void clear_has_end();
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::google::protobuf::internal::HasBits<1> _has_bits_;
mutable int _cached_size_;
::google::protobuf::int32 start_;
::google::protobuf::int32 end_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ReservedRange> DescriptorProto_ReservedRange_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto) */ {
@@ -774,49 +856,53 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /*
static const ::google::protobuf::Descriptor* descriptor();
static const DescriptorProto& default_instance();
- static const DescriptorProto* internal_default_instance();
+ static inline const DescriptorProto* internal_default_instance() {
+ return reinterpret_cast<const DescriptorProto*>(
+ &_DescriptorProto_default_instance_);
+ }
void Swap(DescriptorProto* other);
// implements Message ----------------------------------------------
- inline DescriptorProto* New() const { return New(NULL); }
+ inline DescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); }
- DescriptorProto* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ DescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const DescriptorProto& from);
void MergeFrom(const DescriptorProto& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(DescriptorProto* other);
- void UnsafeMergeFrom(const DescriptorProto& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
@@ -825,18 +911,6 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /*
// accessors -------------------------------------------------------
- // optional string name = 1;
- bool has_name() const;
- void clear_name();
- static const int kNameFieldNumber = 1;
- const ::std::string& name() const;
- void set_name(const ::std::string& value);
- void set_name(const char* value);
- void set_name(const char* value, size_t size);
- ::std::string* mutable_name();
- ::std::string* release_name();
- void set_allocated_name(::std::string* name);
-
// repeated .google.protobuf.FieldDescriptorProto field = 2;
int field_size() const;
void clear_field();
@@ -909,15 +983,6 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /*
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::OneofDescriptorProto >&
oneof_decl() const;
- // optional .google.protobuf.MessageOptions options = 7;
- bool has_options() const;
- void clear_options();
- static const int kOptionsFieldNumber = 7;
- const ::google::protobuf::MessageOptions& options() const;
- ::google::protobuf::MessageOptions* mutable_options();
- ::google::protobuf::MessageOptions* release_options();
- void set_allocated_options(::google::protobuf::MessageOptions* options);
-
// repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;
int reserved_range_size() const;
void clear_reserved_range();
@@ -937,21 +1002,51 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /*
const ::std::string& reserved_name(int index) const;
::std::string* mutable_reserved_name(int index);
void set_reserved_name(int index, const ::std::string& value);
+ #if LANG_CXX11
+ void set_reserved_name(int index, ::std::string&& value);
+ #endif
void set_reserved_name(int index, const char* value);
void set_reserved_name(int index, const char* value, size_t size);
::std::string* add_reserved_name();
void add_reserved_name(const ::std::string& value);
+ #if LANG_CXX11
+ void add_reserved_name(::std::string&& value);
+ #endif
void add_reserved_name(const char* value);
void add_reserved_name(const char* value, size_t size);
const ::google::protobuf::RepeatedPtrField< ::std::string>& reserved_name() const;
::google::protobuf::RepeatedPtrField< ::std::string>* mutable_reserved_name();
+ // optional string name = 1;
+ bool has_name() const;
+ void clear_name();
+ static const int kNameFieldNumber = 1;
+ const ::std::string& name() const;
+ void set_name(const ::std::string& value);
+ #if LANG_CXX11
+ void set_name(::std::string&& value);
+ #endif
+ void set_name(const char* value);
+ void set_name(const char* value, size_t size);
+ ::std::string* mutable_name();
+ ::std::string* release_name();
+ void set_allocated_name(::std::string* name);
+
+ // optional .google.protobuf.MessageOptions options = 7;
+ bool has_options() const;
+ void clear_options();
+ static const int kOptionsFieldNumber = 7;
+ const ::google::protobuf::MessageOptions& options() const;
+ ::google::protobuf::MessageOptions* mutable_options();
+ ::google::protobuf::MessageOptions* release_options();
+ void set_allocated_options(::google::protobuf::MessageOptions* options);
+
// @@protoc_insertion_point(class_scope:google.protobuf.DescriptorProto)
private:
- inline void set_has_name();
- inline void clear_has_name();
- inline void set_has_options();
- inline void clear_has_options();
+ void set_has_name();
+ void clear_has_name();
+ void set_has_options();
+ void clear_has_options();
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::google::protobuf::internal::HasBits<1> _has_bits_;
@@ -966,15 +1061,8 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /*
::google::protobuf::RepeatedPtrField< ::std::string> reserved_name_;
::google::protobuf::internal::ArenaStringPtr name_;
::google::protobuf::MessageOptions* options_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto> DescriptorProto_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldDescriptorProto) */ {
@@ -1000,49 +1088,53 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa
static const ::google::protobuf::Descriptor* descriptor();
static const FieldDescriptorProto& default_instance();
- static const FieldDescriptorProto* internal_default_instance();
+ static inline const FieldDescriptorProto* internal_default_instance() {
+ return reinterpret_cast<const FieldDescriptorProto*>(
+ &_FieldDescriptorProto_default_instance_);
+ }
void Swap(FieldDescriptorProto* other);
// implements Message ----------------------------------------------
- inline FieldDescriptorProto* New() const { return New(NULL); }
+ inline FieldDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); }
- FieldDescriptorProto* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ FieldDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const FieldDescriptorProto& from);
void MergeFrom(const FieldDescriptorProto& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(FieldDescriptorProto* other);
- void UnsafeMergeFrom(const FieldDescriptorProto& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
@@ -1140,39 +1232,24 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa
static const int kNameFieldNumber = 1;
const ::std::string& name() const;
void set_name(const ::std::string& value);
+ #if LANG_CXX11
+ void set_name(::std::string&& value);
+ #endif
void set_name(const char* value);
void set_name(const char* value, size_t size);
::std::string* mutable_name();
::std::string* release_name();
void set_allocated_name(::std::string* name);
- // optional int32 number = 3;
- bool has_number() const;
- void clear_number();
- static const int kNumberFieldNumber = 3;
- ::google::protobuf::int32 number() const;
- void set_number(::google::protobuf::int32 value);
-
- // optional .google.protobuf.FieldDescriptorProto.Label label = 4;
- bool has_label() const;
- void clear_label();
- static const int kLabelFieldNumber = 4;
- ::google::protobuf::FieldDescriptorProto_Label label() const;
- void set_label(::google::protobuf::FieldDescriptorProto_Label value);
-
- // optional .google.protobuf.FieldDescriptorProto.Type type = 5;
- bool has_type() const;
- void clear_type();
- static const int kTypeFieldNumber = 5;
- ::google::protobuf::FieldDescriptorProto_Type type() const;
- void set_type(::google::protobuf::FieldDescriptorProto_Type value);
-
// optional string type_name = 6;
bool has_type_name() const;
void clear_type_name();
static const int kTypeNameFieldNumber = 6;
const ::std::string& type_name() const;
void set_type_name(const ::std::string& value);
+ #if LANG_CXX11
+ void set_type_name(::std::string&& value);
+ #endif
void set_type_name(const char* value);
void set_type_name(const char* value, size_t size);
::std::string* mutable_type_name();
@@ -1185,6 +1262,9 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa
static const int kExtendeeFieldNumber = 2;
const ::std::string& extendee() const;
void set_extendee(const ::std::string& value);
+ #if LANG_CXX11
+ void set_extendee(::std::string&& value);
+ #endif
void set_extendee(const char* value);
void set_extendee(const char* value, size_t size);
::std::string* mutable_extendee();
@@ -1197,25 +1277,24 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa
static const int kDefaultValueFieldNumber = 7;
const ::std::string& default_value() const;
void set_default_value(const ::std::string& value);
+ #if LANG_CXX11
+ void set_default_value(::std::string&& value);
+ #endif
void set_default_value(const char* value);
void set_default_value(const char* value, size_t size);
::std::string* mutable_default_value();
::std::string* release_default_value();
void set_allocated_default_value(::std::string* default_value);
- // optional int32 oneof_index = 9;
- bool has_oneof_index() const;
- void clear_oneof_index();
- static const int kOneofIndexFieldNumber = 9;
- ::google::protobuf::int32 oneof_index() const;
- void set_oneof_index(::google::protobuf::int32 value);
-
// optional string json_name = 10;
bool has_json_name() const;
void clear_json_name();
static const int kJsonNameFieldNumber = 10;
const ::std::string& json_name() const;
void set_json_name(const ::std::string& value);
+ #if LANG_CXX11
+ void set_json_name(::std::string&& value);
+ #endif
void set_json_name(const char* value);
void set_json_name(const char* value, size_t size);
::std::string* mutable_json_name();
@@ -1231,28 +1310,56 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa
::google::protobuf::FieldOptions* release_options();
void set_allocated_options(::google::protobuf::FieldOptions* options);
+ // optional int32 number = 3;
+ bool has_number() const;
+ void clear_number();
+ static const int kNumberFieldNumber = 3;
+ ::google::protobuf::int32 number() const;
+ void set_number(::google::protobuf::int32 value);
+
+ // optional int32 oneof_index = 9;
+ bool has_oneof_index() const;
+ void clear_oneof_index();
+ static const int kOneofIndexFieldNumber = 9;
+ ::google::protobuf::int32 oneof_index() const;
+ void set_oneof_index(::google::protobuf::int32 value);
+
+ // optional .google.protobuf.FieldDescriptorProto.Label label = 4;
+ bool has_label() const;
+ void clear_label();
+ static const int kLabelFieldNumber = 4;
+ ::google::protobuf::FieldDescriptorProto_Label label() const;
+ void set_label(::google::protobuf::FieldDescriptorProto_Label value);
+
+ // optional .google.protobuf.FieldDescriptorProto.Type type = 5;
+ bool has_type() const;
+ void clear_type();
+ static const int kTypeFieldNumber = 5;
+ ::google::protobuf::FieldDescriptorProto_Type type() const;
+ void set_type(::google::protobuf::FieldDescriptorProto_Type value);
+
// @@protoc_insertion_point(class_scope:google.protobuf.FieldDescriptorProto)
private:
- inline void set_has_name();
- inline void clear_has_name();
- inline void set_has_number();
- inline void clear_has_number();
- inline void set_has_label();
- inline void clear_has_label();
- inline void set_has_type();
- inline void clear_has_type();
- inline void set_has_type_name();
- inline void clear_has_type_name();
- inline void set_has_extendee();
- inline void clear_has_extendee();
- inline void set_has_default_value();
- inline void clear_has_default_value();
- inline void set_has_oneof_index();
- inline void clear_has_oneof_index();
- inline void set_has_json_name();
- inline void clear_has_json_name();
- inline void set_has_options();
- inline void clear_has_options();
+ void set_has_name();
+ void clear_has_name();
+ void set_has_number();
+ void clear_has_number();
+ void set_has_label();
+ void clear_has_label();
+ void set_has_type();
+ void clear_has_type();
+ void set_has_type_name();
+ void clear_has_type_name();
+ void set_has_extendee();
+ void clear_has_extendee();
+ void set_has_default_value();
+ void clear_has_default_value();
+ void set_has_oneof_index();
+ void clear_has_oneof_index();
+ void set_has_json_name();
+ void clear_has_json_name();
+ void set_has_options();
+ void clear_has_options();
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::google::protobuf::internal::HasBits<1> _has_bits_;
@@ -1267,15 +1374,8 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa
::google::protobuf::int32 oneof_index_;
int label_;
int type_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<FieldDescriptorProto> FieldDescriptorProto_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.OneofDescriptorProto) */ {
@@ -1301,49 +1401,53 @@ class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Messa
static const ::google::protobuf::Descriptor* descriptor();
static const OneofDescriptorProto& default_instance();
- static const OneofDescriptorProto* internal_default_instance();
+ static inline const OneofDescriptorProto* internal_default_instance() {
+ return reinterpret_cast<const OneofDescriptorProto*>(
+ &_OneofDescriptorProto_default_instance_);
+ }
void Swap(OneofDescriptorProto* other);
// implements Message ----------------------------------------------
- inline OneofDescriptorProto* New() const { return New(NULL); }
+ inline OneofDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); }
- OneofDescriptorProto* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ OneofDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const OneofDescriptorProto& from);
void MergeFrom(const OneofDescriptorProto& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(OneofDescriptorProto* other);
- void UnsafeMergeFrom(const OneofDescriptorProto& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
@@ -1355,6 +1459,9 @@ class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Messa
static const int kNameFieldNumber = 1;
const ::std::string& name() const;
void set_name(const ::std::string& value);
+ #if LANG_CXX11
+ void set_name(::std::string&& value);
+ #endif
void set_name(const char* value);
void set_name(const char* value, size_t size);
::std::string* mutable_name();
@@ -1372,25 +1479,18 @@ class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Messa
// @@protoc_insertion_point(class_scope:google.protobuf.OneofDescriptorProto)
private:
- inline void set_has_name();
- inline void clear_has_name();
- inline void set_has_options();
- inline void clear_has_options();
+ void set_has_name();
+ void clear_has_name();
+ void set_has_options();
+ void clear_has_options();
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::google::protobuf::internal::HasBits<1> _has_bits_;
mutable int _cached_size_;
::google::protobuf::internal::ArenaStringPtr name_;
::google::protobuf::OneofOptions* options_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<OneofDescriptorProto> OneofDescriptorProto_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumDescriptorProto) */ {
@@ -1416,66 +1516,58 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag
static const ::google::protobuf::Descriptor* descriptor();
static const EnumDescriptorProto& default_instance();
- static const EnumDescriptorProto* internal_default_instance();
+ static inline const EnumDescriptorProto* internal_default_instance() {
+ return reinterpret_cast<const EnumDescriptorProto*>(
+ &_EnumDescriptorProto_default_instance_);
+ }
void Swap(EnumDescriptorProto* other);
// implements Message ----------------------------------------------
- inline EnumDescriptorProto* New() const { return New(NULL); }
+ inline EnumDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); }
- EnumDescriptorProto* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ EnumDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const EnumDescriptorProto& from);
void MergeFrom(const EnumDescriptorProto& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(EnumDescriptorProto* other);
- void UnsafeMergeFrom(const EnumDescriptorProto& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
- // optional string name = 1;
- bool has_name() const;
- void clear_name();
- static const int kNameFieldNumber = 1;
- const ::std::string& name() const;
- void set_name(const ::std::string& value);
- void set_name(const char* value);
- void set_name(const char* value, size_t size);
- ::std::string* mutable_name();
- ::std::string* release_name();
- void set_allocated_name(::std::string* name);
-
// repeated .google.protobuf.EnumValueDescriptorProto value = 2;
int value_size() const;
void clear_value();
@@ -1488,6 +1580,21 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto >&
value() const;
+ // optional string name = 1;
+ bool has_name() const;
+ void clear_name();
+ static const int kNameFieldNumber = 1;
+ const ::std::string& name() const;
+ void set_name(const ::std::string& value);
+ #if LANG_CXX11
+ void set_name(::std::string&& value);
+ #endif
+ void set_name(const char* value);
+ void set_name(const char* value, size_t size);
+ ::std::string* mutable_name();
+ ::std::string* release_name();
+ void set_allocated_name(::std::string* name);
+
// optional .google.protobuf.EnumOptions options = 3;
bool has_options() const;
void clear_options();
@@ -1499,10 +1606,10 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag
// @@protoc_insertion_point(class_scope:google.protobuf.EnumDescriptorProto)
private:
- inline void set_has_name();
- inline void clear_has_name();
- inline void set_has_options();
- inline void clear_has_options();
+ void set_has_name();
+ void clear_has_name();
+ void set_has_options();
+ void clear_has_options();
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::google::protobuf::internal::HasBits<1> _has_bits_;
@@ -1510,15 +1617,8 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag
::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto > value_;
::google::protobuf::internal::ArenaStringPtr name_;
::google::protobuf::EnumOptions* options_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<EnumDescriptorProto> EnumDescriptorProto_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValueDescriptorProto) */ {
@@ -1544,49 +1644,53 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M
static const ::google::protobuf::Descriptor* descriptor();
static const EnumValueDescriptorProto& default_instance();
- static const EnumValueDescriptorProto* internal_default_instance();
+ static inline const EnumValueDescriptorProto* internal_default_instance() {
+ return reinterpret_cast<const EnumValueDescriptorProto*>(
+ &_EnumValueDescriptorProto_default_instance_);
+ }
void Swap(EnumValueDescriptorProto* other);
// implements Message ----------------------------------------------
- inline EnumValueDescriptorProto* New() const { return New(NULL); }
+ inline EnumValueDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); }
- EnumValueDescriptorProto* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ EnumValueDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const EnumValueDescriptorProto& from);
void MergeFrom(const EnumValueDescriptorProto& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(EnumValueDescriptorProto* other);
- void UnsafeMergeFrom(const EnumValueDescriptorProto& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
@@ -1598,19 +1702,15 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M
static const int kNameFieldNumber = 1;
const ::std::string& name() const;
void set_name(const ::std::string& value);
+ #if LANG_CXX11
+ void set_name(::std::string&& value);
+ #endif
void set_name(const char* value);
void set_name(const char* value, size_t size);
::std::string* mutable_name();
::std::string* release_name();
void set_allocated_name(::std::string* name);
- // optional int32 number = 2;
- bool has_number() const;
- void clear_number();
- static const int kNumberFieldNumber = 2;
- ::google::protobuf::int32 number() const;
- void set_number(::google::protobuf::int32 value);
-
// optional .google.protobuf.EnumValueOptions options = 3;
bool has_options() const;
void clear_options();
@@ -1620,14 +1720,21 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M
::google::protobuf::EnumValueOptions* release_options();
void set_allocated_options(::google::protobuf::EnumValueOptions* options);
+ // optional int32 number = 2;
+ bool has_number() const;
+ void clear_number();
+ static const int kNumberFieldNumber = 2;
+ ::google::protobuf::int32 number() const;
+ void set_number(::google::protobuf::int32 value);
+
// @@protoc_insertion_point(class_scope:google.protobuf.EnumValueDescriptorProto)
private:
- inline void set_has_name();
- inline void clear_has_name();
- inline void set_has_number();
- inline void clear_has_number();
- inline void set_has_options();
- inline void clear_has_options();
+ void set_has_name();
+ void clear_has_name();
+ void set_has_number();
+ void clear_has_number();
+ void set_has_options();
+ void clear_has_options();
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::google::protobuf::internal::HasBits<1> _has_bits_;
@@ -1635,15 +1742,8 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M
::google::protobuf::internal::ArenaStringPtr name_;
::google::protobuf::EnumValueOptions* options_;
::google::protobuf::int32 number_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<EnumValueDescriptorProto> EnumValueDescriptorProto_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ServiceDescriptorProto) */ {
@@ -1669,66 +1769,58 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes
static const ::google::protobuf::Descriptor* descriptor();
static const ServiceDescriptorProto& default_instance();
- static const ServiceDescriptorProto* internal_default_instance();
+ static inline const ServiceDescriptorProto* internal_default_instance() {
+ return reinterpret_cast<const ServiceDescriptorProto*>(
+ &_ServiceDescriptorProto_default_instance_);
+ }
void Swap(ServiceDescriptorProto* other);
// implements Message ----------------------------------------------
- inline ServiceDescriptorProto* New() const { return New(NULL); }
+ inline ServiceDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); }
- ServiceDescriptorProto* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ ServiceDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const ServiceDescriptorProto& from);
void MergeFrom(const ServiceDescriptorProto& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(ServiceDescriptorProto* other);
- void UnsafeMergeFrom(const ServiceDescriptorProto& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
- // optional string name = 1;
- bool has_name() const;
- void clear_name();
- static const int kNameFieldNumber = 1;
- const ::std::string& name() const;
- void set_name(const ::std::string& value);
- void set_name(const char* value);
- void set_name(const char* value, size_t size);
- ::std::string* mutable_name();
- ::std::string* release_name();
- void set_allocated_name(::std::string* name);
-
// repeated .google.protobuf.MethodDescriptorProto method = 2;
int method_size() const;
void clear_method();
@@ -1741,6 +1833,21 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto >&
method() const;
+ // optional string name = 1;
+ bool has_name() const;
+ void clear_name();
+ static const int kNameFieldNumber = 1;
+ const ::std::string& name() const;
+ void set_name(const ::std::string& value);
+ #if LANG_CXX11
+ void set_name(::std::string&& value);
+ #endif
+ void set_name(const char* value);
+ void set_name(const char* value, size_t size);
+ ::std::string* mutable_name();
+ ::std::string* release_name();
+ void set_allocated_name(::std::string* name);
+
// optional .google.protobuf.ServiceOptions options = 3;
bool has_options() const;
void clear_options();
@@ -1752,10 +1859,10 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes
// @@protoc_insertion_point(class_scope:google.protobuf.ServiceDescriptorProto)
private:
- inline void set_has_name();
- inline void clear_has_name();
- inline void set_has_options();
- inline void clear_has_options();
+ void set_has_name();
+ void clear_has_name();
+ void set_has_options();
+ void clear_has_options();
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::google::protobuf::internal::HasBits<1> _has_bits_;
@@ -1763,15 +1870,8 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes
::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto > method_;
::google::protobuf::internal::ArenaStringPtr name_;
::google::protobuf::ServiceOptions* options_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<ServiceDescriptorProto> ServiceDescriptorProto_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MethodDescriptorProto) */ {
@@ -1797,49 +1897,53 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess
static const ::google::protobuf::Descriptor* descriptor();
static const MethodDescriptorProto& default_instance();
- static const MethodDescriptorProto* internal_default_instance();
+ static inline const MethodDescriptorProto* internal_default_instance() {
+ return reinterpret_cast<const MethodDescriptorProto*>(
+ &_MethodDescriptorProto_default_instance_);
+ }
void Swap(MethodDescriptorProto* other);
// implements Message ----------------------------------------------
- inline MethodDescriptorProto* New() const { return New(NULL); }
+ inline MethodDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); }
- MethodDescriptorProto* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ MethodDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const MethodDescriptorProto& from);
void MergeFrom(const MethodDescriptorProto& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(MethodDescriptorProto* other);
- void UnsafeMergeFrom(const MethodDescriptorProto& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
@@ -1851,6 +1955,9 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess
static const int kNameFieldNumber = 1;
const ::std::string& name() const;
void set_name(const ::std::string& value);
+ #if LANG_CXX11
+ void set_name(::std::string&& value);
+ #endif
void set_name(const char* value);
void set_name(const char* value, size_t size);
::std::string* mutable_name();
@@ -1863,6 +1970,9 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess
static const int kInputTypeFieldNumber = 2;
const ::std::string& input_type() const;
void set_input_type(const ::std::string& value);
+ #if LANG_CXX11
+ void set_input_type(::std::string&& value);
+ #endif
void set_input_type(const char* value);
void set_input_type(const char* value, size_t size);
::std::string* mutable_input_type();
@@ -1875,6 +1985,9 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess
static const int kOutputTypeFieldNumber = 3;
const ::std::string& output_type() const;
void set_output_type(const ::std::string& value);
+ #if LANG_CXX11
+ void set_output_type(::std::string&& value);
+ #endif
void set_output_type(const char* value);
void set_output_type(const char* value, size_t size);
::std::string* mutable_output_type();
@@ -1906,18 +2019,18 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess
// @@protoc_insertion_point(class_scope:google.protobuf.MethodDescriptorProto)
private:
- inline void set_has_name();
- inline void clear_has_name();
- inline void set_has_input_type();
- inline void clear_has_input_type();
- inline void set_has_output_type();
- inline void clear_has_output_type();
- inline void set_has_options();
- inline void clear_has_options();
- inline void set_has_client_streaming();
- inline void clear_has_client_streaming();
- inline void set_has_server_streaming();
- inline void clear_has_server_streaming();
+ void set_has_name();
+ void clear_has_name();
+ void set_has_input_type();
+ void clear_has_input_type();
+ void set_has_output_type();
+ void clear_has_output_type();
+ void set_has_options();
+ void clear_has_options();
+ void set_has_client_streaming();
+ void clear_has_client_streaming();
+ void set_has_server_streaming();
+ void clear_has_server_streaming();
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::google::protobuf::internal::HasBits<1> _has_bits_;
@@ -1928,15 +2041,8 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess
::google::protobuf::MethodOptions* options_;
bool client_streaming_;
bool server_streaming_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<MethodDescriptorProto> MethodDescriptorProto_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileOptions) */ {
@@ -1962,49 +2068,53 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p
static const ::google::protobuf::Descriptor* descriptor();
static const FileOptions& default_instance();
- static const FileOptions* internal_default_instance();
+ static inline const FileOptions* internal_default_instance() {
+ return reinterpret_cast<const FileOptions*>(
+ &_FileOptions_default_instance_);
+ }
void Swap(FileOptions* other);
// implements Message ----------------------------------------------
- inline FileOptions* New() const { return New(NULL); }
+ inline FileOptions* New() const PROTOBUF_FINAL { return New(NULL); }
- FileOptions* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ FileOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const FileOptions& from);
void MergeFrom(const FileOptions& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(FileOptions* other);
- void UnsafeMergeFrom(const FileOptions& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
@@ -2038,12 +2148,27 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p
// accessors -------------------------------------------------------
+ // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
+ int uninterpreted_option_size() const;
+ void clear_uninterpreted_option();
+ static const int kUninterpretedOptionFieldNumber = 999;
+ const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;
+ ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index);
+ ::google::protobuf::UninterpretedOption* add_uninterpreted_option();
+ ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
+ mutable_uninterpreted_option();
+ const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
+ uninterpreted_option() const;
+
// optional string java_package = 1;
bool has_java_package() const;
void clear_java_package();
static const int kJavaPackageFieldNumber = 1;
const ::std::string& java_package() const;
void set_java_package(const ::std::string& value);
+ #if LANG_CXX11
+ void set_java_package(::std::string&& value);
+ #endif
void set_java_package(const char* value);
void set_java_package(const char* value, size_t size);
::std::string* mutable_java_package();
@@ -2056,12 +2181,75 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p
static const int kJavaOuterClassnameFieldNumber = 8;
const ::std::string& java_outer_classname() const;
void set_java_outer_classname(const ::std::string& value);
+ #if LANG_CXX11
+ void set_java_outer_classname(::std::string&& value);
+ #endif
void set_java_outer_classname(const char* value);
void set_java_outer_classname(const char* value, size_t size);
::std::string* mutable_java_outer_classname();
::std::string* release_java_outer_classname();
void set_allocated_java_outer_classname(::std::string* java_outer_classname);
+ // optional string go_package = 11;
+ bool has_go_package() const;
+ void clear_go_package();
+ static const int kGoPackageFieldNumber = 11;
+ const ::std::string& go_package() const;
+ void set_go_package(const ::std::string& value);
+ #if LANG_CXX11
+ void set_go_package(::std::string&& value);
+ #endif
+ void set_go_package(const char* value);
+ void set_go_package(const char* value, size_t size);
+ ::std::string* mutable_go_package();
+ ::std::string* release_go_package();
+ void set_allocated_go_package(::std::string* go_package);
+
+ // optional string objc_class_prefix = 36;
+ bool has_objc_class_prefix() const;
+ void clear_objc_class_prefix();
+ static const int kObjcClassPrefixFieldNumber = 36;
+ const ::std::string& objc_class_prefix() const;
+ void set_objc_class_prefix(const ::std::string& value);
+ #if LANG_CXX11
+ void set_objc_class_prefix(::std::string&& value);
+ #endif
+ void set_objc_class_prefix(const char* value);
+ void set_objc_class_prefix(const char* value, size_t size);
+ ::std::string* mutable_objc_class_prefix();
+ ::std::string* release_objc_class_prefix();
+ void set_allocated_objc_class_prefix(::std::string* objc_class_prefix);
+
+ // optional string csharp_namespace = 37;
+ bool has_csharp_namespace() const;
+ void clear_csharp_namespace();
+ static const int kCsharpNamespaceFieldNumber = 37;
+ const ::std::string& csharp_namespace() const;
+ void set_csharp_namespace(const ::std::string& value);
+ #if LANG_CXX11
+ void set_csharp_namespace(::std::string&& value);
+ #endif
+ void set_csharp_namespace(const char* value);
+ void set_csharp_namespace(const char* value, size_t size);
+ ::std::string* mutable_csharp_namespace();
+ ::std::string* release_csharp_namespace();
+ void set_allocated_csharp_namespace(::std::string* csharp_namespace);
+
+ // optional string swift_prefix = 39;
+ bool has_swift_prefix() const;
+ void clear_swift_prefix();
+ static const int kSwiftPrefixFieldNumber = 39;
+ const ::std::string& swift_prefix() const;
+ void set_swift_prefix(const ::std::string& value);
+ #if LANG_CXX11
+ void set_swift_prefix(::std::string&& value);
+ #endif
+ void set_swift_prefix(const char* value);
+ void set_swift_prefix(const char* value, size_t size);
+ ::std::string* mutable_swift_prefix();
+ ::std::string* release_swift_prefix();
+ void set_allocated_swift_prefix(::std::string* swift_prefix);
+
// optional bool java_multiple_files = 10 [default = false];
bool has_java_multiple_files() const;
void clear_java_multiple_files();
@@ -2083,25 +2271,6 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p
bool java_string_check_utf8() const;
void set_java_string_check_utf8(bool value);
- // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
- bool has_optimize_for() const;
- void clear_optimize_for();
- static const int kOptimizeForFieldNumber = 9;
- ::google::protobuf::FileOptions_OptimizeMode optimize_for() const;
- void set_optimize_for(::google::protobuf::FileOptions_OptimizeMode value);
-
- // optional string go_package = 11;
- bool has_go_package() const;
- void clear_go_package();
- static const int kGoPackageFieldNumber = 11;
- const ::std::string& go_package() const;
- void set_go_package(const ::std::string& value);
- void set_go_package(const char* value);
- void set_go_package(const char* value, size_t size);
- ::std::string* mutable_go_package();
- ::std::string* release_go_package();
- void set_allocated_go_package(::std::string* go_package);
-
// optional bool cc_generic_services = 16 [default = false];
bool has_cc_generic_services() const;
void clear_cc_generic_services();
@@ -2137,73 +2306,46 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p
bool cc_enable_arenas() const;
void set_cc_enable_arenas(bool value);
- // optional string objc_class_prefix = 36;
- bool has_objc_class_prefix() const;
- void clear_objc_class_prefix();
- static const int kObjcClassPrefixFieldNumber = 36;
- const ::std::string& objc_class_prefix() const;
- void set_objc_class_prefix(const ::std::string& value);
- void set_objc_class_prefix(const char* value);
- void set_objc_class_prefix(const char* value, size_t size);
- ::std::string* mutable_objc_class_prefix();
- ::std::string* release_objc_class_prefix();
- void set_allocated_objc_class_prefix(::std::string* objc_class_prefix);
-
- // optional string csharp_namespace = 37;
- bool has_csharp_namespace() const;
- void clear_csharp_namespace();
- static const int kCsharpNamespaceFieldNumber = 37;
- const ::std::string& csharp_namespace() const;
- void set_csharp_namespace(const ::std::string& value);
- void set_csharp_namespace(const char* value);
- void set_csharp_namespace(const char* value, size_t size);
- ::std::string* mutable_csharp_namespace();
- ::std::string* release_csharp_namespace();
- void set_allocated_csharp_namespace(::std::string* csharp_namespace);
-
- // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
- int uninterpreted_option_size() const;
- void clear_uninterpreted_option();
- static const int kUninterpretedOptionFieldNumber = 999;
- const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;
- ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index);
- ::google::protobuf::UninterpretedOption* add_uninterpreted_option();
- ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
- mutable_uninterpreted_option();
- const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
- uninterpreted_option() const;
+ // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
+ bool has_optimize_for() const;
+ void clear_optimize_for();
+ static const int kOptimizeForFieldNumber = 9;
+ ::google::protobuf::FileOptions_OptimizeMode optimize_for() const;
+ void set_optimize_for(::google::protobuf::FileOptions_OptimizeMode value);
GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(FileOptions)
// @@protoc_insertion_point(class_scope:google.protobuf.FileOptions)
private:
- inline void set_has_java_package();
- inline void clear_has_java_package();
- inline void set_has_java_outer_classname();
- inline void clear_has_java_outer_classname();
- inline void set_has_java_multiple_files();
- inline void clear_has_java_multiple_files();
- inline void set_has_java_generate_equals_and_hash();
- inline void clear_has_java_generate_equals_and_hash();
- inline void set_has_java_string_check_utf8();
- inline void clear_has_java_string_check_utf8();
- inline void set_has_optimize_for();
- inline void clear_has_optimize_for();
- inline void set_has_go_package();
- inline void clear_has_go_package();
- inline void set_has_cc_generic_services();
- inline void clear_has_cc_generic_services();
- inline void set_has_java_generic_services();
- inline void clear_has_java_generic_services();
- inline void set_has_py_generic_services();
- inline void clear_has_py_generic_services();
- inline void set_has_deprecated();
- inline void clear_has_deprecated();
- inline void set_has_cc_enable_arenas();
- inline void clear_has_cc_enable_arenas();
- inline void set_has_objc_class_prefix();
- inline void clear_has_objc_class_prefix();
- inline void set_has_csharp_namespace();
- inline void clear_has_csharp_namespace();
+ void set_has_java_package();
+ void clear_has_java_package();
+ void set_has_java_outer_classname();
+ void clear_has_java_outer_classname();
+ void set_has_java_multiple_files();
+ void clear_has_java_multiple_files();
+ void set_has_java_generate_equals_and_hash();
+ void clear_has_java_generate_equals_and_hash();
+ void set_has_java_string_check_utf8();
+ void clear_has_java_string_check_utf8();
+ void set_has_optimize_for();
+ void clear_has_optimize_for();
+ void set_has_go_package();
+ void clear_has_go_package();
+ void set_has_cc_generic_services();
+ void clear_has_cc_generic_services();
+ void set_has_java_generic_services();
+ void clear_has_java_generic_services();
+ void set_has_py_generic_services();
+ void clear_has_py_generic_services();
+ void set_has_deprecated();
+ void clear_has_deprecated();
+ void set_has_cc_enable_arenas();
+ void clear_has_cc_enable_arenas();
+ void set_has_objc_class_prefix();
+ void clear_has_objc_class_prefix();
+ void set_has_csharp_namespace();
+ void clear_has_csharp_namespace();
+ void set_has_swift_prefix();
+ void clear_has_swift_prefix();
::google::protobuf::internal::ExtensionSet _extensions_;
@@ -2216,6 +2358,7 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p
::google::protobuf::internal::ArenaStringPtr go_package_;
::google::protobuf::internal::ArenaStringPtr objc_class_prefix_;
::google::protobuf::internal::ArenaStringPtr csharp_namespace_;
+ ::google::protobuf::internal::ArenaStringPtr swift_prefix_;
bool java_multiple_files_;
bool java_generate_equals_and_hash_;
bool java_string_check_utf8_;
@@ -2225,15 +2368,8 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p
bool deprecated_;
bool cc_enable_arenas_;
int optimize_for_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<FileOptions> FileOptions_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MessageOptions) */ {
@@ -2259,54 +2395,70 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /*
static const ::google::protobuf::Descriptor* descriptor();
static const MessageOptions& default_instance();
- static const MessageOptions* internal_default_instance();
+ static inline const MessageOptions* internal_default_instance() {
+ return reinterpret_cast<const MessageOptions*>(
+ &_MessageOptions_default_instance_);
+ }
void Swap(MessageOptions* other);
// implements Message ----------------------------------------------
- inline MessageOptions* New() const { return New(NULL); }
+ inline MessageOptions* New() const PROTOBUF_FINAL { return New(NULL); }
- MessageOptions* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ MessageOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const MessageOptions& from);
void MergeFrom(const MessageOptions& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(MessageOptions* other);
- void UnsafeMergeFrom(const MessageOptions& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
+ // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
+ int uninterpreted_option_size() const;
+ void clear_uninterpreted_option();
+ static const int kUninterpretedOptionFieldNumber = 999;
+ const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;
+ ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index);
+ ::google::protobuf::UninterpretedOption* add_uninterpreted_option();
+ ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
+ mutable_uninterpreted_option();
+ const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
+ uninterpreted_option() const;
+
// optional bool message_set_wire_format = 1 [default = false];
bool has_message_set_wire_format() const;
void clear_message_set_wire_format();
@@ -2335,29 +2487,17 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /*
bool map_entry() const;
void set_map_entry(bool value);
- // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
- int uninterpreted_option_size() const;
- void clear_uninterpreted_option();
- static const int kUninterpretedOptionFieldNumber = 999;
- const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;
- ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index);
- ::google::protobuf::UninterpretedOption* add_uninterpreted_option();
- ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
- mutable_uninterpreted_option();
- const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
- uninterpreted_option() const;
-
GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(MessageOptions)
// @@protoc_insertion_point(class_scope:google.protobuf.MessageOptions)
private:
- inline void set_has_message_set_wire_format();
- inline void clear_has_message_set_wire_format();
- inline void set_has_no_standard_descriptor_accessor();
- inline void clear_has_no_standard_descriptor_accessor();
- inline void set_has_deprecated();
- inline void clear_has_deprecated();
- inline void set_has_map_entry();
- inline void clear_has_map_entry();
+ void set_has_message_set_wire_format();
+ void clear_has_message_set_wire_format();
+ void set_has_no_standard_descriptor_accessor();
+ void clear_has_no_standard_descriptor_accessor();
+ void set_has_deprecated();
+ void clear_has_deprecated();
+ void set_has_map_entry();
+ void clear_has_map_entry();
::google::protobuf::internal::ExtensionSet _extensions_;
@@ -2369,15 +2509,8 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /*
bool no_standard_descriptor_accessor_;
bool deprecated_;
bool map_entry_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<MessageOptions> MessageOptions_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldOptions) */ {
@@ -2403,49 +2536,53 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@
static const ::google::protobuf::Descriptor* descriptor();
static const FieldOptions& default_instance();
- static const FieldOptions* internal_default_instance();
+ static inline const FieldOptions* internal_default_instance() {
+ return reinterpret_cast<const FieldOptions*>(
+ &_FieldOptions_default_instance_);
+ }
void Swap(FieldOptions* other);
// implements Message ----------------------------------------------
- inline FieldOptions* New() const { return New(NULL); }
+ inline FieldOptions* New() const PROTOBUF_FINAL { return New(NULL); }
- FieldOptions* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ FieldOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const FieldOptions& from);
void MergeFrom(const FieldOptions& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(FieldOptions* other);
- void UnsafeMergeFrom(const FieldOptions& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
@@ -2507,6 +2644,18 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@
// accessors -------------------------------------------------------
+ // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
+ int uninterpreted_option_size() const;
+ void clear_uninterpreted_option();
+ static const int kUninterpretedOptionFieldNumber = 999;
+ const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;
+ ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index);
+ ::google::protobuf::UninterpretedOption* add_uninterpreted_option();
+ ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
+ mutable_uninterpreted_option();
+ const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
+ uninterpreted_option() const;
+
// optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];
bool has_ctype() const;
void clear_ctype();
@@ -2514,13 +2663,6 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@
::google::protobuf::FieldOptions_CType ctype() const;
void set_ctype(::google::protobuf::FieldOptions_CType value);
- // optional bool packed = 2;
- bool has_packed() const;
- void clear_packed();
- static const int kPackedFieldNumber = 2;
- bool packed() const;
- void set_packed(bool value);
-
// optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];
bool has_jstype() const;
void clear_jstype();
@@ -2528,6 +2670,13 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@
::google::protobuf::FieldOptions_JSType jstype() const;
void set_jstype(::google::protobuf::FieldOptions_JSType value);
+ // optional bool packed = 2;
+ bool has_packed() const;
+ void clear_packed();
+ static const int kPackedFieldNumber = 2;
+ bool packed() const;
+ void set_packed(bool value);
+
// optional bool lazy = 5 [default = false];
bool has_lazy() const;
void clear_lazy();
@@ -2549,33 +2698,21 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@
bool weak() const;
void set_weak(bool value);
- // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
- int uninterpreted_option_size() const;
- void clear_uninterpreted_option();
- static const int kUninterpretedOptionFieldNumber = 999;
- const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;
- ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index);
- ::google::protobuf::UninterpretedOption* add_uninterpreted_option();
- ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
- mutable_uninterpreted_option();
- const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
- uninterpreted_option() const;
-
GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(FieldOptions)
// @@protoc_insertion_point(class_scope:google.protobuf.FieldOptions)
private:
- inline void set_has_ctype();
- inline void clear_has_ctype();
- inline void set_has_packed();
- inline void clear_has_packed();
- inline void set_has_jstype();
- inline void clear_has_jstype();
- inline void set_has_lazy();
- inline void clear_has_lazy();
- inline void set_has_deprecated();
- inline void clear_has_deprecated();
- inline void set_has_weak();
- inline void clear_has_weak();
+ void set_has_ctype();
+ void clear_has_ctype();
+ void set_has_packed();
+ void clear_has_packed();
+ void set_has_jstype();
+ void clear_has_jstype();
+ void set_has_lazy();
+ void clear_has_lazy();
+ void set_has_deprecated();
+ void clear_has_deprecated();
+ void set_has_weak();
+ void clear_has_weak();
::google::protobuf::internal::ExtensionSet _extensions_;
@@ -2589,15 +2726,8 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@
bool lazy_;
bool deprecated_;
bool weak_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<FieldOptions> FieldOptions_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.OneofOptions) */ {
@@ -2623,49 +2753,53 @@ class LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@
static const ::google::protobuf::Descriptor* descriptor();
static const OneofOptions& default_instance();
- static const OneofOptions* internal_default_instance();
+ static inline const OneofOptions* internal_default_instance() {
+ return reinterpret_cast<const OneofOptions*>(
+ &_OneofOptions_default_instance_);
+ }
void Swap(OneofOptions* other);
// implements Message ----------------------------------------------
- inline OneofOptions* New() const { return New(NULL); }
+ inline OneofOptions* New() const PROTOBUF_FINAL { return New(NULL); }
- OneofOptions* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ OneofOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const OneofOptions& from);
void MergeFrom(const OneofOptions& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(OneofOptions* other);
- void UnsafeMergeFrom(const OneofOptions& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
@@ -2693,15 +2827,8 @@ class LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@
::google::protobuf::internal::HasBits<1> _has_bits_;
mutable int _cached_size_;
::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<OneofOptions> OneofOptions_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumOptions) */ {
@@ -2727,54 +2854,70 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@p
static const ::google::protobuf::Descriptor* descriptor();
static const EnumOptions& default_instance();
- static const EnumOptions* internal_default_instance();
+ static inline const EnumOptions* internal_default_instance() {
+ return reinterpret_cast<const EnumOptions*>(
+ &_EnumOptions_default_instance_);
+ }
void Swap(EnumOptions* other);
// implements Message ----------------------------------------------
- inline EnumOptions* New() const { return New(NULL); }
+ inline EnumOptions* New() const PROTOBUF_FINAL { return New(NULL); }
- EnumOptions* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ EnumOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const EnumOptions& from);
void MergeFrom(const EnumOptions& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(EnumOptions* other);
- void UnsafeMergeFrom(const EnumOptions& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
+ // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
+ int uninterpreted_option_size() const;
+ void clear_uninterpreted_option();
+ static const int kUninterpretedOptionFieldNumber = 999;
+ const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;
+ ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index);
+ ::google::protobuf::UninterpretedOption* add_uninterpreted_option();
+ ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
+ mutable_uninterpreted_option();
+ const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
+ uninterpreted_option() const;
+
// optional bool allow_alias = 2;
bool has_allow_alias() const;
void clear_allow_alias();
@@ -2789,25 +2932,13 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@p
bool deprecated() const;
void set_deprecated(bool value);
- // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
- int uninterpreted_option_size() const;
- void clear_uninterpreted_option();
- static const int kUninterpretedOptionFieldNumber = 999;
- const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;
- ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index);
- ::google::protobuf::UninterpretedOption* add_uninterpreted_option();
- ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*
- mutable_uninterpreted_option();
- const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
- uninterpreted_option() const;
-
GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(EnumOptions)
// @@protoc_insertion_point(class_scope:google.protobuf.EnumOptions)
private:
- inline void set_has_allow_alias();
- inline void clear_has_allow_alias();
- inline void set_has_deprecated();
- inline void clear_has_deprecated();
+ void set_has_allow_alias();
+ void clear_has_allow_alias();
+ void set_has_deprecated();
+ void clear_has_deprecated();
::google::protobuf::internal::ExtensionSet _extensions_;
@@ -2817,15 +2948,8 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@p
::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_;
bool allow_alias_;
bool deprecated_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<EnumOptions> EnumOptions_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValueOptions) */ {
@@ -2851,61 +2975,58 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message /
static const ::google::protobuf::Descriptor* descriptor();
static const EnumValueOptions& default_instance();
- static const EnumValueOptions* internal_default_instance();
+ static inline const EnumValueOptions* internal_default_instance() {
+ return reinterpret_cast<const EnumValueOptions*>(
+ &_EnumValueOptions_default_instance_);
+ }
void Swap(EnumValueOptions* other);
// implements Message ----------------------------------------------
- inline EnumValueOptions* New() const { return New(NULL); }
+ inline EnumValueOptions* New() const PROTOBUF_FINAL { return New(NULL); }
- EnumValueOptions* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ EnumValueOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const EnumValueOptions& from);
void MergeFrom(const EnumValueOptions& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(EnumValueOptions* other);
- void UnsafeMergeFrom(const EnumValueOptions& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
- // optional bool deprecated = 1 [default = false];
- bool has_deprecated() const;
- void clear_deprecated();
- static const int kDeprecatedFieldNumber = 1;
- bool deprecated() const;
- void set_deprecated(bool value);
-
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
int uninterpreted_option_size() const;
void clear_uninterpreted_option();
@@ -2918,11 +3039,18 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message /
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
uninterpreted_option() const;
+ // optional bool deprecated = 1 [default = false];
+ bool has_deprecated() const;
+ void clear_deprecated();
+ static const int kDeprecatedFieldNumber = 1;
+ bool deprecated() const;
+ void set_deprecated(bool value);
+
GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(EnumValueOptions)
// @@protoc_insertion_point(class_scope:google.protobuf.EnumValueOptions)
private:
- inline void set_has_deprecated();
- inline void clear_has_deprecated();
+ void set_has_deprecated();
+ void clear_has_deprecated();
::google::protobuf::internal::ExtensionSet _extensions_;
@@ -2931,15 +3059,8 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message /
mutable int _cached_size_;
::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_;
bool deprecated_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<EnumValueOptions> EnumValueOptions_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ServiceOptions) */ {
@@ -2965,61 +3086,58 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /*
static const ::google::protobuf::Descriptor* descriptor();
static const ServiceOptions& default_instance();
- static const ServiceOptions* internal_default_instance();
+ static inline const ServiceOptions* internal_default_instance() {
+ return reinterpret_cast<const ServiceOptions*>(
+ &_ServiceOptions_default_instance_);
+ }
void Swap(ServiceOptions* other);
// implements Message ----------------------------------------------
- inline ServiceOptions* New() const { return New(NULL); }
+ inline ServiceOptions* New() const PROTOBUF_FINAL { return New(NULL); }
- ServiceOptions* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ ServiceOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const ServiceOptions& from);
void MergeFrom(const ServiceOptions& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(ServiceOptions* other);
- void UnsafeMergeFrom(const ServiceOptions& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
- // optional bool deprecated = 33 [default = false];
- bool has_deprecated() const;
- void clear_deprecated();
- static const int kDeprecatedFieldNumber = 33;
- bool deprecated() const;
- void set_deprecated(bool value);
-
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
int uninterpreted_option_size() const;
void clear_uninterpreted_option();
@@ -3032,11 +3150,18 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /*
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
uninterpreted_option() const;
+ // optional bool deprecated = 33 [default = false];
+ bool has_deprecated() const;
+ void clear_deprecated();
+ static const int kDeprecatedFieldNumber = 33;
+ bool deprecated() const;
+ void set_deprecated(bool value);
+
GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(ServiceOptions)
// @@protoc_insertion_point(class_scope:google.protobuf.ServiceOptions)
private:
- inline void set_has_deprecated();
- inline void clear_has_deprecated();
+ void set_has_deprecated();
+ void clear_has_deprecated();
::google::protobuf::internal::ExtensionSet _extensions_;
@@ -3045,15 +3170,8 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /*
mutable int _cached_size_;
::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_;
bool deprecated_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<ServiceOptions> ServiceOptions_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MethodOptions) */ {
@@ -3079,60 +3197,85 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @
static const ::google::protobuf::Descriptor* descriptor();
static const MethodOptions& default_instance();
- static const MethodOptions* internal_default_instance();
+ static inline const MethodOptions* internal_default_instance() {
+ return reinterpret_cast<const MethodOptions*>(
+ &_MethodOptions_default_instance_);
+ }
void Swap(MethodOptions* other);
// implements Message ----------------------------------------------
- inline MethodOptions* New() const { return New(NULL); }
+ inline MethodOptions* New() const PROTOBUF_FINAL { return New(NULL); }
- MethodOptions* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ MethodOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const MethodOptions& from);
void MergeFrom(const MethodOptions& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(MethodOptions* other);
- void UnsafeMergeFrom(const MethodOptions& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
- // accessors -------------------------------------------------------
+ typedef MethodOptions_IdempotencyLevel IdempotencyLevel;
+ static const IdempotencyLevel IDEMPOTENCY_UNKNOWN =
+ MethodOptions_IdempotencyLevel_IDEMPOTENCY_UNKNOWN;
+ static const IdempotencyLevel NO_SIDE_EFFECTS =
+ MethodOptions_IdempotencyLevel_NO_SIDE_EFFECTS;
+ static const IdempotencyLevel IDEMPOTENT =
+ MethodOptions_IdempotencyLevel_IDEMPOTENT;
+ static inline bool IdempotencyLevel_IsValid(int value) {
+ return MethodOptions_IdempotencyLevel_IsValid(value);
+ }
+ static const IdempotencyLevel IdempotencyLevel_MIN =
+ MethodOptions_IdempotencyLevel_IdempotencyLevel_MIN;
+ static const IdempotencyLevel IdempotencyLevel_MAX =
+ MethodOptions_IdempotencyLevel_IdempotencyLevel_MAX;
+ static const int IdempotencyLevel_ARRAYSIZE =
+ MethodOptions_IdempotencyLevel_IdempotencyLevel_ARRAYSIZE;
+ static inline const ::google::protobuf::EnumDescriptor*
+ IdempotencyLevel_descriptor() {
+ return MethodOptions_IdempotencyLevel_descriptor();
+ }
+ static inline const ::std::string& IdempotencyLevel_Name(IdempotencyLevel value) {
+ return MethodOptions_IdempotencyLevel_Name(value);
+ }
+ static inline bool IdempotencyLevel_Parse(const ::std::string& name,
+ IdempotencyLevel* value) {
+ return MethodOptions_IdempotencyLevel_Parse(name, value);
+ }
- // optional bool deprecated = 33 [default = false];
- bool has_deprecated() const;
- void clear_deprecated();
- static const int kDeprecatedFieldNumber = 33;
- bool deprecated() const;
- void set_deprecated(bool value);
+ // accessors -------------------------------------------------------
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
int uninterpreted_option_size() const;
@@ -3146,11 +3289,27 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&
uninterpreted_option() const;
+ // optional bool deprecated = 33 [default = false];
+ bool has_deprecated() const;
+ void clear_deprecated();
+ static const int kDeprecatedFieldNumber = 33;
+ bool deprecated() const;
+ void set_deprecated(bool value);
+
+ // optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];
+ bool has_idempotency_level() const;
+ void clear_idempotency_level();
+ static const int kIdempotencyLevelFieldNumber = 34;
+ ::google::protobuf::MethodOptions_IdempotencyLevel idempotency_level() const;
+ void set_idempotency_level(::google::protobuf::MethodOptions_IdempotencyLevel value);
+
GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(MethodOptions)
// @@protoc_insertion_point(class_scope:google.protobuf.MethodOptions)
private:
- inline void set_has_deprecated();
- inline void clear_has_deprecated();
+ void set_has_deprecated();
+ void clear_has_deprecated();
+ void set_has_idempotency_level();
+ void clear_has_idempotency_level();
::google::protobuf::internal::ExtensionSet _extensions_;
@@ -3159,15 +3318,9 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @
mutable int _cached_size_;
::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_;
bool deprecated_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();
-
- void InitAsDefaultInstance();
+ int idempotency_level_;
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<MethodOptions> MethodOptions_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UninterpretedOption.NamePart) */ {
@@ -3193,49 +3346,53 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu
static const ::google::protobuf::Descriptor* descriptor();
static const UninterpretedOption_NamePart& default_instance();
- static const UninterpretedOption_NamePart* internal_default_instance();
+ static inline const UninterpretedOption_NamePart* internal_default_instance() {
+ return reinterpret_cast<const UninterpretedOption_NamePart*>(
+ &_UninterpretedOption_NamePart_default_instance_);
+ }
void Swap(UninterpretedOption_NamePart* other);
// implements Message ----------------------------------------------
- inline UninterpretedOption_NamePart* New() const { return New(NULL); }
+ inline UninterpretedOption_NamePart* New() const PROTOBUF_FINAL { return New(NULL); }
- UninterpretedOption_NamePart* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ UninterpretedOption_NamePart* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const UninterpretedOption_NamePart& from);
void MergeFrom(const UninterpretedOption_NamePart& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(UninterpretedOption_NamePart* other);
- void UnsafeMergeFrom(const UninterpretedOption_NamePart& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
@@ -3247,6 +3404,9 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu
static const int kNamePartFieldNumber = 1;
const ::std::string& name_part() const;
void set_name_part(const ::std::string& value);
+ #if LANG_CXX11
+ void set_name_part(::std::string&& value);
+ #endif
void set_name_part(const char* value);
void set_name_part(const char* value, size_t size);
::std::string* mutable_name_part();
@@ -3262,10 +3422,10 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu
// @@protoc_insertion_point(class_scope:google.protobuf.UninterpretedOption.NamePart)
private:
- inline void set_has_name_part();
- inline void clear_has_name_part();
- inline void set_has_is_extension();
- inline void clear_has_is_extension();
+ void set_has_name_part();
+ void clear_has_name_part();
+ void set_has_is_extension();
+ void clear_has_is_extension();
// helper for ByteSizeLong()
size_t RequiredFieldsByteSizeFallback() const;
@@ -3275,15 +3435,8 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu
mutable int _cached_size_;
::google::protobuf::internal::ArenaStringPtr name_part_;
bool is_extension_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption_NamePart> UninterpretedOption_NamePart_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UninterpretedOption) */ {
@@ -3309,49 +3462,53 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag
static const ::google::protobuf::Descriptor* descriptor();
static const UninterpretedOption& default_instance();
- static const UninterpretedOption* internal_default_instance();
+ static inline const UninterpretedOption* internal_default_instance() {
+ return reinterpret_cast<const UninterpretedOption*>(
+ &_UninterpretedOption_default_instance_);
+ }
void Swap(UninterpretedOption* other);
// implements Message ----------------------------------------------
- inline UninterpretedOption* New() const { return New(NULL); }
+ inline UninterpretedOption* New() const PROTOBUF_FINAL { return New(NULL); }
- UninterpretedOption* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ UninterpretedOption* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const UninterpretedOption& from);
void MergeFrom(const UninterpretedOption& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(UninterpretedOption* other);
- void UnsafeMergeFrom(const UninterpretedOption& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
@@ -3377,39 +3534,24 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag
static const int kIdentifierValueFieldNumber = 3;
const ::std::string& identifier_value() const;
void set_identifier_value(const ::std::string& value);
+ #if LANG_CXX11
+ void set_identifier_value(::std::string&& value);
+ #endif
void set_identifier_value(const char* value);
void set_identifier_value(const char* value, size_t size);
::std::string* mutable_identifier_value();
::std::string* release_identifier_value();
void set_allocated_identifier_value(::std::string* identifier_value);
- // optional uint64 positive_int_value = 4;
- bool has_positive_int_value() const;
- void clear_positive_int_value();
- static const int kPositiveIntValueFieldNumber = 4;
- ::google::protobuf::uint64 positive_int_value() const;
- void set_positive_int_value(::google::protobuf::uint64 value);
-
- // optional int64 negative_int_value = 5;
- bool has_negative_int_value() const;
- void clear_negative_int_value();
- static const int kNegativeIntValueFieldNumber = 5;
- ::google::protobuf::int64 negative_int_value() const;
- void set_negative_int_value(::google::protobuf::int64 value);
-
- // optional double double_value = 6;
- bool has_double_value() const;
- void clear_double_value();
- static const int kDoubleValueFieldNumber = 6;
- double double_value() const;
- void set_double_value(double value);
-
// optional bytes string_value = 7;
bool has_string_value() const;
void clear_string_value();
static const int kStringValueFieldNumber = 7;
const ::std::string& string_value() const;
void set_string_value(const ::std::string& value);
+ #if LANG_CXX11
+ void set_string_value(::std::string&& value);
+ #endif
void set_string_value(const char* value);
void set_string_value(const void* value, size_t size);
::std::string* mutable_string_value();
@@ -3422,26 +3564,50 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag
static const int kAggregateValueFieldNumber = 8;
const ::std::string& aggregate_value() const;
void set_aggregate_value(const ::std::string& value);
+ #if LANG_CXX11
+ void set_aggregate_value(::std::string&& value);
+ #endif
void set_aggregate_value(const char* value);
void set_aggregate_value(const char* value, size_t size);
::std::string* mutable_aggregate_value();
::std::string* release_aggregate_value();
void set_allocated_aggregate_value(::std::string* aggregate_value);
+ // optional uint64 positive_int_value = 4;
+ bool has_positive_int_value() const;
+ void clear_positive_int_value();
+ static const int kPositiveIntValueFieldNumber = 4;
+ ::google::protobuf::uint64 positive_int_value() const;
+ void set_positive_int_value(::google::protobuf::uint64 value);
+
+ // optional int64 negative_int_value = 5;
+ bool has_negative_int_value() const;
+ void clear_negative_int_value();
+ static const int kNegativeIntValueFieldNumber = 5;
+ ::google::protobuf::int64 negative_int_value() const;
+ void set_negative_int_value(::google::protobuf::int64 value);
+
+ // optional double double_value = 6;
+ bool has_double_value() const;
+ void clear_double_value();
+ static const int kDoubleValueFieldNumber = 6;
+ double double_value() const;
+ void set_double_value(double value);
+
// @@protoc_insertion_point(class_scope:google.protobuf.UninterpretedOption)
private:
- inline void set_has_identifier_value();
- inline void clear_has_identifier_value();
- inline void set_has_positive_int_value();
- inline void clear_has_positive_int_value();
- inline void set_has_negative_int_value();
- inline void clear_has_negative_int_value();
- inline void set_has_double_value();
- inline void clear_has_double_value();
- inline void set_has_string_value();
- inline void clear_has_string_value();
- inline void set_has_aggregate_value();
- inline void clear_has_aggregate_value();
+ void set_has_identifier_value();
+ void clear_has_identifier_value();
+ void set_has_positive_int_value();
+ void clear_has_positive_int_value();
+ void set_has_negative_int_value();
+ void clear_has_negative_int_value();
+ void set_has_double_value();
+ void clear_has_double_value();
+ void set_has_string_value();
+ void clear_has_string_value();
+ void set_has_aggregate_value();
+ void clear_has_aggregate_value();
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::google::protobuf::internal::HasBits<1> _has_bits_;
@@ -3453,15 +3619,8 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag
::google::protobuf::uint64 positive_int_value_;
::google::protobuf::int64 negative_int_value_;
double double_value_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption> UninterpretedOption_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceCodeInfo.Location) */ {
@@ -3487,49 +3646,53 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me
static const ::google::protobuf::Descriptor* descriptor();
static const SourceCodeInfo_Location& default_instance();
- static const SourceCodeInfo_Location* internal_default_instance();
+ static inline const SourceCodeInfo_Location* internal_default_instance() {
+ return reinterpret_cast<const SourceCodeInfo_Location*>(
+ &_SourceCodeInfo_Location_default_instance_);
+ }
void Swap(SourceCodeInfo_Location* other);
// implements Message ----------------------------------------------
- inline SourceCodeInfo_Location* New() const { return New(NULL); }
+ inline SourceCodeInfo_Location* New() const PROTOBUF_FINAL { return New(NULL); }
- SourceCodeInfo_Location* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ SourceCodeInfo_Location* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const SourceCodeInfo_Location& from);
void MergeFrom(const SourceCodeInfo_Location& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(SourceCodeInfo_Location* other);
- void UnsafeMergeFrom(const SourceCodeInfo_Location& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
@@ -3559,12 +3722,37 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me
::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
mutable_span();
+ // repeated string leading_detached_comments = 6;
+ int leading_detached_comments_size() const;
+ void clear_leading_detached_comments();
+ static const int kLeadingDetachedCommentsFieldNumber = 6;
+ const ::std::string& leading_detached_comments(int index) const;
+ ::std::string* mutable_leading_detached_comments(int index);
+ void set_leading_detached_comments(int index, const ::std::string& value);
+ #if LANG_CXX11
+ void set_leading_detached_comments(int index, ::std::string&& value);
+ #endif
+ void set_leading_detached_comments(int index, const char* value);
+ void set_leading_detached_comments(int index, const char* value, size_t size);
+ ::std::string* add_leading_detached_comments();
+ void add_leading_detached_comments(const ::std::string& value);
+ #if LANG_CXX11
+ void add_leading_detached_comments(::std::string&& value);
+ #endif
+ void add_leading_detached_comments(const char* value);
+ void add_leading_detached_comments(const char* value, size_t size);
+ const ::google::protobuf::RepeatedPtrField< ::std::string>& leading_detached_comments() const;
+ ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_leading_detached_comments();
+
// optional string leading_comments = 3;
bool has_leading_comments() const;
void clear_leading_comments();
static const int kLeadingCommentsFieldNumber = 3;
const ::std::string& leading_comments() const;
void set_leading_comments(const ::std::string& value);
+ #if LANG_CXX11
+ void set_leading_comments(::std::string&& value);
+ #endif
void set_leading_comments(const char* value);
void set_leading_comments(const char* value, size_t size);
::std::string* mutable_leading_comments();
@@ -3577,34 +3765,21 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me
static const int kTrailingCommentsFieldNumber = 4;
const ::std::string& trailing_comments() const;
void set_trailing_comments(const ::std::string& value);
+ #if LANG_CXX11
+ void set_trailing_comments(::std::string&& value);
+ #endif
void set_trailing_comments(const char* value);
void set_trailing_comments(const char* value, size_t size);
::std::string* mutable_trailing_comments();
::std::string* release_trailing_comments();
void set_allocated_trailing_comments(::std::string* trailing_comments);
- // repeated string leading_detached_comments = 6;
- int leading_detached_comments_size() const;
- void clear_leading_detached_comments();
- static const int kLeadingDetachedCommentsFieldNumber = 6;
- const ::std::string& leading_detached_comments(int index) const;
- ::std::string* mutable_leading_detached_comments(int index);
- void set_leading_detached_comments(int index, const ::std::string& value);
- void set_leading_detached_comments(int index, const char* value);
- void set_leading_detached_comments(int index, const char* value, size_t size);
- ::std::string* add_leading_detached_comments();
- void add_leading_detached_comments(const ::std::string& value);
- void add_leading_detached_comments(const char* value);
- void add_leading_detached_comments(const char* value, size_t size);
- const ::google::protobuf::RepeatedPtrField< ::std::string>& leading_detached_comments() const;
- ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_leading_detached_comments();
-
// @@protoc_insertion_point(class_scope:google.protobuf.SourceCodeInfo.Location)
private:
- inline void set_has_leading_comments();
- inline void clear_has_leading_comments();
- inline void set_has_trailing_comments();
- inline void clear_has_trailing_comments();
+ void set_has_leading_comments();
+ void clear_has_leading_comments();
+ void set_has_trailing_comments();
+ void clear_has_trailing_comments();
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::google::protobuf::internal::HasBits<1> _has_bits_;
@@ -3616,15 +3791,8 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me
::google::protobuf::RepeatedPtrField< ::std::string> leading_detached_comments_;
::google::protobuf::internal::ArenaStringPtr leading_comments_;
::google::protobuf::internal::ArenaStringPtr trailing_comments_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo_Location> SourceCodeInfo_Location_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceCodeInfo) */ {
@@ -3650,49 +3818,53 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /*
static const ::google::protobuf::Descriptor* descriptor();
static const SourceCodeInfo& default_instance();
- static const SourceCodeInfo* internal_default_instance();
+ static inline const SourceCodeInfo* internal_default_instance() {
+ return reinterpret_cast<const SourceCodeInfo*>(
+ &_SourceCodeInfo_default_instance_);
+ }
void Swap(SourceCodeInfo* other);
// implements Message ----------------------------------------------
- inline SourceCodeInfo* New() const { return New(NULL); }
+ inline SourceCodeInfo* New() const PROTOBUF_FINAL { return New(NULL); }
- SourceCodeInfo* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ SourceCodeInfo* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const SourceCodeInfo& from);
void MergeFrom(const SourceCodeInfo& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(SourceCodeInfo* other);
- void UnsafeMergeFrom(const SourceCodeInfo& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
@@ -3719,15 +3891,8 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /*
::google::protobuf::internal::HasBits<1> _has_bits_;
mutable int _cached_size_;
::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location > location_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo> SourceCodeInfo_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.GeneratedCodeInfo.Annotation) */ {
@@ -3753,49 +3918,53 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu
static const ::google::protobuf::Descriptor* descriptor();
static const GeneratedCodeInfo_Annotation& default_instance();
- static const GeneratedCodeInfo_Annotation* internal_default_instance();
+ static inline const GeneratedCodeInfo_Annotation* internal_default_instance() {
+ return reinterpret_cast<const GeneratedCodeInfo_Annotation*>(
+ &_GeneratedCodeInfo_Annotation_default_instance_);
+ }
void Swap(GeneratedCodeInfo_Annotation* other);
// implements Message ----------------------------------------------
- inline GeneratedCodeInfo_Annotation* New() const { return New(NULL); }
+ inline GeneratedCodeInfo_Annotation* New() const PROTOBUF_FINAL { return New(NULL); }
- GeneratedCodeInfo_Annotation* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ GeneratedCodeInfo_Annotation* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const GeneratedCodeInfo_Annotation& from);
void MergeFrom(const GeneratedCodeInfo_Annotation& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(GeneratedCodeInfo_Annotation* other);
- void UnsafeMergeFrom(const GeneratedCodeInfo_Annotation& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
@@ -3819,6 +3988,9 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu
static const int kSourceFileFieldNumber = 2;
const ::std::string& source_file() const;
void set_source_file(const ::std::string& value);
+ #if LANG_CXX11
+ void set_source_file(::std::string&& value);
+ #endif
void set_source_file(const char* value);
void set_source_file(const char* value, size_t size);
::std::string* mutable_source_file();
@@ -3841,12 +4013,12 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu
// @@protoc_insertion_point(class_scope:google.protobuf.GeneratedCodeInfo.Annotation)
private:
- inline void set_has_source_file();
- inline void clear_has_source_file();
- inline void set_has_begin();
- inline void clear_has_begin();
- inline void set_has_end();
- inline void clear_has_end();
+ void set_has_source_file();
+ void clear_has_source_file();
+ void set_has_begin();
+ void clear_has_begin();
+ void set_has_end();
+ void clear_has_end();
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::google::protobuf::internal::HasBits<1> _has_bits_;
@@ -3856,15 +4028,8 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu
::google::protobuf::internal::ArenaStringPtr source_file_;
::google::protobuf::int32 begin_;
::google::protobuf::int32 end_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo_Annotation> GeneratedCodeInfo_Annotation_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.GeneratedCodeInfo) */ {
@@ -3890,49 +4055,53 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message
static const ::google::protobuf::Descriptor* descriptor();
static const GeneratedCodeInfo& default_instance();
- static const GeneratedCodeInfo* internal_default_instance();
+ static inline const GeneratedCodeInfo* internal_default_instance() {
+ return reinterpret_cast<const GeneratedCodeInfo*>(
+ &_GeneratedCodeInfo_default_instance_);
+ }
void Swap(GeneratedCodeInfo* other);
// implements Message ----------------------------------------------
- inline GeneratedCodeInfo* New() const { return New(NULL); }
+ inline GeneratedCodeInfo* New() const PROTOBUF_FINAL { return New(NULL); }
- GeneratedCodeInfo* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ GeneratedCodeInfo* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const GeneratedCodeInfo& from);
void MergeFrom(const GeneratedCodeInfo& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(GeneratedCodeInfo* other);
- void UnsafeMergeFrom(const GeneratedCodeInfo& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
@@ -3959,15 +4128,8 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message
::google::protobuf::internal::HasBits<1> _has_bits_;
mutable int _cached_size_;
::google::protobuf::RepeatedPtrField< ::google::protobuf::GeneratedCodeInfo_Annotation > annotation_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fdescriptor_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo> GeneratedCodeInfo_default_instance_;
-
// ===================================================================
@@ -4006,9 +4168,6 @@ FileDescriptorSet::file() const {
return file_;
}
-inline const FileDescriptorSet* FileDescriptorSet::internal_default_instance() {
- return &FileDescriptorSet_default_instance_.get();
-}
// -------------------------------------------------------------------
// FileDescriptorProto
@@ -4029,13 +4188,21 @@ inline void FileDescriptorProto::clear_name() {
}
inline const ::std::string& FileDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.GetNoArena();
}
inline void FileDescriptorProto::set_name(const ::std::string& value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.name)
}
+#if LANG_CXX11
+inline void FileDescriptorProto::set_name(::std::string&& value) {
+ set_has_name();
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileDescriptorProto.name)
+}
+#endif
inline void FileDescriptorProto::set_name(const char* value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -4083,13 +4250,21 @@ inline void FileDescriptorProto::clear_package() {
}
inline const ::std::string& FileDescriptorProto::package() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.package)
- return package_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return package_.GetNoArena();
}
inline void FileDescriptorProto::set_package(const ::std::string& value) {
set_has_package();
package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.package)
}
+#if LANG_CXX11
+inline void FileDescriptorProto::set_package(::std::string&& value) {
+ set_has_package();
+ package_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileDescriptorProto.package)
+}
+#endif
inline void FileDescriptorProto::set_package(const char* value) {
set_has_package();
package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -4140,6 +4315,12 @@ inline void FileDescriptorProto::set_dependency(int index, const ::std::string&
// @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.dependency)
dependency_.Mutable(index)->assign(value);
}
+#if LANG_CXX11
+inline void FileDescriptorProto::set_dependency(int index, ::std::string&& value) {
+ // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.dependency)
+ dependency_.Mutable(index)->assign(std::move(value));
+}
+#endif
inline void FileDescriptorProto::set_dependency(int index, const char* value) {
dependency_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.dependency)
@@ -4157,6 +4338,12 @@ inline void FileDescriptorProto::add_dependency(const ::std::string& value) {
dependency_.Add()->assign(value);
// @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.dependency)
}
+#if LANG_CXX11
+inline void FileDescriptorProto::add_dependency(::std::string&& value) {
+ dependency_.Add()->assign(std::move(value));
+ // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.dependency)
+}
+#endif
inline void FileDescriptorProto::add_dependency(const char* value) {
dependency_.Add()->assign(value);
// @@protoc_insertion_point(field_add_char:google.protobuf.FileDescriptorProto.dependency)
@@ -4358,13 +4545,13 @@ FileDescriptorProto::extension() const {
// optional .google.protobuf.FileOptions options = 8;
inline bool FileDescriptorProto::has_options() const {
- return (_has_bits_[0] & 0x00000200u) != 0;
+ return (_has_bits_[0] & 0x00000008u) != 0;
}
inline void FileDescriptorProto::set_has_options() {
- _has_bits_[0] |= 0x00000200u;
+ _has_bits_[0] |= 0x00000008u;
}
inline void FileDescriptorProto::clear_has_options() {
- _has_bits_[0] &= ~0x00000200u;
+ _has_bits_[0] &= ~0x00000008u;
}
inline void FileDescriptorProto::clear_options() {
if (options_ != NULL) options_->::google::protobuf::FileOptions::Clear();
@@ -4403,13 +4590,13 @@ inline void FileDescriptorProto::set_allocated_options(::google::protobuf::FileO
// optional .google.protobuf.SourceCodeInfo source_code_info = 9;
inline bool FileDescriptorProto::has_source_code_info() const {
- return (_has_bits_[0] & 0x00000400u) != 0;
+ return (_has_bits_[0] & 0x00000010u) != 0;
}
inline void FileDescriptorProto::set_has_source_code_info() {
- _has_bits_[0] |= 0x00000400u;
+ _has_bits_[0] |= 0x00000010u;
}
inline void FileDescriptorProto::clear_has_source_code_info() {
- _has_bits_[0] &= ~0x00000400u;
+ _has_bits_[0] &= ~0x00000010u;
}
inline void FileDescriptorProto::clear_source_code_info() {
if (source_code_info_ != NULL) source_code_info_->::google::protobuf::SourceCodeInfo::Clear();
@@ -4448,13 +4635,13 @@ inline void FileDescriptorProto::set_allocated_source_code_info(::google::protob
// optional string syntax = 12;
inline bool FileDescriptorProto::has_syntax() const {
- return (_has_bits_[0] & 0x00000800u) != 0;
+ return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void FileDescriptorProto::set_has_syntax() {
- _has_bits_[0] |= 0x00000800u;
+ _has_bits_[0] |= 0x00000004u;
}
inline void FileDescriptorProto::clear_has_syntax() {
- _has_bits_[0] &= ~0x00000800u;
+ _has_bits_[0] &= ~0x00000004u;
}
inline void FileDescriptorProto::clear_syntax() {
syntax_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -4462,13 +4649,21 @@ inline void FileDescriptorProto::clear_syntax() {
}
inline const ::std::string& FileDescriptorProto::syntax() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.syntax)
- return syntax_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return syntax_.GetNoArena();
}
inline void FileDescriptorProto::set_syntax(const ::std::string& value) {
set_has_syntax();
syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.syntax)
}
+#if LANG_CXX11
+inline void FileDescriptorProto::set_syntax(::std::string&& value) {
+ set_has_syntax();
+ syntax_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileDescriptorProto.syntax)
+}
+#endif
inline void FileDescriptorProto::set_syntax(const char* value) {
set_has_syntax();
syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -4500,9 +4695,6 @@ inline void FileDescriptorProto::set_allocated_syntax(::std::string* syntax) {
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.syntax)
}
-inline const FileDescriptorProto* FileDescriptorProto::internal_default_instance() {
- return &FileDescriptorProto_default_instance_.get();
-}
// -------------------------------------------------------------------
// DescriptorProto_ExtensionRange
@@ -4555,9 +4747,6 @@ inline void DescriptorProto_ExtensionRange::set_end(::google::protobuf::int32 va
// @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.end)
}
-inline const DescriptorProto_ExtensionRange* DescriptorProto_ExtensionRange::internal_default_instance() {
- return &DescriptorProto_ExtensionRange_default_instance_.get();
-}
// -------------------------------------------------------------------
// DescriptorProto_ReservedRange
@@ -4610,9 +4799,6 @@ inline void DescriptorProto_ReservedRange::set_end(::google::protobuf::int32 val
// @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.end)
}
-inline const DescriptorProto_ReservedRange* DescriptorProto_ReservedRange::internal_default_instance() {
- return &DescriptorProto_ReservedRange_default_instance_.get();
-}
// -------------------------------------------------------------------
// DescriptorProto
@@ -4633,13 +4819,21 @@ inline void DescriptorProto::clear_name() {
}
inline const ::std::string& DescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.GetNoArena();
}
inline void DescriptorProto::set_name(const ::std::string& value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.name)
}
+#if LANG_CXX11
+inline void DescriptorProto::set_name(::std::string&& value) {
+ set_has_name();
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.DescriptorProto.name)
+}
+#endif
inline void DescriptorProto::set_name(const char* value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -4853,13 +5047,13 @@ DescriptorProto::oneof_decl() const {
// optional .google.protobuf.MessageOptions options = 7;
inline bool DescriptorProto::has_options() const {
- return (_has_bits_[0] & 0x00000080u) != 0;
+ return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void DescriptorProto::set_has_options() {
- _has_bits_[0] |= 0x00000080u;
+ _has_bits_[0] |= 0x00000002u;
}
inline void DescriptorProto::clear_has_options() {
- _has_bits_[0] &= ~0x00000080u;
+ _has_bits_[0] &= ~0x00000002u;
}
inline void DescriptorProto::clear_options() {
if (options_ != NULL) options_->::google::protobuf::MessageOptions::Clear();
@@ -4945,6 +5139,12 @@ inline void DescriptorProto::set_reserved_name(int index, const ::std::string& v
// @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.reserved_name)
reserved_name_.Mutable(index)->assign(value);
}
+#if LANG_CXX11
+inline void DescriptorProto::set_reserved_name(int index, ::std::string&& value) {
+ // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.reserved_name)
+ reserved_name_.Mutable(index)->assign(std::move(value));
+}
+#endif
inline void DescriptorProto::set_reserved_name(int index, const char* value) {
reserved_name_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set_char:google.protobuf.DescriptorProto.reserved_name)
@@ -4962,6 +5162,12 @@ inline void DescriptorProto::add_reserved_name(const ::std::string& value) {
reserved_name_.Add()->assign(value);
// @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_name)
}
+#if LANG_CXX11
+inline void DescriptorProto::add_reserved_name(::std::string&& value) {
+ reserved_name_.Add()->assign(std::move(value));
+ // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_name)
+}
+#endif
inline void DescriptorProto::add_reserved_name(const char* value) {
reserved_name_.Add()->assign(value);
// @@protoc_insertion_point(field_add_char:google.protobuf.DescriptorProto.reserved_name)
@@ -4981,9 +5187,6 @@ DescriptorProto::mutable_reserved_name() {
return &reserved_name_;
}
-inline const DescriptorProto* DescriptorProto::internal_default_instance() {
- return &DescriptorProto_default_instance_.get();
-}
// -------------------------------------------------------------------
// FieldDescriptorProto
@@ -5004,13 +5207,21 @@ inline void FieldDescriptorProto::clear_name() {
}
inline const ::std::string& FieldDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.GetNoArena();
}
inline void FieldDescriptorProto::set_name(const ::std::string& value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.name)
}
+#if LANG_CXX11
+inline void FieldDescriptorProto::set_name(::std::string&& value) {
+ set_has_name();
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.name)
+}
+#endif
inline void FieldDescriptorProto::set_name(const char* value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -5044,13 +5255,13 @@ inline void FieldDescriptorProto::set_allocated_name(::std::string* name) {
// optional int32 number = 3;
inline bool FieldDescriptorProto::has_number() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
+ return (_has_bits_[0] & 0x00000040u) != 0;
}
inline void FieldDescriptorProto::set_has_number() {
- _has_bits_[0] |= 0x00000002u;
+ _has_bits_[0] |= 0x00000040u;
}
inline void FieldDescriptorProto::clear_has_number() {
- _has_bits_[0] &= ~0x00000002u;
+ _has_bits_[0] &= ~0x00000040u;
}
inline void FieldDescriptorProto::clear_number() {
number_ = 0;
@@ -5068,13 +5279,13 @@ inline void FieldDescriptorProto::set_number(::google::protobuf::int32 value) {
// optional .google.protobuf.FieldDescriptorProto.Label label = 4;
inline bool FieldDescriptorProto::has_label() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
+ return (_has_bits_[0] & 0x00000100u) != 0;
}
inline void FieldDescriptorProto::set_has_label() {
- _has_bits_[0] |= 0x00000004u;
+ _has_bits_[0] |= 0x00000100u;
}
inline void FieldDescriptorProto::clear_has_label() {
- _has_bits_[0] &= ~0x00000004u;
+ _has_bits_[0] &= ~0x00000100u;
}
inline void FieldDescriptorProto::clear_label() {
label_ = 1;
@@ -5093,13 +5304,13 @@ inline void FieldDescriptorProto::set_label(::google::protobuf::FieldDescriptorP
// optional .google.protobuf.FieldDescriptorProto.Type type = 5;
inline bool FieldDescriptorProto::has_type() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
+ return (_has_bits_[0] & 0x00000200u) != 0;
}
inline void FieldDescriptorProto::set_has_type() {
- _has_bits_[0] |= 0x00000008u;
+ _has_bits_[0] |= 0x00000200u;
}
inline void FieldDescriptorProto::clear_has_type() {
- _has_bits_[0] &= ~0x00000008u;
+ _has_bits_[0] &= ~0x00000200u;
}
inline void FieldDescriptorProto::clear_type() {
type_ = 1;
@@ -5118,13 +5329,13 @@ inline void FieldDescriptorProto::set_type(::google::protobuf::FieldDescriptorPr
// optional string type_name = 6;
inline bool FieldDescriptorProto::has_type_name() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
+ return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void FieldDescriptorProto::set_has_type_name() {
- _has_bits_[0] |= 0x00000010u;
+ _has_bits_[0] |= 0x00000002u;
}
inline void FieldDescriptorProto::clear_has_type_name() {
- _has_bits_[0] &= ~0x00000010u;
+ _has_bits_[0] &= ~0x00000002u;
}
inline void FieldDescriptorProto::clear_type_name() {
type_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -5132,13 +5343,21 @@ inline void FieldDescriptorProto::clear_type_name() {
}
inline const ::std::string& FieldDescriptorProto::type_name() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.type_name)
- return type_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return type_name_.GetNoArena();
}
inline void FieldDescriptorProto::set_type_name(const ::std::string& value) {
set_has_type_name();
type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.type_name)
}
+#if LANG_CXX11
+inline void FieldDescriptorProto::set_type_name(::std::string&& value) {
+ set_has_type_name();
+ type_name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.type_name)
+}
+#endif
inline void FieldDescriptorProto::set_type_name(const char* value) {
set_has_type_name();
type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -5172,13 +5391,13 @@ inline void FieldDescriptorProto::set_allocated_type_name(::std::string* type_na
// optional string extendee = 2;
inline bool FieldDescriptorProto::has_extendee() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
+ return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void FieldDescriptorProto::set_has_extendee() {
- _has_bits_[0] |= 0x00000020u;
+ _has_bits_[0] |= 0x00000004u;
}
inline void FieldDescriptorProto::clear_has_extendee() {
- _has_bits_[0] &= ~0x00000020u;
+ _has_bits_[0] &= ~0x00000004u;
}
inline void FieldDescriptorProto::clear_extendee() {
extendee_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -5186,13 +5405,21 @@ inline void FieldDescriptorProto::clear_extendee() {
}
inline const ::std::string& FieldDescriptorProto::extendee() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.extendee)
- return extendee_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return extendee_.GetNoArena();
}
inline void FieldDescriptorProto::set_extendee(const ::std::string& value) {
set_has_extendee();
extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.extendee)
}
+#if LANG_CXX11
+inline void FieldDescriptorProto::set_extendee(::std::string&& value) {
+ set_has_extendee();
+ extendee_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.extendee)
+}
+#endif
inline void FieldDescriptorProto::set_extendee(const char* value) {
set_has_extendee();
extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -5226,13 +5453,13 @@ inline void FieldDescriptorProto::set_allocated_extendee(::std::string* extendee
// optional string default_value = 7;
inline bool FieldDescriptorProto::has_default_value() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
+ return (_has_bits_[0] & 0x00000008u) != 0;
}
inline void FieldDescriptorProto::set_has_default_value() {
- _has_bits_[0] |= 0x00000040u;
+ _has_bits_[0] |= 0x00000008u;
}
inline void FieldDescriptorProto::clear_has_default_value() {
- _has_bits_[0] &= ~0x00000040u;
+ _has_bits_[0] &= ~0x00000008u;
}
inline void FieldDescriptorProto::clear_default_value() {
default_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -5240,13 +5467,21 @@ inline void FieldDescriptorProto::clear_default_value() {
}
inline const ::std::string& FieldDescriptorProto::default_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.default_value)
- return default_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return default_value_.GetNoArena();
}
inline void FieldDescriptorProto::set_default_value(const ::std::string& value) {
set_has_default_value();
default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.default_value)
}
+#if LANG_CXX11
+inline void FieldDescriptorProto::set_default_value(::std::string&& value) {
+ set_has_default_value();
+ default_value_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.default_value)
+}
+#endif
inline void FieldDescriptorProto::set_default_value(const char* value) {
set_has_default_value();
default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -5304,13 +5539,13 @@ inline void FieldDescriptorProto::set_oneof_index(::google::protobuf::int32 valu
// optional string json_name = 10;
inline bool FieldDescriptorProto::has_json_name() const {
- return (_has_bits_[0] & 0x00000100u) != 0;
+ return (_has_bits_[0] & 0x00000010u) != 0;
}
inline void FieldDescriptorProto::set_has_json_name() {
- _has_bits_[0] |= 0x00000100u;
+ _has_bits_[0] |= 0x00000010u;
}
inline void FieldDescriptorProto::clear_has_json_name() {
- _has_bits_[0] &= ~0x00000100u;
+ _has_bits_[0] &= ~0x00000010u;
}
inline void FieldDescriptorProto::clear_json_name() {
json_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -5318,13 +5553,21 @@ inline void FieldDescriptorProto::clear_json_name() {
}
inline const ::std::string& FieldDescriptorProto::json_name() const {
// @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.json_name)
- return json_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return json_name_.GetNoArena();
}
inline void FieldDescriptorProto::set_json_name(const ::std::string& value) {
set_has_json_name();
json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.json_name)
}
+#if LANG_CXX11
+inline void FieldDescriptorProto::set_json_name(::std::string&& value) {
+ set_has_json_name();
+ json_name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FieldDescriptorProto.json_name)
+}
+#endif
inline void FieldDescriptorProto::set_json_name(const char* value) {
set_has_json_name();
json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -5358,13 +5601,13 @@ inline void FieldDescriptorProto::set_allocated_json_name(::std::string* json_na
// optional .google.protobuf.FieldOptions options = 8;
inline bool FieldDescriptorProto::has_options() const {
- return (_has_bits_[0] & 0x00000200u) != 0;
+ return (_has_bits_[0] & 0x00000020u) != 0;
}
inline void FieldDescriptorProto::set_has_options() {
- _has_bits_[0] |= 0x00000200u;
+ _has_bits_[0] |= 0x00000020u;
}
inline void FieldDescriptorProto::clear_has_options() {
- _has_bits_[0] &= ~0x00000200u;
+ _has_bits_[0] &= ~0x00000020u;
}
inline void FieldDescriptorProto::clear_options() {
if (options_ != NULL) options_->::google::protobuf::FieldOptions::Clear();
@@ -5401,9 +5644,6 @@ inline void FieldDescriptorProto::set_allocated_options(::google::protobuf::Fiel
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.options)
}
-inline const FieldDescriptorProto* FieldDescriptorProto::internal_default_instance() {
- return &FieldDescriptorProto_default_instance_.get();
-}
// -------------------------------------------------------------------
// OneofDescriptorProto
@@ -5424,13 +5664,21 @@ inline void OneofDescriptorProto::clear_name() {
}
inline const ::std::string& OneofDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.GetNoArena();
}
inline void OneofDescriptorProto::set_name(const ::std::string& value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.OneofDescriptorProto.name)
}
+#if LANG_CXX11
+inline void OneofDescriptorProto::set_name(::std::string&& value) {
+ set_has_name();
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.OneofDescriptorProto.name)
+}
+#endif
inline void OneofDescriptorProto::set_name(const char* value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -5507,9 +5755,6 @@ inline void OneofDescriptorProto::set_allocated_options(::google::protobuf::Oneo
// @@protoc_insertion_point(field_set_allocated:google.protobuf.OneofDescriptorProto.options)
}
-inline const OneofDescriptorProto* OneofDescriptorProto::internal_default_instance() {
- return &OneofDescriptorProto_default_instance_.get();
-}
// -------------------------------------------------------------------
// EnumDescriptorProto
@@ -5530,13 +5775,21 @@ inline void EnumDescriptorProto::clear_name() {
}
inline const ::std::string& EnumDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.GetNoArena();
}
inline void EnumDescriptorProto::set_name(const ::std::string& value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.name)
}
+#if LANG_CXX11
+inline void EnumDescriptorProto::set_name(::std::string&& value) {
+ set_has_name();
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.EnumDescriptorProto.name)
+}
+#endif
inline void EnumDescriptorProto::set_name(const char* value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -5600,13 +5853,13 @@ EnumDescriptorProto::value() const {
// optional .google.protobuf.EnumOptions options = 3;
inline bool EnumDescriptorProto::has_options() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
+ return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void EnumDescriptorProto::set_has_options() {
- _has_bits_[0] |= 0x00000004u;
+ _has_bits_[0] |= 0x00000002u;
}
inline void EnumDescriptorProto::clear_has_options() {
- _has_bits_[0] &= ~0x00000004u;
+ _has_bits_[0] &= ~0x00000002u;
}
inline void EnumDescriptorProto::clear_options() {
if (options_ != NULL) options_->::google::protobuf::EnumOptions::Clear();
@@ -5643,9 +5896,6 @@ inline void EnumDescriptorProto::set_allocated_options(::google::protobuf::EnumO
// @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumDescriptorProto.options)
}
-inline const EnumDescriptorProto* EnumDescriptorProto::internal_default_instance() {
- return &EnumDescriptorProto_default_instance_.get();
-}
// -------------------------------------------------------------------
// EnumValueDescriptorProto
@@ -5666,13 +5916,21 @@ inline void EnumValueDescriptorProto::clear_name() {
}
inline const ::std::string& EnumValueDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.GetNoArena();
}
inline void EnumValueDescriptorProto::set_name(const ::std::string& value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.EnumValueDescriptorProto.name)
}
+#if LANG_CXX11
+inline void EnumValueDescriptorProto::set_name(::std::string&& value) {
+ set_has_name();
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.EnumValueDescriptorProto.name)
+}
+#endif
inline void EnumValueDescriptorProto::set_name(const char* value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -5706,13 +5964,13 @@ inline void EnumValueDescriptorProto::set_allocated_name(::std::string* name) {
// optional int32 number = 2;
inline bool EnumValueDescriptorProto::has_number() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
+ return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void EnumValueDescriptorProto::set_has_number() {
- _has_bits_[0] |= 0x00000002u;
+ _has_bits_[0] |= 0x00000004u;
}
inline void EnumValueDescriptorProto::clear_has_number() {
- _has_bits_[0] &= ~0x00000002u;
+ _has_bits_[0] &= ~0x00000004u;
}
inline void EnumValueDescriptorProto::clear_number() {
number_ = 0;
@@ -5730,13 +5988,13 @@ inline void EnumValueDescriptorProto::set_number(::google::protobuf::int32 value
// optional .google.protobuf.EnumValueOptions options = 3;
inline bool EnumValueDescriptorProto::has_options() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
+ return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void EnumValueDescriptorProto::set_has_options() {
- _has_bits_[0] |= 0x00000004u;
+ _has_bits_[0] |= 0x00000002u;
}
inline void EnumValueDescriptorProto::clear_has_options() {
- _has_bits_[0] &= ~0x00000004u;
+ _has_bits_[0] &= ~0x00000002u;
}
inline void EnumValueDescriptorProto::clear_options() {
if (options_ != NULL) options_->::google::protobuf::EnumValueOptions::Clear();
@@ -5773,9 +6031,6 @@ inline void EnumValueDescriptorProto::set_allocated_options(::google::protobuf::
// @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValueDescriptorProto.options)
}
-inline const EnumValueDescriptorProto* EnumValueDescriptorProto::internal_default_instance() {
- return &EnumValueDescriptorProto_default_instance_.get();
-}
// -------------------------------------------------------------------
// ServiceDescriptorProto
@@ -5796,13 +6051,21 @@ inline void ServiceDescriptorProto::clear_name() {
}
inline const ::std::string& ServiceDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.GetNoArena();
}
inline void ServiceDescriptorProto::set_name(const ::std::string& value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.ServiceDescriptorProto.name)
}
+#if LANG_CXX11
+inline void ServiceDescriptorProto::set_name(::std::string&& value) {
+ set_has_name();
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.ServiceDescriptorProto.name)
+}
+#endif
inline void ServiceDescriptorProto::set_name(const char* value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -5866,13 +6129,13 @@ ServiceDescriptorProto::method() const {
// optional .google.protobuf.ServiceOptions options = 3;
inline bool ServiceDescriptorProto::has_options() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
+ return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void ServiceDescriptorProto::set_has_options() {
- _has_bits_[0] |= 0x00000004u;
+ _has_bits_[0] |= 0x00000002u;
}
inline void ServiceDescriptorProto::clear_has_options() {
- _has_bits_[0] &= ~0x00000004u;
+ _has_bits_[0] &= ~0x00000002u;
}
inline void ServiceDescriptorProto::clear_options() {
if (options_ != NULL) options_->::google::protobuf::ServiceOptions::Clear();
@@ -5909,9 +6172,6 @@ inline void ServiceDescriptorProto::set_allocated_options(::google::protobuf::Se
// @@protoc_insertion_point(field_set_allocated:google.protobuf.ServiceDescriptorProto.options)
}
-inline const ServiceDescriptorProto* ServiceDescriptorProto::internal_default_instance() {
- return &ServiceDescriptorProto_default_instance_.get();
-}
// -------------------------------------------------------------------
// MethodDescriptorProto
@@ -5932,13 +6192,21 @@ inline void MethodDescriptorProto::clear_name() {
}
inline const ::std::string& MethodDescriptorProto::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.GetNoArena();
}
inline void MethodDescriptorProto::set_name(const ::std::string& value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.name)
}
+#if LANG_CXX11
+inline void MethodDescriptorProto::set_name(::std::string&& value) {
+ set_has_name();
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.MethodDescriptorProto.name)
+}
+#endif
inline void MethodDescriptorProto::set_name(const char* value) {
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -5986,13 +6254,21 @@ inline void MethodDescriptorProto::clear_input_type() {
}
inline const ::std::string& MethodDescriptorProto::input_type() const {
// @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.input_type)
- return input_type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return input_type_.GetNoArena();
}
inline void MethodDescriptorProto::set_input_type(const ::std::string& value) {
set_has_input_type();
input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.input_type)
}
+#if LANG_CXX11
+inline void MethodDescriptorProto::set_input_type(::std::string&& value) {
+ set_has_input_type();
+ input_type_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.MethodDescriptorProto.input_type)
+}
+#endif
inline void MethodDescriptorProto::set_input_type(const char* value) {
set_has_input_type();
input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -6040,13 +6316,21 @@ inline void MethodDescriptorProto::clear_output_type() {
}
inline const ::std::string& MethodDescriptorProto::output_type() const {
// @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.output_type)
- return output_type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return output_type_.GetNoArena();
}
inline void MethodDescriptorProto::set_output_type(const ::std::string& value) {
set_has_output_type();
output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.output_type)
}
+#if LANG_CXX11
+inline void MethodDescriptorProto::set_output_type(::std::string&& value) {
+ set_has_output_type();
+ output_type_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.MethodDescriptorProto.output_type)
+}
+#endif
inline void MethodDescriptorProto::set_output_type(const char* value) {
set_has_output_type();
output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -6171,9 +6455,6 @@ inline void MethodDescriptorProto::set_server_streaming(bool value) {
// @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.server_streaming)
}
-inline const MethodDescriptorProto* MethodDescriptorProto::internal_default_instance() {
- return &MethodDescriptorProto_default_instance_.get();
-}
// -------------------------------------------------------------------
// FileOptions
@@ -6194,13 +6475,21 @@ inline void FileOptions::clear_java_package() {
}
inline const ::std::string& FileOptions::java_package() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_package)
- return java_package_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return java_package_.GetNoArena();
}
inline void FileOptions::set_java_package(const ::std::string& value) {
set_has_java_package();
java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_package)
}
+#if LANG_CXX11
+inline void FileOptions::set_java_package(::std::string&& value) {
+ set_has_java_package();
+ java_package_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.java_package)
+}
+#endif
inline void FileOptions::set_java_package(const char* value) {
set_has_java_package();
java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -6248,13 +6537,21 @@ inline void FileOptions::clear_java_outer_classname() {
}
inline const ::std::string& FileOptions::java_outer_classname() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_outer_classname)
- return java_outer_classname_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return java_outer_classname_.GetNoArena();
}
inline void FileOptions::set_java_outer_classname(const ::std::string& value) {
set_has_java_outer_classname();
java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_outer_classname)
}
+#if LANG_CXX11
+inline void FileOptions::set_java_outer_classname(::std::string&& value) {
+ set_has_java_outer_classname();
+ java_outer_classname_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.java_outer_classname)
+}
+#endif
inline void FileOptions::set_java_outer_classname(const char* value) {
set_has_java_outer_classname();
java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -6288,13 +6585,13 @@ inline void FileOptions::set_allocated_java_outer_classname(::std::string* java_
// optional bool java_multiple_files = 10 [default = false];
inline bool FileOptions::has_java_multiple_files() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
+ return (_has_bits_[0] & 0x00000040u) != 0;
}
inline void FileOptions::set_has_java_multiple_files() {
- _has_bits_[0] |= 0x00000004u;
+ _has_bits_[0] |= 0x00000040u;
}
inline void FileOptions::clear_has_java_multiple_files() {
- _has_bits_[0] &= ~0x00000004u;
+ _has_bits_[0] &= ~0x00000040u;
}
inline void FileOptions::clear_java_multiple_files() {
java_multiple_files_ = false;
@@ -6312,13 +6609,13 @@ inline void FileOptions::set_java_multiple_files(bool value) {
// optional bool java_generate_equals_and_hash = 20 [deprecated = true];
inline bool FileOptions::has_java_generate_equals_and_hash() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
+ return (_has_bits_[0] & 0x00000080u) != 0;
}
inline void FileOptions::set_has_java_generate_equals_and_hash() {
- _has_bits_[0] |= 0x00000008u;
+ _has_bits_[0] |= 0x00000080u;
}
inline void FileOptions::clear_has_java_generate_equals_and_hash() {
- _has_bits_[0] &= ~0x00000008u;
+ _has_bits_[0] &= ~0x00000080u;
}
inline void FileOptions::clear_java_generate_equals_and_hash() {
java_generate_equals_and_hash_ = false;
@@ -6336,13 +6633,13 @@ inline void FileOptions::set_java_generate_equals_and_hash(bool value) {
// optional bool java_string_check_utf8 = 27 [default = false];
inline bool FileOptions::has_java_string_check_utf8() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
+ return (_has_bits_[0] & 0x00000100u) != 0;
}
inline void FileOptions::set_has_java_string_check_utf8() {
- _has_bits_[0] |= 0x00000010u;
+ _has_bits_[0] |= 0x00000100u;
}
inline void FileOptions::clear_has_java_string_check_utf8() {
- _has_bits_[0] &= ~0x00000010u;
+ _has_bits_[0] &= ~0x00000100u;
}
inline void FileOptions::clear_java_string_check_utf8() {
java_string_check_utf8_ = false;
@@ -6360,13 +6657,13 @@ inline void FileOptions::set_java_string_check_utf8(bool value) {
// optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
inline bool FileOptions::has_optimize_for() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
+ return (_has_bits_[0] & 0x00004000u) != 0;
}
inline void FileOptions::set_has_optimize_for() {
- _has_bits_[0] |= 0x00000020u;
+ _has_bits_[0] |= 0x00004000u;
}
inline void FileOptions::clear_has_optimize_for() {
- _has_bits_[0] &= ~0x00000020u;
+ _has_bits_[0] &= ~0x00004000u;
}
inline void FileOptions::clear_optimize_for() {
optimize_for_ = 1;
@@ -6385,13 +6682,13 @@ inline void FileOptions::set_optimize_for(::google::protobuf::FileOptions_Optimi
// optional string go_package = 11;
inline bool FileOptions::has_go_package() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
+ return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void FileOptions::set_has_go_package() {
- _has_bits_[0] |= 0x00000040u;
+ _has_bits_[0] |= 0x00000004u;
}
inline void FileOptions::clear_has_go_package() {
- _has_bits_[0] &= ~0x00000040u;
+ _has_bits_[0] &= ~0x00000004u;
}
inline void FileOptions::clear_go_package() {
go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -6399,13 +6696,21 @@ inline void FileOptions::clear_go_package() {
}
inline const ::std::string& FileOptions::go_package() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.go_package)
- return go_package_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return go_package_.GetNoArena();
}
inline void FileOptions::set_go_package(const ::std::string& value) {
set_has_go_package();
go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.go_package)
}
+#if LANG_CXX11
+inline void FileOptions::set_go_package(::std::string&& value) {
+ set_has_go_package();
+ go_package_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.go_package)
+}
+#endif
inline void FileOptions::set_go_package(const char* value) {
set_has_go_package();
go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -6439,13 +6744,13 @@ inline void FileOptions::set_allocated_go_package(::std::string* go_package) {
// optional bool cc_generic_services = 16 [default = false];
inline bool FileOptions::has_cc_generic_services() const {
- return (_has_bits_[0] & 0x00000080u) != 0;
+ return (_has_bits_[0] & 0x00000200u) != 0;
}
inline void FileOptions::set_has_cc_generic_services() {
- _has_bits_[0] |= 0x00000080u;
+ _has_bits_[0] |= 0x00000200u;
}
inline void FileOptions::clear_has_cc_generic_services() {
- _has_bits_[0] &= ~0x00000080u;
+ _has_bits_[0] &= ~0x00000200u;
}
inline void FileOptions::clear_cc_generic_services() {
cc_generic_services_ = false;
@@ -6463,13 +6768,13 @@ inline void FileOptions::set_cc_generic_services(bool value) {
// optional bool java_generic_services = 17 [default = false];
inline bool FileOptions::has_java_generic_services() const {
- return (_has_bits_[0] & 0x00000100u) != 0;
+ return (_has_bits_[0] & 0x00000400u) != 0;
}
inline void FileOptions::set_has_java_generic_services() {
- _has_bits_[0] |= 0x00000100u;
+ _has_bits_[0] |= 0x00000400u;
}
inline void FileOptions::clear_has_java_generic_services() {
- _has_bits_[0] &= ~0x00000100u;
+ _has_bits_[0] &= ~0x00000400u;
}
inline void FileOptions::clear_java_generic_services() {
java_generic_services_ = false;
@@ -6487,13 +6792,13 @@ inline void FileOptions::set_java_generic_services(bool value) {
// optional bool py_generic_services = 18 [default = false];
inline bool FileOptions::has_py_generic_services() const {
- return (_has_bits_[0] & 0x00000200u) != 0;
+ return (_has_bits_[0] & 0x00000800u) != 0;
}
inline void FileOptions::set_has_py_generic_services() {
- _has_bits_[0] |= 0x00000200u;
+ _has_bits_[0] |= 0x00000800u;
}
inline void FileOptions::clear_has_py_generic_services() {
- _has_bits_[0] &= ~0x00000200u;
+ _has_bits_[0] &= ~0x00000800u;
}
inline void FileOptions::clear_py_generic_services() {
py_generic_services_ = false;
@@ -6511,13 +6816,13 @@ inline void FileOptions::set_py_generic_services(bool value) {
// optional bool deprecated = 23 [default = false];
inline bool FileOptions::has_deprecated() const {
- return (_has_bits_[0] & 0x00000400u) != 0;
+ return (_has_bits_[0] & 0x00001000u) != 0;
}
inline void FileOptions::set_has_deprecated() {
- _has_bits_[0] |= 0x00000400u;
+ _has_bits_[0] |= 0x00001000u;
}
inline void FileOptions::clear_has_deprecated() {
- _has_bits_[0] &= ~0x00000400u;
+ _has_bits_[0] &= ~0x00001000u;
}
inline void FileOptions::clear_deprecated() {
deprecated_ = false;
@@ -6535,13 +6840,13 @@ inline void FileOptions::set_deprecated(bool value) {
// optional bool cc_enable_arenas = 31 [default = false];
inline bool FileOptions::has_cc_enable_arenas() const {
- return (_has_bits_[0] & 0x00000800u) != 0;
+ return (_has_bits_[0] & 0x00002000u) != 0;
}
inline void FileOptions::set_has_cc_enable_arenas() {
- _has_bits_[0] |= 0x00000800u;
+ _has_bits_[0] |= 0x00002000u;
}
inline void FileOptions::clear_has_cc_enable_arenas() {
- _has_bits_[0] &= ~0x00000800u;
+ _has_bits_[0] &= ~0x00002000u;
}
inline void FileOptions::clear_cc_enable_arenas() {
cc_enable_arenas_ = false;
@@ -6559,13 +6864,13 @@ inline void FileOptions::set_cc_enable_arenas(bool value) {
// optional string objc_class_prefix = 36;
inline bool FileOptions::has_objc_class_prefix() const {
- return (_has_bits_[0] & 0x00001000u) != 0;
+ return (_has_bits_[0] & 0x00000008u) != 0;
}
inline void FileOptions::set_has_objc_class_prefix() {
- _has_bits_[0] |= 0x00001000u;
+ _has_bits_[0] |= 0x00000008u;
}
inline void FileOptions::clear_has_objc_class_prefix() {
- _has_bits_[0] &= ~0x00001000u;
+ _has_bits_[0] &= ~0x00000008u;
}
inline void FileOptions::clear_objc_class_prefix() {
objc_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -6573,13 +6878,21 @@ inline void FileOptions::clear_objc_class_prefix() {
}
inline const ::std::string& FileOptions::objc_class_prefix() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.objc_class_prefix)
- return objc_class_prefix_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return objc_class_prefix_.GetNoArena();
}
inline void FileOptions::set_objc_class_prefix(const ::std::string& value) {
set_has_objc_class_prefix();
objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.objc_class_prefix)
}
+#if LANG_CXX11
+inline void FileOptions::set_objc_class_prefix(::std::string&& value) {
+ set_has_objc_class_prefix();
+ objc_class_prefix_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.objc_class_prefix)
+}
+#endif
inline void FileOptions::set_objc_class_prefix(const char* value) {
set_has_objc_class_prefix();
objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -6613,13 +6926,13 @@ inline void FileOptions::set_allocated_objc_class_prefix(::std::string* objc_cla
// optional string csharp_namespace = 37;
inline bool FileOptions::has_csharp_namespace() const {
- return (_has_bits_[0] & 0x00002000u) != 0;
+ return (_has_bits_[0] & 0x00000010u) != 0;
}
inline void FileOptions::set_has_csharp_namespace() {
- _has_bits_[0] |= 0x00002000u;
+ _has_bits_[0] |= 0x00000010u;
}
inline void FileOptions::clear_has_csharp_namespace() {
- _has_bits_[0] &= ~0x00002000u;
+ _has_bits_[0] &= ~0x00000010u;
}
inline void FileOptions::clear_csharp_namespace() {
csharp_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -6627,13 +6940,21 @@ inline void FileOptions::clear_csharp_namespace() {
}
inline const ::std::string& FileOptions::csharp_namespace() const {
// @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_namespace)
- return csharp_namespace_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return csharp_namespace_.GetNoArena();
}
inline void FileOptions::set_csharp_namespace(const ::std::string& value) {
set_has_csharp_namespace();
csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_namespace)
}
+#if LANG_CXX11
+inline void FileOptions::set_csharp_namespace(::std::string&& value) {
+ set_has_csharp_namespace();
+ csharp_namespace_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.csharp_namespace)
+}
+#endif
inline void FileOptions::set_csharp_namespace(const char* value) {
set_has_csharp_namespace();
csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -6665,6 +6986,68 @@ inline void FileOptions::set_allocated_csharp_namespace(::std::string* csharp_na
// @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace)
}
+// optional string swift_prefix = 39;
+inline bool FileOptions::has_swift_prefix() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+inline void FileOptions::set_has_swift_prefix() {
+ _has_bits_[0] |= 0x00000020u;
+}
+inline void FileOptions::clear_has_swift_prefix() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+inline void FileOptions::clear_swift_prefix() {
+ swift_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_swift_prefix();
+}
+inline const ::std::string& FileOptions::swift_prefix() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.swift_prefix)
+ return swift_prefix_.GetNoArena();
+}
+inline void FileOptions::set_swift_prefix(const ::std::string& value) {
+ set_has_swift_prefix();
+ swift_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.swift_prefix)
+}
+#if LANG_CXX11
+inline void FileOptions::set_swift_prefix(::std::string&& value) {
+ set_has_swift_prefix();
+ swift_prefix_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.swift_prefix)
+}
+#endif
+inline void FileOptions::set_swift_prefix(const char* value) {
+ set_has_swift_prefix();
+ swift_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.swift_prefix)
+}
+inline void FileOptions::set_swift_prefix(const char* value, size_t size) {
+ set_has_swift_prefix();
+ swift_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.swift_prefix)
+}
+inline ::std::string* FileOptions::mutable_swift_prefix() {
+ set_has_swift_prefix();
+ // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.swift_prefix)
+ return swift_prefix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* FileOptions::release_swift_prefix() {
+ // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.swift_prefix)
+ clear_has_swift_prefix();
+ return swift_prefix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void FileOptions::set_allocated_swift_prefix(::std::string* swift_prefix) {
+ if (swift_prefix != NULL) {
+ set_has_swift_prefix();
+ } else {
+ clear_has_swift_prefix();
+ }
+ swift_prefix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), swift_prefix);
+ // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.swift_prefix)
+}
+
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
inline int FileOptions::uninterpreted_option_size() const {
return uninterpreted_option_.size();
@@ -6695,9 +7078,6 @@ FileOptions::uninterpreted_option() const {
return uninterpreted_option_;
}
-inline const FileOptions* FileOptions::internal_default_instance() {
- return &FileOptions_default_instance_.get();
-}
// -------------------------------------------------------------------
// MessageOptions
@@ -6828,9 +7208,6 @@ MessageOptions::uninterpreted_option() const {
return uninterpreted_option_;
}
-inline const MessageOptions* MessageOptions::internal_default_instance() {
- return &MessageOptions_default_instance_.get();
-}
// -------------------------------------------------------------------
// FieldOptions
@@ -6862,13 +7239,13 @@ inline void FieldOptions::set_ctype(::google::protobuf::FieldOptions_CType value
// optional bool packed = 2;
inline bool FieldOptions::has_packed() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
+ return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void FieldOptions::set_has_packed() {
- _has_bits_[0] |= 0x00000002u;
+ _has_bits_[0] |= 0x00000004u;
}
inline void FieldOptions::clear_has_packed() {
- _has_bits_[0] &= ~0x00000002u;
+ _has_bits_[0] &= ~0x00000004u;
}
inline void FieldOptions::clear_packed() {
packed_ = false;
@@ -6886,13 +7263,13 @@ inline void FieldOptions::set_packed(bool value) {
// optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];
inline bool FieldOptions::has_jstype() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
+ return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void FieldOptions::set_has_jstype() {
- _has_bits_[0] |= 0x00000004u;
+ _has_bits_[0] |= 0x00000002u;
}
inline void FieldOptions::clear_has_jstype() {
- _has_bits_[0] &= ~0x00000004u;
+ _has_bits_[0] &= ~0x00000002u;
}
inline void FieldOptions::clear_jstype() {
jstype_ = 0;
@@ -7011,9 +7388,6 @@ FieldOptions::uninterpreted_option() const {
return uninterpreted_option_;
}
-inline const FieldOptions* FieldOptions::internal_default_instance() {
- return &FieldOptions_default_instance_.get();
-}
// -------------------------------------------------------------------
// OneofOptions
@@ -7048,9 +7422,6 @@ OneofOptions::uninterpreted_option() const {
return uninterpreted_option_;
}
-inline const OneofOptions* OneofOptions::internal_default_instance() {
- return &OneofOptions_default_instance_.get();
-}
// -------------------------------------------------------------------
// EnumOptions
@@ -7133,9 +7504,6 @@ EnumOptions::uninterpreted_option() const {
return uninterpreted_option_;
}
-inline const EnumOptions* EnumOptions::internal_default_instance() {
- return &EnumOptions_default_instance_.get();
-}
// -------------------------------------------------------------------
// EnumValueOptions
@@ -7194,9 +7562,6 @@ EnumValueOptions::uninterpreted_option() const {
return uninterpreted_option_;
}
-inline const EnumValueOptions* EnumValueOptions::internal_default_instance() {
- return &EnumValueOptions_default_instance_.get();
-}
// -------------------------------------------------------------------
// ServiceOptions
@@ -7255,9 +7620,6 @@ ServiceOptions::uninterpreted_option() const {
return uninterpreted_option_;
}
-inline const ServiceOptions* ServiceOptions::internal_default_instance() {
- return &ServiceOptions_default_instance_.get();
-}
// -------------------------------------------------------------------
// MethodOptions
@@ -7286,6 +7648,31 @@ inline void MethodOptions::set_deprecated(bool value) {
// @@protoc_insertion_point(field_set:google.protobuf.MethodOptions.deprecated)
}
+// optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];
+inline bool MethodOptions::has_idempotency_level() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void MethodOptions::set_has_idempotency_level() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void MethodOptions::clear_has_idempotency_level() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void MethodOptions::clear_idempotency_level() {
+ idempotency_level_ = 0;
+ clear_has_idempotency_level();
+}
+inline ::google::protobuf::MethodOptions_IdempotencyLevel MethodOptions::idempotency_level() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.MethodOptions.idempotency_level)
+ return static_cast< ::google::protobuf::MethodOptions_IdempotencyLevel >(idempotency_level_);
+}
+inline void MethodOptions::set_idempotency_level(::google::protobuf::MethodOptions_IdempotencyLevel value) {
+ assert(::google::protobuf::MethodOptions_IdempotencyLevel_IsValid(value));
+ set_has_idempotency_level();
+ idempotency_level_ = value;
+ // @@protoc_insertion_point(field_set:google.protobuf.MethodOptions.idempotency_level)
+}
+
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
inline int MethodOptions::uninterpreted_option_size() const {
return uninterpreted_option_.size();
@@ -7316,9 +7703,6 @@ MethodOptions::uninterpreted_option() const {
return uninterpreted_option_;
}
-inline const MethodOptions* MethodOptions::internal_default_instance() {
- return &MethodOptions_default_instance_.get();
-}
// -------------------------------------------------------------------
// UninterpretedOption_NamePart
@@ -7339,13 +7723,21 @@ inline void UninterpretedOption_NamePart::clear_name_part() {
}
inline const ::std::string& UninterpretedOption_NamePart::name_part() const {
// @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.name_part)
- return name_part_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_part_.GetNoArena();
}
inline void UninterpretedOption_NamePart::set_name_part(const ::std::string& value) {
set_has_name_part();
name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.name_part)
}
+#if LANG_CXX11
+inline void UninterpretedOption_NamePart::set_name_part(::std::string&& value) {
+ set_has_name_part();
+ name_part_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.NamePart.name_part)
+}
+#endif
inline void UninterpretedOption_NamePart::set_name_part(const char* value) {
set_has_name_part();
name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -7401,9 +7793,6 @@ inline void UninterpretedOption_NamePart::set_is_extension(bool value) {
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.is_extension)
}
-inline const UninterpretedOption_NamePart* UninterpretedOption_NamePart::internal_default_instance() {
- return &UninterpretedOption_NamePart_default_instance_.get();
-}
// -------------------------------------------------------------------
// UninterpretedOption
@@ -7440,13 +7829,13 @@ UninterpretedOption::name() const {
// optional string identifier_value = 3;
inline bool UninterpretedOption::has_identifier_value() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
+ return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void UninterpretedOption::set_has_identifier_value() {
- _has_bits_[0] |= 0x00000002u;
+ _has_bits_[0] |= 0x00000001u;
}
inline void UninterpretedOption::clear_has_identifier_value() {
- _has_bits_[0] &= ~0x00000002u;
+ _has_bits_[0] &= ~0x00000001u;
}
inline void UninterpretedOption::clear_identifier_value() {
identifier_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -7454,13 +7843,21 @@ inline void UninterpretedOption::clear_identifier_value() {
}
inline const ::std::string& UninterpretedOption::identifier_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.identifier_value)
- return identifier_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return identifier_value_.GetNoArena();
}
inline void UninterpretedOption::set_identifier_value(const ::std::string& value) {
set_has_identifier_value();
identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.identifier_value)
}
+#if LANG_CXX11
+inline void UninterpretedOption::set_identifier_value(::std::string&& value) {
+ set_has_identifier_value();
+ identifier_value_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.identifier_value)
+}
+#endif
inline void UninterpretedOption::set_identifier_value(const char* value) {
set_has_identifier_value();
identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -7494,13 +7891,13 @@ inline void UninterpretedOption::set_allocated_identifier_value(::std::string* i
// optional uint64 positive_int_value = 4;
inline bool UninterpretedOption::has_positive_int_value() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
+ return (_has_bits_[0] & 0x00000008u) != 0;
}
inline void UninterpretedOption::set_has_positive_int_value() {
- _has_bits_[0] |= 0x00000004u;
+ _has_bits_[0] |= 0x00000008u;
}
inline void UninterpretedOption::clear_has_positive_int_value() {
- _has_bits_[0] &= ~0x00000004u;
+ _has_bits_[0] &= ~0x00000008u;
}
inline void UninterpretedOption::clear_positive_int_value() {
positive_int_value_ = GOOGLE_ULONGLONG(0);
@@ -7518,13 +7915,13 @@ inline void UninterpretedOption::set_positive_int_value(::google::protobuf::uint
// optional int64 negative_int_value = 5;
inline bool UninterpretedOption::has_negative_int_value() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
+ return (_has_bits_[0] & 0x00000010u) != 0;
}
inline void UninterpretedOption::set_has_negative_int_value() {
- _has_bits_[0] |= 0x00000008u;
+ _has_bits_[0] |= 0x00000010u;
}
inline void UninterpretedOption::clear_has_negative_int_value() {
- _has_bits_[0] &= ~0x00000008u;
+ _has_bits_[0] &= ~0x00000010u;
}
inline void UninterpretedOption::clear_negative_int_value() {
negative_int_value_ = GOOGLE_LONGLONG(0);
@@ -7542,13 +7939,13 @@ inline void UninterpretedOption::set_negative_int_value(::google::protobuf::int6
// optional double double_value = 6;
inline bool UninterpretedOption::has_double_value() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
+ return (_has_bits_[0] & 0x00000020u) != 0;
}
inline void UninterpretedOption::set_has_double_value() {
- _has_bits_[0] |= 0x00000010u;
+ _has_bits_[0] |= 0x00000020u;
}
inline void UninterpretedOption::clear_has_double_value() {
- _has_bits_[0] &= ~0x00000010u;
+ _has_bits_[0] &= ~0x00000020u;
}
inline void UninterpretedOption::clear_double_value() {
double_value_ = 0;
@@ -7566,13 +7963,13 @@ inline void UninterpretedOption::set_double_value(double value) {
// optional bytes string_value = 7;
inline bool UninterpretedOption::has_string_value() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
+ return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void UninterpretedOption::set_has_string_value() {
- _has_bits_[0] |= 0x00000020u;
+ _has_bits_[0] |= 0x00000002u;
}
inline void UninterpretedOption::clear_has_string_value() {
- _has_bits_[0] &= ~0x00000020u;
+ _has_bits_[0] &= ~0x00000002u;
}
inline void UninterpretedOption::clear_string_value() {
string_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -7580,13 +7977,21 @@ inline void UninterpretedOption::clear_string_value() {
}
inline const ::std::string& UninterpretedOption::string_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.string_value)
- return string_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return string_value_.GetNoArena();
}
inline void UninterpretedOption::set_string_value(const ::std::string& value) {
set_has_string_value();
string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.string_value)
}
+#if LANG_CXX11
+inline void UninterpretedOption::set_string_value(::std::string&& value) {
+ set_has_string_value();
+ string_value_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.string_value)
+}
+#endif
inline void UninterpretedOption::set_string_value(const char* value) {
set_has_string_value();
string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -7620,13 +8025,13 @@ inline void UninterpretedOption::set_allocated_string_value(::std::string* strin
// optional string aggregate_value = 8;
inline bool UninterpretedOption::has_aggregate_value() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
+ return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void UninterpretedOption::set_has_aggregate_value() {
- _has_bits_[0] |= 0x00000040u;
+ _has_bits_[0] |= 0x00000004u;
}
inline void UninterpretedOption::clear_has_aggregate_value() {
- _has_bits_[0] &= ~0x00000040u;
+ _has_bits_[0] &= ~0x00000004u;
}
inline void UninterpretedOption::clear_aggregate_value() {
aggregate_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -7634,13 +8039,21 @@ inline void UninterpretedOption::clear_aggregate_value() {
}
inline const ::std::string& UninterpretedOption::aggregate_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.aggregate_value)
- return aggregate_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return aggregate_value_.GetNoArena();
}
inline void UninterpretedOption::set_aggregate_value(const ::std::string& value) {
set_has_aggregate_value();
aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.aggregate_value)
}
+#if LANG_CXX11
+inline void UninterpretedOption::set_aggregate_value(::std::string&& value) {
+ set_has_aggregate_value();
+ aggregate_value_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.UninterpretedOption.aggregate_value)
+}
+#endif
inline void UninterpretedOption::set_aggregate_value(const char* value) {
set_has_aggregate_value();
aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -7672,9 +8085,6 @@ inline void UninterpretedOption::set_allocated_aggregate_value(::std::string* ag
// @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.aggregate_value)
}
-inline const UninterpretedOption* UninterpretedOption::internal_default_instance() {
- return &UninterpretedOption_default_instance_.get();
-}
// -------------------------------------------------------------------
// SourceCodeInfo_Location
@@ -7741,13 +8151,13 @@ SourceCodeInfo_Location::mutable_span() {
// optional string leading_comments = 3;
inline bool SourceCodeInfo_Location::has_leading_comments() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
+ return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void SourceCodeInfo_Location::set_has_leading_comments() {
- _has_bits_[0] |= 0x00000004u;
+ _has_bits_[0] |= 0x00000001u;
}
inline void SourceCodeInfo_Location::clear_has_leading_comments() {
- _has_bits_[0] &= ~0x00000004u;
+ _has_bits_[0] &= ~0x00000001u;
}
inline void SourceCodeInfo_Location::clear_leading_comments() {
leading_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -7755,13 +8165,21 @@ inline void SourceCodeInfo_Location::clear_leading_comments() {
}
inline const ::std::string& SourceCodeInfo_Location::leading_comments() const {
// @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.leading_comments)
- return leading_comments_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return leading_comments_.GetNoArena();
}
inline void SourceCodeInfo_Location::set_leading_comments(const ::std::string& value) {
set_has_leading_comments();
leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_comments)
}
+#if LANG_CXX11
+inline void SourceCodeInfo_Location::set_leading_comments(::std::string&& value) {
+ set_has_leading_comments();
+ leading_comments_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceCodeInfo.Location.leading_comments)
+}
+#endif
inline void SourceCodeInfo_Location::set_leading_comments(const char* value) {
set_has_leading_comments();
leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -7795,13 +8213,13 @@ inline void SourceCodeInfo_Location::set_allocated_leading_comments(::std::strin
// optional string trailing_comments = 4;
inline bool SourceCodeInfo_Location::has_trailing_comments() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
+ return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void SourceCodeInfo_Location::set_has_trailing_comments() {
- _has_bits_[0] |= 0x00000008u;
+ _has_bits_[0] |= 0x00000002u;
}
inline void SourceCodeInfo_Location::clear_has_trailing_comments() {
- _has_bits_[0] &= ~0x00000008u;
+ _has_bits_[0] &= ~0x00000002u;
}
inline void SourceCodeInfo_Location::clear_trailing_comments() {
trailing_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -7809,13 +8227,21 @@ inline void SourceCodeInfo_Location::clear_trailing_comments() {
}
inline const ::std::string& SourceCodeInfo_Location::trailing_comments() const {
// @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.trailing_comments)
- return trailing_comments_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return trailing_comments_.GetNoArena();
}
inline void SourceCodeInfo_Location::set_trailing_comments(const ::std::string& value) {
set_has_trailing_comments();
trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.trailing_comments)
}
+#if LANG_CXX11
+inline void SourceCodeInfo_Location::set_trailing_comments(::std::string&& value) {
+ set_has_trailing_comments();
+ trailing_comments_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceCodeInfo.Location.trailing_comments)
+}
+#endif
inline void SourceCodeInfo_Location::set_trailing_comments(const char* value) {
set_has_trailing_comments();
trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -7866,6 +8292,12 @@ inline void SourceCodeInfo_Location::set_leading_detached_comments(int index, co
// @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
leading_detached_comments_.Mutable(index)->assign(value);
}
+#if LANG_CXX11
+inline void SourceCodeInfo_Location::set_leading_detached_comments(int index, ::std::string&& value) {
+ // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
+ leading_detached_comments_.Mutable(index)->assign(std::move(value));
+}
+#endif
inline void SourceCodeInfo_Location::set_leading_detached_comments(int index, const char* value) {
leading_detached_comments_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
@@ -7883,6 +8315,12 @@ inline void SourceCodeInfo_Location::add_leading_detached_comments(const ::std::
leading_detached_comments_.Add()->assign(value);
// @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
}
+#if LANG_CXX11
+inline void SourceCodeInfo_Location::add_leading_detached_comments(::std::string&& value) {
+ leading_detached_comments_.Add()->assign(std::move(value));
+ // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
+}
+#endif
inline void SourceCodeInfo_Location::add_leading_detached_comments(const char* value) {
leading_detached_comments_.Add()->assign(value);
// @@protoc_insertion_point(field_add_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)
@@ -7902,9 +8340,6 @@ SourceCodeInfo_Location::mutable_leading_detached_comments() {
return &leading_detached_comments_;
}
-inline const SourceCodeInfo_Location* SourceCodeInfo_Location::internal_default_instance() {
- return &SourceCodeInfo_Location_default_instance_.get();
-}
// -------------------------------------------------------------------
// SourceCodeInfo
@@ -7939,9 +8374,6 @@ SourceCodeInfo::location() const {
return location_;
}
-inline const SourceCodeInfo* SourceCodeInfo::internal_default_instance() {
- return &SourceCodeInfo_default_instance_.get();
-}
// -------------------------------------------------------------------
// GeneratedCodeInfo_Annotation
@@ -7978,13 +8410,13 @@ GeneratedCodeInfo_Annotation::mutable_path() {
// optional string source_file = 2;
inline bool GeneratedCodeInfo_Annotation::has_source_file() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
+ return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void GeneratedCodeInfo_Annotation::set_has_source_file() {
- _has_bits_[0] |= 0x00000002u;
+ _has_bits_[0] |= 0x00000001u;
}
inline void GeneratedCodeInfo_Annotation::clear_has_source_file() {
- _has_bits_[0] &= ~0x00000002u;
+ _has_bits_[0] &= ~0x00000001u;
}
inline void GeneratedCodeInfo_Annotation::clear_source_file() {
source_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@@ -7992,13 +8424,21 @@ inline void GeneratedCodeInfo_Annotation::clear_source_file() {
}
inline const ::std::string& GeneratedCodeInfo_Annotation::source_file() const {
// @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
- return source_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return source_file_.GetNoArena();
}
inline void GeneratedCodeInfo_Annotation::set_source_file(const ::std::string& value) {
set_has_source_file();
source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
}
+#if LANG_CXX11
+inline void GeneratedCodeInfo_Annotation::set_source_file(::std::string&& value) {
+ set_has_source_file();
+ source_file_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.GeneratedCodeInfo.Annotation.source_file)
+}
+#endif
inline void GeneratedCodeInfo_Annotation::set_source_file(const char* value) {
set_has_source_file();
source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -8032,13 +8472,13 @@ inline void GeneratedCodeInfo_Annotation::set_allocated_source_file(::std::strin
// optional int32 begin = 3;
inline bool GeneratedCodeInfo_Annotation::has_begin() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
+ return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void GeneratedCodeInfo_Annotation::set_has_begin() {
- _has_bits_[0] |= 0x00000004u;
+ _has_bits_[0] |= 0x00000002u;
}
inline void GeneratedCodeInfo_Annotation::clear_has_begin() {
- _has_bits_[0] &= ~0x00000004u;
+ _has_bits_[0] &= ~0x00000002u;
}
inline void GeneratedCodeInfo_Annotation::clear_begin() {
begin_ = 0;
@@ -8056,13 +8496,13 @@ inline void GeneratedCodeInfo_Annotation::set_begin(::google::protobuf::int32 va
// optional int32 end = 4;
inline bool GeneratedCodeInfo_Annotation::has_end() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
+ return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void GeneratedCodeInfo_Annotation::set_has_end() {
- _has_bits_[0] |= 0x00000008u;
+ _has_bits_[0] |= 0x00000004u;
}
inline void GeneratedCodeInfo_Annotation::clear_has_end() {
- _has_bits_[0] &= ~0x00000008u;
+ _has_bits_[0] &= ~0x00000004u;
}
inline void GeneratedCodeInfo_Annotation::clear_end() {
end_ = 0;
@@ -8078,9 +8518,6 @@ inline void GeneratedCodeInfo_Annotation::set_end(::google::protobuf::int32 valu
// @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.end)
}
-inline const GeneratedCodeInfo_Annotation* GeneratedCodeInfo_Annotation::internal_default_instance() {
- return &GeneratedCodeInfo_Annotation_default_instance_.get();
-}
// -------------------------------------------------------------------
// GeneratedCodeInfo
@@ -8115,9 +8552,6 @@ GeneratedCodeInfo::annotation() const {
return annotation_;
}
-inline const GeneratedCodeInfo* GeneratedCodeInfo::internal_default_instance() {
- return &GeneratedCodeInfo_default_instance_.get();
-}
#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS
// -------------------------------------------------------------------
@@ -8170,6 +8604,7 @@ inline const GeneratedCodeInfo* GeneratedCodeInfo::internal_default_instance() {
// @@protoc_insertion_point(namespace_scope)
+
} // namespace protobuf
} // namespace google
@@ -8202,6 +8637,11 @@ template <>
inline const EnumDescriptor* GetEnumDescriptor< ::google::protobuf::FieldOptions_JSType>() {
return ::google::protobuf::FieldOptions_JSType_descriptor();
}
+template <> struct is_proto_enum< ::google::protobuf::MethodOptions_IdempotencyLevel> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::google::protobuf::MethodOptions_IdempotencyLevel>() {
+ return ::google::protobuf::MethodOptions_IdempotencyLevel_descriptor();
+}
} // namespace protobuf
} // namespace google
diff --git a/src/google/protobuf/descriptor.proto b/src/google/protobuf/descriptor.proto
index 558ae23e..e5f83e62 100644
--- a/src/google/protobuf/descriptor.proto
+++ b/src/google/protobuf/descriptor.proto
@@ -40,7 +40,7 @@
syntax = "proto2";
package google.protobuf;
-option go_package = "descriptor";
+option go_package = "github.com/golang/protobuf/protoc-gen-go/descriptor;descriptor";
option java_package = "com.google.protobuf";
option java_outer_classname = "DescriptorProtos";
option csharp_namespace = "Google.Protobuf.Reflection";
@@ -139,7 +139,11 @@ message FieldDescriptorProto {
TYPE_FIXED32 = 7;
TYPE_BOOL = 8;
TYPE_STRING = 9;
- TYPE_GROUP = 10; // Tag-delimited aggregate.
+ // Tag-delimited aggregate.
+ // Group type is deprecated and not supported in proto3. However, Proto3
+ // implementations should still be able to parse the group wire format and
+ // treat group fields as unknown fields.
+ TYPE_GROUP = 10;
TYPE_MESSAGE = 11; // Length-delimited aggregate.
// New in version 2.
@@ -157,7 +161,6 @@ message FieldDescriptorProto {
LABEL_OPTIONAL = 1;
LABEL_REQUIRED = 2;
LABEL_REPEATED = 3;
- // TODO(sanjay): Should we add LABEL_MAP?
};
optional string name = 1;
@@ -367,6 +370,12 @@ message FileOptions {
// Namespace for generated classes; defaults to the package.
optional string csharp_namespace = 37;
+ // By default Swift generators will take the proto package and CamelCase it
+ // replacing '.' with underscore and use that to prefix the types/symbols
+ // defined. When this options is provided, they will use this value instead
+ // to prefix the types/symbols defined.
+ optional string swift_prefix = 39;
+
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
@@ -431,13 +440,14 @@ message MessageOptions {
// parser.
optional bool map_entry = 7;
+ reserved 8; // javalite_serializable
+
+
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;
-
- reserved 8; // javalite_serializable
}
message FieldOptions {
@@ -551,6 +561,7 @@ message EnumOptions {
// is a formalization for deprecating enums.
optional bool deprecated = 3 [default=false];
+
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
@@ -605,6 +616,17 @@ message MethodOptions {
// this is a formalization for deprecating methods.
optional bool deprecated = 33 [default=false];
+ // Is this method side-effect-free (or safe in HTTP parlance), or idempotent,
+ // or neither? HTTP based RPC implementation may choose GET verb for safe
+ // methods, and PUT verb for idempotent methods instead of the default POST.
+ enum IdempotencyLevel {
+ IDEMPOTENCY_UNKNOWN = 0;
+ NO_SIDE_EFFECTS = 1; // implies idempotent
+ IDEMPOTENT = 2; // idempotent, but may have side effects
+ }
+ optional IdempotencyLevel idempotency_level =
+ 34 [default=IDEMPOTENCY_UNKNOWN];
+
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
diff --git a/src/google/protobuf/descriptor_database.cc b/src/google/protobuf/descriptor_database.cc
index 2117c020..57ae960f 100644
--- a/src/google/protobuf/descriptor_database.cc
+++ b/src/google/protobuf/descriptor_database.cc
@@ -97,11 +97,12 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddSymbol(
// Try to look up the symbol to make sure a super-symbol doesn't already
// exist.
- typename map<string, Value>::iterator iter = FindLastLessOrEqual(name);
+ typename std::map<string, Value>::iterator iter = FindLastLessOrEqual(name);
if (iter == by_symbol_.end()) {
// Apparently the map is currently empty. Just insert and be done with it.
- by_symbol_.insert(typename map<string, Value>::value_type(name, value));
+ by_symbol_.insert(
+ typename std::map<string, Value>::value_type(name, value));
return true;
}
@@ -128,7 +129,8 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddSymbol(
// Insert the new symbol using the iterator as a hint, the new entry will
// appear immediately before the one the iterator is pointing at.
- by_symbol_.insert(iter, typename map<string, Value>::value_type(name, value));
+ by_symbol_.insert(iter,
+ typename std::map<string, Value>::value_type(name, value));
return true;
}
@@ -179,7 +181,7 @@ Value SimpleDescriptorDatabase::DescriptorIndex<Value>::FindFile(
template <typename Value>
Value SimpleDescriptorDatabase::DescriptorIndex<Value>::FindSymbol(
const string& name) {
- typename map<string, Value>::iterator iter = FindLastLessOrEqual(name);
+ typename std::map<string, Value>::iterator iter = FindLastLessOrEqual(name);
return (iter != by_symbol_.end() && IsSubSymbol(iter->first, name)) ?
iter->second : Value();
@@ -196,8 +198,8 @@ Value SimpleDescriptorDatabase::DescriptorIndex<Value>::FindExtension(
template <typename Value>
bool SimpleDescriptorDatabase::DescriptorIndex<Value>::FindAllExtensionNumbers(
const string& containing_type,
- vector<int>* output) {
- typename map<pair<string, int>, Value>::const_iterator it =
+ std::vector<int>* output) {
+ typename std::map<pair<string, int>, Value>::const_iterator it =
by_extension_.lower_bound(std::make_pair(containing_type, 0));
bool success = false;
@@ -217,7 +219,8 @@ SimpleDescriptorDatabase::DescriptorIndex<Value>::FindLastLessOrEqual(
// Find the last key in the map which sorts less than or equal to the
// symbol name. Since upper_bound() returns the *first* key that sorts
// *greater* than the input, we want the element immediately before that.
- typename map<string, Value>::iterator iter = by_symbol_.upper_bound(name);
+ typename std::map<string, Value>::iterator iter =
+ by_symbol_.upper_bound(name);
if (iter != by_symbol_.begin()) --iter;
return iter;
}
@@ -284,7 +287,7 @@ bool SimpleDescriptorDatabase::FindFileContainingExtension(
bool SimpleDescriptorDatabase::FindAllExtensionNumbers(
const string& extendee_type,
- vector<int>* output) {
+ std::vector<int>* output) {
return index_.FindAllExtensionNumbers(extendee_type, output);
}
@@ -340,7 +343,7 @@ bool EncodedDescriptorDatabase::FindFileContainingSymbol(
bool EncodedDescriptorDatabase::FindNameOfFileContainingSymbol(
const string& symbol_name,
string* output) {
- pair<const void*, int> encoded_file = index_.FindSymbol(symbol_name);
+ std::pair<const void*, int> encoded_file = index_.FindSymbol(symbol_name);
if (encoded_file.first == NULL) return false;
// Optimization: The name should be the first field in the encoded message.
@@ -352,7 +355,7 @@ bool EncodedDescriptorDatabase::FindNameOfFileContainingSymbol(
FileDescriptorProto::kNameFieldNumber,
internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED);
- if (input.ReadTag() == kNameTag) {
+ if (input.ReadTagNoLastTag() == kNameTag) {
// Success!
return internal::WireFormatLite::ReadString(&input, output);
} else {
@@ -376,12 +379,12 @@ bool EncodedDescriptorDatabase::FindFileContainingExtension(
bool EncodedDescriptorDatabase::FindAllExtensionNumbers(
const string& extendee_type,
- vector<int>* output) {
+ std::vector<int>* output) {
return index_.FindAllExtensionNumbers(extendee_type, output);
}
bool EncodedDescriptorDatabase::MaybeParse(
- pair<const void*, int> encoded_file,
+ std::pair<const void*, int> encoded_file,
FileDescriptorProto* output) {
if (encoded_file.first == NULL) return false;
return output->ParseFromArray(encoded_file.first, encoded_file.second);
@@ -431,11 +434,11 @@ bool DescriptorPoolDatabase::FindFileContainingExtension(
bool DescriptorPoolDatabase::FindAllExtensionNumbers(
const string& extendee_type,
- vector<int>* output) {
+ std::vector<int>* output) {
const Descriptor* extendee = pool_.FindMessageTypeByName(extendee_type);
if (extendee == NULL) return false;
- vector<const FieldDescriptor*> extensions;
+ std::vector<const FieldDescriptor*> extensions;
pool_.FindAllExtensions(extendee, &extensions);
for (int i = 0; i < extensions.size(); ++i) {
@@ -454,7 +457,7 @@ MergedDescriptorDatabase::MergedDescriptorDatabase(
sources_.push_back(source2);
}
MergedDescriptorDatabase::MergedDescriptorDatabase(
- const vector<DescriptorDatabase*>& sources)
+ const std::vector<DescriptorDatabase*>& sources)
: sources_(sources) {}
MergedDescriptorDatabase::~MergedDescriptorDatabase() {}
@@ -517,23 +520,23 @@ bool MergedDescriptorDatabase::FindFileContainingExtension(
bool MergedDescriptorDatabase::FindAllExtensionNumbers(
const string& extendee_type,
- vector<int>* output) {
- set<int> merged_results;
- vector<int> results;
+ std::vector<int>* output) {
+ std::set<int> merged_results;
+ std::vector<int> results;
bool success = false;
for (int i = 0; i < sources_.size(); i++) {
if (sources_[i]->FindAllExtensionNumbers(extendee_type, &results)) {
- std::copy(
- results.begin(), results.end(),
- insert_iterator<set<int> >(merged_results, merged_results.begin()));
+ std::copy(results.begin(), results.end(),
+ std::insert_iterator<std::set<int> >(merged_results,
+ merged_results.begin()));
success = true;
}
results.clear();
}
std::copy(merged_results.begin(), merged_results.end(),
- insert_iterator<vector<int> >(*output, output->end()));
+ std::insert_iterator<std::vector<int> >(*output, output->end()));
return success;
}
diff --git a/src/google/protobuf/descriptor_database.h b/src/google/protobuf/descriptor_database.h
index 86002d56..be97a6d8 100644
--- a/src/google/protobuf/descriptor_database.h
+++ b/src/google/protobuf/descriptor_database.h
@@ -97,7 +97,7 @@ class LIBPROTOBUF_EXPORT DescriptorDatabase {
// This method has a default implementation that always returns
// false.
virtual bool FindAllExtensionNumbers(const string& /* extendee_type */,
- vector<int>* /* output */) {
+ std::vector<int>* /* output */) {
return false;
}
@@ -150,7 +150,7 @@ class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase {
int field_number,
FileDescriptorProto* output);
bool FindAllExtensionNumbers(const string& extendee_type,
- vector<int>* output);
+ std::vector<int>* output);
private:
// So that it can use DescriptorIndex.
@@ -175,12 +175,12 @@ class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase {
Value FindSymbol(const string& name);
Value FindExtension(const string& containing_type, int field_number);
bool FindAllExtensionNumbers(const string& containing_type,
- vector<int>* output);
+ std::vector<int>* output);
private:
- map<string, Value> by_name_;
- map<string, Value> by_symbol_;
- map<pair<string, int>, Value> by_extension_;
+ std::map<string, Value> by_name_;
+ std::map<string, Value> by_symbol_;
+ std::map<std::pair<string, int>, Value> by_extension_;
// Invariant: The by_symbol_ map does not contain any symbols which are
// prefixes of other symbols in the map. For example, "foo.bar" is a
@@ -235,7 +235,7 @@ class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase {
// Find the last entry in the by_symbol_ map whose key is less than or
// equal to the given name.
- typename map<string, Value>::iterator FindLastLessOrEqual(
+ typename std::map<string, Value>::iterator FindLastLessOrEqual(
const string& name);
// True if either the arguments are equal or super_symbol identifies a
@@ -250,7 +250,7 @@ class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase {
DescriptorIndex<const FileDescriptorProto*> index_;
- vector<const FileDescriptorProto*> files_to_delete_;
+ std::vector<const FileDescriptorProto*> files_to_delete_;
// If file is non-NULL, copy it into *output and return true, otherwise
// return false.
@@ -295,15 +295,16 @@ class LIBPROTOBUF_EXPORT EncodedDescriptorDatabase : public DescriptorDatabase {
int field_number,
FileDescriptorProto* output);
bool FindAllExtensionNumbers(const string& extendee_type,
- vector<int>* output);
+ std::vector<int>* output);
private:
- SimpleDescriptorDatabase::DescriptorIndex<pair<const void*, int> > index_;
- vector<void*> files_to_delete_;
+ SimpleDescriptorDatabase::DescriptorIndex<std::pair<const void*, int> >
+ index_;
+ std::vector<void*> files_to_delete_;
// If encoded_file.first is non-NULL, parse the data into *output and return
// true, otherwise return false.
- bool MaybeParse(pair<const void*, int> encoded_file,
+ bool MaybeParse(std::pair<const void*, int> encoded_file,
FileDescriptorProto* output);
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EncodedDescriptorDatabase);
@@ -324,7 +325,7 @@ class LIBPROTOBUF_EXPORT DescriptorPoolDatabase : public DescriptorDatabase {
int field_number,
FileDescriptorProto* output);
bool FindAllExtensionNumbers(const string& extendee_type,
- vector<int>* output);
+ std::vector<int>* output);
private:
const DescriptorPool& pool_;
@@ -341,7 +342,8 @@ class LIBPROTOBUF_EXPORT MergedDescriptorDatabase : public DescriptorDatabase {
// Merge more than two databases. The sources remain property of the caller.
// The vector may be deleted after the constructor returns but the
// DescriptorDatabases need to stick around.
- explicit MergedDescriptorDatabase(const vector<DescriptorDatabase*>& sources);
+ explicit MergedDescriptorDatabase(
+ const std::vector<DescriptorDatabase*>& sources);
~MergedDescriptorDatabase();
// implements DescriptorDatabase -----------------------------------
@@ -355,11 +357,11 @@ class LIBPROTOBUF_EXPORT MergedDescriptorDatabase : public DescriptorDatabase {
// Merges the results of calling all databases. Returns true iff any
// of the databases returned true.
bool FindAllExtensionNumbers(const string& extendee_type,
- vector<int>* output);
+ std::vector<int>* output);
private:
- vector<DescriptorDatabase*> sources_;
+ std::vector<DescriptorDatabase*> sources_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MergedDescriptorDatabase);
};
diff --git a/src/google/protobuf/descriptor_database_unittest.cc b/src/google/protobuf/descriptor_database_unittest.cc
index 4f568f7d..05d67656 100644
--- a/src/google/protobuf/descriptor_database_unittest.cc
+++ b/src/google/protobuf/descriptor_database_unittest.cc
@@ -410,7 +410,7 @@ TEST_P(DescriptorDatabaseTest, FindAllExtensionNumbers) {
"extension { name:\"waldo\" extendee: \"Bar\" number:56 } ");
{
- vector<int> numbers;
+ std::vector<int> numbers;
EXPECT_TRUE(database_->FindAllExtensionNumbers("Foo", &numbers));
ASSERT_EQ(2, numbers.size());
std::sort(numbers.begin(), numbers.end());
@@ -419,7 +419,7 @@ TEST_P(DescriptorDatabaseTest, FindAllExtensionNumbers) {
}
{
- vector<int> numbers;
+ std::vector<int> numbers;
EXPECT_TRUE(database_->FindAllExtensionNumbers("corge.Bar", &numbers));
// Note: won't find extension 56 due to the name not being fully qualified.
ASSERT_EQ(1, numbers.size());
@@ -428,13 +428,13 @@ TEST_P(DescriptorDatabaseTest, FindAllExtensionNumbers) {
{
// Can't find extensions for non-existent types.
- vector<int> numbers;
+ std::vector<int> numbers;
EXPECT_FALSE(database_->FindAllExtensionNumbers("NoSuchType", &numbers));
}
{
// Can't find extensions for unqualified types.
- vector<int> numbers;
+ std::vector<int> numbers;
EXPECT_FALSE(database_->FindAllExtensionNumbers("Bar", &numbers));
}
}
@@ -708,7 +708,7 @@ TEST_F(MergedDescriptorDatabaseTest, FindFileContainingExtension) {
TEST_F(MergedDescriptorDatabaseTest, FindAllExtensionNumbers) {
{
// Message only has extension in database1_
- vector<int> numbers;
+ std::vector<int> numbers;
EXPECT_TRUE(forward_merged_.FindAllExtensionNumbers("Foo", &numbers));
ASSERT_EQ(1, numbers.size());
EXPECT_EQ(3, numbers[0]);
@@ -716,7 +716,7 @@ TEST_F(MergedDescriptorDatabaseTest, FindAllExtensionNumbers) {
{
// Message only has extension in database2_
- vector<int> numbers;
+ std::vector<int> numbers;
EXPECT_TRUE(forward_merged_.FindAllExtensionNumbers("Bar", &numbers));
ASSERT_EQ(1, numbers.size());
EXPECT_EQ(5, numbers[0]);
@@ -724,7 +724,7 @@ TEST_F(MergedDescriptorDatabaseTest, FindAllExtensionNumbers) {
{
// Merge results from the two databases.
- vector<int> numbers;
+ std::vector<int> numbers;
EXPECT_TRUE(forward_merged_.FindAllExtensionNumbers("Baz", &numbers));
ASSERT_EQ(2, numbers.size());
std::sort(numbers.begin(), numbers.end());
@@ -733,7 +733,7 @@ TEST_F(MergedDescriptorDatabaseTest, FindAllExtensionNumbers) {
}
{
- vector<int> numbers;
+ std::vector<int> numbers;
EXPECT_TRUE(reverse_merged_.FindAllExtensionNumbers("Baz", &numbers));
ASSERT_EQ(2, numbers.size());
std::sort(numbers.begin(), numbers.end());
@@ -743,7 +743,7 @@ TEST_F(MergedDescriptorDatabaseTest, FindAllExtensionNumbers) {
{
// Can't find extensions for a non-existent message.
- vector<int> numbers;
+ std::vector<int> numbers;
EXPECT_FALSE(reverse_merged_.FindAllExtensionNumbers("Blah", &numbers));
}
}
diff --git a/src/google/protobuf/descriptor_unittest.cc b/src/google/protobuf/descriptor_unittest.cc
index f6b3f1c5..7ec75156 100644
--- a/src/google/protobuf/descriptor_unittest.cc
+++ b/src/google/protobuf/descriptor_unittest.cc
@@ -41,8 +41,11 @@
#include <vector>
#include <google/protobuf/compiler/importer.h>
+#include <google/protobuf/compiler/parser.h>
#include <google/protobuf/unittest.pb.h>
#include <google/protobuf/unittest_custom_options.pb.h>
+#include <google/protobuf/unittest_proto3_arena.pb.h>
+#include <google/protobuf/io/tokenizer.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/descriptor.h>
@@ -55,6 +58,7 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/logging.h>
+#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/testing/googletest.h>
#include <gtest/gtest.h>
@@ -488,6 +492,65 @@ TEST_F(FileDescriptorTest, Syntax) {
}
}
+void ExtractDebugString(
+ const FileDescriptor* file, std::set<string>* visited,
+ std::vector<std::pair<string, string> >* debug_strings) {
+ if (!visited->insert(file->name()).second) {
+ return;
+ }
+ for (int i = 0; i < file->dependency_count(); ++i) {
+ ExtractDebugString(file->dependency(i), visited, debug_strings);
+ }
+ debug_strings->push_back(make_pair(file->name(), file->DebugString()));
+}
+
+class SimpleErrorCollector : public google::protobuf::io::ErrorCollector {
+ public:
+ // implements ErrorCollector ---------------------------------------
+ void AddError(int line, int column, const string& message) {
+ last_error_ = StringPrintf("%d:%d:", line, column) + message;
+ }
+
+ const string& last_error() { return last_error_; }
+
+ private:
+ string last_error_;
+};
+// Test that the result of FileDescriptor::DebugString() can be used to create
+// the original descriptors.
+TEST_F(FileDescriptorTest, DebugStringRoundTrip) {
+ std::set<string> visited;
+ std::vector<std::pair<string, string> > debug_strings;
+ ExtractDebugString(protobuf_unittest::TestAllTypes::descriptor()->file(),
+ &visited, &debug_strings);
+ ExtractDebugString(
+ protobuf_unittest::TestMessageWithCustomOptions::descriptor()->file(),
+ &visited, &debug_strings);
+ ExtractDebugString(proto3_arena_unittest::TestAllTypes::descriptor()->file(),
+ &visited, &debug_strings);
+ ASSERT_GE(debug_strings.size(), 3);
+
+ DescriptorPool pool;
+ for (int i = 0; i < debug_strings.size(); ++i) {
+ const string& name = debug_strings[i].first;
+ const string& content = debug_strings[i].second;
+ google::protobuf::io::ArrayInputStream input_stream(content.data(), content.size());
+ SimpleErrorCollector error_collector;
+ google::protobuf::io::Tokenizer tokenizer(&input_stream, &error_collector);
+ google::protobuf::compiler::Parser parser;
+ parser.RecordErrorsTo(&error_collector);
+ FileDescriptorProto proto;
+ ASSERT_TRUE(parser.Parse(&tokenizer, &proto))
+ << error_collector.last_error() << "\n"
+ << content;
+ ASSERT_EQ("", error_collector.last_error());
+ proto.set_name(name);
+ const FileDescriptor* descriptor = pool.BuildFile(proto);
+ ASSERT_TRUE(descriptor != NULL) << proto.DebugString();
+ EXPECT_EQ(content, descriptor->DebugString());
+ }
+}
+
// ===================================================================
// Test simple flat messages and fields.
@@ -1861,7 +1924,7 @@ TEST_F(ExtensionDescriptorTest, FindExtensionByName) {
}
TEST_F(ExtensionDescriptorTest, FindAllExtensions) {
- vector<const FieldDescriptor*> extensions;
+ std::vector<const FieldDescriptor*> extensions;
pool_.FindAllExtensions(foo_, &extensions);
ASSERT_EQ(4, extensions.size());
EXPECT_EQ(10, extensions[0]->number());
@@ -2625,7 +2688,7 @@ TEST_P(AllowUnknownDependenciesTest, CustomOption) {
// Verify that no extension options were set, but they were left as
// uninterpreted_options.
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
file->options().GetReflection()->ListFields(file->options(), &fields);
ASSERT_EQ(2, fields.size());
EXPECT_TRUE(file->options().has_optimize_for());
@@ -3276,6 +3339,85 @@ TEST(CustomOptions, OptionsWithRequiredEnums) {
EXPECT_EQ(protobuf_unittest::NewOptionType::NEW_VALUE, new_enum_opt.value());
}
+// Test that FileDescriptor::DebugString() formats custom options correctly.
+TEST(CustomOptions, DebugString) {
+ DescriptorPool pool;
+
+ FileDescriptorProto file_proto;
+ MessageOptions::descriptor()->file()->CopyTo(&file_proto);
+ ASSERT_TRUE(pool.BuildFile(file_proto) != NULL);
+
+ // Add "foo.proto":
+ // import "google/protobuf/descriptor.proto";
+ // package "protobuf_unittest";
+ // option (protobuf_unittest.cc_option1) = 1;
+ // option (protobuf_unittest.cc_option2) = 2;
+ // extend google.protobuf.FieldOptions {
+ // optional int32 cc_option1 = 7736974;
+ // optional int32 cc_option2 = 7736975;
+ // }
+ ASSERT_TRUE(TextFormat::ParseFromString(
+ "name: \"foo.proto\" "
+ "package: \"protobuf_unittest\" "
+ "dependency: \"google/protobuf/descriptor.proto\" "
+ "options { "
+ " uninterpreted_option { "
+ " name { "
+ " name_part: \"protobuf_unittest.cc_option1\" "
+ " is_extension: true "
+ " } "
+ " positive_int_value: 1 "
+ " } "
+ " uninterpreted_option { "
+ " name { "
+ " name_part: \"protobuf_unittest.cc_option2\" "
+ " is_extension: true "
+ " } "
+ " positive_int_value: 2 "
+ " } "
+ "} "
+ "extension { "
+ " name: \"cc_option1\" "
+ " extendee: \".google.protobuf.FileOptions\" "
+ // This field number is intentionally chosen to be the same as
+ // (.fileopt1) defined in unittest_custom_options.proto (linked
+ // in this test binary). This is to test whether we are messing
+ // generated pool with custom descriptor pools when dealing with
+ // custom options.
+ " number: 7736974 "
+ " label: LABEL_OPTIONAL "
+ " type: TYPE_INT32 "
+ "}"
+ "extension { "
+ " name: \"cc_option2\" "
+ " extendee: \".google.protobuf.FileOptions\" "
+ " number: 7736975 "
+ " label: LABEL_OPTIONAL "
+ " type: TYPE_INT32 "
+ "}",
+ &file_proto));
+ const FileDescriptor* descriptor = pool.BuildFile(file_proto);
+ ASSERT_TRUE(descriptor != NULL);
+
+ EXPECT_EQ(2, descriptor->extension_count());
+
+ ASSERT_EQ(
+ "syntax = \"proto2\";\n"
+ "\n"
+ "import \"google/protobuf/descriptor.proto\";\n"
+ "package protobuf_unittest;\n"
+ "\n"
+ "option (.protobuf_unittest.cc_option1) = 1;\n"
+ "option (.protobuf_unittest.cc_option2) = 2;\n"
+ "\n"
+ "extend .google.protobuf.FileOptions {\n"
+ " optional int32 cc_option1 = 7736974;\n"
+ " optional int32 cc_option2 = 7736975;\n"
+ "}\n"
+ "\n",
+ descriptor->DebugString());
+}
+
// ===================================================================
class ValidationErrorTest : public testing::Test {
@@ -5169,7 +5311,7 @@ TEST_F(ValidationErrorTest, ErrorsReportedToLogError) {
"message_type { name: \"Foo\" } ",
&file_proto));
- vector<string> errors;
+ std::vector<string> errors;
{
ScopedMemoryLog log;
@@ -5598,8 +5740,8 @@ TEST_F(ValidationErrorTest, EnumValuesConflictWhenPrefixesStripped) {
"}",
"foo.proto: BAR__BAZ: NAME: When enum name is stripped and label is "
"PascalCased (BarBaz), this value label conflicts with "
- "FOO_ENUM_BAR_BAZ. This "
- "will make the proto fail to compile for some languages, such as C#.\n");
+ "FOO_ENUM_BAR_BAZ. This will make the proto fail to compile for some "
+ "languages, such as C#.\n");
BuildFileWithErrors(
"syntax: 'proto3'"
@@ -5611,8 +5753,8 @@ TEST_F(ValidationErrorTest, EnumValuesConflictWhenPrefixesStripped) {
"}",
"foo.proto: BAR_BAZ: NAME: When enum name is stripped and label is "
"PascalCased (BarBaz), this value label conflicts with "
- "FOO_ENUM__BAR_BAZ. This "
- "will make the proto fail to compile for some languages, such as C#.\n");
+ "FOO_ENUM__BAR_BAZ. This will make the proto fail to compile for some "
+ "languages, such as C#.\n");
// This isn't an error because the underscore will cause the PascalCase to
// differ by case (BarBaz vs. Barbaz).
@@ -6159,7 +6301,7 @@ TEST_F(DatabaseBackedPoolTest, FindAllExtensions) {
for (int i = 0; i < 2; ++i) {
// Repeat the lookup twice, to check that we get consistent
// results despite the fallback database lookup mutating the pool.
- vector<const FieldDescriptor*> extensions;
+ std::vector<const FieldDescriptor*> extensions;
pool.FindAllExtensions(foo, &extensions);
ASSERT_EQ(1, extensions.size());
EXPECT_EQ(5, extensions[0]->number());
@@ -6170,7 +6312,7 @@ TEST_F(DatabaseBackedPoolTest, ErrorWithoutErrorCollector) {
ErrorDescriptorDatabase error_database;
DescriptorPool pool(&error_database);
- vector<string> errors;
+ std::vector<string> errors;
{
ScopedMemoryLog log;
diff --git a/src/google/protobuf/duration.pb.cc b/src/google/protobuf/duration.pb.cc
index f7cc647f..d9b4fb1f 100644
--- a/src/google/protobuf/duration.pb.cc
+++ b/src/google/protobuf/duration.pb.cc
@@ -19,110 +19,103 @@
namespace google {
namespace protobuf {
+class DurationDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Duration> {
+} _Duration_default_instance_;
+
+namespace protobuf_google_2fprotobuf_2fduration_2eproto {
+
namespace {
-const ::google::protobuf::Descriptor* Duration_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- Duration_reflection_ = NULL;
+::google::protobuf::Metadata file_level_metadata[1];
} // namespace
+const ::google::protobuf::uint32 TableStruct::offsets[] = {
+ ~0u, // no _has_bits_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, seconds_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, nanos_),
+};
-void protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto() GOOGLE_ATTRIBUTE_COLD;
-void protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto() {
- protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto();
- const ::google::protobuf::FileDescriptor* file =
- ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
- "google/protobuf/duration.proto");
- GOOGLE_CHECK(file != NULL);
- Duration_descriptor_ = file->message_type(0);
- static const int Duration_offsets_[2] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, seconds_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, nanos_),
- };
- Duration_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- Duration_descriptor_,
- Duration::internal_default_instance(),
- Duration_offsets_,
- -1,
- -1,
- -1,
- sizeof(Duration),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, _internal_metadata_));
-}
+static const ::google::protobuf::internal::MigrationSchema schemas[] = {
+ { 0, -1, sizeof(Duration)},
+};
+
+static ::google::protobuf::Message const * const file_default_instances[] = {
+ reinterpret_cast<const ::google::protobuf::Message*>(&_Duration_default_instance_),
+};
namespace {
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
+void protobuf_AssignDescriptors() {
+ AddDescriptors();
+ ::google::protobuf::MessageFactory* factory = NULL;
+ AssignDescriptors(
+ "google/protobuf/duration.proto", schemas, file_default_instances, TableStruct::offsets, factory,
+ file_level_metadata, NULL, NULL);
+}
+
void protobuf_AssignDescriptorsOnce() {
- ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
- &protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto);
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);
}
void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;
void protobuf_RegisterTypes(const ::std::string&) {
protobuf_AssignDescriptorsOnce();
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- Duration_descriptor_, Duration::internal_default_instance());
+ ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1);
}
} // namespace
-void protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto() {
- Duration_default_instance_.Shutdown();
- delete Duration_reflection_;
+void TableStruct::Shutdown() {
+ _Duration_default_instance_.Shutdown();
+ delete file_level_metadata[0].reflection;
}
-void protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_impl() {
+void TableStruct::InitDefaultsImpl() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
- Duration_default_instance_.DefaultConstruct();
- Duration_default_instance_.get_mutable()->InitAsDefaultInstance();
+ ::google::protobuf::internal::InitProtobufDefaults();
+ _Duration_default_instance_.DefaultConstruct();
}
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_once_);
-void protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto() {
- ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_once_,
- &protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_impl);
+void InitDefaults() {
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);
}
-void protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_impl() {
- GOOGLE_PROTOBUF_VERIFY_VERSION;
-
- protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto();
+void AddDescriptorsImpl() {
+ InitDefaults();
+ static const char descriptor[] = {
+ "\n\036google/protobuf/duration.proto\022\017google"
+ ".protobuf\"*\n\010Duration\022\017\n\007seconds\030\001 \001(\003\022\r"
+ "\n\005nanos\030\002 \001(\005B|\n\023com.google.protobufB\rDu"
+ "rationProtoP\001Z*github.com/golang/protobu"
+ "f/ptypes/duration\370\001\001\242\002\003GPB\252\002\036Google.Prot"
+ "obuf.WellKnownTypesb\006proto3"
+ };
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
- "\n\036google/protobuf/duration.proto\022\017google"
- ".protobuf\"*\n\010Duration\022\017\n\007seconds\030\001 \001(\003\022\r"
- "\n\005nanos\030\002 \001(\005B|\n\023com.google.protobufB\rDu"
- "rationProtoP\001Z*github.com/golang/protobu"
- "f/ptypes/duration\370\001\001\242\002\003GPB\252\002\036Google.Prot"
- "obuf.WellKnownTypesb\006proto3", 227);
+ descriptor, 227);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"google/protobuf/duration.proto", &protobuf_RegisterTypes);
- ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto);
+ ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);
}
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_once_);
-void protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto() {
- ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_once_,
- &protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_impl);
+void AddDescriptors() {
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
}
// Force AddDescriptors() to be called at static initialization time.
-struct StaticDescriptorInitializer_google_2fprotobuf_2fduration_2eproto {
- StaticDescriptorInitializer_google_2fprotobuf_2fduration_2eproto() {
- protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto();
+struct StaticDescriptorInitializer {
+ StaticDescriptorInitializer() {
+ AddDescriptors();
}
-} static_descriptor_initializer_google_2fprotobuf_2fduration_2eproto_;
+} static_descriptor_initializer;
-namespace {
-
-static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN;
-static void MergeFromFail(int line) {
- ::google::protobuf::internal::MergeFromFail(__FILE__, line);
-}
-
-} // namespace
+} // namespace protobuf_google_2fprotobuf_2fduration_2eproto
// ===================================================================
@@ -134,7 +127,9 @@ const int Duration::kNanosFieldNumber;
Duration::Duration()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fduration_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.Duration)
}
@@ -142,21 +137,20 @@ Duration::Duration(::google::protobuf::Arena* arena)
: ::google::protobuf::Message(),
_internal_metadata_(arena) {
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto();
+ protobuf_google_2fprotobuf_2fduration_2eproto::InitDefaults();
#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Duration)
}
-
-void Duration::InitAsDefaultInstance() {
-}
-
Duration::Duration(const Duration& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ ::memcpy(&seconds_, &from.seconds_,
+ reinterpret_cast<char*>(&nanos_) -
+ reinterpret_cast<char*>(&seconds_) + sizeof(nanos_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.Duration)
}
@@ -191,44 +185,23 @@ void Duration::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* Duration::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return Duration_descriptor_;
+ protobuf_google_2fprotobuf_2fduration_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fduration_2eproto::file_level_metadata[0].descriptor;
}
const Duration& Duration::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto();
+ protobuf_google_2fprotobuf_2fduration_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<Duration> Duration_default_instance_;
-
Duration* Duration::New(::google::protobuf::Arena* arena) const {
return ::google::protobuf::Arena::CreateMessage<Duration>(arena);
}
void Duration::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Duration)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(Duration, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<Duration*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- ZR_(seconds_, nanos_);
-
-#undef ZR_HELPER_
-#undef ZR_
-
+ ::memset(&seconds_, 0, reinterpret_cast<char*>(&nanos_) -
+ reinterpret_cast<char*>(&seconds_) + sizeof(nanos_));
}
bool Duration::MergePartialFromCodedStream(
@@ -237,13 +210,14 @@ bool Duration::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Duration)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional int64 seconds = 1;
+ // int64 seconds = 1;
case 1: {
- if (tag == 8) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(8u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(
@@ -251,14 +225,13 @@ bool Duration::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(16)) goto parse_nanos;
break;
}
- // optional int32 nanos = 2;
+ // int32 nanos = 2;
case 2: {
- if (tag == 16) {
- parse_nanos:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(16u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
@@ -266,7 +239,6 @@ bool Duration::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -294,12 +266,12 @@ failure:
void Duration::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.Duration)
- // optional int64 seconds = 1;
+ // int64 seconds = 1;
if (this->seconds() != 0) {
::google::protobuf::internal::WireFormatLite::WriteInt64(1, this->seconds(), output);
}
- // optional int32 nanos = 2;
+ // int32 nanos = 2;
if (this->nanos() != 0) {
::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->nanos(), output);
}
@@ -309,14 +281,14 @@ void Duration::SerializeWithCachedSizes(
::google::protobuf::uint8* Duration::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Duration)
- // optional int64 seconds = 1;
+ // int64 seconds = 1;
if (this->seconds() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(1, this->seconds(), target);
}
- // optional int32 nanos = 2;
+ // int32 nanos = 2;
if (this->nanos() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->nanos(), target);
}
@@ -329,14 +301,14 @@ size_t Duration::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Duration)
size_t total_size = 0;
- // optional int64 seconds = 1;
+ // int64 seconds = 1;
if (this->seconds() != 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int64Size(
this->seconds());
}
- // optional int32 nanos = 2;
+ // int32 nanos = 2;
if (this->nanos() != 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
@@ -352,7 +324,7 @@ size_t Duration::ByteSizeLong() const {
void Duration::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Duration)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const Duration* source =
::google::protobuf::internal::DynamicCastToGenerated<const Duration>(
&from);
@@ -361,21 +333,14 @@ void Duration::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Duration)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void Duration::MergeFrom(const Duration& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Duration)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void Duration::UnsafeMergeFrom(const Duration& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
if (from.seconds() != 0) {
set_seconds(from.seconds());
}
@@ -395,11 +360,10 @@ void Duration::CopyFrom(const Duration& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Duration)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool Duration::IsInitialized() const {
-
return true;
}
@@ -408,10 +372,13 @@ void Duration::Swap(Duration* other) {
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
- Duration temp;
- temp.UnsafeMergeFrom(*this);
- CopyFrom(*other);
- other->CopyFrom(temp);
+ Duration* temp = New(GetArenaNoVirtual());
+ temp->MergeFrom(*other);
+ other->CopyFrom(*this);
+ InternalSwap(temp);
+ if (GetArenaNoVirtual() == NULL) {
+ delete temp;
+ }
}
}
void Duration::UnsafeArenaSwap(Duration* other) {
@@ -422,22 +389,18 @@ void Duration::UnsafeArenaSwap(Duration* other) {
void Duration::InternalSwap(Duration* other) {
std::swap(seconds_, other->seconds_);
std::swap(nanos_, other->nanos_);
- _internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata Duration::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = Duration_descriptor_;
- metadata.reflection = Duration_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fduration_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fduration_2eproto::file_level_metadata[0];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// Duration
-// optional int64 seconds = 1;
+// int64 seconds = 1;
void Duration::clear_seconds() {
seconds_ = GOOGLE_LONGLONG(0);
}
@@ -451,7 +414,7 @@ void Duration::set_seconds(::google::protobuf::int64 value) {
// @@protoc_insertion_point(field_set:google.protobuf.Duration.seconds)
}
-// optional int32 nanos = 2;
+// int32 nanos = 2;
void Duration::clear_nanos() {
nanos_ = 0;
}
@@ -465,9 +428,6 @@ void Duration::set_nanos(::google::protobuf::int32 value) {
// @@protoc_insertion_point(field_set:google.protobuf.Duration.nanos)
}
-inline const Duration* Duration::internal_default_instance() {
- return &Duration_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// @@protoc_insertion_point(namespace_scope)
diff --git a/src/google/protobuf/duration.pb.h b/src/google/protobuf/duration.pb.h
index 3ed1a6d3..591c11d1 100644
--- a/src/google/protobuf/duration.pb.h
+++ b/src/google/protobuf/duration.pb.h
@@ -8,37 +8,48 @@
#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3001000
+#if GOOGLE_PROTOBUF_VERSION < 3002000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
#endif
+#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata.h>
#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/extension_set.h>
+#include <google/protobuf/repeated_field.h> // IWYU pragma: export
+#include <google/protobuf/extension_set.h> // IWYU pragma: export
#include <google/protobuf/unknown_field_set.h>
// @@protoc_insertion_point(includes)
+namespace google {
+namespace protobuf {
+class Duration;
+class DurationDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern DurationDefaultTypeInternal _Duration_default_instance_;
+} // namespace protobuf
+} // namespace google
namespace google {
namespace protobuf {
+namespace protobuf_google_2fprotobuf_2fduration_2eproto {
// Internal implementation detail -- do not call these.
-void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto();
-void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto();
-void protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto();
-void protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto();
-
-class Duration;
+struct LIBPROTOBUF_EXPORT TableStruct {
+ static const ::google::protobuf::uint32 offsets[];
+ static void InitDefaultsImpl();
+ static void Shutdown();
+};
+void LIBPROTOBUF_EXPORT AddDescriptors();
+void LIBPROTOBUF_EXPORT InitDefaults();
+} // namespace protobuf_google_2fprotobuf_2fduration_2eproto
// ===================================================================
@@ -54,47 +65,53 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot
return *this;
}
- inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }
- inline void* GetMaybeArenaPointer() const {
+ inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {
+ return GetArenaNoVirtual();
+ }
+ inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {
return MaybeArenaPtr();
}
static const ::google::protobuf::Descriptor* descriptor();
static const Duration& default_instance();
- static const Duration* internal_default_instance();
+ static inline const Duration* internal_default_instance() {
+ return reinterpret_cast<const Duration*>(
+ &_Duration_default_instance_);
+ }
void UnsafeArenaSwap(Duration* other);
void Swap(Duration* other);
// implements Message ----------------------------------------------
- inline Duration* New() const { return New(NULL); }
+ inline Duration* New() const PROTOBUF_FINAL { return New(NULL); }
- Duration* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ Duration* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Duration& from);
void MergeFrom(const Duration& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(Duration* other);
- void UnsafeMergeFrom(const Duration& from);
protected:
explicit Duration(::google::protobuf::Arena* arena);
private:
@@ -109,19 +126,19 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
- // optional int64 seconds = 1;
+ // int64 seconds = 1;
void clear_seconds();
static const int kSecondsFieldNumber = 1;
::google::protobuf::int64 seconds() const;
void set_seconds(::google::protobuf::int64 value);
- // optional int32 nanos = 2;
+ // int32 nanos = 2;
void clear_nanos();
static const int kNanosFieldNumber = 2;
::google::protobuf::int32 nanos() const;
@@ -137,15 +154,8 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot
::google::protobuf::int64 seconds_;
::google::protobuf::int32 nanos_;
mutable int _cached_size_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fduration_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<Duration> Duration_default_instance_;
-
// ===================================================================
@@ -154,7 +164,7 @@ extern ::google::protobuf::internal::ExplicitlyConstructed<Duration> Duration_de
#if !PROTOBUF_INLINE_NOT_IN_HEADERS
// Duration
-// optional int64 seconds = 1;
+// int64 seconds = 1;
inline void Duration::clear_seconds() {
seconds_ = GOOGLE_LONGLONG(0);
}
@@ -168,7 +178,7 @@ inline void Duration::set_seconds(::google::protobuf::int64 value) {
// @@protoc_insertion_point(field_set:google.protobuf.Duration.seconds)
}
-// optional int32 nanos = 2;
+// int32 nanos = 2;
inline void Duration::clear_nanos() {
nanos_ = 0;
}
@@ -182,13 +192,11 @@ inline void Duration::set_nanos(::google::protobuf::int32 value) {
// @@protoc_insertion_point(field_set:google.protobuf.Duration.nanos)
}
-inline const Duration* Duration::internal_default_instance() {
- return &Duration_default_instance_.get();
-}
#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS
// @@protoc_insertion_point(namespace_scope)
+
} // namespace protobuf
} // namespace google
diff --git a/src/google/protobuf/dynamic_message.cc b/src/google/protobuf/dynamic_message.cc
index f51bc9d6..d6bde495 100644
--- a/src/google/protobuf/dynamic_message.cc
+++ b/src/google/protobuf/dynamic_message.cc
@@ -88,11 +88,11 @@
namespace google {
namespace protobuf {
-using internal::WireFormat;
+using internal::DynamicMapField;
using internal::ExtensionSet;
using internal::GeneratedMessageReflection;
+using internal::InternalMetadataWithArena;
using internal::MapField;
-using internal::DynamicMapField;
using internal::ArenaStringPtr;
@@ -221,7 +221,7 @@ class DynamicMessage : public Message {
int size;
int has_bits_offset;
int oneof_case_offset;
- int unknown_fields_offset;
+ int internal_metadata_offset;
int extensions_offset;
// Not owned by the TypeInfo.
@@ -231,20 +231,19 @@ class DynamicMessage : public Message {
// Warning: The order in which the following pointers are defined is
// important (the prototype must be deleted *before* the offsets).
- google::protobuf::scoped_array<int> offsets;
+ google::protobuf::scoped_array<uint32> offsets;
+ google::protobuf::scoped_array<uint32> has_bits_indices;
google::protobuf::scoped_ptr<const GeneratedMessageReflection> reflection;
// Don't use a scoped_ptr to hold the prototype: the destructor for
// DynamicMessage needs to know whether it is the prototype, and does so by
// looking back at this field. This would assume details about the
// implementation of scoped_ptr.
const DynamicMessage* prototype;
- void* default_oneof_instance;
- TypeInfo() : prototype(NULL), default_oneof_instance(NULL) {}
+ TypeInfo() : prototype(NULL) {}
~TypeInfo() {
delete prototype;
- operator delete(default_oneof_instance);
}
};
@@ -327,14 +326,15 @@ void DynamicMessage::SharedCtor() {
// Initialize oneof cases.
for (int i = 0 ; i < descriptor->oneof_decl_count(); ++i) {
- new(OffsetToPointer(type_info_->oneof_case_offset + sizeof(uint32) * i))
+ new (OffsetToPointer(type_info_->oneof_case_offset + sizeof(uint32) * i))
uint32(0);
}
- new(OffsetToPointer(type_info_->unknown_fields_offset)) UnknownFieldSet;
+ new (OffsetToPointer(type_info_->internal_metadata_offset))
+ InternalMetadataWithArena;
if (type_info_->extensions_offset != -1) {
- new(OffsetToPointer(type_info_->extensions_offset)) ExtensionSet;
+ new (OffsetToPointer(type_info_->extensions_offset)) ExtensionSet;
}
for (int i = 0; i < descriptor->field_count(); i++) {
@@ -379,10 +379,10 @@ void DynamicMessage::SharedCtor() {
if (is_prototype()) {
default_value = &field->default_value_string();
} else {
- default_value =
- &(reinterpret_cast<const ArenaStringPtr*>(
- type_info_->prototype->OffsetToPointer(
- type_info_->offsets[i]))->Get(NULL));
+ default_value = &(reinterpret_cast<const ArenaStringPtr*>(
+ type_info_->prototype->OffsetToPointer(
+ type_info_->offsets[i]))
+ ->Get());
}
ArenaStringPtr* asp = new(field_ptr) ArenaStringPtr();
asp->UnsafeSetDefault(default_value);
@@ -413,8 +413,9 @@ void DynamicMessage::SharedCtor() {
DynamicMessage::~DynamicMessage() {
const Descriptor* descriptor = type_info_->type;
- reinterpret_cast<UnknownFieldSet*>(
- OffsetToPointer(type_info_->unknown_fields_offset))->~UnknownFieldSet();
+ reinterpret_cast<InternalMetadataWithArena*>(
+ OffsetToPointer(type_info_->internal_metadata_offset))
+ ->~InternalMetadataWithArena();
if (type_info_->extensions_offset != -1) {
reinterpret_cast<ExtensionSet*>(
@@ -445,10 +446,10 @@ DynamicMessage::~DynamicMessage() {
case FieldOptions::STRING: {
const ::std::string* default_value =
&(reinterpret_cast<const ArenaStringPtr*>(
- reinterpret_cast<uint8*>(
- type_info_->default_oneof_instance)
- + type_info_->offsets[i])
- ->Get(NULL));
+ reinterpret_cast<const uint8*>(
+ type_info_->prototype) +
+ type_info_->offsets[i])
+ ->Get());
reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy(
default_value, NULL);
break;
@@ -506,8 +507,9 @@ DynamicMessage::~DynamicMessage() {
case FieldOptions::STRING: {
const ::std::string* default_value =
&(reinterpret_cast<const ArenaStringPtr*>(
- type_info_->prototype->OffsetToPointer(
- type_info_->offsets[i]))->Get(NULL));
+ type_info_->prototype->OffsetToPointer(
+ type_info_->offsets[i]))
+ ->Get());
reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy(
default_value, NULL);
break;
@@ -535,10 +537,6 @@ void DynamicMessage::CrossLinkPrototypes() {
for (int i = 0; i < descriptor->field_count(); i++) {
const FieldDescriptor* field = descriptor->field(i);
void* field_ptr = OffsetToPointer(type_info_->offsets[i]);
- if (field->containing_oneof()) {
- field_ptr = reinterpret_cast<uint8*>(
- type_info_->default_oneof_instance) + type_info_->offsets[i];
- }
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
!field->is_repeated()) {
@@ -610,7 +608,7 @@ DynamicMessageFactory::~DynamicMessageFactory() {
iter != prototypes_->map_.end(); ++iter) {
DeleteDefaultOneofInstance(iter->second->type,
iter->second->offsets.get(),
- iter->second->default_oneof_instance);
+ iter->second->prototype);
delete iter->second;
}
}
@@ -649,7 +647,8 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock(
// or not that field is set.
// Compute size and offsets.
- int* offsets = new int[type->field_count() + type->oneof_decl_count()];
+ uint32* offsets =
+ new uint32[type->field_count() + type->oneof_decl_count()];
type_info->offsets.reset(offsets);
// Decide all field offsets by packing in order.
@@ -667,6 +666,12 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock(
DivideRoundingUp(type->field_count(), bitsizeof(uint32));
size += has_bits_array_size * sizeof(uint32);
size = AlignOffset(size);
+
+ uint32* has_bits_indices = new uint32[type->field_count()];
+ for (int i = 0; i < type->field_count(); i++) {
+ has_bits_indices[i] = i;
+ }
+ type_info->has_bits_indices.reset(has_bits_indices);
}
// The oneof_case, if any. It is an array of uint32s.
@@ -687,6 +692,8 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock(
}
// All the fields.
+ //
+ // TODO(b/31226269): Optimize the order of fields to minimize padding.
for (int i = 0; i < type->field_count(); i++) {
// Make sure field is aligned to avoid bus errors.
// Oneof fields do not use any space.
@@ -705,19 +712,37 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock(
size += kMaxOneofUnionSize;
}
- // Add the UnknownFieldSet to the end.
+ // Add the InternalMetadataWithArena to the end.
size = AlignOffset(size);
- type_info->unknown_fields_offset = size;
- size += sizeof(UnknownFieldSet);
+ type_info->internal_metadata_offset = size;
+ size += sizeof(InternalMetadataWithArena);
// Align the final size to make sure no clever allocators think that
// alignment is not necessary.
- size = AlignOffset(size);
type_info->size = size;
- // Allocate the prototype.
+
+ // Construct the reflection object.
+
+ if (type->oneof_decl_count() > 0) {
+ // Compute the size of default oneof instance and offsets of default
+ // oneof fields.
+ for (int i = 0; i < type->oneof_decl_count(); i++) {
+ for (int j = 0; j < type->oneof_decl(i)->field_count(); j++) {
+ const FieldDescriptor* field = type->oneof_decl(i)->field(j);
+ int field_size = OneofFieldSpaceUsed(field);
+ size = AlignTo(size, std::min(kSafeAlignment, field_size));
+ offsets[field->index()] = size;
+ size += field_size;
+ }
+ }
+ }
+ size = AlignOffset(size);
+
+ // Allocate the prototype + oneof fields.
void* base = operator new(size);
memset(base, 0, size);
+
// The prototype in type_info has to be set before creating the prototype
// instance on memory. e.g., message Foo { map<int32, Foo> a = 1; }. When
// creating prototype for Foo, prototype of the map entry will also be
@@ -727,38 +752,26 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock(
type_info->prototype = static_cast<DynamicMessage*>(base);
DynamicMessage* prototype = new(base) DynamicMessage(type_info);
- // Construct the reflection object.
if (type->oneof_decl_count() > 0) {
- // Compute the size of default oneof instance and offsets of default
- // oneof fields.
- int oneof_size = 0;
- for (int i = 0; i < type->oneof_decl_count(); i++) {
- for (int j = 0; j < type->oneof_decl(i)->field_count(); j++) {
- const FieldDescriptor* field = type->oneof_decl(i)->field(j);
- int field_size = OneofFieldSpaceUsed(field);
- oneof_size = AlignTo(oneof_size, std::min(kSafeAlignment, field_size));
- offsets[field->index()] = oneof_size;
- oneof_size += field_size;
- }
- }
// Construct default oneof instance.
- type_info->default_oneof_instance = ::operator new(oneof_size);
ConstructDefaultOneofInstance(type_info->type,
type_info->offsets.get(),
- type_info->default_oneof_instance);
- type_info->reflection.reset(new GeneratedMessageReflection(
- type_info->type, type_info->prototype, type_info->offsets.get(),
- type_info->has_bits_offset, type_info->unknown_fields_offset,
- type_info->extensions_offset, type_info->default_oneof_instance,
- type_info->oneof_case_offset, type_info->pool, this, type_info->size,
- -1 /* arena_offset */));
- } else {
- type_info->reflection.reset(new GeneratedMessageReflection(
- type_info->type, type_info->prototype, type_info->offsets.get(),
- type_info->has_bits_offset, type_info->unknown_fields_offset,
- type_info->extensions_offset, type_info->pool, this, type_info->size,
- -1 /* arena_offset */));
+ prototype);
}
+
+ internal::ReflectionSchema schema = {
+ type_info->prototype,
+ type_info->offsets.get(),
+ type_info->has_bits_indices.get(),
+ type_info->has_bits_offset,
+ type_info->internal_metadata_offset,
+ type_info->extensions_offset,
+ type_info->oneof_case_offset,
+ type_info->size};
+
+ type_info->reflection.reset(new GeneratedMessageReflection(
+ type_info->type, schema, type_info->pool, this));
+
// Cross link prototypes.
prototype->CrossLinkPrototypes();
@@ -767,7 +780,7 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock(
void DynamicMessageFactory::ConstructDefaultOneofInstance(
const Descriptor* type,
- const int offsets[],
+ const uint32 offsets[],
void* default_oneof_instance) {
for (int i = 0; i < type->oneof_decl_count(); i++) {
for (int j = 0; j < type->oneof_decl(i)->field_count(); j++) {
@@ -813,8 +826,8 @@ void DynamicMessageFactory::ConstructDefaultOneofInstance(
void DynamicMessageFactory::DeleteDefaultOneofInstance(
const Descriptor* type,
- const int offsets[],
- void* default_oneof_instance) {
+ const uint32 offsets[],
+ const void* default_oneof_instance) {
for (int i = 0; i < type->oneof_decl_count(); i++) {
for (int j = 0; j < type->oneof_decl(i)->field_count(); j++) {
const FieldDescriptor* field = type->oneof_decl(i)->field(j);
diff --git a/src/google/protobuf/dynamic_message.h b/src/google/protobuf/dynamic_message.h
index f74cd7dd..816170ea 100644
--- a/src/google/protobuf/dynamic_message.h
+++ b/src/google/protobuf/dynamic_message.h
@@ -38,12 +38,15 @@
#ifndef GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__
#define GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__
+#include <algorithm>
#include <memory>
#ifndef _SHARED_PTR_H
#include <google/protobuf/stubs/shared_ptr.h>
#endif
+#include <vector>
#include <google/protobuf/message.h>
+#include <google/protobuf/repeated_field.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/mutex.h>
@@ -136,16 +139,97 @@ class LIBPROTOBUF_EXPORT DynamicMessageFactory : public MessageFactory {
// Construct default oneof instance for reflection usage if oneof
// is defined.
static void ConstructDefaultOneofInstance(const Descriptor* type,
- const int offsets[],
+ const uint32 offsets[],
void* default_oneof_instance);
// Delete default oneof instance. Called by ~DynamicMessageFactory.
static void DeleteDefaultOneofInstance(const Descriptor* type,
- const int offsets[],
- void* default_oneof_instance);
+ const uint32 offsets[],
+ const void* default_oneof_instance);
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMessageFactory);
};
+// Helper for computing a sorted list of map entries via reflection.
+class LIBPROTOBUF_EXPORT DynamicMapSorter {
+ public:
+ static std::vector<const Message*> Sort(const Message& message,
+ int map_size,
+ const Reflection* reflection,
+ const FieldDescriptor* field) {
+ std::vector<const Message*> result(map_size);
+ const RepeatedPtrField<Message>& map_field =
+ reflection->GetRepeatedPtrField<Message>(message, field);
+ int i = 0;
+ for (RepeatedPtrField<Message>::const_pointer_iterator it =
+ map_field.pointer_begin(); it != map_field.pointer_end(); ) {
+ result[i++] = *it++;
+ }
+ GOOGLE_DCHECK_EQ(result.size(), static_cast<size_t>(i));
+ MapEntryMessageComparator comparator(field->message_type());
+ std::sort(result.begin(), result.end(), comparator);
+ // Complain if the keys aren't in ascending order.
+#ifndef NDEBUG
+ for (int j = 1; j < map_size; j++) {
+ if (!comparator(result[j - 1], result[j])) {
+ GOOGLE_LOG(ERROR) << (comparator(result[j], result[j - 1]) ?
+ "internal error in map key sorting" :
+ "map keys are not unique");
+ }
+ }
+#endif
+ return result;
+ }
+
+ private:
+ class LIBPROTOBUF_EXPORT MapEntryMessageComparator {
+ public:
+ explicit MapEntryMessageComparator(const Descriptor* descriptor)
+ : field_(descriptor->field(0)) {}
+
+ bool operator()(const Message* a, const Message* b) {
+ const Reflection* reflection = a->GetReflection();
+ switch (field_->cpp_type()) {
+ case FieldDescriptor::CPPTYPE_BOOL: {
+ bool first = reflection->GetBool(*a, field_);
+ bool second = reflection->GetBool(*b, field_);
+ return first < second;
+ }
+ case FieldDescriptor::CPPTYPE_INT32: {
+ int32 first = reflection->GetInt32(*a, field_);
+ int32 second = reflection->GetInt32(*b, field_);
+ return first < second;
+ }
+ case FieldDescriptor::CPPTYPE_INT64: {
+ int64 first = reflection->GetInt64(*a, field_);
+ int64 second = reflection->GetInt64(*b, field_);
+ return first < second;
+ }
+ case FieldDescriptor::CPPTYPE_UINT32: {
+ uint32 first = reflection->GetUInt32(*a, field_);
+ uint32 second = reflection->GetUInt32(*b, field_);
+ return first < second;
+ }
+ case FieldDescriptor::CPPTYPE_UINT64: {
+ uint64 first = reflection->GetUInt64(*a, field_);
+ uint64 second = reflection->GetUInt64(*b, field_);
+ return first < second;
+ }
+ case FieldDescriptor::CPPTYPE_STRING: {
+ string first = reflection->GetString(*a, field_);
+ string second = reflection->GetString(*b, field_);
+ return first < second;
+ }
+ default:
+ GOOGLE_LOG(DFATAL) << "Invalid key for map field.";
+ return true;
+ }
+ }
+
+ private:
+ const FieldDescriptor* field_;
+ };
+};
+
} // namespace protobuf
} // namespace google
diff --git a/src/google/protobuf/empty.pb.cc b/src/google/protobuf/empty.pb.cc
index f19bf2a6..31cba097 100644
--- a/src/google/protobuf/empty.pb.cc
+++ b/src/google/protobuf/empty.pb.cc
@@ -19,107 +19,100 @@
namespace google {
namespace protobuf {
+class EmptyDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Empty> {
+} _Empty_default_instance_;
+
+namespace protobuf_google_2fprotobuf_2fempty_2eproto {
+
namespace {
-const ::google::protobuf::Descriptor* Empty_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- Empty_reflection_ = NULL;
+::google::protobuf::Metadata file_level_metadata[1];
} // namespace
+const ::google::protobuf::uint32 TableStruct::offsets[] = {
+ ~0u, // no _has_bits_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Empty, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+};
-void protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto() GOOGLE_ATTRIBUTE_COLD;
-void protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto() {
- protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto();
- const ::google::protobuf::FileDescriptor* file =
- ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
- "google/protobuf/empty.proto");
- GOOGLE_CHECK(file != NULL);
- Empty_descriptor_ = file->message_type(0);
- static const int Empty_offsets_[1] = {
- };
- Empty_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- Empty_descriptor_,
- Empty::internal_default_instance(),
- Empty_offsets_,
- -1,
- -1,
- -1,
- sizeof(Empty),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Empty, _internal_metadata_));
-}
+static const ::google::protobuf::internal::MigrationSchema schemas[] = {
+ { 0, -1, sizeof(Empty)},
+};
+
+static ::google::protobuf::Message const * const file_default_instances[] = {
+ reinterpret_cast<const ::google::protobuf::Message*>(&_Empty_default_instance_),
+};
namespace {
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
+void protobuf_AssignDescriptors() {
+ AddDescriptors();
+ ::google::protobuf::MessageFactory* factory = NULL;
+ AssignDescriptors(
+ "google/protobuf/empty.proto", schemas, file_default_instances, TableStruct::offsets, factory,
+ file_level_metadata, NULL, NULL);
+}
+
void protobuf_AssignDescriptorsOnce() {
- ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
- &protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto);
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);
}
void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;
void protobuf_RegisterTypes(const ::std::string&) {
protobuf_AssignDescriptorsOnce();
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- Empty_descriptor_, Empty::internal_default_instance());
+ ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1);
}
} // namespace
-void protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto() {
- Empty_default_instance_.Shutdown();
- delete Empty_reflection_;
+void TableStruct::Shutdown() {
+ _Empty_default_instance_.Shutdown();
+ delete file_level_metadata[0].reflection;
}
-void protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_impl() {
+void TableStruct::InitDefaultsImpl() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
- Empty_default_instance_.DefaultConstruct();
- Empty_default_instance_.get_mutable()->InitAsDefaultInstance();
+ ::google::protobuf::internal::InitProtobufDefaults();
+ _Empty_default_instance_.DefaultConstruct();
}
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_once_);
-void protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto() {
- ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_once_,
- &protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_impl);
+void InitDefaults() {
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);
}
-void protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_impl() {
- GOOGLE_PROTOBUF_VERIFY_VERSION;
-
- protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto();
+void AddDescriptorsImpl() {
+ InitDefaults();
+ static const char descriptor[] = {
+ "\n\033google/protobuf/empty.proto\022\017google.pr"
+ "otobuf\"\007\n\005EmptyBv\n\023com.google.protobufB\n"
+ "EmptyProtoP\001Z\'github.com/golang/protobuf"
+ "/ptypes/empty\370\001\001\242\002\003GPB\252\002\036Google.Protobuf"
+ ".WellKnownTypesb\006proto3"
+ };
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
- "\n\033google/protobuf/empty.proto\022\017google.pr"
- "otobuf\"\007\n\005EmptyBv\n\023com.google.protobufB\n"
- "EmptyProtoP\001Z\'github.com/golang/protobuf"
- "/ptypes/empty\370\001\001\242\002\003GPB\252\002\036Google.Protobuf"
- ".WellKnownTypesb\006proto3", 183);
+ descriptor, 183);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"google/protobuf/empty.proto", &protobuf_RegisterTypes);
- ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto);
+ ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);
}
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_once_);
-void protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto() {
- ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_once_,
- &protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_impl);
+void AddDescriptors() {
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
}
// Force AddDescriptors() to be called at static initialization time.
-struct StaticDescriptorInitializer_google_2fprotobuf_2fempty_2eproto {
- StaticDescriptorInitializer_google_2fprotobuf_2fempty_2eproto() {
- protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto();
+struct StaticDescriptorInitializer {
+ StaticDescriptorInitializer() {
+ AddDescriptors();
}
-} static_descriptor_initializer_google_2fprotobuf_2fempty_2eproto_;
-
-namespace {
+} static_descriptor_initializer;
-static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN;
-static void MergeFromFail(int line) {
- ::google::protobuf::internal::MergeFromFail(__FILE__, line);
-}
-
-} // namespace
+} // namespace protobuf_google_2fprotobuf_2fempty_2eproto
// ===================================================================
@@ -129,7 +122,9 @@ static void MergeFromFail(int line) {
Empty::Empty()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fempty_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.Empty)
}
@@ -137,21 +132,17 @@ Empty::Empty(::google::protobuf::Arena* arena)
: ::google::protobuf::Message(),
_internal_metadata_(arena) {
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto();
+ protobuf_google_2fprotobuf_2fempty_2eproto::InitDefaults();
#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Empty)
}
-
-void Empty::InitAsDefaultInstance() {
-}
-
Empty::Empty(const Empty& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:google.protobuf.Empty)
}
@@ -184,17 +175,15 @@ void Empty::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* Empty::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return Empty_descriptor_;
+ protobuf_google_2fprotobuf_2fempty_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fempty_2eproto::file_level_metadata[0].descriptor;
}
const Empty& Empty::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto();
+ protobuf_google_2fprotobuf_2fempty_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<Empty> Empty_default_instance_;
-
Empty* Empty::New(::google::protobuf::Arena* arena) const {
return ::google::protobuf::Arena::CreateMessage<Empty>(arena);
}
@@ -209,7 +198,7 @@ bool Empty::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Empty)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
handle_unusual:
@@ -237,7 +226,7 @@ void Empty::SerializeWithCachedSizes(
::google::protobuf::uint8* Empty::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Empty)
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Empty)
return target;
@@ -256,7 +245,7 @@ size_t Empty::ByteSizeLong() const {
void Empty::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Empty)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const Empty* source =
::google::protobuf::internal::DynamicCastToGenerated<const Empty>(
&from);
@@ -265,21 +254,14 @@ void Empty::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Empty)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void Empty::MergeFrom(const Empty& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Empty)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void Empty::UnsafeMergeFrom(const Empty& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
}
void Empty::CopyFrom(const ::google::protobuf::Message& from) {
@@ -293,11 +275,10 @@ void Empty::CopyFrom(const Empty& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Empty)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool Empty::IsInitialized() const {
-
return true;
}
@@ -306,10 +287,13 @@ void Empty::Swap(Empty* other) {
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
- Empty temp;
- temp.UnsafeMergeFrom(*this);
- CopyFrom(*other);
- other->CopyFrom(temp);
+ Empty* temp = New(GetArenaNoVirtual());
+ temp->MergeFrom(*other);
+ other->CopyFrom(*this);
+ InternalSwap(temp);
+ if (GetArenaNoVirtual() == NULL) {
+ delete temp;
+ }
}
}
void Empty::UnsafeArenaSwap(Empty* other) {
@@ -318,24 +302,17 @@ void Empty::UnsafeArenaSwap(Empty* other) {
InternalSwap(other);
}
void Empty::InternalSwap(Empty* other) {
- _internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata Empty::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = Empty_descriptor_;
- metadata.reflection = Empty_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fempty_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fempty_2eproto::file_level_metadata[0];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// Empty
-inline const Empty* Empty::internal_default_instance() {
- return &Empty_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// @@protoc_insertion_point(namespace_scope)
diff --git a/src/google/protobuf/empty.pb.h b/src/google/protobuf/empty.pb.h
index 29309366..a75d6dd6 100644
--- a/src/google/protobuf/empty.pb.h
+++ b/src/google/protobuf/empty.pb.h
@@ -8,37 +8,48 @@
#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3001000
+#if GOOGLE_PROTOBUF_VERSION < 3002000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
#endif
+#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata.h>
#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/extension_set.h>
+#include <google/protobuf/repeated_field.h> // IWYU pragma: export
+#include <google/protobuf/extension_set.h> // IWYU pragma: export
#include <google/protobuf/unknown_field_set.h>
// @@protoc_insertion_point(includes)
+namespace google {
+namespace protobuf {
+class Empty;
+class EmptyDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern EmptyDefaultTypeInternal _Empty_default_instance_;
+} // namespace protobuf
+} // namespace google
namespace google {
namespace protobuf {
+namespace protobuf_google_2fprotobuf_2fempty_2eproto {
// Internal implementation detail -- do not call these.
-void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto();
-void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto();
-void protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto();
-void protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto();
-
-class Empty;
+struct LIBPROTOBUF_EXPORT TableStruct {
+ static const ::google::protobuf::uint32 offsets[];
+ static void InitDefaultsImpl();
+ static void Shutdown();
+};
+void LIBPROTOBUF_EXPORT AddDescriptors();
+void LIBPROTOBUF_EXPORT InitDefaults();
+} // namespace protobuf_google_2fprotobuf_2fempty_2eproto
// ===================================================================
@@ -54,47 +65,53 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_
return *this;
}
- inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }
- inline void* GetMaybeArenaPointer() const {
+ inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {
+ return GetArenaNoVirtual();
+ }
+ inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {
return MaybeArenaPtr();
}
static const ::google::protobuf::Descriptor* descriptor();
static const Empty& default_instance();
- static const Empty* internal_default_instance();
+ static inline const Empty* internal_default_instance() {
+ return reinterpret_cast<const Empty*>(
+ &_Empty_default_instance_);
+ }
void UnsafeArenaSwap(Empty* other);
void Swap(Empty* other);
// implements Message ----------------------------------------------
- inline Empty* New() const { return New(NULL); }
+ inline Empty* New() const PROTOBUF_FINAL { return New(NULL); }
- Empty* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ Empty* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Empty& from);
void MergeFrom(const Empty& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(Empty* other);
- void UnsafeMergeFrom(const Empty& from);
protected:
explicit Empty(::google::protobuf::Arena* arena);
private:
@@ -109,7 +126,7 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
@@ -123,15 +140,8 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
mutable int _cached_size_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fempty_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<Empty> Empty_default_instance_;
-
// ===================================================================
@@ -140,13 +150,11 @@ extern ::google::protobuf::internal::ExplicitlyConstructed<Empty> Empty_default_
#if !PROTOBUF_INLINE_NOT_IN_HEADERS
// Empty
-inline const Empty* Empty::internal_default_instance() {
- return &Empty_default_instance_.get();
-}
#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS
// @@protoc_insertion_point(namespace_scope)
+
} // namespace protobuf
} // namespace google
diff --git a/src/google/protobuf/extension_set.cc b/src/google/protobuf/extension_set.cc
index ad164e3e..955c079b 100644
--- a/src/google/protobuf/extension_set.cc
+++ b/src/google/protobuf/extension_set.cc
@@ -76,7 +76,7 @@ inline bool is_packable(WireFormatLite::WireType type) {
}
// Registry stuff.
-typedef hash_map<pair<const MessageLite*, int>,
+typedef hash_map<std::pair<const MessageLite*, int>,
ExtensionInfo> ExtensionRegistry;
ExtensionRegistry* registry_ = NULL;
GOOGLE_PROTOBUF_DECLARE_ONCE(registry_init_);
@@ -1371,7 +1371,7 @@ size_t ExtensionSet::ByteSize() const {
bool ExtensionSet::MaybeNewExtension(int number,
const FieldDescriptor* descriptor,
Extension** result) {
- pair<ExtensionMap::iterator, bool> insert_result =
+ std::pair<ExtensionMap::iterator, bool> insert_result =
extensions_.insert(std::make_pair(number, Extension()));
*result = &insert_result.first->second;
(*result)->descriptor = descriptor;
diff --git a/src/google/protobuf/extension_set_heavy.cc b/src/google/protobuf/extension_set_heavy.cc
index 1bbc8fef..8f8f180a 100644
--- a/src/google/protobuf/extension_set_heavy.cc
+++ b/src/google/protobuf/extension_set_heavy.cc
@@ -35,6 +35,7 @@
// Contains methods defined in extension_set.h which cannot be part of the
// lite library because they use descriptors or reflection.
+#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/extension_set.h>
@@ -413,12 +414,16 @@ uint8* ExtensionSet::SerializeWithCachedSizesToArray(int start_field_number,
int end_field_number,
uint8* target) const {
return InternalSerializeWithCachedSizesToArray(
- start_field_number, end_field_number, false, target);
+ start_field_number, end_field_number,
+ google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(),
+ target);
}
uint8* ExtensionSet::SerializeMessageSetWithCachedSizesToArray(
uint8* target) const {
- return InternalSerializeMessageSetWithCachedSizesToArray(false, target);
+ return InternalSerializeMessageSetWithCachedSizesToArray(
+ google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(),
+ target);
}
uint8* ExtensionSet::InternalSerializeWithCachedSizesToArray(
@@ -587,11 +592,12 @@ ExtensionSet::Extension::InternalSerializeMessageSetItemWithCachedSizesToArray(
WireFormatLite::kMessageSetTypeIdNumber, number, target);
// Write message.
if (is_lazy) {
- target = lazymessage_value->WriteMessageToArray(
- WireFormatLite::kMessageSetMessageNumber, target);
+ target = lazymessage_value->InternalWriteMessageToArray(
+ WireFormatLite::kMessageSetMessageNumber, deterministic, target);
} else {
- target = WireFormatLite::WriteMessageToArray(
- WireFormatLite::kMessageSetMessageNumber, *message_value, target);
+ target = WireFormatLite::InternalWriteMessageToArray(
+ WireFormatLite::kMessageSetMessageNumber, *message_value, deterministic,
+ target);
}
// End group.
target = io::CodedOutputStream::WriteTagToArray(
@@ -656,7 +662,7 @@ bool ExtensionSet::ParseMessageSetItem(io::CodedInputStream* input,
string message_data;
while (true) {
- const uint32 tag = input->ReadTag();
+ const uint32 tag = input->ReadTagNoLastTag();
if (tag == 0) return false;
switch (tag) {
diff --git a/src/google/protobuf/extension_set_unittest.cc b/src/google/protobuf/extension_set_unittest.cc
index a70a2ff6..d6b823c0 100644
--- a/src/google/protobuf/extension_set_unittest.cc
+++ b/src/google/protobuf/extension_set_unittest.cc
@@ -331,7 +331,7 @@ TEST(ExtensionSetTest, SwapExtension) {
unittest::TestAllExtensions message2;
TestUtil::SetAllExtensions(&message1);
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
// Swap empty fields.
const Reflection* reflection = message1.GetReflection();
@@ -363,7 +363,7 @@ TEST(ExtensionSetTest, SwapExtensionWithEmpty) {
TestUtil::SetAllExtensions(&message3);
const Reflection* reflection = message3.GetReflection();
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
reflection->ListFields(message3, &fields);
reflection->SwapFields(&message1, &message2, fields);
@@ -380,7 +380,7 @@ TEST(ExtensionSetTest, SwapExtensionBothFull) {
TestUtil::SetAllExtensions(&message2);
const Reflection* reflection = message1.GetReflection();
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
reflection->ListFields(message1, &fields);
reflection->SwapFields(&message1, &message2, fields);
@@ -490,7 +490,7 @@ TEST(ExtensionSetTest, SwapFieldsOfExtensionBothFullWithArena) {
TestUtil::SetAllExtensions(message2);
const Reflection* reflection = message1->GetReflection();
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
reflection->ListFields(*message1, &fields);
reflection->SwapFields(message1, message2, fields);
TestUtil::ExpectAllExtensionsSet(*message1);
@@ -504,7 +504,7 @@ TEST(ExtensionSetTest, SwapExtensionWithSelf) {
TestUtil::SetAllExtensions(&message1);
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
const Reflection* reflection = message1.GetReflection();
reflection->ListFields(message1, &fields);
reflection->SwapFields(&message1, &message1, fields);
diff --git a/src/google/protobuf/field_mask.pb.cc b/src/google/protobuf/field_mask.pb.cc
index 5d80d297..c9409fe5 100644
--- a/src/google/protobuf/field_mask.pb.cc
+++ b/src/google/protobuf/field_mask.pb.cc
@@ -19,109 +19,102 @@
namespace google {
namespace protobuf {
+class FieldMaskDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FieldMask> {
+} _FieldMask_default_instance_;
+
+namespace protobuf_google_2fprotobuf_2ffield_5fmask_2eproto {
+
namespace {
-const ::google::protobuf::Descriptor* FieldMask_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- FieldMask_reflection_ = NULL;
+::google::protobuf::Metadata file_level_metadata[1];
} // namespace
+const ::google::protobuf::uint32 TableStruct::offsets[] = {
+ ~0u, // no _has_bits_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldMask, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldMask, paths_),
+};
-void protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto() GOOGLE_ATTRIBUTE_COLD;
-void protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto() {
- protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto();
- const ::google::protobuf::FileDescriptor* file =
- ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
- "google/protobuf/field_mask.proto");
- GOOGLE_CHECK(file != NULL);
- FieldMask_descriptor_ = file->message_type(0);
- static const int FieldMask_offsets_[1] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldMask, paths_),
- };
- FieldMask_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- FieldMask_descriptor_,
- FieldMask::internal_default_instance(),
- FieldMask_offsets_,
- -1,
- -1,
- -1,
- sizeof(FieldMask),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldMask, _internal_metadata_));
-}
+static const ::google::protobuf::internal::MigrationSchema schemas[] = {
+ { 0, -1, sizeof(FieldMask)},
+};
+
+static ::google::protobuf::Message const * const file_default_instances[] = {
+ reinterpret_cast<const ::google::protobuf::Message*>(&_FieldMask_default_instance_),
+};
namespace {
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
+void protobuf_AssignDescriptors() {
+ AddDescriptors();
+ ::google::protobuf::MessageFactory* factory = NULL;
+ AssignDescriptors(
+ "google/protobuf/field_mask.proto", schemas, file_default_instances, TableStruct::offsets, factory,
+ file_level_metadata, NULL, NULL);
+}
+
void protobuf_AssignDescriptorsOnce() {
- ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
- &protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto);
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);
}
void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;
void protobuf_RegisterTypes(const ::std::string&) {
protobuf_AssignDescriptorsOnce();
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- FieldMask_descriptor_, FieldMask::internal_default_instance());
+ ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1);
}
} // namespace
-void protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto() {
- FieldMask_default_instance_.Shutdown();
- delete FieldMask_reflection_;
+void TableStruct::Shutdown() {
+ _FieldMask_default_instance_.Shutdown();
+ delete file_level_metadata[0].reflection;
}
-void protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_impl() {
+void TableStruct::InitDefaultsImpl() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
- ::google::protobuf::internal::GetEmptyString();
- FieldMask_default_instance_.DefaultConstruct();
- FieldMask_default_instance_.get_mutable()->InitAsDefaultInstance();
+ ::google::protobuf::internal::InitProtobufDefaults();
+ _FieldMask_default_instance_.DefaultConstruct();
}
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_once_);
-void protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto() {
- ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_once_,
- &protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_impl);
+void InitDefaults() {
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);
}
-void protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_impl() {
- GOOGLE_PROTOBUF_VERIFY_VERSION;
-
- protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto();
+void AddDescriptorsImpl() {
+ InitDefaults();
+ static const char descriptor[] = {
+ "\n google/protobuf/field_mask.proto\022\017goog"
+ "le.protobuf\"\032\n\tFieldMask\022\r\n\005paths\030\001 \003(\tB"
+ "\211\001\n\023com.google.protobufB\016FieldMaskProtoP"
+ "\001Z9google.golang.org/genproto/protobuf/f"
+ "ield_mask;field_mask\242\002\003GPB\252\002\036Google.Prot"
+ "obuf.WellKnownTypesb\006proto3"
+ };
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
- "\n google/protobuf/field_mask.proto\022\017goog"
- "le.protobuf\"\032\n\tFieldMask\022\r\n\005paths\030\001 \003(\tB"
- "N\n\023com.google.protobufB\016FieldMaskProtoP\001"
- "\242\002\003GPB\252\002\036Google.Protobuf.WellKnownTypesb"
- "\006proto3", 167);
+ descriptor, 227);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"google/protobuf/field_mask.proto", &protobuf_RegisterTypes);
- ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto);
+ ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);
}
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_once_);
-void protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto() {
- ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_once_,
- &protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_impl);
+void AddDescriptors() {
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
}
// Force AddDescriptors() to be called at static initialization time.
-struct StaticDescriptorInitializer_google_2fprotobuf_2ffield_5fmask_2eproto {
- StaticDescriptorInitializer_google_2fprotobuf_2ffield_5fmask_2eproto() {
- protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto();
+struct StaticDescriptorInitializer {
+ StaticDescriptorInitializer() {
+ AddDescriptors();
}
-} static_descriptor_initializer_google_2fprotobuf_2ffield_5fmask_2eproto_;
-
-namespace {
-
-static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN;
-static void MergeFromFail(int line) {
- ::google::protobuf::internal::MergeFromFail(__FILE__, line);
-}
+} static_descriptor_initializer;
-} // namespace
+} // namespace protobuf_google_2fprotobuf_2ffield_5fmask_2eproto
// ===================================================================
@@ -132,19 +125,18 @@ const int FieldMask::kPathsFieldNumber;
FieldMask::FieldMask()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.FieldMask)
}
-
-void FieldMask::InitAsDefaultInstance() {
-}
-
FieldMask::FieldMask(const FieldMask& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ paths_(from.paths_),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:google.protobuf.FieldMask)
}
@@ -166,17 +158,15 @@ void FieldMask::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* FieldMask::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return FieldMask_descriptor_;
+ protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::file_level_metadata[0].descriptor;
}
const FieldMask& FieldMask::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto();
+ protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<FieldMask> FieldMask_default_instance_;
-
FieldMask* FieldMask::New(::google::protobuf::Arena* arena) const {
FieldMask* n = new FieldMask;
if (arena != NULL) {
@@ -196,14 +186,14 @@ bool FieldMask::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.FieldMask)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// repeated string paths = 1;
case 1: {
- if (tag == 10) {
- parse_paths:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->add_paths()));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
@@ -214,8 +204,6 @@ bool FieldMask::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(10)) goto parse_paths;
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -244,7 +232,7 @@ void FieldMask::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.FieldMask)
// repeated string paths = 1;
- for (int i = 0; i < this->paths_size(); i++) {
+ for (int i = 0, n = this->paths_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->paths(i).data(), this->paths(i).length(),
::google::protobuf::internal::WireFormatLite::SERIALIZE,
@@ -258,10 +246,10 @@ void FieldMask::SerializeWithCachedSizes(
::google::protobuf::uint8* FieldMask::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FieldMask)
// repeated string paths = 1;
- for (int i = 0; i < this->paths_size(); i++) {
+ for (int i = 0, n = this->paths_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->paths(i).data(), this->paths(i).length(),
::google::protobuf::internal::WireFormatLite::SERIALIZE,
@@ -281,7 +269,7 @@ size_t FieldMask::ByteSizeLong() const {
// repeated string paths = 1;
total_size += 1 *
::google::protobuf::internal::FromIntSize(this->paths_size());
- for (int i = 0; i < this->paths_size(); i++) {
+ for (int i = 0, n = this->paths_size(); i < n; i++) {
total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
this->paths(i));
}
@@ -295,7 +283,7 @@ size_t FieldMask::ByteSizeLong() const {
void FieldMask::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FieldMask)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const FieldMask* source =
::google::protobuf::internal::DynamicCastToGenerated<const FieldMask>(
&from);
@@ -304,22 +292,15 @@ void FieldMask::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FieldMask)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void FieldMask::MergeFrom(const FieldMask& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldMask)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void FieldMask::UnsafeMergeFrom(const FieldMask& from) {
- GOOGLE_DCHECK(&from != this);
- paths_.UnsafeMergeFrom(from.paths_);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ paths_.MergeFrom(from.paths_);
}
void FieldMask::CopyFrom(const ::google::protobuf::Message& from) {
@@ -333,11 +314,10 @@ void FieldMask::CopyFrom(const FieldMask& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FieldMask)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool FieldMask::IsInitialized() const {
-
return true;
}
@@ -347,16 +327,12 @@ void FieldMask::Swap(FieldMask* other) {
}
void FieldMask::InternalSwap(FieldMask* other) {
paths_.UnsafeArenaSwap(&other->paths_);
- _internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata FieldMask::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = FieldMask_descriptor_;
- metadata.reflection = FieldMask_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::file_level_metadata[0];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -381,6 +357,12 @@ void FieldMask::set_paths(int index, const ::std::string& value) {
// @@protoc_insertion_point(field_set:google.protobuf.FieldMask.paths)
paths_.Mutable(index)->assign(value);
}
+#if LANG_CXX11
+void FieldMask::set_paths(int index, ::std::string&& value) {
+ // @@protoc_insertion_point(field_set:google.protobuf.FieldMask.paths)
+ paths_.Mutable(index)->assign(std::move(value));
+}
+#endif
void FieldMask::set_paths(int index, const char* value) {
paths_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set_char:google.protobuf.FieldMask.paths)
@@ -398,6 +380,12 @@ void FieldMask::add_paths(const ::std::string& value) {
paths_.Add()->assign(value);
// @@protoc_insertion_point(field_add:google.protobuf.FieldMask.paths)
}
+#if LANG_CXX11
+void FieldMask::add_paths(::std::string&& value) {
+ paths_.Add()->assign(std::move(value));
+ // @@protoc_insertion_point(field_add:google.protobuf.FieldMask.paths)
+}
+#endif
void FieldMask::add_paths(const char* value) {
paths_.Add()->assign(value);
// @@protoc_insertion_point(field_add_char:google.protobuf.FieldMask.paths)
@@ -417,9 +405,6 @@ FieldMask::mutable_paths() {
return &paths_;
}
-inline const FieldMask* FieldMask::internal_default_instance() {
- return &FieldMask_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// @@protoc_insertion_point(namespace_scope)
diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h
index 17cb6bbf..b609f235 100644
--- a/src/google/protobuf/field_mask.pb.h
+++ b/src/google/protobuf/field_mask.pb.h
@@ -8,37 +8,48 @@
#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3001000
+#if GOOGLE_PROTOBUF_VERSION < 3002000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
#endif
+#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata.h>
#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/extension_set.h>
+#include <google/protobuf/repeated_field.h> // IWYU pragma: export
+#include <google/protobuf/extension_set.h> // IWYU pragma: export
#include <google/protobuf/unknown_field_set.h>
// @@protoc_insertion_point(includes)
+namespace google {
+namespace protobuf {
+class FieldMask;
+class FieldMaskDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern FieldMaskDefaultTypeInternal _FieldMask_default_instance_;
+} // namespace protobuf
+} // namespace google
namespace google {
namespace protobuf {
+namespace protobuf_google_2fprotobuf_2ffield_5fmask_2eproto {
// Internal implementation detail -- do not call these.
-void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto();
-void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto();
-void protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto();
-void protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto();
-
-class FieldMask;
+struct LIBPROTOBUF_EXPORT TableStruct {
+ static const ::google::protobuf::uint32 offsets[];
+ static void InitDefaultsImpl();
+ static void Shutdown();
+};
+void LIBPROTOBUF_EXPORT AddDescriptors();
+void LIBPROTOBUF_EXPORT InitDefaults();
+} // namespace protobuf_google_2fprotobuf_2ffield_5fmask_2eproto
// ===================================================================
@@ -57,49 +68,53 @@ class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@pro
static const ::google::protobuf::Descriptor* descriptor();
static const FieldMask& default_instance();
- static const FieldMask* internal_default_instance();
+ static inline const FieldMask* internal_default_instance() {
+ return reinterpret_cast<const FieldMask*>(
+ &_FieldMask_default_instance_);
+ }
void Swap(FieldMask* other);
// implements Message ----------------------------------------------
- inline FieldMask* New() const { return New(NULL); }
+ inline FieldMask* New() const PROTOBUF_FINAL { return New(NULL); }
- FieldMask* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ FieldMask* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const FieldMask& from);
void MergeFrom(const FieldMask& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(FieldMask* other);
- void UnsafeMergeFrom(const FieldMask& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
@@ -112,10 +127,16 @@ class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@pro
const ::std::string& paths(int index) const;
::std::string* mutable_paths(int index);
void set_paths(int index, const ::std::string& value);
+ #if LANG_CXX11
+ void set_paths(int index, ::std::string&& value);
+ #endif
void set_paths(int index, const char* value);
void set_paths(int index, const char* value, size_t size);
::std::string* add_paths();
void add_paths(const ::std::string& value);
+ #if LANG_CXX11
+ void add_paths(::std::string&& value);
+ #endif
void add_paths(const char* value);
void add_paths(const char* value, size_t size);
const ::google::protobuf::RepeatedPtrField< ::std::string>& paths() const;
@@ -127,15 +148,8 @@ class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@pro
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::google::protobuf::RepeatedPtrField< ::std::string> paths_;
mutable int _cached_size_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2ffield_5fmask_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<FieldMask> FieldMask_default_instance_;
-
// ===================================================================
@@ -163,6 +177,12 @@ inline void FieldMask::set_paths(int index, const ::std::string& value) {
// @@protoc_insertion_point(field_set:google.protobuf.FieldMask.paths)
paths_.Mutable(index)->assign(value);
}
+#if LANG_CXX11
+inline void FieldMask::set_paths(int index, ::std::string&& value) {
+ // @@protoc_insertion_point(field_set:google.protobuf.FieldMask.paths)
+ paths_.Mutable(index)->assign(std::move(value));
+}
+#endif
inline void FieldMask::set_paths(int index, const char* value) {
paths_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set_char:google.protobuf.FieldMask.paths)
@@ -180,6 +200,12 @@ inline void FieldMask::add_paths(const ::std::string& value) {
paths_.Add()->assign(value);
// @@protoc_insertion_point(field_add:google.protobuf.FieldMask.paths)
}
+#if LANG_CXX11
+inline void FieldMask::add_paths(::std::string&& value) {
+ paths_.Add()->assign(std::move(value));
+ // @@protoc_insertion_point(field_add:google.protobuf.FieldMask.paths)
+}
+#endif
inline void FieldMask::add_paths(const char* value) {
paths_.Add()->assign(value);
// @@protoc_insertion_point(field_add_char:google.protobuf.FieldMask.paths)
@@ -199,13 +225,11 @@ FieldMask::mutable_paths() {
return &paths_;
}
-inline const FieldMask* FieldMask::internal_default_instance() {
- return &FieldMask_default_instance_.get();
-}
#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS
// @@protoc_insertion_point(namespace_scope)
+
} // namespace protobuf
} // namespace google
diff --git a/src/google/protobuf/field_mask.proto b/src/google/protobuf/field_mask.proto
index b6d32a79..c68d247c 100644
--- a/src/google/protobuf/field_mask.proto
+++ b/src/google/protobuf/field_mask.proto
@@ -37,6 +37,7 @@ option java_package = "com.google.protobuf";
option java_outer_classname = "FieldMaskProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
+option go_package = "google.golang.org/genproto/protobuf/field_mask;field_mask";
// `FieldMask` represents a set of symbolic field paths, for example:
//
diff --git a/src/google/protobuf/generated_message_reflection.cc b/src/google/protobuf/generated_message_reflection.cc
index 6f418433..2f8f8256 100644
--- a/src/google/protobuf/generated_message_reflection.cc
+++ b/src/google/protobuf/generated_message_reflection.cc
@@ -44,6 +44,7 @@
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/map_field.h>
#include <google/protobuf/repeated_field.h>
+// #include "google/protobuf/bridge/compatibility_mode_support.h"
#define GOOGLE_PROTOBUF_HAS_ONEOF
@@ -72,18 +73,28 @@ const string& NameOfEnum(const EnumDescriptor* descriptor, int value) {
return (d == NULL ? GetEmptyString() : d->name());
}
-namespace {
-inline bool SupportsArenas(const Descriptor* descriptor) {
- return descriptor->file()->options().cc_enable_arenas();
-}
-} // anonymous namespace
-
// ===================================================================
// Helpers for reporting usage errors (e.g. trying to use GetInt32() on
// a string field).
namespace {
+template <class To>
+To* GetPointerAtOffset(Message* message, uint32 offset) {
+ return reinterpret_cast<To*>(reinterpret_cast<char*>(message) + offset);
+}
+
+template <class To>
+const To* GetConstPointerAtOffset(const Message* message, uint32 offset) {
+ return reinterpret_cast<const To*>(reinterpret_cast<const char*>(message) +
+ offset);
+}
+
+template <class To>
+const To& GetConstRefAtOffset(const Message& message, uint32 offset) {
+ return *GetConstPointerAtOffset<To>(&message, offset);
+}
+
void ReportReflectionUsageError(
const Descriptor* descriptor, const FieldDescriptor* field,
const char* method, const char* description) {
@@ -173,43 +184,14 @@ static void ReportReflectionUsageEnumTypeError(
// ===================================================================
GeneratedMessageReflection::GeneratedMessageReflection(
- const Descriptor* descriptor, const Message* default_instance,
- const int offsets[], int has_bits_offset, int unknown_fields_offset,
- int extensions_offset, const DescriptorPool* descriptor_pool,
- MessageFactory* factory, int object_size, int arena_offset)
+ const Descriptor* descriptor, const ReflectionSchema& schema,
+ const DescriptorPool* pool, MessageFactory* factory)
: descriptor_(descriptor),
- default_instance_(default_instance),
- offsets_(offsets),
- has_bits_offset_(has_bits_offset),
- unknown_fields_offset_(unknown_fields_offset),
- extensions_offset_(extensions_offset),
- arena_offset_(arena_offset),
- object_size_(object_size),
- descriptor_pool_((descriptor_pool == NULL)
- ? DescriptorPool::generated_pool()
- : descriptor_pool),
- message_factory_(factory) {}
-
-GeneratedMessageReflection::GeneratedMessageReflection(
- const Descriptor* descriptor, const Message* default_instance,
- const int offsets[], int has_bits_offset, int unknown_fields_offset,
- int extensions_offset, const void* default_oneof_instance,
- int oneof_case_offset, const DescriptorPool* descriptor_pool,
- MessageFactory* factory, int object_size, int arena_offset)
- : descriptor_(descriptor),
- default_instance_(default_instance),
- default_oneof_instance_(default_oneof_instance),
- offsets_(offsets),
- has_bits_offset_(has_bits_offset),
- oneof_case_offset_(oneof_case_offset),
- unknown_fields_offset_(unknown_fields_offset),
- extensions_offset_(extensions_offset),
- arena_offset_(arena_offset),
- object_size_(object_size),
- descriptor_pool_((descriptor_pool == NULL)
- ? DescriptorPool::generated_pool()
- : descriptor_pool),
- message_factory_(factory) {}
+ schema_(schema),
+ descriptor_pool_((pool == NULL) ? DescriptorPool::generated_pool()
+ : pool),
+ message_factory_(factory) {
+}
GeneratedMessageReflection::~GeneratedMessageReflection() {}
@@ -236,39 +218,33 @@ const UnknownFieldSet& GetEmptyUnknownFieldSet() {
const UnknownFieldSet& GeneratedMessageReflection::GetUnknownFields(
const Message& message) const {
if (descriptor_->file()->syntax() == FileDescriptor::SYNTAX_PROTO3) {
+ // We have to ensure that any mutations made to the return value of
+ // MutableUnknownFields() are not reflected here.
return GetEmptyUnknownFieldSet();
- }
- if (unknown_fields_offset_ == kUnknownFieldSetInMetadata) {
+ } else {
return GetInternalMetadataWithArena(message).unknown_fields();
}
- const void* ptr = reinterpret_cast<const uint8*>(&message) +
- unknown_fields_offset_;
- return *reinterpret_cast<const UnknownFieldSet*>(ptr);
}
UnknownFieldSet* GeneratedMessageReflection::MutableUnknownFields(
Message* message) const {
- if (unknown_fields_offset_ == kUnknownFieldSetInMetadata) {
- return MutableInternalMetadataWithArena(message)->
- mutable_unknown_fields();
- }
- void* ptr = reinterpret_cast<uint8*>(message) + unknown_fields_offset_;
- return reinterpret_cast<UnknownFieldSet*>(ptr);
+ return MutableInternalMetadataWithArena(message)->mutable_unknown_fields();
}
int GeneratedMessageReflection::SpaceUsed(const Message& message) const {
// object_size_ already includes the in-memory representation of each field
// in the message, so we only need to account for additional memory used by
// the fields.
- int total_size = object_size_;
+ int total_size = schema_.GetObjectSize();
total_size += GetUnknownFields(message).SpaceUsedExcludingSelf();
- if (extensions_offset_ != -1) {
+ if (schema_.HasExtensionSet()) {
total_size += GetExtensionSet(message).SpaceUsedExcludingSelf();
}
- for (int i = 0; i < descriptor_->field_count(); i++) {
+ const int field_count = descriptor_->field_count();
+ for (int i = 0; i < field_count; i++) {
const FieldDescriptor* field = descriptor_->field(i);
if (field->is_repeated()) {
@@ -337,9 +313,9 @@ int GeneratedMessageReflection::SpaceUsed(const Message& message) const {
// the prototype. Only count the string if it has been changed
// from the default value.
const string* default_ptr =
- &DefaultRaw<ArenaStringPtr>(field).Get(NULL);
+ &DefaultRaw<ArenaStringPtr>(field).Get();
const string* ptr =
- &GetField<ArenaStringPtr>(message, field).Get(default_ptr);
+ &GetField<ArenaStringPtr>(message, field).Get();
if (ptr != default_ptr) {
// string fields are represented by just a pointer, so also
@@ -353,7 +329,7 @@ int GeneratedMessageReflection::SpaceUsed(const Message& message) const {
}
case FieldDescriptor::CPPTYPE_MESSAGE:
- if (&message == default_instance_) {
+ if (schema_.IsDefaultInstance(message)) {
// For singular fields, the prototype just stores a pointer to the
// external type's prototype, so there is no extra memory usage.
} else {
@@ -475,9 +451,9 @@ void GeneratedMessageReflection::SwapField(
string1->Swap(string2);
} else {
const string* default_ptr =
- &DefaultRaw<ArenaStringPtr>(field).Get(NULL);
- const string temp = string1->Get(default_ptr);
- string1->Set(default_ptr, string2->Get(default_ptr), arena1);
+ &DefaultRaw<ArenaStringPtr>(field).Get();
+ const string temp = string1->Get();
+ string1->Set(default_ptr, string2->Get(), arena1);
string2->Set(default_ptr, temp, arena2);
}
}
@@ -638,37 +614,49 @@ void GeneratedMessageReflection::Swap(
// Slow copy path.
// Use our arena as temp space, if available.
Message* temp = message1->New(GetArena(message1));
- temp->MergeFrom(*message1);
- message1->CopyFrom(*message2);
- message2->CopyFrom(*temp);
+ temp->MergeFrom(*message2);
+ message2->CopyFrom(*message1);
+ Swap(message1, temp);
if (GetArena(message1) == NULL) {
delete temp;
}
return;
}
- if (has_bits_offset_ != -1) {
+ if (schema_.HasHasbits()) {
uint32* has_bits1 = MutableHasBits(message1);
uint32* has_bits2 = MutableHasBits(message2);
- int has_bits_size = (descriptor_->field_count() + 31) / 32;
+
+ int fields_with_has_bits = 0;
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const FieldDescriptor* field = descriptor_->field(i);
+ if (field->is_repeated() || field->containing_oneof()) {
+ continue;
+ }
+ fields_with_has_bits++;
+ }
+
+ int has_bits_size = (fields_with_has_bits + 31) / 32;
for (int i = 0; i < has_bits_size; i++) {
std::swap(has_bits1[i], has_bits2[i]);
}
}
- for (int i = 0; i < descriptor_->field_count(); i++) {
+ const int field_count = descriptor_->field_count();
+ for (int i = 0; i < field_count; i++) {
const FieldDescriptor* field = descriptor_->field(i);
if (!field->containing_oneof()) {
SwapField(message1, message2, field);
}
}
- for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
+ const int oneof_decl_count = descriptor_->oneof_decl_count();
+ for (int i = 0; i < oneof_decl_count; i++) {
SwapOneofField(message1, message2, descriptor_->oneof_decl(i));
}
- if (extensions_offset_ != -1) {
+ if (schema_.HasExtensionSet()) {
MutableExtensionSet(message1)->Swap(MutableExtensionSet(message2));
}
@@ -678,7 +666,7 @@ void GeneratedMessageReflection::Swap(
void GeneratedMessageReflection::SwapFields(
Message* message1,
Message* message2,
- const vector<const FieldDescriptor*>& fields) const {
+ const std::vector<const FieldDescriptor*>& fields) const {
if (message1 == message2) return;
// TODO(kenton): Other Reflection methods should probably check this too.
@@ -699,7 +687,8 @@ void GeneratedMessageReflection::SwapFields(
std::set<int> swapped_oneof;
- for (int i = 0; i < fields.size(); i++) {
+ const int fields_size = static_cast<int>(fields.size());
+ for (int i = 0; i < fields_size; i++) {
const FieldDescriptor* field = fields[i];
if (field->is_extension()) {
MutableExtensionSet(message1)->SwapExtension(
@@ -715,8 +704,11 @@ void GeneratedMessageReflection::SwapFields(
swapped_oneof.insert(oneof_index);
SwapOneofField(message1, message2, field->containing_oneof());
} else {
- // Swap has bit.
- SwapBit(message1, message2, field);
+ // Swap has bit for non-repeated fields. We have already checked for
+ // oneof already.
+ if (!field->is_repeated()) {
+ SwapBit(message1, message2, field);
+ }
// Swap field.
SwapField(message1, message2, field);
}
@@ -821,9 +813,9 @@ void GeneratedMessageReflection::ClearField(
default: // TODO(kenton): Support other string reps.
case FieldOptions::STRING: {
const string* default_ptr =
- &DefaultRaw<ArenaStringPtr>(field).Get(NULL);
- MutableRaw<ArenaStringPtr>(message, field)->Destroy(default_ptr,
- GetArena(message));
+ &DefaultRaw<ArenaStringPtr>(field).Get();
+ MutableRaw<ArenaStringPtr>(message, field)->SetAllocated(
+ default_ptr, NULL, GetArena(message));
break;
}
}
@@ -831,7 +823,7 @@ void GeneratedMessageReflection::ClearField(
}
case FieldDescriptor::CPPTYPE_MESSAGE:
- if (has_bits_offset_ == -1) {
+ if (!schema_.HasHasbits()) {
// Proto3 does not have has-bits and we need to set a message field
// to NULL in order to indicate its un-presence.
if (GetArena(message) == NULL) {
@@ -1008,28 +1000,36 @@ struct FieldNumberSorter {
}
};
-inline bool IsIndexInHasBitSet(const uint32* has_bit_set, uint32 index) {
- return ((has_bit_set[index / 32] >> (index % 32)) & static_cast<uint32>(1))
- != 0;
+inline bool IsIndexInHasBitSet(
+ const uint32* has_bit_set, uint32 has_bit_index) {
+ GOOGLE_DCHECK_NE(has_bit_index, ~0u);
+ return ((has_bit_set[has_bit_index / 32] >> (has_bit_index % 32)) &
+ static_cast<uint32>(1)) != 0;
}
} // namespace
void GeneratedMessageReflection::ListFields(
const Message& message,
- vector<const FieldDescriptor*>* output) const {
+ std::vector<const FieldDescriptor*>* output) const {
output->clear();
// Optimization: The default instance never has any fields set.
- if (&message == default_instance_) return;
+ if (schema_.IsDefaultInstance(message)) return;
// Optimization: Avoid calling GetHasBits() and HasOneofField() many times
- // within the field loop.
- const uint32* const has_bits = GetHasBits(message);
- const uint32* const oneof_case_array = reinterpret_cast<const uint32*>(
- reinterpret_cast<const uint8*>(&message) + oneof_case_offset_);
-
- output->reserve(descriptor_->field_count());
- for (int i = 0; i < descriptor_->field_count(); i++) {
+ // within the field loop. We allow this violation of ReflectionSchema
+ // encapsulation because this function takes a noticable about of CPU
+ // fleetwide and properly allowing this optimization through public interfaces
+ // seems more trouble than it is worth.
+ const uint32* const has_bits =
+ schema_.HasHasbits() ? GetHasBits(message) : NULL;
+ const uint32* const has_bits_indices = schema_.has_bit_indices_;
+ const uint32* const oneof_case_array =
+ &GetConstRefAtOffset<uint32>(message, schema_.oneof_case_offset_);
+
+ const int field_count = descriptor_->field_count();
+ output->reserve(field_count);
+ for (int i = 0; i < field_count; i++) {
const FieldDescriptor* field = descriptor_->field(i);
if (field->is_repeated()) {
if (FieldSize(message, field) > 0) {
@@ -1044,7 +1044,7 @@ void GeneratedMessageReflection::ListFields(
}
} else if (has_bits) {
// Equivalent to: HasBit(message, field)
- if (IsIndexInHasBitSet(has_bits, i)) {
+ if (IsIndexInHasBitSet(has_bits, has_bits_indices[i])) {
output->push_back(field);
}
} else if (HasBit(message, field)) { // Fall back on proto3-style HasBit.
@@ -1053,7 +1053,7 @@ void GeneratedMessageReflection::ListFields(
}
}
- if (extensions_offset_ != -1) {
+ if (schema_.HasExtensionSet()) {
GetExtensionSet(message).AppendToList(descriptor_, descriptor_pool_,
output);
}
@@ -1147,9 +1147,7 @@ string GeneratedMessageReflection::GetString(
switch (field->options().ctype()) {
default: // TODO(kenton): Support other string reps.
case FieldOptions::STRING: {
- const string* default_ptr =
- &DefaultRaw<ArenaStringPtr>(field).Get(NULL);
- return GetField<ArenaStringPtr>(message, field).Get(default_ptr);
+ return GetField<ArenaStringPtr>(message, field).Get();
}
}
@@ -1169,9 +1167,7 @@ const string& GeneratedMessageReflection::GetStringReference(
switch (field->options().ctype()) {
default: // TODO(kenton): Support other string reps.
case FieldOptions::STRING: {
- const string* default_ptr =
- &DefaultRaw<ArenaStringPtr>(field).Get(NULL);
- return GetField<ArenaStringPtr>(message, field).Get(default_ptr);
+ return GetField<ArenaStringPtr>(message, field).Get();
}
}
@@ -1192,8 +1188,7 @@ void GeneratedMessageReflection::SetString(
switch (field->options().ctype()) {
default: // TODO(kenton): Support other string reps.
case FieldOptions::STRING: {
- const string* default_ptr =
- &DefaultRaw<ArenaStringPtr>(field).Get(NULL);
+ const string* default_ptr = &DefaultRaw<ArenaStringPtr>(field).Get();
if (field->containing_oneof() && !HasOneofField(*message, field)) {
ClearOneof(message, field->containing_oneof());
MutableField<ArenaStringPtr>(message, field)->UnsafeSetDefault(
@@ -1513,7 +1508,7 @@ void GeneratedMessageReflection::UnsafeArenaSetAllocatedMessage(
USAGE_CHECK_ALL(SetAllocatedMessage, SINGULAR, MESSAGE);
if (field->is_extension()) {
- MutableExtensionSet(message)->SetAllocatedMessage(
+ MutableExtensionSet(message)->UnsafeArenaSetAllocatedMessage(
field->number(), field->type(), field, sub_message);
} else {
if (field->containing_oneof()) {
@@ -1581,7 +1576,9 @@ Message* GeneratedMessageReflection::UnsafeArenaReleaseMessage(
MutableExtensionSet(message)->UnsafeArenaReleaseMessage(field,
factory));
} else {
- ClearBit(message, field);
+ if (!(field->is_repeated() || field->containing_oneof())) {
+ ClearBit(message, field);
+ }
if (field->containing_oneof()) {
if (HasOneofField(*message, field)) {
*MutableOneofCase(message, field->containing_oneof()) = 0;
@@ -1727,11 +1724,10 @@ void* GeneratedMessageReflection::MutableRawRepeatedField(
} else {
// Trigger transform for MapField
if (IsMapFieldInApi(field)) {
- return reinterpret_cast<MapFieldBase*>(reinterpret_cast<uint8*>(message) +
- offsets_[field->index()])
+ return MutableRawNonOneof<MapFieldBase>(message, field)
->MutableRepeatedField();
}
- return reinterpret_cast<uint8*>(message) + offsets_[field->index()];
+ return MutableRawNonOneof<void>(message, field);
}
}
@@ -1758,11 +1754,9 @@ const void* GeneratedMessageReflection::GetRawRepeatedField(
} else {
// Trigger transform for MapField
if (IsMapFieldInApi(field)) {
- return &(reinterpret_cast<const MapFieldBase*>(
- reinterpret_cast<const uint8*>(&message) +
- offsets_[field->index()])->GetRepeatedField());
+ return &(GetRawNonOneof<MapFieldBase>(message, field).GetRepeatedField());
}
- return reinterpret_cast<const uint8*>(&message) + offsets_[field->index()];
+ return &GetRawNonOneof<char>(message, field);
}
}
@@ -1844,7 +1838,7 @@ int GeneratedMessageReflection::MapSize(
const FieldDescriptor* GeneratedMessageReflection::FindKnownExtensionByName(
const string& name) const {
- if (extensions_offset_ == -1) return NULL;
+ if (!schema_.HasExtensionSet()) return NULL;
const FieldDescriptor* result = descriptor_pool_->FindExtensionByName(name);
if (result != NULL && result->containing_type() == descriptor_) {
@@ -1856,7 +1850,8 @@ const FieldDescriptor* GeneratedMessageReflection::FindKnownExtensionByName(
const Descriptor* type = descriptor_pool_->FindMessageTypeByName(name);
if (type != NULL) {
// Look for a matching extension in the foreign type's scope.
- for (int i = 0; i < type->extension_count(); i++) {
+ const int type_extension_count = type->extension_count();
+ for (int i = 0; i < type_extension_count; i++) {
const FieldDescriptor* extension = type->extension(i);
if (extension->containing_type() == descriptor_ &&
extension->type() == FieldDescriptor::TYPE_MESSAGE &&
@@ -1874,7 +1869,7 @@ const FieldDescriptor* GeneratedMessageReflection::FindKnownExtensionByName(
const FieldDescriptor* GeneratedMessageReflection::FindKnownExtensionByNumber(
int number) const {
- if (extensions_offset_ == -1) return NULL;
+ if (!schema_.HasExtensionSet()) return NULL;
return descriptor_pool_->FindExtensionByNumber(descriptor_, number);
}
@@ -1887,202 +1882,176 @@ bool GeneratedMessageReflection::SupportsUnknownEnumValues() const {
// These simple template accessors obtain pointers (or references) to
// the given field.
+
+template <class Type>
+const Type& GeneratedMessageReflection::GetRawNonOneof(
+ const Message& message, const FieldDescriptor* field) const {
+ return GetConstRefAtOffset<Type>(message,
+ schema_.GetFieldOffsetNonOneof(field));
+}
+
+template <class Type>
+Type* GeneratedMessageReflection::MutableRawNonOneof(
+ Message* message, const FieldDescriptor* field) const {
+ return GetPointerAtOffset<Type>(message,
+ schema_.GetFieldOffsetNonOneof(field));
+}
+
template <typename Type>
-inline const Type& GeneratedMessageReflection::GetRaw(
+const Type& GeneratedMessageReflection::GetRaw(
const Message& message, const FieldDescriptor* field) const {
if (field->containing_oneof() && !HasOneofField(message, field)) {
return DefaultRaw<Type>(field);
}
- int index = field->containing_oneof() ?
- descriptor_->field_count() + field->containing_oneof()->index() :
- field->index();
- const void* ptr = reinterpret_cast<const uint8*>(&message) +
- offsets_[index];
- return *reinterpret_cast<const Type*>(ptr);
+ return GetConstRefAtOffset<Type>(message, schema_.GetFieldOffset(field));
}
template <typename Type>
-inline Type* GeneratedMessageReflection::MutableRaw(
- Message* message, const FieldDescriptor* field) const {
- int index = field->containing_oneof() ?
- descriptor_->field_count() + field->containing_oneof()->index() :
- field->index();
- void* ptr = reinterpret_cast<uint8*>(message) + offsets_[index];
- return reinterpret_cast<Type*>(ptr);
+Type* GeneratedMessageReflection::MutableRaw(Message* message,
+ const FieldDescriptor* field) const {
+ return GetPointerAtOffset<Type>(message, schema_.GetFieldOffset(field));
}
-template <typename Type>
-inline const Type& GeneratedMessageReflection::DefaultRaw(
- const FieldDescriptor* field) const {
- const void* ptr = field->containing_oneof() ?
- reinterpret_cast<const uint8*>(default_oneof_instance_) +
- offsets_[field->index()] :
- reinterpret_cast<const uint8*>(default_instance_) +
- offsets_[field->index()];
- return *reinterpret_cast<const Type*>(ptr);
-}
inline const uint32* GeneratedMessageReflection::GetHasBits(
const Message& message) const {
- if (has_bits_offset_ == -1) { // proto3 with no has-bits.
- return NULL;
- }
- const void* ptr = reinterpret_cast<const uint8*>(&message) + has_bits_offset_;
- return reinterpret_cast<const uint32*>(ptr);
+ GOOGLE_DCHECK(schema_.HasHasbits());
+ return &GetConstRefAtOffset<uint32>(message, schema_.HasBitsOffset());
}
+
inline uint32* GeneratedMessageReflection::MutableHasBits(
Message* message) const {
- if (has_bits_offset_ == -1) {
- return NULL;
- }
- void* ptr = reinterpret_cast<uint8*>(message) + has_bits_offset_;
- return reinterpret_cast<uint32*>(ptr);
+ GOOGLE_DCHECK(schema_.HasHasbits());
+ return GetPointerAtOffset<uint32>(message, schema_.HasBitsOffset());
}
inline uint32 GeneratedMessageReflection::GetOneofCase(
- const Message& message,
- const OneofDescriptor* oneof_descriptor) const {
- const void* ptr = reinterpret_cast<const uint8*>(&message)
- + oneof_case_offset_;
- return reinterpret_cast<const uint32*>(ptr)[oneof_descriptor->index()];
+ const Message& message, const OneofDescriptor* oneof_descriptor) const {
+ return GetConstRefAtOffset<uint32>(
+ message, schema_.GetOneofCaseOffset(oneof_descriptor));
}
inline uint32* GeneratedMessageReflection::MutableOneofCase(
- Message* message,
- const OneofDescriptor* oneof_descriptor) const {
- void* ptr = reinterpret_cast<uint8*>(message) + oneof_case_offset_;
- return &(reinterpret_cast<uint32*>(ptr)[oneof_descriptor->index()]);
+ Message* message, const OneofDescriptor* oneof_descriptor) const {
+ return GetPointerAtOffset<uint32>(
+ message, schema_.GetOneofCaseOffset(oneof_descriptor));
}
inline const ExtensionSet& GeneratedMessageReflection::GetExtensionSet(
const Message& message) const {
- GOOGLE_DCHECK_NE(extensions_offset_, -1);
- const void* ptr = reinterpret_cast<const uint8*>(&message) +
- extensions_offset_;
- return *reinterpret_cast<const ExtensionSet*>(ptr);
+ return GetConstRefAtOffset<ExtensionSet>(message,
+ schema_.GetExtensionSetOffset());
}
+
inline ExtensionSet* GeneratedMessageReflection::MutableExtensionSet(
Message* message) const {
- GOOGLE_DCHECK_NE(extensions_offset_, -1);
- void* ptr = reinterpret_cast<uint8*>(message) + extensions_offset_;
- return reinterpret_cast<ExtensionSet*>(ptr);
+ return GetPointerAtOffset<ExtensionSet>(message,
+ schema_.GetExtensionSetOffset());
}
inline Arena* GeneratedMessageReflection::GetArena(Message* message) const {
- if (arena_offset_ == kNoArenaPointer) {
- return NULL;
- }
-
- if (unknown_fields_offset_ == kUnknownFieldSetInMetadata) {
- // zero-overhead arena pointer overloading UnknownFields
- return GetInternalMetadataWithArena(*message).arena();
- }
-
- // Baseline case: message class has a dedicated arena pointer.
- void* ptr = reinterpret_cast<uint8*>(message) + arena_offset_;
- return *reinterpret_cast<Arena**>(ptr);
+ return GetInternalMetadataWithArena(*message).arena();
}
inline const InternalMetadataWithArena&
GeneratedMessageReflection::GetInternalMetadataWithArena(
const Message& message) const {
- const void* ptr = reinterpret_cast<const uint8*>(&message) + arena_offset_;
- return *reinterpret_cast<const InternalMetadataWithArena*>(ptr);
+ return GetConstRefAtOffset<InternalMetadataWithArena>(
+ message, schema_.GetMetadataOffset());
}
inline InternalMetadataWithArena*
GeneratedMessageReflection::MutableInternalMetadataWithArena(
Message* message) const {
- void* ptr = reinterpret_cast<uint8*>(message) + arena_offset_;
- return reinterpret_cast<InternalMetadataWithArena*>(ptr);
+ return GetPointerAtOffset<InternalMetadataWithArena>(
+ message, schema_.GetMetadataOffset());
}
-inline bool
-GeneratedMessageReflection::GetIsDefaultInstance(
- const Message& message) const {
- return &message == default_instance_;
+template <typename Type>
+inline const Type& GeneratedMessageReflection::DefaultRaw(
+ const FieldDescriptor* field) const {
+ return *reinterpret_cast<const Type*>(schema_.GetFieldDefault(field));
}
// Simple accessors for manipulating has_bits_.
inline bool GeneratedMessageReflection::HasBit(
const Message& message, const FieldDescriptor* field) const {
- if (has_bits_offset_ == -1) {
- // proto3: no has-bits. All fields present except messages, which are
- // present only if their message-field pointer is non-NULL.
- if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
- return !GetIsDefaultInstance(message) &&
- GetRaw<const Message*>(message, field) != NULL;
- } else {
- // Non-message field (and non-oneof, since that was handled in HasField()
- // before calling us), and singular (again, checked in HasField). So, this
- // field must be a scalar.
-
- // Scalar primitive (numeric or string/bytes) fields are present if
- // their value is non-zero (numeric) or non-empty (string/bytes). N.B.:
- // we must use this definition here, rather than the "scalar fields
- // always present" in the proto3 docs, because MergeFrom() semantics
- // require presence as "present on wire", and reflection-based merge
- // (which uses HasField()) needs to be consistent with this.
- switch (field->cpp_type()) {
- case FieldDescriptor::CPPTYPE_STRING:
- switch (field->options().ctype()) {
- default: {
- const string* default_ptr =
- &DefaultRaw<ArenaStringPtr>(field).Get(NULL);
- return GetField<ArenaStringPtr>(message, field).Get(
- default_ptr).size() > 0;
- }
+ if (schema_.HasHasbits()) {
+ return IsIndexInHasBitSet(GetHasBits(message), schema_.HasBitIndex(field));
+ }
+
+ // proto3: no has-bits. All fields present except messages, which are
+ // present only if their message-field pointer is non-NULL.
+ if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
+ return !schema_.IsDefaultInstance(message) &&
+ GetRaw<const Message*>(message, field) != NULL;
+ } else {
+ // Non-message field (and non-oneof, since that was handled in HasField()
+ // before calling us), and singular (again, checked in HasField). So, this
+ // field must be a scalar.
+
+ // Scalar primitive (numeric or string/bytes) fields are present if
+ // their value is non-zero (numeric) or non-empty (string/bytes). N.B.:
+ // we must use this definition here, rather than the "scalar fields
+ // always present" in the proto3 docs, because MergeFrom() semantics
+ // require presence as "present on wire", and reflection-based merge
+ // (which uses HasField()) needs to be consistent with this.
+ switch (field->cpp_type()) {
+ case FieldDescriptor::CPPTYPE_STRING:
+ switch (field->options().ctype()) {
+ default: {
+ return GetField<ArenaStringPtr>(message, field).Get().size() > 0;
}
- return false;
- case FieldDescriptor::CPPTYPE_BOOL:
- return GetRaw<bool>(message, field) != false;
- case FieldDescriptor::CPPTYPE_INT32:
- return GetRaw<int32>(message, field) != 0;
- case FieldDescriptor::CPPTYPE_INT64:
- return GetRaw<int64>(message, field) != 0;
- case FieldDescriptor::CPPTYPE_UINT32:
- return GetRaw<uint32>(message, field) != 0;
- case FieldDescriptor::CPPTYPE_UINT64:
- return GetRaw<uint64>(message, field) != 0;
- case FieldDescriptor::CPPTYPE_FLOAT:
- return GetRaw<float>(message, field) != 0.0;
- case FieldDescriptor::CPPTYPE_DOUBLE:
- return GetRaw<double>(message, field) != 0.0;
- case FieldDescriptor::CPPTYPE_ENUM:
- return GetRaw<int>(message, field) != 0;
- case FieldDescriptor::CPPTYPE_MESSAGE:
- // handled above; avoid warning
- GOOGLE_LOG(FATAL) << "Reached impossible case in HasBit().";
- break;
- }
+ }
+ return false;
+ case FieldDescriptor::CPPTYPE_BOOL:
+ return GetRaw<bool>(message, field) != false;
+ case FieldDescriptor::CPPTYPE_INT32:
+ return GetRaw<int32>(message, field) != 0;
+ case FieldDescriptor::CPPTYPE_INT64:
+ return GetRaw<int64>(message, field) != 0;
+ case FieldDescriptor::CPPTYPE_UINT32:
+ return GetRaw<uint32>(message, field) != 0;
+ case FieldDescriptor::CPPTYPE_UINT64:
+ return GetRaw<uint64>(message, field) != 0;
+ case FieldDescriptor::CPPTYPE_FLOAT:
+ return GetRaw<float>(message, field) != 0.0;
+ case FieldDescriptor::CPPTYPE_DOUBLE:
+ return GetRaw<double>(message, field) != 0.0;
+ case FieldDescriptor::CPPTYPE_ENUM:
+ return GetRaw<int>(message, field) != 0;
+ case FieldDescriptor::CPPTYPE_MESSAGE:
+ // handled above; avoid warning
+ break;
}
+ GOOGLE_LOG(FATAL) << "Reached impossible case in HasBit().";
+ return false;
}
- return IsIndexInHasBitSet(GetHasBits(message), field->index());
}
inline void GeneratedMessageReflection::SetBit(
Message* message, const FieldDescriptor* field) const {
- if (has_bits_offset_ == -1) {
+ if (!schema_.HasHasbits()) {
return;
}
- const uint32 index = static_cast<uint32>(field->index());
+ const uint32 index = schema_.HasBitIndex(field);
MutableHasBits(message)[index / 32] |=
(static_cast<uint32>(1) << (index % 32));
}
inline void GeneratedMessageReflection::ClearBit(
Message* message, const FieldDescriptor* field) const {
- if (has_bits_offset_ == -1) {
+ if (!schema_.HasHasbits()) {
return;
}
- const uint32 index = static_cast<uint32>(field->index());
+ const uint32 index = schema_.HasBitIndex(field);
MutableHasBits(message)[index / 32] &=
~(static_cast<uint32>(1) << (index % 32));
}
inline void GeneratedMessageReflection::SwapBit(
Message* message1, Message* message2, const FieldDescriptor* field) const {
- if (has_bits_offset_ == -1) {
+ if (!schema_.HasHasbits()) {
return;
}
bool temp_has_bit = HasBit(*message1, field);
@@ -2135,7 +2104,7 @@ inline void GeneratedMessageReflection::ClearOneof(
default: // TODO(kenton): Support other string reps.
case FieldOptions::STRING: {
const string* default_ptr =
- &DefaultRaw<ArenaStringPtr>(field).Get(NULL);
+ &DefaultRaw<ArenaStringPtr>(field).Get();
MutableField<ArenaStringPtr>(message, field)->
Destroy(default_ptr, GetArena(message));
break;
@@ -2247,7 +2216,7 @@ void* GeneratedMessageReflection::RepeatedFieldData(
return MutableExtensionSet(message)->MutableRawRepeatedField(
field->number(), field->type(), field->is_packed(), field);
} else {
- return reinterpret_cast<uint8*>(message) + offsets_[field->index()];
+ return MutableRawNonOneof<char>(message, field);
}
}
@@ -2259,42 +2228,128 @@ MapFieldBase* GeneratedMessageReflection::MapData(
return MutableRaw<MapFieldBase>(message, field);
}
-GeneratedMessageReflection*
-GeneratedMessageReflection::NewGeneratedMessageReflection(
- const Descriptor* descriptor,
- const Message* default_instance,
- const int offsets[],
- int has_bits_offset,
- int unknown_fields_offset,
- int extensions_offset,
- const void* default_oneof_instance,
- int oneof_case_offset,
- int object_size,
- int arena_offset,
- int is_default_instance_offset) {
- return new GeneratedMessageReflection(
- descriptor, default_instance, offsets, has_bits_offset,
- unknown_fields_offset, extensions_offset, default_oneof_instance,
- oneof_case_offset, DescriptorPool::generated_pool(),
- MessageFactory::generated_factory(), object_size, arena_offset);
-}
-
-GeneratedMessageReflection*
-GeneratedMessageReflection::NewGeneratedMessageReflection(
- const Descriptor* descriptor,
- const Message* default_instance,
- const int offsets[],
- int has_bits_offset,
- int unknown_fields_offset,
- int extensions_offset,
- int object_size,
- int arena_offset,
- int is_default_instance_offset) {
- return new GeneratedMessageReflection(
- descriptor, default_instance, offsets, has_bits_offset,
- unknown_fields_offset, extensions_offset,
- DescriptorPool::generated_pool(), MessageFactory::generated_factory(),
- object_size, arena_offset);
+namespace {
+
+// Helper function to transform migration schema into reflection schema.
+ReflectionSchema MigrationToReflectionSchema(
+ const Message* const* default_instance, const uint32* offsets,
+ MigrationSchema migration_schema) {
+ ReflectionSchema result;
+ result.default_instance_ = *default_instance;
+ // First 5 offsets are offsets to the special fields. The following offsets
+ // are the proto fields.
+ result.offsets_ = offsets + migration_schema.offsets_index + 4;
+ result.has_bit_indices_ = offsets + migration_schema.has_bit_indices_index;
+ result.has_bits_offset_ = offsets[migration_schema.offsets_index + 0];
+ result.metadata_offset_ = offsets[migration_schema.offsets_index + 1];
+ result.extensions_offset_ = offsets[migration_schema.offsets_index + 2];
+ result.oneof_case_offset_ = offsets[migration_schema.offsets_index + 3];
+ result.object_size_ = migration_schema.object_size;
+ result.weak_field_map_offset_ = 0;
+ return result;
+}
+
+template<typename Schema>
+class AssignDescriptorsHelper {
+ public:
+ AssignDescriptorsHelper(MessageFactory* factory,
+ Metadata* file_level_metadata,
+ const EnumDescriptor** file_level_enum_descriptors,
+ const Schema* schemas,
+ const Message* const* default_instance_data,
+ const uint32* offsets)
+ : factory_(factory),
+ file_level_metadata_(file_level_metadata),
+ file_level_enum_descriptors_(file_level_enum_descriptors),
+ schemas_(schemas),
+ default_instance_data_(default_instance_data),
+ offsets_(offsets) {}
+
+ void AssignMessageDescriptor(const Descriptor* descriptor) {
+ for (int i = 0; i < descriptor->nested_type_count(); i++) {
+ AssignMessageDescriptor(descriptor->nested_type(i));
+ }
+
+ file_level_metadata_->descriptor = descriptor;
+
+ if (!descriptor->options().map_entry()) {
+ // Only set reflection for non map types.
+ file_level_metadata_->reflection = new GeneratedMessageReflection(
+ descriptor, MigrationToReflectionSchema(default_instance_data_++,
+ offsets_, *schemas_),
+ ::google::protobuf::DescriptorPool::generated_pool(), factory_);
+ for (int i = 0; i < descriptor->enum_type_count(); i++) {
+ AssignEnumDescriptor(descriptor->enum_type(i));
+ }
+ schemas_++;
+ }
+ file_level_metadata_++;
+ }
+
+ void AssignEnumDescriptor(const EnumDescriptor* descriptor) {
+ *file_level_enum_descriptors_ = descriptor;
+ file_level_enum_descriptors_++;
+ }
+
+ private:
+ MessageFactory* factory_;
+ Metadata* file_level_metadata_;
+ const EnumDescriptor** file_level_enum_descriptors_;
+ const Schema* schemas_;
+ const Message* const * default_instance_data_;
+ const uint32* offsets_;
+};
+
+} // namespace
+
+void AssignDescriptors(
+ const string& filename, const MigrationSchema* schemas,
+ const Message* const* default_instances_, const uint32* offsets,
+ MessageFactory* factory,
+ // update the following descriptor arrays.
+ Metadata* file_level_metadata,
+ const EnumDescriptor** file_level_enum_descriptors,
+ const ServiceDescriptor** file_level_service_descriptors) {
+ const ::google::protobuf::FileDescriptor* file =
+ ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(filename);
+ GOOGLE_CHECK(file != NULL);
+
+ if (!factory) factory = MessageFactory::generated_factory();
+
+ AssignDescriptorsHelper<MigrationSchema> helper(factory, file_level_metadata,
+ file_level_enum_descriptors, schemas,
+ default_instances_, offsets);
+
+ for (int i = 0; i < file->message_type_count(); i++) {
+ helper.AssignMessageDescriptor(file->message_type(i));
+ }
+
+ for (int i = 0; i < file->enum_type_count(); i++) {
+ helper.AssignEnumDescriptor(file->enum_type(i));
+ }
+ if (file->options().cc_generic_services()) {
+ for (int i = 0; i < file->service_count(); i++) {
+ file_level_service_descriptors[i] = file->service(i);
+ }
+ }
+}
+
+void RegisterAllTypesInternal(const Metadata* file_level_metadata, int size) {
+ for (int i = 0; i < size; i++) {
+ const GeneratedMessageReflection* reflection =
+ static_cast<const GeneratedMessageReflection*>(
+ file_level_metadata[i].reflection);
+ if (reflection) {
+ // It's not a map type
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ file_level_metadata[i].descriptor,
+ reflection->schema_.default_instance_);
+ }
+ }
+}
+
+void RegisterAllTypes(const Metadata* file_level_metadata, int size) {
+ RegisterAllTypesInternal(file_level_metadata, size);
}
} // namespace internal
diff --git a/src/google/protobuf/generated_message_reflection.h b/src/google/protobuf/generated_message_reflection.h
index 1413b110..8b1362a2 100644
--- a/src/google/protobuf/generated_message_reflection.h
+++ b/src/google/protobuf/generated_message_reflection.h
@@ -45,6 +45,7 @@
// TODO(jasonh): Remove this once the compiler change to directly include this
// is released to components.
#include <google/protobuf/generated_enum_reflection.h>
+#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/message.h>
#include <google/protobuf/metadata.h>
#include <google/protobuf/unknown_field_set.h>
@@ -73,6 +74,148 @@ class GeneratedMessageReflection;
// Defined in other files.
class ExtensionSet; // extension_set.h
+// This struct describes the internal layout of the message, hence this is
+// used to act on the message reflectively.
+// default_instance: The default instance of the message. This is only
+// used to obtain pointers to default instances of embedded
+// messages, which GetMessage() will return if the particular
+// sub-message has not been initialized yet. (Thus, all
+// embedded message fields *must* have non-NULL pointers
+// in the default instance.)
+// offsets: An array of ints giving the byte offsets.
+// For each oneof field, the offset is relative to the
+// default_oneof_instance. These can be computed at compile
+// time using the
+// PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET() macro.
+// For each none oneof field, the offset is related to
+// the start of the message object. These can be computed
+// at compile time using the
+// GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET() macro.
+// Besides offsets for all fields, this array also contains
+// offsets for oneof unions. The offset of the i-th oneof
+// union is offsets[descriptor->field_count() + i].
+// has_bit_indices: Mapping from field indexes to their index in the has
+// bit array.
+// has_bits_offset: Offset in the message of an array of uint32s of size
+// descriptor->field_count()/32, rounded up. This is a
+// bitfield where each bit indicates whether or not the
+// corresponding field of the message has been initialized.
+// The bit for field index i is obtained by the expression:
+// has_bits[i / 32] & (1 << (i % 32))
+// unknown_fields_offset: Offset in the message of the UnknownFieldSet for
+// the message.
+// extensions_offset: Offset in the message of the ExtensionSet for the
+// message, or -1 if the message type has no extension
+// ranges.
+// oneof_case_offset: Offset in the message of an array of uint32s of
+// size descriptor->oneof_decl_count(). Each uint32
+// indicates what field is set for each oneof.
+// object_size: The size of a message object of this type, as measured
+// by sizeof().
+// arena_offset: If a message doesn't have a unknown_field_set that stores
+// the arena, it must have a direct pointer to the arena.
+struct ReflectionSchema {
+ public:
+ // Size of a google::protobuf::Message object of this type.
+ uint32 GetObjectSize() const { return object_size_; }
+
+ // Offset of a non-oneof field. Getting a field offset is slightly more
+ // efficient when we know statically that it is not a oneof field.
+ uint32 GetFieldOffsetNonOneof(const FieldDescriptor* field) const {
+ GOOGLE_DCHECK(!field->containing_oneof());
+ return offsets_[field->index()];
+ }
+
+ // Offset of any field.
+ uint32 GetFieldOffset(const FieldDescriptor* field) const {
+ if (field->containing_oneof()) {
+ size_t offset = field->containing_type()->field_count() +
+ field->containing_oneof()->index();
+ return offsets_[offset];
+ } else {
+ return GetFieldOffsetNonOneof(field);
+ }
+ }
+
+ uint32 GetOneofCaseOffset(const OneofDescriptor* oneof_descriptor) const {
+ return oneof_case_offset_ + (oneof_descriptor->index() * sizeof(uint32));
+ }
+
+ bool HasHasbits() const { return has_bits_offset_ != -1; }
+
+ // Bit index within the bit array of hasbits. Bit order is low-to-high.
+ uint32 HasBitIndex(const FieldDescriptor* field) const {
+ GOOGLE_DCHECK(HasHasbits());
+ return has_bit_indices_[field->index()];
+ }
+
+ // Byte offset of the hasbits array.
+ uint32 HasBitsOffset() const {
+ GOOGLE_DCHECK(HasHasbits());
+ return has_bits_offset_;
+ }
+
+ // The offset of the InternalMetadataWithArena member.
+ // For Lite this will actually be an InternalMetadataWithArenaLite.
+ // The schema doesn't contain enough information to distinguish between
+ // these two cases.
+ uint32 GetMetadataOffset() const {
+ return metadata_offset_;
+ }
+
+ // Whether this message has an ExtensionSet.
+ bool HasExtensionSet() const { return extensions_offset_ != -1; }
+
+ // The offset of the ExtensionSet in this message.
+ uint32 GetExtensionSetOffset() const {
+ GOOGLE_DCHECK(HasExtensionSet());
+ return extensions_offset_;
+ }
+
+ // The off set of WeakFieldMap when the message contains weak fields.
+ // The default is 0 for now.
+ int GetWeakFieldMapOffset() const { return weak_field_map_offset_; }
+
+ bool IsDefaultInstance(const Message& message) const {
+ return &message == default_instance_;
+ }
+
+ // Returns a pointer to the default value for this field. The size and type
+ // of the underlying data depends on the field's type.
+ const void *GetFieldDefault(const FieldDescriptor* field) const {
+ return reinterpret_cast<const uint8*>(default_instance_) +
+ offsets_[field->index()];
+ }
+
+ // These members are intended to be private, but we cannot actually make them
+ // private because this prevents us from using aggregate initialization of
+ // them, ie.
+ //
+ // ReflectionSchema schema = {a, b, c, d, e, ...};
+ // private:
+ const Message* default_instance_;
+ const uint32* offsets_;
+ const uint32* has_bit_indices_;
+ int has_bits_offset_;
+ int metadata_offset_;
+ int extensions_offset_;
+ int oneof_case_offset_;
+ int object_size_;
+ int weak_field_map_offset_;
+};
+
+// Structs that the code generator emits directly to describe a message.
+// These should never used directly except to build a ReflectionSchema
+// object.
+//
+// EXPERIMENTAL: these are changing rapidly, and may completely disappear
+// or merge with ReflectionSchema.
+struct MigrationSchema {
+ int32 offsets_index;
+ int32 has_bit_indices_index;
+ int object_size;
+};
+
// THIS CLASS IS NOT INTENDED FOR DIRECT USE. It is intended for use
// by generated code. This class is just a big hack that reduces code
// size.
@@ -97,109 +240,24 @@ class ExtensionSet; // extension_set.h
// of whatever type the individual field would be. Strings and
// Messages use RepeatedPtrFields while everything else uses
// RepeatedFields.
-class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection {
+class LIBPROTOBUF_EXPORT GeneratedMessageReflection PROTOBUF_FINAL
+ : public Reflection {
public:
// Constructs a GeneratedMessageReflection.
// Parameters:
// descriptor: The descriptor for the message type being implemented.
- // default_instance: The default instance of the message. This is only
- // used to obtain pointers to default instances of embedded
- // messages, which GetMessage() will return if the particular
- // sub-message has not been initialized yet. (Thus, all
- // embedded message fields *must* have non-NULL pointers
- // in the default instance.)
- // offsets: An array of ints giving the byte offsets, relative to
- // the start of the message object, of each field. These can
- // be computed at compile time using the
- // GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET() macro, defined
- // below.
- // has_bits_offset: Offset in the message of an array of uint32s of size
- // descriptor->field_count()/32, rounded up. This is a
- // bitfield where each bit indicates whether or not the
- // corresponding field of the message has been initialized.
- // The bit for field index i is obtained by the expression:
- // has_bits[i / 32] & (1 << (i % 32))
- // unknown_fields_offset: Offset in the message of the UnknownFieldSet for
- // the message.
- // extensions_offset: Offset in the message of the ExtensionSet for the
- // message, or -1 if the message type has no extension
- // ranges.
+ // schema: The description of the internal guts of the message.
// pool: DescriptorPool to search for extension definitions. Only
// used by FindKnownExtensionByName() and
// FindKnownExtensionByNumber().
// factory: MessageFactory to use to construct extension messages.
- // object_size: The size of a message object of this type, as measured
- // by sizeof().
GeneratedMessageReflection(const Descriptor* descriptor,
- const Message* default_instance,
- const int offsets[], int has_bits_offset,
- int unknown_fields_offset, int extensions_offset,
+ const ReflectionSchema& schema,
const DescriptorPool* pool,
- MessageFactory* factory, int object_size,
- int arena_offset);
+ MessageFactory* factory);
- // Similar with the construction above. Call this construction if the
- // message has oneof definition.
- // Parameters:
- // offsets: An array of ints giving the byte offsets.
- // For each oneof field, the offset is relative to the
- // default_oneof_instance. These can be computed at compile
- // time using the
- // PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET() macro.
- // For each none oneof field, the offset is related to
- // the start of the message object. These can be computed
- // at compile time using the
- // GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET() macro.
- // Besides offsets for all fields, this array also contains
- // offsets for oneof unions. The offset of the i-th oneof
- // union is offsets[descriptor->field_count() + i].
- // default_oneof_instance: The default instance of the oneofs. It is a
- // struct holding the default value of all oneof fields
- // for this message. It is only used to obtain pointers
- // to default instances of oneof fields, which Get
- // methods will return if the field is not set.
- // oneof_case_offset: Offset in the message of an array of uint32s of
- // size descriptor->oneof_decl_count(). Each uint32
- // indicates what field is set for each oneof.
- // other parameters are the same with the construction above.
- GeneratedMessageReflection(const Descriptor* descriptor,
- const Message* default_instance,
- const int offsets[], int has_bits_offset,
- int unknown_fields_offset, int extensions_offset,
- const void* default_oneof_instance,
- int oneof_case_offset, const DescriptorPool* pool,
- MessageFactory* factory, int object_size,
- int arena_offset);
~GeneratedMessageReflection();
- // Shorter-to-call helpers for the above two constructions that work if the
- // pool and factory are the usual, namely, DescriptorPool::generated_pool()
- // and MessageFactory::generated_factory().
-
- static GeneratedMessageReflection* NewGeneratedMessageReflection(
- const Descriptor* descriptor,
- const Message* default_instance,
- const int offsets[],
- int has_bits_offset,
- int unknown_fields_offset,
- int extensions_offset,
- const void* default_oneof_instance,
- int oneof_case_offset,
- int object_size,
- int arena_offset,
- int is_default_instance_offset = -1);
-
- static GeneratedMessageReflection* NewGeneratedMessageReflection(
- const Descriptor* descriptor,
- const Message* default_instance,
- const int offsets[],
- int has_bits_offset,
- int unknown_fields_offset,
- int extensions_offset,
- int object_size,
- int arena_offset,
- int is_default_instance_offset = -1);
-
// implements Reflection -------------------------------------------
const UnknownFieldSet& GetUnknownFields(const Message& message) const;
@@ -424,36 +482,27 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection {
private:
friend class GeneratedMessage;
-
- // To parse directly into a proto2 generated class, the class GMR_Handlers
- // needs access to member offsets and hasbits.
friend class upb::google_opensource::GMR_Handlers;
- const Descriptor* descriptor_;
- const Message* default_instance_;
- const void* default_oneof_instance_;
- const int* offsets_;
-
- int has_bits_offset_;
- int oneof_case_offset_;
- int unknown_fields_offset_;
- int extensions_offset_;
- int arena_offset_;
- int object_size_;
+ const Descriptor* const descriptor_;
+ const ReflectionSchema schema_;
+ const DescriptorPool* const descriptor_pool_;
+ MessageFactory* const message_factory_;
- const DescriptorPool* descriptor_pool_;
- MessageFactory* message_factory_;
+ template <class T>
+ const T& GetRawNonOneof(const Message& message,
+ const FieldDescriptor* field) const;
+ template <class T>
+ T* MutableRawNonOneof(Message* message, const FieldDescriptor* field) const;
template <typename Type>
- inline const Type& GetRaw(const Message& message,
+ const Type& GetRaw(const Message& message,
const FieldDescriptor* field) const;
template <typename Type>
inline Type* MutableRaw(Message* message,
const FieldDescriptor* field) const;
template <typename Type>
inline const Type& DefaultRaw(const FieldDescriptor* field) const;
- template <typename Type>
- inline const Type& DefaultOneofRaw(const FieldDescriptor* field) const;
inline const uint32* GetHasBits(const Message& message) const;
inline uint32* MutableHasBits(Message* message) const;
@@ -466,12 +515,12 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection {
inline const ExtensionSet& GetExtensionSet(const Message& message) const;
inline ExtensionSet* MutableExtensionSet(Message* message) const;
inline Arena* GetArena(Message* message) const;
- inline const internal::InternalMetadataWithArena&
- GetInternalMetadataWithArena(const Message& message) const;
- inline internal::InternalMetadataWithArena*
- MutableInternalMetadataWithArena(Message* message) const;
- inline bool GetIsDefaultInstance(const Message& message) const;
+ inline const InternalMetadataWithArena& GetInternalMetadataWithArena(
+ const Message& message) const;
+
+ inline InternalMetadataWithArena*
+ MutableInternalMetadataWithArena(Message* message) const;
inline bool HasBit(const Message& message,
const FieldDescriptor* field) const;
@@ -559,6 +608,9 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection {
internal::MapFieldBase* MapData(
Message* message, const FieldDescriptor* field) const;
+ friend inline // inline so nobody can call this function.
+ void
+ RegisterAllTypesInternal(const Metadata* file_level_metadata, int size);
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GeneratedMessageReflection);
};
@@ -585,14 +637,14 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection {
// choose 16 rather than some other number just in case the compiler would
// be confused by an unaligned pointer.
#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TYPE, FIELD) \
- static_cast<int>( \
- reinterpret_cast<const char*>( \
- &reinterpret_cast<const TYPE*>(16)->FIELD) - \
+ static_cast< ::google::protobuf::uint32>( \
+ reinterpret_cast<const char*>( \
+ &reinterpret_cast<const TYPE*>(16)->FIELD) - \
reinterpret_cast<const char*>(16))
#endif
#define PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(ONEOF, FIELD) \
- static_cast<int>( \
+ static_cast< ::google::protobuf::uint32>( \
reinterpret_cast<const char*>(&(ONEOF->FIELD)) \
- reinterpret_cast<const char*>(ONEOF))
@@ -622,6 +674,8 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection {
template<typename To, typename From>
inline To dynamic_cast_if_available(From from) {
#if defined(GOOGLE_PROTOBUF_NO_RTTI) || (defined(_MSC_VER)&&!defined(_CPPRTTI))
+ // Avoid the compiler warning about unused variables.
+ (void)from;
return NULL;
#else
return dynamic_cast<To>(from);
@@ -664,6 +718,17 @@ T* DynamicCastToGenerated(Message* from) {
return const_cast<T*>(DynamicCastToGenerated<const T>(message_const));
}
+LIBPROTOBUF_EXPORT void AssignDescriptors(
+ const string& filename, const MigrationSchema* schemas,
+ const Message* const* default_instances_, const uint32* offsets,
+ MessageFactory* factory,
+ // update the following descriptor arrays.
+ Metadata* file_level_metadata,
+ const EnumDescriptor** file_level_enum_descriptors,
+ const ServiceDescriptor** file_level_service_descriptors);
+
+LIBPROTOBUF_EXPORT void RegisterAllTypes(const Metadata* file_level_metadata, int size);
+
} // namespace internal
} // namespace protobuf
diff --git a/src/google/protobuf/generated_message_reflection_unittest.cc b/src/google/protobuf/generated_message_reflection_unittest.cc
index 6276b667..242cc4a1 100644
--- a/src/google/protobuf/generated_message_reflection_unittest.cc
+++ b/src/google/protobuf/generated_message_reflection_unittest.cc
@@ -48,9 +48,10 @@
#include <google/protobuf/stubs/shared_ptr.h>
#endif
-#include <google/protobuf/descriptor.h>
#include <google/protobuf/test_util.h>
#include <google/protobuf/unittest.pb.h>
+#include <google/protobuf/arena.h>
+#include <google/protobuf/descriptor.h>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
@@ -222,7 +223,7 @@ TEST(GeneratedMessageReflectionTest, SwapFields) {
message2.set_optional_string("hello");
message2.mutable_repeated_int64()->Add(30);
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
const Descriptor* descriptor = message1.GetDescriptor();
fields.push_back(descriptor->FindFieldByName("optional_double"));
fields.push_back(descriptor->FindFieldByName("repeated_int32"));
@@ -255,7 +256,7 @@ TEST(GeneratedMessageReflectionTest, SwapFieldsAll) {
TestUtil::SetAllFields(&message2);
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
const Reflection* reflection = message1.GetReflection();
reflection->ListFields(message2, &fields);
reflection->SwapFields(&message1, &message2, fields);
@@ -270,7 +271,7 @@ TEST(GeneratedMessageReflectionTest, SwapFieldsAllExtension) {
TestUtil::SetAllExtensions(&message1);
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
const Reflection* reflection = message1.GetReflection();
reflection->ListFields(message1, &fields);
reflection->SwapFields(&message1, &message2, fields);
@@ -306,7 +307,7 @@ TEST(GeneratedMessageReflectionTest, SwapFieldsOneof) {
unittest::TestOneof2 message1, message2;
TestUtil::SetOneof1(&message1);
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
const Descriptor* descriptor = message1.GetDescriptor();
for (int i = 0; i < descriptor->field_count(); i++) {
fields.push_back(descriptor->field(i));
@@ -519,6 +520,41 @@ TEST(GeneratedMessageReflectionTest, SetAllocatedMessageTest) {
&to_message, TestUtil::ReflectionTester::IS_NULL);
}
+TEST(GeneratedMessageReflectionTest, SetAllocatedMessageOnArenaTest) {
+ unittest::TestAllTypes from_message1;
+ unittest::TestAllTypes from_message2;
+ ::google::protobuf::Arena arena;
+ unittest::TestAllTypes* to_message =
+ ::google::protobuf::Arena::CreateMessage<unittest::TestAllTypes>(&arena);
+ TestUtil::ReflectionTester reflection_tester(
+ unittest::TestAllTypes::descriptor());
+ reflection_tester.SetAllFieldsViaReflection(&from_message1);
+ reflection_tester.SetAllFieldsViaReflection(&from_message2);
+
+ // Before moving fields, we expect the nested messages to be NULL.
+ reflection_tester.ExpectMessagesReleasedViaReflection(
+ to_message, TestUtil::ReflectionTester::IS_NULL);
+
+ // After fields are moved we should get non-NULL releases.
+ reflection_tester.SetAllocatedOptionalMessageFieldsToMessageViaReflection(
+ &from_message1, to_message);
+ reflection_tester.ExpectMessagesReleasedViaReflection(
+ to_message, TestUtil::ReflectionTester::NOT_NULL);
+
+ // Another move to make sure that we can SetAllocated several times.
+ reflection_tester.SetAllocatedOptionalMessageFieldsToMessageViaReflection(
+ &from_message2, to_message);
+ reflection_tester.ExpectMessagesReleasedViaReflection(
+ to_message, TestUtil::ReflectionTester::NOT_NULL);
+
+ // After SetAllocatedOptionalMessageFieldsToNullViaReflection() we expect the
+ // releases to be NULL again.
+ reflection_tester.SetAllocatedOptionalMessageFieldsToNullViaReflection(
+ to_message);
+ reflection_tester.ExpectMessagesReleasedViaReflection(
+ to_message, TestUtil::ReflectionTester::IS_NULL);
+}
+
TEST(GeneratedMessageReflectionTest, SetAllocatedExtensionMessageTest) {
unittest::TestAllExtensions from_message1;
unittest::TestAllExtensions from_message2;
@@ -552,6 +588,41 @@ TEST(GeneratedMessageReflectionTest, SetAllocatedExtensionMessageTest) {
&to_message, TestUtil::ReflectionTester::IS_NULL);
}
+TEST(GeneratedMessageReflectionTest, SetAllocatedExtensionMessageOnArenaTest) {
+ ::google::protobuf::Arena arena;
+ unittest::TestAllExtensions* to_message =
+ ::google::protobuf::Arena::CreateMessage<unittest::TestAllExtensions>(&arena);
+ unittest::TestAllExtensions from_message1;
+ unittest::TestAllExtensions from_message2;
+ TestUtil::ReflectionTester reflection_tester(
+ unittest::TestAllExtensions::descriptor());
+ reflection_tester.SetAllFieldsViaReflection(&from_message1);
+ reflection_tester.SetAllFieldsViaReflection(&from_message2);
+
+ // Before moving fields, we expect the nested messages to be NULL.
+ reflection_tester.ExpectMessagesReleasedViaReflection(
+ to_message, TestUtil::ReflectionTester::IS_NULL);
+
+ // After fields are moved we should get non-NULL releases.
+ reflection_tester.SetAllocatedOptionalMessageFieldsToMessageViaReflection(
+ &from_message1, to_message);
+ reflection_tester.ExpectMessagesReleasedViaReflection(
+ to_message, TestUtil::ReflectionTester::NOT_NULL);
+
+ // Another move to make sure that we can SetAllocated several times.
+ reflection_tester.SetAllocatedOptionalMessageFieldsToMessageViaReflection(
+ &from_message2, to_message);
+ reflection_tester.ExpectMessagesReleasedViaReflection(
+ to_message, TestUtil::ReflectionTester::NOT_NULL);
+
+ // After SetAllocatedOptionalMessageFieldsToNullViaReflection() we expect the
+ // releases to be NULL again.
+ reflection_tester.SetAllocatedOptionalMessageFieldsToNullViaReflection(
+ to_message);
+ reflection_tester.ExpectMessagesReleasedViaReflection(
+ to_message, TestUtil::ReflectionTester::IS_NULL);
+}
+
TEST(GeneratedMessageReflectionTest, AddRepeatedMessage) {
unittest::TestAllTypes message;
@@ -608,7 +679,7 @@ TEST(GeneratedMessageReflectionTest, ListFieldsOneOf) {
TestUtil::SetOneof1(&message);
const Reflection* reflection = message.GetReflection();
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
reflection->ListFields(message, &fields);
EXPECT_EQ(4, fields.size());
}
@@ -723,6 +794,59 @@ TEST(GeneratedMessageReflectionTest, SetAllocatedOneofMessageTest) {
delete released;
}
+TEST(GeneratedMessageReflectionTest, SetAllocatedOneofMessageOnArenaTest) {
+ unittest::TestOneof2 from_message1;
+ unittest::TestOneof2 from_message2;
+ ::google::protobuf::Arena arena;
+ unittest::TestOneof2* to_message =
+ ::google::protobuf::Arena::CreateMessage<unittest::TestOneof2>(&arena);
+ const Descriptor* descriptor = unittest::TestOneof2::descriptor();
+ const Reflection* reflection = to_message->GetReflection();
+
+ Message* released = reflection->ReleaseMessage(
+ to_message, descriptor->FindFieldByName("foo_lazy_message"));
+ EXPECT_TRUE(released == NULL);
+ released = reflection->ReleaseMessage(
+ to_message, descriptor->FindFieldByName("foo_message"));
+ EXPECT_TRUE(released == NULL);
+
+ TestUtil::ReflectionTester::SetOneofViaReflection(&from_message1);
+ TestUtil::ReflectionTester::ExpectOneofSetViaReflection(from_message1);
+
+ TestUtil::ReflectionTester::
+ SetAllocatedOptionalMessageFieldsToMessageViaReflection(
+ &from_message1, to_message);
+ const Message& sub_message = reflection->GetMessage(
+ *to_message, descriptor->FindFieldByName("foo_lazy_message"));
+ released = reflection->ReleaseMessage(
+ to_message, descriptor->FindFieldByName("foo_lazy_message"));
+ EXPECT_TRUE(released != NULL);
+ // Since sub_message is arena allocated, releasing it results in copying it
+ // into new heap-allocated memory.
+ EXPECT_NE(&sub_message, released);
+ delete released;
+
+ TestUtil::ReflectionTester::SetOneofViaReflection(&from_message2);
+
+ reflection->MutableMessage(
+ &from_message2, descriptor->FindFieldByName("foo_message"));
+
+ TestUtil::ReflectionTester::
+ SetAllocatedOptionalMessageFieldsToMessageViaReflection(
+ &from_message2, to_message);
+
+ const Message& sub_message2 = reflection->GetMessage(
+ *to_message, descriptor->FindFieldByName("foo_message"));
+ released = reflection->ReleaseMessage(
+ to_message, descriptor->FindFieldByName("foo_message"));
+ EXPECT_TRUE(released != NULL);
+ // Since sub_message2 is arena allocated, releasing it results in copying it
+ // into new heap-allocated memory.
+ EXPECT_NE(&sub_message2, released);
+ delete released;
+}
+
+
TEST(GeneratedMessageReflectionTest, ReleaseMessageTest) {
unittest::TestAllTypes message;
TestUtil::ReflectionTester reflection_tester(
diff --git a/src/google/protobuf/generated_message_util.cc b/src/google/protobuf/generated_message_util.cc
index 73f55927..b4d2c9c1 100644
--- a/src/google/protobuf/generated_message_util.cc
+++ b/src/google/protobuf/generated_message_util.cc
@@ -51,9 +51,7 @@ double NaN() {
ExplicitlyConstructed< ::std::string> fixed_address_empty_string;
GOOGLE_PROTOBUF_DECLARE_ONCE(empty_string_once_init_);
-void DeleteEmptyString() {
- GetEmptyStringAlreadyInited().~string();
-}
+void DeleteEmptyString() { fixed_address_empty_string.Shutdown(); }
void InitEmptyString() {
fixed_address_empty_string.DefaultConstruct();
@@ -73,10 +71,8 @@ int StringSpaceUsedExcludingSelf(const string& str) {
-void MergeFromFail(const char* file, int line) {
- GOOGLE_CHECK(false) << file << ":" << line;
- // Open-source GOOGLE_CHECK(false) is not NORETURN.
- exit(1);
+void InitProtobufDefaults() {
+ GetEmptyString();
}
} // namespace internal
diff --git a/src/google/protobuf/generated_message_util.h b/src/google/protobuf/generated_message_util.h
index 8dc64c49..14101832 100644
--- a/src/google/protobuf/generated_message_util.h
+++ b/src/google/protobuf/generated_message_util.h
@@ -45,6 +45,14 @@
#include <google/protobuf/stubs/once.h>
#include <google/protobuf/has_bits.h>
+#ifndef PROTOBUF_FINAL
+#if LANG_CXX11
+#define PROTOBUF_FINAL final
+#else
+#define PROTOBUF_FINAL
+#endif
+#endif // !PROTOBUF_FINAL
+
namespace google {
namespace protobuf {
@@ -91,7 +99,13 @@ class ExplicitlyConstructed {
}
}
- const T& get() const { return reinterpret_cast<const T&>(union_); }
+#if LANG_CXX11
+ constexpr
+#endif
+ const T&
+ get() const {
+ return reinterpret_cast<const T&>(union_);
+ }
T* get_mutable() { return reinterpret_cast<T*>(&union_); }
private:
@@ -111,7 +125,7 @@ class ExplicitlyConstructed {
// Default empty string object. Don't use this directly. Instead, call
// GetEmptyString() to get the reference.
-extern ExplicitlyConstructed< ::std::string> fixed_address_empty_string;
+LIBPROTOBUF_EXPORT extern ExplicitlyConstructed< ::std::string> fixed_address_empty_string;
LIBPROTOBUF_EXPORT extern ProtobufOnceType empty_string_once_init_;
LIBPROTOBUF_EXPORT void InitEmptyString();
@@ -140,9 +154,7 @@ template <class Type> bool AllAreInitialized(const Type& t) {
return true;
}
-// Helper function to crash on merge failure.
-// Moved out of generated code to reduce binary size.
-LIBPROTOBUF_EXPORT void MergeFromFail(const char* file, int line) GOOGLE_ATTRIBUTE_NORETURN;
+LIBPROTOBUF_EXPORT void InitProtobufDefaults();
// We compute sizes as size_t but cache them as int. This function converts a
// computed size to a cached size. Since we don't proceed with serialization if
diff --git a/src/google/protobuf/has_bits.h b/src/google/protobuf/has_bits.h
index 133bc02a..cb1d7ccc 100644
--- a/src/google/protobuf/has_bits.h
+++ b/src/google/protobuf/has_bits.h
@@ -61,10 +61,41 @@ class HasBits {
bool operator!=(const HasBits<doublewords>& rhs) const {
return !(*this == rhs);
}
+
+ bool empty() const;
+
private:
::google::protobuf::uint32 has_bits_[doublewords];
};
+template <>
+inline bool HasBits<1>::empty() const {
+ return !has_bits_[0];
+}
+
+template <>
+inline bool HasBits<2>::empty() const {
+ return !(has_bits_[0] | has_bits_[1]);
+}
+
+template <>
+inline bool HasBits<3>::empty() const {
+ return !(has_bits_[0] | has_bits_[1] | has_bits_[2]);
+}
+
+template <>
+inline bool HasBits<4>::empty() const {
+ return !(has_bits_[0] | has_bits_[1] | has_bits_[2] | has_bits_[3]);
+}
+
+template <size_t doublewords>
+inline bool HasBits<doublewords>::empty() const {
+ for (size_t i = 0; i < doublewords; ++i) {
+ if (has_bits_[i]) return false;
+ }
+ return true;
+}
+
} // namespace internal
} // namespace protobuf
diff --git a/src/google/protobuf/io/coded_stream.cc b/src/google/protobuf/io/coded_stream.cc
index 08394ca7..3c2e0fbd 100644
--- a/src/google/protobuf/io/coded_stream.cc
+++ b/src/google/protobuf/io/coded_stream.cc
@@ -47,7 +47,6 @@
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/stl_util.h>
-#include <google/protobuf/stubs/port.h>
namespace google {
@@ -550,9 +549,15 @@ bool CodedInputStream::ReadVarint64Slow(uint64* value) {
uint32 b;
do {
- if (count == kMaxVarintBytes) return false;
+ if (count == kMaxVarintBytes) {
+ *value = 0;
+ return false;
+ }
while (buffer_ == buffer_end_) {
- if (!Refresh()) return false;
+ if (!Refresh()) {
+ *value = 0;
+ return false;
+ }
}
b = *buffer_;
result |= static_cast<uint64>(b & 0x7F) << (7 * count);
@@ -602,13 +607,13 @@ bool CodedInputStream::Refresh() {
if (total_bytes_warning_threshold_ >= 0 &&
total_bytes_read_ >= total_bytes_warning_threshold_) {
- GOOGLE_LOG(WARNING) << "Reading dangerously large protocol message. If the "
- "message turns out to be larger than "
- << total_bytes_limit_ << " bytes, parsing will be halted "
- "for security reasons. To increase the limit (or to "
- "disable these warnings), see "
- "CodedInputStream::SetTotalBytesLimit() in "
- "google/protobuf/io/coded_stream.h.";
+ GOOGLE_LOG(INFO) << "Reading dangerously large protocol message. If the "
+ "message turns out to be larger than "
+ << total_bytes_limit_ << " bytes, parsing will be halted "
+ "for security reasons. To increase the limit (or to "
+ "disable these warnings), see "
+ "CodedInputStream::SetTotalBytesLimit() in "
+ "google/protobuf/io/coded_stream.h.";
// Don't warn again for this stream, and print total size at the end.
total_bytes_warning_threshold_ = -2;
@@ -789,104 +794,12 @@ void CodedOutputStream::WriteVarint32SlowPath(uint32 value) {
WriteRaw(bytes, size);
}
-inline uint8* CodedOutputStream::WriteVarint64ToArrayInline(
- uint64 value, uint8* target) {
- // Splitting into 32-bit pieces gives better performance on 32-bit
- // processors.
- uint32 part0 = static_cast<uint32>(value );
- uint32 part1 = static_cast<uint32>(value >> 28);
- uint32 part2 = static_cast<uint32>(value >> 56);
-
- int size;
-
- // Here we can't really optimize for small numbers, since the value is
- // split into three parts. Cheking for numbers < 128, for instance,
- // would require three comparisons, since you'd have to make sure part1
- // and part2 are zero. However, if the caller is using 64-bit integers,
- // it is likely that they expect the numbers to often be very large, so
- // we probably don't want to optimize for small numbers anyway. Thus,
- // we end up with a hardcoded binary search tree...
- if (part2 == 0) {
- if (part1 == 0) {
- if (part0 < (1 << 14)) {
- if (part0 < (1 << 7)) {
- size = 1; goto size1;
- } else {
- size = 2; goto size2;
- }
- } else {
- if (part0 < (1 << 21)) {
- size = 3; goto size3;
- } else {
- size = 4; goto size4;
- }
- }
- } else {
- if (part1 < (1 << 14)) {
- if (part1 < (1 << 7)) {
- size = 5; goto size5;
- } else {
- size = 6; goto size6;
- }
- } else {
- if (part1 < (1 << 21)) {
- size = 7; goto size7;
- } else {
- size = 8; goto size8;
- }
- }
- }
- } else {
- if (part2 < (1 << 7)) {
- size = 9; goto size9;
- } else {
- size = 10; goto size10;
- }
- }
-
- GOOGLE_LOG(FATAL) << "Can't get here.";
-
- size10: target[9] = static_cast<uint8>((part2 >> 7) | 0x80);
- size9 : target[8] = static_cast<uint8>((part2 ) | 0x80);
- size8 : target[7] = static_cast<uint8>((part1 >> 21) | 0x80);
- size7 : target[6] = static_cast<uint8>((part1 >> 14) | 0x80);
- size6 : target[5] = static_cast<uint8>((part1 >> 7) | 0x80);
- size5 : target[4] = static_cast<uint8>((part1 ) | 0x80);
- size4 : target[3] = static_cast<uint8>((part0 >> 21) | 0x80);
- size3 : target[2] = static_cast<uint8>((part0 >> 14) | 0x80);
- size2 : target[1] = static_cast<uint8>((part0 >> 7) | 0x80);
- size1 : target[0] = static_cast<uint8>((part0 ) | 0x80);
-
- target[size-1] &= 0x7F;
- return target + size;
-}
-
-void CodedOutputStream::WriteVarint64(uint64 value) {
- if (buffer_size_ >= kMaxVarintBytes) {
- // Fast path: We have enough bytes left in the buffer to guarantee that
- // this write won't cross the end, so we can skip the checks.
- uint8* target = buffer_;
-
- uint8* end = WriteVarint64ToArrayInline(value, target);
- int size = end - target;
- Advance(size);
- } else {
- // Slow path: This write might cross the end of the buffer, so we
- // compose the bytes first then use WriteRaw().
- uint8 bytes[kMaxVarintBytes];
- int size = 0;
- while (value > 0x7F) {
- bytes[size++] = (static_cast<uint8>(value) & 0x7F) | 0x80;
- value >>= 7;
- }
- bytes[size++] = static_cast<uint8>(value) & 0x7F;
- WriteRaw(bytes, size);
- }
-}
-
-uint8* CodedOutputStream::WriteVarint64ToArray(
- uint64 value, uint8* target) {
- return WriteVarint64ToArrayInline(value, target);
+void CodedOutputStream::WriteVarint64SlowPath(uint64 value) {
+ uint8 bytes[kMaxVarintBytes];
+ uint8* target = &bytes[0];
+ uint8* end = WriteVarint64ToArray(value, target);
+ int size = end - target;
+ WriteRaw(bytes, size);
}
bool CodedOutputStream::Refresh() {
@@ -903,20 +816,6 @@ bool CodedOutputStream::Refresh() {
}
}
-size_t CodedOutputStream::VarintSize32Fallback(uint32 value) {
- GOOGLE_DCHECK_NE(0, value); // This is enforced by our caller.
-
- return 1 + Bits::Log2FloorNonZero(value) / 7;
-}
-
-size_t CodedOutputStream::VarintSize64(uint64 value) {
- if (value < (1 << 7)) {
- return 1;
- }
-
- return 1 + Bits::Log2FloorNonZero64(value) / 7;
-}
-
uint8* CodedOutputStream::WriteStringWithSizeToArray(const string& str,
uint8* target) {
GOOGLE_DCHECK_LE(str.size(), kuint32max);
diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h
index 1402cc17..b71b4a98 100644
--- a/src/google/protobuf/io/coded_stream.h
+++ b/src/google/protobuf/io/coded_stream.h
@@ -110,6 +110,7 @@
#define GOOGLE_PROTOBUF_IO_CODED_STREAM_H__
#include <assert.h>
+#include <climits>
#include <string>
#include <utility>
#ifdef _MSC_VER
@@ -139,6 +140,8 @@ namespace protobuf {
class DescriptorPool;
class MessageFactory;
+namespace internal { void MapTestForceDeterministic(); }
+
namespace io {
// Defined in this file.
@@ -249,12 +252,16 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
bool ReadVarintSizeAsInt(int* value);
// Read a tag. This calls ReadVarint32() and returns the result, or returns
- // zero (which is not a valid tag) if ReadVarint32() fails. Also, it updates
- // the last tag value, which can be checked with LastTagWas().
+ // zero (which is not a valid tag) if ReadVarint32() fails. Also, ReadTag
+ // (but not ReadTagNoLastTag) updates the last tag value, which can be checked
+ // with LastTagWas().
+ //
// Always inline because this is only called in one place per parse loop
// but it is called for every iteration of said loop, so it should be fast.
// GCC doesn't want to inline this by default.
GOOGLE_ATTRIBUTE_ALWAYS_INLINE uint32 ReadTag();
+ GOOGLE_ATTRIBUTE_ALWAYS_INLINE uint32 ReadTagNoLastTag();
+
// This usually a faster alternative to ReadTag() when cutoff is a manifest
// constant. It does particularly well for cutoff >= 127. The first part
@@ -266,6 +273,8 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
// to avoid an extra "is tag == 0?" check here.)
GOOGLE_ATTRIBUTE_ALWAYS_INLINE std::pair<uint32, bool> ReadTagWithCutoff(
uint32 cutoff);
+ GOOGLE_ATTRIBUTE_ALWAYS_INLINE std::pair<uint32, bool> ReadTagWithCutoffNoLastTag(
+ uint32 cutoff);
// Usually returns true if calling ReadVarint32() now would produce the given
// value. Will always return false if ReadVarint32() would not return the
@@ -293,8 +302,10 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
// zero, and ConsumedEntireMessage() will return true.
bool ExpectAtEnd();
- // If the last call to ReadTag() or ReadTagWithCutoff() returned the
- // given value, returns true. Otherwise, returns false;
+ // If the last call to ReadTag() or ReadTagWithCutoff() returned the given
+ // value, returns true. Otherwise, returns false.
+ // ReadTagNoLastTag/ReadTagWithCutoffNoLastTag do not preserve the last
+ // returned value.
//
// This is needed because parsers for some types of embedded messages
// (with field type TYPE_GROUP) don't actually know that they've reached the
@@ -612,6 +623,13 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
int ReadVarintSizeAsIntSlow();
bool ReadLittleEndian32Fallback(uint32* value);
bool ReadLittleEndian64Fallback(uint64* value);
+
+ template<bool update_last_tag>
+ GOOGLE_ATTRIBUTE_ALWAYS_INLINE uint32 ReadTagImplementation();
+ template<bool update_last_tag>
+ GOOGLE_ATTRIBUTE_ALWAYS_INLINE
+ std::pair<uint32, bool> ReadTagWithCutoffImplementation(uint32 cutoff);
+
// Fallback/slow methods for reading tags. These do not update last_tag_,
// but will set legitimate_message_end_ if we are at the end of the input
// stream.
@@ -622,7 +640,7 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
// Return the size of the buffer.
int BufferSize() const;
- static const int kDefaultTotalBytesLimit = 64 << 20; // 64MB
+ static const int kDefaultTotalBytesLimit = INT_MAX;
static const int kDefaultTotalBytesWarningThreshold = 32 << 20; // 32MB
@@ -842,15 +860,19 @@ class LIBPROTOBUF_EXPORT CodedOutputStream {
serialization_deterministic_override_ = value;
}
// See above. Also, note that users of this CodedOutputStream may need to
- // call IsSerializationDeterminstic() to serialize in the intended way. This
+ // call IsSerializationDeterministic() to serialize in the intended way. This
// CodedOutputStream cannot enforce a desire for deterministic serialization
// by itself.
- bool IsSerializationDeterminstic() const {
+ bool IsSerializationDeterministic() const {
return serialization_deterministic_is_overridden_ ?
serialization_deterministic_override_ :
default_serialization_deterministic_;
}
+ static bool IsDefaultSerializationDeterministic() {
+ return default_serialization_deterministic_;
+ }
+
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CodedOutputStream);
@@ -879,20 +901,11 @@ class LIBPROTOBUF_EXPORT CodedOutputStream {
// If this write might cross the end of the buffer, we compose the bytes first
// then use WriteRaw().
void WriteVarint32SlowPath(uint32 value);
-
- // Always-inlined versions of WriteVarint* functions so that code can be
- // reused, while still controlling size. For instance, WriteVarint32ToArray()
- // should not directly call this: since it is inlined itself, doing so
- // would greatly increase the size of generated code. Instead, it should call
- // WriteVarint32FallbackToArray. Meanwhile, WriteVarint32() is already
- // out-of-line, so it should just invoke this directly to avoid any extra
- // function call overhead.
- GOOGLE_ATTRIBUTE_ALWAYS_INLINE static uint8* WriteVarint64ToArrayInline(
- uint64 value, uint8* target);
-
- static size_t VarintSize32Fallback(uint32 value);
+ void WriteVarint64SlowPath(uint64 value);
// See above. Other projects may use "friend" to allow them to call this.
+ // Requires: no protocol buffer serialization in progress.
+ friend void ::google::protobuf::internal::MapTestForceDeterministic();
static void SetDefaultSerializationDeterministic() {
default_serialization_deterministic_ = true;
}
@@ -981,8 +994,7 @@ inline const uint8* CodedInputStream::ReadLittleEndian64FromArray(
inline bool CodedInputStream::ReadLittleEndian32(uint32* value) {
#if defined(PROTOBUF_LITTLE_ENDIAN)
if (GOOGLE_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) {
- memcpy(value, buffer_, sizeof(*value));
- Advance(sizeof(*value));
+ buffer_ = ReadLittleEndian32FromArray(buffer_, value);
return true;
} else {
return ReadLittleEndian32Fallback(value);
@@ -995,8 +1007,7 @@ inline bool CodedInputStream::ReadLittleEndian32(uint32* value) {
inline bool CodedInputStream::ReadLittleEndian64(uint64* value) {
#if defined(PROTOBUF_LITTLE_ENDIAN)
if (GOOGLE_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) {
- memcpy(value, buffer_, sizeof(*value));
- Advance(sizeof(*value));
+ buffer_ = ReadLittleEndian64FromArray(buffer_, value);
return true;
} else {
return ReadLittleEndian64Fallback(value);
@@ -1007,21 +1018,47 @@ inline bool CodedInputStream::ReadLittleEndian64(uint64* value) {
}
inline uint32 CodedInputStream::ReadTag() {
+ return ReadTagImplementation<true>();
+}
+
+inline uint32 CodedInputStream::ReadTagNoLastTag() {
+ return ReadTagImplementation<false>();
+}
+
+template<bool update_last_tag>
+inline uint32 CodedInputStream::ReadTagImplementation() {
uint32 v = 0;
if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_)) {
v = *buffer_;
if (v < 0x80) {
- last_tag_ = v;
+ if (update_last_tag) {
+ last_tag_ = v;
+ }
Advance(1);
return v;
}
}
- last_tag_ = ReadTagFallback(v);
- return last_tag_;
+ v = ReadTagFallback(v);
+ if (update_last_tag) {
+ last_tag_ = v;
+ }
+ return v;
}
inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoff(
uint32 cutoff) {
+ return ReadTagWithCutoffImplementation<true>(cutoff);
+}
+
+inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoffNoLastTag(
+ uint32 cutoff) {
+ return ReadTagWithCutoffImplementation<false>(cutoff);
+}
+
+template<bool update_last_tag>
+inline std::pair<uint32, bool>
+CodedInputStream::ReadTagWithCutoffImplementation(
+ uint32 cutoff) {
// In performance-sensitive code we can expect cutoff to be a compile-time
// constant, and things like "cutoff >= kMax1ByteVarint" to be evaluated at
// compile time.
@@ -1033,7 +1070,10 @@ inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoff(
first_byte_or_zero = buffer_[0];
if (static_cast<int8>(buffer_[0]) > 0) {
const uint32 kMax1ByteVarint = 0x7f;
- uint32 tag = last_tag_ = buffer_[0];
+ uint32 tag = buffer_[0];
+ if (update_last_tag) {
+ last_tag_ = tag;
+ }
Advance(1);
return std::make_pair(tag, cutoff >= kMax1ByteVarint || tag <= cutoff);
}
@@ -1044,7 +1084,10 @@ inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoff(
GOOGLE_PREDICT_TRUE(buffer_ + 1 < buffer_end_) &&
GOOGLE_PREDICT_TRUE((buffer_[0] & ~buffer_[1]) >= 0x80)) {
const uint32 kMax2ByteVarint = (0x7f << 7) + 0x7f;
- uint32 tag = last_tag_ = (1u << 7) * buffer_[1] + (buffer_[0] - 0x80);
+ uint32 tag = (1u << 7) * buffer_[1] + (buffer_[0] - 0x80);
+ if (update_last_tag) {
+ last_tag_ = tag;
+ }
Advance(2);
// It might make sense to test for tag == 0 now, but it is so rare that
// that we don't bother. A varint-encoded 0 should be one byte unless
@@ -1057,8 +1100,11 @@ inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoff(
}
}
// Slow path
- last_tag_ = ReadTagFallback(first_byte_or_zero);
- return std::make_pair(last_tag_, static_cast<uint32>(last_tag_ - 1) < cutoff);
+ const uint32 tag = ReadTagFallback(first_byte_or_zero);
+ if (update_last_tag) {
+ last_tag_ = tag;
+ }
+ return std::make_pair(tag, static_cast<uint32>(tag - 1) < cutoff);
}
inline bool CodedInputStream::LastTagWas(uint32 expected) {
@@ -1153,21 +1199,24 @@ inline uint8* CodedOutputStream::WriteVarint32ToArray(uint32 value,
return target + 1;
}
-inline void CodedOutputStream::WriteVarint32SignExtended(int32 value) {
- if (value < 0) {
- WriteVarint64(static_cast<uint64>(value));
- } else {
- WriteVarint32(static_cast<uint32>(value));
+inline uint8* CodedOutputStream::WriteVarint64ToArray(uint64 value,
+ uint8* target) {
+ while (value >= 0x80) {
+ *target = static_cast<uint8>(value | 0x80);
+ value >>= 7;
+ ++target;
}
+ *target = static_cast<uint8>(value);
+ return target + 1;
+}
+
+inline void CodedOutputStream::WriteVarint32SignExtended(int32 value) {
+ WriteVarint64(static_cast<uint64>(value));
}
inline uint8* CodedOutputStream::WriteVarint32SignExtendedToArray(
int32 value, uint8* target) {
- if (value < 0) {
- return WriteVarint64ToArray(static_cast<uint64>(value), target);
- } else {
- return WriteVarint32ToArray(static_cast<uint32>(value), target);
- }
+ return WriteVarint64ToArray(static_cast<uint64>(value), target);
}
inline uint8* CodedOutputStream::WriteLittleEndian32ToArray(uint32 value,
@@ -1216,6 +1265,19 @@ inline void CodedOutputStream::WriteVarint32(uint32 value) {
}
}
+inline void CodedOutputStream::WriteVarint64(uint64 value) {
+ if (buffer_size_ >= 10) {
+ // Fast path: We have enough bytes left in the buffer to guarantee that
+ // this write won't cross the end, so we can skip the checks.
+ uint8* target = buffer_;
+ uint8* end = WriteVarint64ToArray(value, target);
+ int size = static_cast<int>(end - target);
+ Advance(size);
+ } else {
+ WriteVarint64SlowPath(value);
+ }
+}
+
inline void CodedOutputStream::WriteTag(uint32 value) {
WriteVarint32(value);
}
@@ -1226,11 +1288,23 @@ inline uint8* CodedOutputStream::WriteTagToArray(
}
inline size_t CodedOutputStream::VarintSize32(uint32 value) {
- if (value < (1 << 7)) {
- return 1;
- } else {
- return VarintSize32Fallback(value);
- }
+ // This computes value == 0 ? 1 : floor(log2(value)) / 7 + 1
+ // Use an explicit multiplication to implement the divide of
+ // a number in the 1..31 range.
+ // Explicit OR 0x1 to avoid calling Bits::Log2FloorNonZero(0), which is
+ // undefined.
+ uint32 log2value = Bits::Log2FloorNonZero(value | 0x1);
+ return static_cast<size_t>((log2value * 9 + 73) / 64);
+}
+
+inline size_t CodedOutputStream::VarintSize64(uint64 value) {
+ // This computes value == 0 ? 1 : floor(log2(value)) / 7 + 1
+ // Use an explicit multiplication to implement the divide of
+ // a number in the 1..63 range.
+ // Explicit OR 0x1 to avoid calling Bits::Log2FloorNonZero(0), which is
+ // undefined.
+ uint32 log2value = Bits::Log2FloorNonZero64(value | 0x1);
+ return static_cast<size_t>((log2value * 9 + 73) / 64);
}
inline size_t CodedOutputStream::VarintSize32SignExtended(int32 value) {
diff --git a/src/google/protobuf/io/coded_stream_unittest.cc b/src/google/protobuf/io/coded_stream_unittest.cc
index 9f1ebc3f..31574d5b 100644
--- a/src/google/protobuf/io/coded_stream_unittest.cc
+++ b/src/google/protobuf/io/coded_stream_unittest.cc
@@ -135,7 +135,7 @@ class CodedStreamTest : public testing::Test {
// for further information.
static void SetupTotalBytesLimitWarningTest(
int total_bytes_limit, int warning_threshold,
- vector<string>* out_errors, vector<string>* out_warnings);
+ std::vector<string>* out_errors, std::vector<string>* out_warnings);
// Buffer used during most of the tests. This assumes tests run sequentially.
static const int kBufferSize = 1024 * 64;
@@ -245,7 +245,7 @@ TEST_F(CodedStreamTest, EmptyInputBeforeEos) {
int count_;
} in;
CodedInputStream input(&in);
- input.ReadTag();
+ input.ReadTagNoLastTag();
EXPECT_TRUE(input.ConsumedEntireMessage());
}
@@ -446,6 +446,21 @@ TEST_2D(CodedStreamTest, ReadVarint32Error, kVarintErrorCases, kBlockSizes) {
EXPECT_EQ(kVarintErrorCases_case.can_parse, coded_input.ReadVarint32(&value));
}
+TEST_2D(CodedStreamTest, ReadVarint32Error_LeavesValueInInitializedState,
+ kVarintErrorCases, kBlockSizes) {
+ memcpy(buffer_, kVarintErrorCases_case.bytes, kVarintErrorCases_case.size);
+ ArrayInputStream input(buffer_, kVarintErrorCases_case.size,
+ kBlockSizes_case);
+ CodedInputStream coded_input(&input);
+
+ uint32 value = 0;
+ EXPECT_EQ(kVarintErrorCases_case.can_parse, coded_input.ReadVarint32(&value));
+ // While the specific value following a failure is not critical, we do want to
+ // ensure that it doesn't get set to an uninitialized value. (This check fails
+ // in MSAN mode if value has been set to an uninitialized value.)
+ EXPECT_EQ(value, value);
+}
+
TEST_2D(CodedStreamTest, ReadVarint64Error, kVarintErrorCases, kBlockSizes) {
memcpy(buffer_, kVarintErrorCases_case.bytes, kVarintErrorCases_case.size);
ArrayInputStream input(buffer_, kVarintErrorCases_case.size,
@@ -456,6 +471,21 @@ TEST_2D(CodedStreamTest, ReadVarint64Error, kVarintErrorCases, kBlockSizes) {
EXPECT_EQ(kVarintErrorCases_case.can_parse, coded_input.ReadVarint64(&value));
}
+TEST_2D(CodedStreamTest, ReadVarint64Error_LeavesValueInInitializedState,
+ kVarintErrorCases, kBlockSizes) {
+ memcpy(buffer_, kVarintErrorCases_case.bytes, kVarintErrorCases_case.size);
+ ArrayInputStream input(buffer_, kVarintErrorCases_case.size,
+ kBlockSizes_case);
+ CodedInputStream coded_input(&input);
+
+ uint64 value = 0;
+ EXPECT_EQ(kVarintErrorCases_case.can_parse, coded_input.ReadVarint64(&value));
+ // While the specific value following a failure is not critical, we do want to
+ // ensure that it doesn't get set to an uninitialized value. (This check fails
+ // in MSAN mode if value has been set to an uninitialized value.)
+ EXPECT_EQ(value, value);
+}
+
// -------------------------------------------------------------------
// VarintSize
@@ -495,6 +525,28 @@ TEST_1D(CodedStreamTest, VarintSize64, kVarintSizeCases) {
CodedOutputStream::VarintSize64(kVarintSizeCases_case.value));
}
+TEST_F(CodedStreamTest, VarintSize32PowersOfTwo) {
+ int expected = 1;
+ for (int i = 1; i < 32; i++) {
+ if (i % 7 == 0) {
+ expected += 1;
+ }
+ EXPECT_EQ(expected,
+ CodedOutputStream::VarintSize32(static_cast<uint32>(0x1u << i)));
+ }
+}
+
+TEST_F(CodedStreamTest, VarintSize64PowersOfTwo) {
+ int expected = 1;
+ for (int i = 1; i < 64; i++) {
+ if (i % 7 == 0) {
+ expected += 1;
+ }
+ EXPECT_EQ(expected, CodedOutputStream::VarintSize64(
+ static_cast<uint64>(0x1ull << i)));
+ }
+}
+
// -------------------------------------------------------------------
// Fixed-size int tests
@@ -1177,7 +1229,7 @@ TEST_F(CodedStreamTest, TotalBytesLimit) {
EXPECT_TRUE(coded_input.ReadString(&str, 16));
EXPECT_EQ(0, coded_input.BytesUntilTotalBytesLimit());
- vector<string> errors;
+ std::vector<string> errors;
{
ScopedMemoryLog error_log;
@@ -1211,7 +1263,7 @@ TEST_F(CodedStreamTest, TotalBytesLimitNotValidMessageEnd) {
// Read a tag. Should fail, but report being a valid endpoint since it's
// a regular limit.
- EXPECT_EQ(0, coded_input.ReadTag());
+ EXPECT_EQ(0, coded_input.ReadTagNoLastTag());
EXPECT_TRUE(coded_input.ConsumedEntireMessage());
// Pop the limit.
@@ -1219,7 +1271,7 @@ TEST_F(CodedStreamTest, TotalBytesLimitNotValidMessageEnd) {
// Read a tag. Should fail, and report *not* being a valid endpoint, since
// this time we're hitting the total bytes limit.
- EXPECT_EQ(0, coded_input.ReadTag());
+ EXPECT_EQ(0, coded_input.ReadTagNoLastTag());
EXPECT_FALSE(coded_input.ConsumedEntireMessage());
}
@@ -1229,7 +1281,7 @@ TEST_F(CodedStreamTest, TotalBytesLimitNotValidMessageEnd) {
// vectors.
void CodedStreamTest::SetupTotalBytesLimitWarningTest(
int total_bytes_limit, int warning_threshold,
- vector<string>* out_errors, vector<string>* out_warnings) {
+ std::vector<string>* out_errors, std::vector<string>* out_warnings) {
ArrayInputStream raw_input(buffer_, sizeof(buffer_), 128);
ScopedMemoryLog scoped_log;
@@ -1245,25 +1297,21 @@ void CodedStreamTest::SetupTotalBytesLimitWarningTest(
}
TEST_F(CodedStreamTest, TotalBytesLimitWarning) {
- vector<string> errors;
- vector<string> warnings;
+ std::vector<string> errors;
+ std::vector<string> warnings;
SetupTotalBytesLimitWarningTest(10240, 1024, &errors, &warnings);
EXPECT_EQ(0, errors.size());
- ASSERT_EQ(2, warnings.size());
- EXPECT_PRED_FORMAT2(testing::IsSubstring,
- "Reading dangerously large protocol message. If the message turns out to "
- "be larger than 10240 bytes, parsing will be halted for security reasons.",
- warnings[0]);
+ EXPECT_EQ(1, warnings.size());
EXPECT_PRED_FORMAT2(testing::IsSubstring,
"The total number of bytes read was 2048",
- warnings[1]);
+ warnings[0]);
}
TEST_F(CodedStreamTest, TotalBytesLimitWarningDisabled) {
- vector<string> errors;
- vector<string> warnings;
+ std::vector<string> errors;
+ std::vector<string> warnings;
// Test with -1
SetupTotalBytesLimitWarningTest(10240, -1, &errors, &warnings);
@@ -1362,7 +1410,7 @@ TEST_F(CodedStreamTest, InputOver2G) {
// input.BackUp() with the correct number of bytes on destruction.
ReallyBigInputStream input;
- vector<string> errors;
+ std::vector<string> errors;
{
ScopedMemoryLog error_log;
diff --git a/src/google/protobuf/io/gzip_stream.cc b/src/google/protobuf/io/gzip_stream.cc
index 9c621b6a..a569eff0 100644
--- a/src/google/protobuf/io/gzip_stream.cc
+++ b/src/google/protobuf/io/gzip_stream.cc
@@ -168,7 +168,7 @@ void GzipInputStream::BackUp(int count) {
}
bool GzipInputStream::Skip(int count) {
const void* data;
- int size;
+ int size = 0;
bool ok = Next(&data, &size);
while (ok && (size < count)) {
count -= size;
diff --git a/src/google/protobuf/io/gzip_stream.h b/src/google/protobuf/io/gzip_stream.h
index 15b02fe3..df1a446e 100644
--- a/src/google/protobuf/io/gzip_stream.h
+++ b/src/google/protobuf/io/gzip_stream.h
@@ -118,7 +118,7 @@ class LIBPROTOBUF_EXPORT GzipOutputStream : public ZeroCopyOutputStream {
ZLIB = 2,
};
- struct Options {
+ struct LIBPROTOBUF_EXPORT Options {
// Defaults to GZIP.
Format format;
diff --git a/src/google/protobuf/io/printer.cc b/src/google/protobuf/io/printer.cc
index 7532b098..99e895f5 100644
--- a/src/google/protobuf/io/printer.cc
+++ b/src/google/protobuf/io/printer.cc
@@ -70,8 +70,8 @@ Printer::~Printer() {
}
bool Printer::GetSubstitutionRange(const char* varname,
- pair<size_t, size_t>* range) {
- map<string, pair<size_t, size_t> >::const_iterator iter =
+ std::pair<size_t, size_t>* range) {
+ std::map<string, std::pair<size_t, size_t> >::const_iterator iter =
substitutions_.find(varname);
if (iter == substitutions_.end()) {
GOOGLE_LOG(DFATAL) << " Undefined variable in annotation: " << varname;
@@ -87,12 +87,12 @@ bool Printer::GetSubstitutionRange(const char* varname,
}
void Printer::Annotate(const char* begin_varname, const char* end_varname,
- const string& file_path, const vector<int>& path) {
+ const string& file_path, const std::vector<int>& path) {
if (annotation_collector_ == NULL) {
// Can't generate signatures with this Printer.
return;
}
- pair<size_t, size_t> begin, end;
+ std::pair<size_t, size_t> begin, end;
if (!GetSubstitutionRange(begin_varname, &begin) ||
!GetSubstitutionRange(end_varname, &end)) {
return;
@@ -106,7 +106,8 @@ void Printer::Annotate(const char* begin_varname, const char* end_varname,
}
}
-void Printer::Print(const map<string, string>& variables, const char* text) {
+void Printer::Print(const std::map<string, string>& variables,
+ const char* text) {
int size = strlen(text);
int pos = 0; // The number of bytes we've written so far.
substitutions_.clear();
@@ -143,14 +144,15 @@ void Printer::Print(const map<string, string>& variables, const char* text) {
WriteRaw(&variable_delimiter_, 1);
} else {
// Replace with the variable's value.
- map<string, string>::const_iterator iter = variables.find(varname);
+ std::map<string, string>::const_iterator iter = variables.find(varname);
if (iter == variables.end()) {
GOOGLE_LOG(DFATAL) << " Undefined variable: " << varname;
} else {
size_t begin = offset_;
WriteRaw(iter->second.data(), iter->second.size());
- pair<map<string, pair<size_t, size_t> >::iterator, bool> inserted =
- substitutions_.insert(
+ std::pair<std::map<string, std::pair<size_t, size_t> >::iterator,
+ bool>
+ inserted = substitutions_.insert(
std::make_pair(varname, std::make_pair(begin, offset_)));
if (!inserted.second) {
// This variable was used multiple times. Make its span have
@@ -172,13 +174,13 @@ void Printer::Print(const map<string, string>& variables, const char* text) {
}
void Printer::Print(const char* text) {
- static map<string, string> empty;
+ static std::map<string, string> empty;
Print(empty, text);
}
void Printer::Print(const char* text,
const char* variable, const string& value) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars[variable] = value;
Print(vars, text);
}
@@ -186,7 +188,7 @@ void Printer::Print(const char* text,
void Printer::Print(const char* text,
const char* variable1, const string& value1,
const char* variable2, const string& value2) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars[variable1] = value1;
vars[variable2] = value2;
Print(vars, text);
@@ -196,7 +198,7 @@ void Printer::Print(const char* text,
const char* variable1, const string& value1,
const char* variable2, const string& value2,
const char* variable3, const string& value3) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars[variable1] = value1;
vars[variable2] = value2;
vars[variable3] = value3;
@@ -208,7 +210,7 @@ void Printer::Print(const char* text,
const char* variable2, const string& value2,
const char* variable3, const string& value3,
const char* variable4, const string& value4) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars[variable1] = value1;
vars[variable2] = value2;
vars[variable3] = value3;
@@ -222,7 +224,7 @@ void Printer::Print(const char* text,
const char* variable3, const string& value3,
const char* variable4, const string& value4,
const char* variable5, const string& value5) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars[variable1] = value1;
vars[variable2] = value2;
vars[variable3] = value3;
@@ -238,7 +240,7 @@ void Printer::Print(const char* text,
const char* variable4, const string& value4,
const char* variable5, const string& value5,
const char* variable6, const string& value6) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars[variable1] = value1;
vars[variable2] = value2;
vars[variable3] = value3;
@@ -256,7 +258,7 @@ void Printer::Print(const char* text,
const char* variable5, const string& value5,
const char* variable6, const string& value6,
const char* variable7, const string& value7) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars[variable1] = value1;
vars[variable2] = value2;
vars[variable3] = value3;
@@ -276,7 +278,7 @@ void Printer::Print(const char* text,
const char* variable6, const string& value6,
const char* variable7, const string& value7,
const char* variable8, const string& value8) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars[variable1] = value1;
vars[variable2] = value2;
vars[variable3] = value3;
diff --git a/src/google/protobuf/io/printer.h b/src/google/protobuf/io/printer.h
index e78e2efd..e666445b 100644
--- a/src/google/protobuf/io/printer.h
+++ b/src/google/protobuf/io/printer.h
@@ -55,7 +55,7 @@ class LIBPROTOBUF_EXPORT AnnotationCollector {
// before end_offset are associated with the SourceCodeInfo-style path.
virtual void AddAnnotation(size_t begin_offset, size_t end_offset,
const string& file_path,
- const vector<int>& path) = 0;
+ const std::vector<int>& path) = 0;
virtual ~AnnotationCollector() {}
};
@@ -73,7 +73,8 @@ class AnnotationProtoCollector : public AnnotationCollector {
// Override for AnnotationCollector::AddAnnotation.
virtual void AddAnnotation(size_t begin_offset, size_t end_offset,
- const string& file_path, const vector<int>& path) {
+ const string& file_path,
+ const std::vector<int>& path) {
typename AnnotationProto::Annotation* annotation =
annotation_proto_->add_annotation();
for (int i = 0; i < path.size(); ++i) {
@@ -195,7 +196,7 @@ class LIBPROTOBUF_EXPORT Printer {
// of building the location path.
return;
}
- vector<int> path;
+ std::vector<int> path;
descriptor->GetLocationPath(&path);
Annotate(begin_varname, end_varname, descriptor->file()->name(), path);
}
@@ -216,7 +217,7 @@ class LIBPROTOBUF_EXPORT Printer {
// Annotations aren't turned on for this Printer.
return;
}
- vector<int> empty_path;
+ std::vector<int> empty_path;
Annotate(begin_varname, end_varname, file_name, empty_path);
}
@@ -225,7 +226,7 @@ class LIBPROTOBUF_EXPORT Printer {
// substituted are identified by their names surrounded by delimiter
// characters (as given to the constructor). The variable bindings are
// defined by the given map.
- void Print(const map<string, string>& variables, const char* text);
+ void Print(const std::map<string, string>& variables, const char* text);
// Like the first Print(), except the substitutions are given as parameters.
void Print(const char* text);
@@ -308,7 +309,7 @@ class LIBPROTOBUF_EXPORT Printer {
// substituted for end_varname. Note that begin_varname and end_varname
// may refer to the same variable.
void Annotate(const char* begin_varname, const char* end_varname,
- const string& file_path, const vector<int>& path);
+ const string& file_path, const std::vector<int>& path);
const char variable_delimiter_;
@@ -331,13 +332,14 @@ class LIBPROTOBUF_EXPORT Printer {
// start offset is the beginning of the substitution; the end offset is the
// last byte of the substitution plus one (such that (end - start) is the
// length of the substituted string).
- map<string, pair<size_t, size_t> > substitutions_;
+ std::map<string, std::pair<size_t, size_t> > substitutions_;
// Returns true and sets range to the substitution range in the output for
// varname if varname was used once in the last call to Print. If varname
// was not used, or if it was used multiple times, returns false (and
// fails a debug assertion).
- bool GetSubstitutionRange(const char* varname, pair<size_t, size_t>* range);
+ bool GetSubstitutionRange(const char* varname,
+ std::pair<size_t, size_t>* range);
// If non-null, annotation_collector_ is used to store annotations about
// generated code.
diff --git a/src/google/protobuf/io/printer_unittest.cc b/src/google/protobuf/io/printer_unittest.cc
index 95f3afa2..0435228a 100644
--- a/src/google/protobuf/io/printer_unittest.cc
+++ b/src/google/protobuf/io/printer_unittest.cc
@@ -121,7 +121,7 @@ TEST(Printer, VariableSubstitution) {
{
Printer printer(&output, '$');
- map<string, string> vars;
+ std::map<string, string> vars;
vars["foo"] = "World";
vars["bar"] = "$foo$";
@@ -187,7 +187,7 @@ class MockDescriptorFile {
// annotations.
class MockDescriptor {
public:
- MockDescriptor(const string& file, const vector<int>& path)
+ MockDescriptor(const string& file, const std::vector<int>& path)
: file_(file), path_(path) {}
// The mock file in which this descriptor was defined.
@@ -201,7 +201,7 @@ class MockDescriptor {
void GetLocationPath(std::vector<int>* output) const { *output = path_; }
MockDescriptorFile file_;
- vector<int> path_;
+ std::vector<int> path_;
};
TEST(Printer, AnnotateMap) {
@@ -211,13 +211,13 @@ TEST(Printer, AnnotateMap) {
AnnotationProtoCollector<GeneratedCodeInfo> info_collector(&info);
{
Printer printer(&output, '$', &info_collector);
- map<string, string> vars;
+ std::map<string, string> vars;
vars["foo"] = "3";
vars["bar"] = "5";
printer.Print(vars, "012$foo$4$bar$\n");
- vector<int> path_1;
+ std::vector<int> path_1;
path_1.push_back(33);
- vector<int> path_2;
+ std::vector<int> path_2;
path_2.push_back(11);
path_2.push_back(22);
MockDescriptor descriptor_1("path_1", path_1);
@@ -255,9 +255,9 @@ TEST(Printer, AnnotateInline) {
{
Printer printer(&output, '$', &info_collector);
printer.Print("012$foo$4$bar$\n", "foo", "3", "bar", "5");
- vector<int> path_1;
+ std::vector<int> path_1;
path_1.push_back(33);
- vector<int> path_2;
+ std::vector<int> path_2;
path_2.push_back(11);
path_2.push_back(22);
MockDescriptor descriptor_1("path_1", path_1);
@@ -295,7 +295,7 @@ TEST(Printer, AnnotateRange) {
{
Printer printer(&output, '$', &info_collector);
printer.Print("012$foo$4$bar$\n", "foo", "3", "bar", "5");
- vector<int> path;
+ std::vector<int> path;
path.push_back(33);
MockDescriptor descriptor("path", path);
printer.Annotate("foo", "bar", &descriptor);
@@ -320,7 +320,7 @@ TEST(Printer, AnnotateEmptyRange) {
Printer printer(&output, '$', &info_collector);
printer.Print("012$foo$4$baz$$bam$$bar$\n", "foo", "3", "bar", "5", "baz",
"", "bam", "");
- vector<int> path;
+ std::vector<int> path;
path.push_back(33);
MockDescriptor descriptor("path", path);
printer.Annotate("baz", "bam", &descriptor);
@@ -344,7 +344,7 @@ TEST(Printer, AnnotateDespiteUnrelatedMultipleUses) {
{
Printer printer(&output, '$', &info_collector);
printer.Print("012$foo$4$foo$$bar$\n", "foo", "3", "bar", "5");
- vector<int> path;
+ std::vector<int> path;
path.push_back(33);
MockDescriptor descriptor("path", path);
printer.Annotate("bar", "bar", &descriptor);
@@ -368,7 +368,7 @@ TEST(Printer, Indenting) {
{
Printer printer(&output, '$');
- map<string, string> vars;
+ std::map<string, string> vars;
vars["newline"] = "\n";
@@ -432,7 +432,7 @@ TEST(Printer, AnnotateMultipleUsesDeath) {
{
Printer printer(&output, '$', &info_collector);
printer.Print("012$foo$4$foo$\n", "foo", "3");
- vector<int> path;
+ std::vector<int> path;
path.push_back(33);
MockDescriptor descriptor("path", path);
EXPECT_DEBUG_DEATH(printer.Annotate("foo", "foo", &descriptor), "multiple");
@@ -447,7 +447,7 @@ TEST(Printer, AnnotateNegativeLengthDeath) {
{
Printer printer(&output, '$', &info_collector);
printer.Print("012$foo$4$bar$\n", "foo", "3", "bar", "5");
- vector<int> path;
+ std::vector<int> path;
path.push_back(33);
MockDescriptor descriptor("path", path);
EXPECT_DEBUG_DEATH(printer.Annotate("bar", "foo", &descriptor), "negative");
@@ -462,7 +462,7 @@ TEST(Printer, AnnotateUndefinedDeath) {
{
Printer printer(&output, '$', &info_collector);
printer.Print("012$foo$4$foo$\n", "foo", "3");
- vector<int> path;
+ std::vector<int> path;
path.push_back(33);
MockDescriptor descriptor("path", path);
EXPECT_DEBUG_DEATH(printer.Annotate("bar", "bar", &descriptor),
diff --git a/src/google/protobuf/io/tokenizer.cc b/src/google/protobuf/io/tokenizer.cc
index b3550dfb..916d1606 100644
--- a/src/google/protobuf/io/tokenizer.cc
+++ b/src/google/protobuf/io/tokenizer.cc
@@ -665,7 +665,7 @@ namespace {
class CommentCollector {
public:
CommentCollector(string* prev_trailing_comments,
- vector<string>* detached_comments,
+ std::vector<string>* detached_comments,
string* next_leading_comments)
: prev_trailing_comments_(prev_trailing_comments),
detached_comments_(detached_comments),
@@ -737,7 +737,7 @@ class CommentCollector {
private:
string* prev_trailing_comments_;
- vector<string>* detached_comments_;
+ std::vector<string>* detached_comments_;
string* next_leading_comments_;
string comment_buffer_;
@@ -757,7 +757,7 @@ class CommentCollector {
} // namespace
bool Tokenizer::NextWithComments(string* prev_trailing_comments,
- vector<string>* detached_comments,
+ std::vector<string>* detached_comments,
string* next_leading_comments) {
CommentCollector collector(prev_trailing_comments, detached_comments,
next_leading_comments);
diff --git a/src/google/protobuf/io/tokenizer.h b/src/google/protobuf/io/tokenizer.h
index 77a873bc..e80d564c 100644
--- a/src/google/protobuf/io/tokenizer.h
+++ b/src/google/protobuf/io/tokenizer.h
@@ -191,7 +191,7 @@ class LIBPROTOBUF_EXPORT Tokenizer {
// * grault. */
// optional int32 grault = 6;
bool NextWithComments(string* prev_trailing_comments,
- vector<string>* detached_comments,
+ std::vector<string>* detached_comments,
string* next_leading_comments);
// Parse helpers ---------------------------------------------------
diff --git a/src/google/protobuf/io/tokenizer_unittest.cc b/src/google/protobuf/io/tokenizer_unittest.cc
index ae0811f8..cadeb696 100644
--- a/src/google/protobuf/io/tokenizer_unittest.cc
+++ b/src/google/protobuf/io/tokenizer_unittest.cc
@@ -199,8 +199,8 @@ struct SimpleTokenCase {
Tokenizer::TokenType type;
};
-inline ostream& operator<<(ostream& out,
- const SimpleTokenCase& test_case) {
+inline std::ostream& operator<<(std::ostream& out,
+ const SimpleTokenCase& test_case) {
return out << CEscape(test_case.input);
}
@@ -333,8 +333,8 @@ struct MultiTokenCase {
// needed.
};
-inline ostream& operator<<(ostream& out,
- const MultiTokenCase& test_case) {
+inline std::ostream& operator<<(std::ostream& out,
+ const MultiTokenCase& test_case) {
return out << CEscape(test_case.input);
}
@@ -520,8 +520,8 @@ struct DocCommentCase {
const char* next_leading_comments;
};
-inline ostream& operator<<(ostream& out,
- const DocCommentCase& test_case) {
+inline std::ostream& operator<<(std::ostream& out,
+ const DocCommentCase& test_case) {
return out << CEscape(test_case.input);
}
@@ -693,7 +693,7 @@ TEST_2D(TokenizerTest, DocComments, kDocCommentCases, kBlockSizes) {
EXPECT_EQ("prev", tokenizer2.current().text);
string prev_trailing_comments;
- vector<string> detached_comments;
+ std::vector<string> detached_comments;
string next_leading_comments;
tokenizer.NextWithComments(&prev_trailing_comments, &detached_comments,
&next_leading_comments);
@@ -860,8 +860,7 @@ struct ErrorCase {
const char* errors;
};
-inline ostream& operator<<(ostream& out,
- const ErrorCase& test_case) {
+inline std::ostream& operator<<(std::ostream& out, const ErrorCase& test_case) {
return out << CEscape(test_case.input);
}
diff --git a/src/google/protobuf/io/zero_copy_stream_impl.cc b/src/google/protobuf/io/zero_copy_stream_impl.cc
index 7ec2b5da..109c55c1 100644
--- a/src/google/protobuf/io/zero_copy_stream_impl.cc
+++ b/src/google/protobuf/io/zero_copy_stream_impl.cc
@@ -270,10 +270,8 @@ bool FileOutputStream::CopyingFileOutputStream::Write(
// ===================================================================
-IstreamInputStream::IstreamInputStream(istream* input, int block_size)
- : copying_input_(input),
- impl_(&copying_input_, block_size) {
-}
+IstreamInputStream::IstreamInputStream(std::istream* input, int block_size)
+ : copying_input_(input), impl_(&copying_input_, block_size) {}
IstreamInputStream::~IstreamInputStream() {}
@@ -294,9 +292,8 @@ int64 IstreamInputStream::ByteCount() const {
}
IstreamInputStream::CopyingIstreamInputStream::CopyingIstreamInputStream(
- istream* input)
- : input_(input) {
-}
+ std::istream* input)
+ : input_(input) {}
IstreamInputStream::CopyingIstreamInputStream::~CopyingIstreamInputStream() {}
@@ -312,10 +309,8 @@ int IstreamInputStream::CopyingIstreamInputStream::Read(
// ===================================================================
-OstreamOutputStream::OstreamOutputStream(ostream* output, int block_size)
- : copying_output_(output),
- impl_(&copying_output_, block_size) {
-}
+OstreamOutputStream::OstreamOutputStream(std::ostream* output, int block_size)
+ : copying_output_(output), impl_(&copying_output_, block_size) {}
OstreamOutputStream::~OstreamOutputStream() {
impl_.Flush();
@@ -334,9 +329,8 @@ int64 OstreamOutputStream::ByteCount() const {
}
OstreamOutputStream::CopyingOstreamOutputStream::CopyingOstreamOutputStream(
- ostream* output)
- : output_(output) {
-}
+ std::ostream* output)
+ : output_(output) {}
OstreamOutputStream::CopyingOstreamOutputStream::~CopyingOstreamOutputStream() {
}
diff --git a/src/google/protobuf/io/zero_copy_stream_unittest.cc b/src/google/protobuf/io/zero_copy_stream_unittest.cc
index a9db8872..235cbca4 100644
--- a/src/google/protobuf/io/zero_copy_stream_unittest.cc
+++ b/src/google/protobuf/io/zero_copy_stream_unittest.cc
@@ -882,7 +882,7 @@ TEST_F(IoTest, IostreamIo) {
for (int i = 0; i < kBlockSizeCount; i++) {
for (int j = 0; j < kBlockSizeCount; j++) {
{
- stringstream stream;
+ std::stringstream stream;
{
OstreamOutputStream output(&stream, kBlockSizes[i]);
@@ -898,7 +898,7 @@ TEST_F(IoTest, IostreamIo) {
}
{
- stringstream stream;
+ std::stringstream stream;
{
OstreamOutputStream output(&stream, kBlockSizes[i]);
diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h
index 2d295510..6458714e 100644
--- a/src/google/protobuf/map.h
+++ b/src/google/protobuf/map.h
@@ -523,13 +523,13 @@ class Map {
typedef size_t size_type;
typedef hash<Key> hasher;
- explicit Map(bool old_style = true)
+ explicit Map(bool old_style = false)
: arena_(NULL),
default_enum_value_(0),
old_style_(old_style) {
Init();
}
- explicit Map(Arena* arena, bool old_style = true)
+ explicit Map(Arena* arena, bool old_style = false)
: arena_(arena),
default_enum_value_(0),
old_style_(old_style) {
@@ -543,7 +543,7 @@ class Map {
insert(other.begin(), other.end());
}
template <class InputIt>
- Map(const InputIt& first, const InputIt& last, bool old_style = true)
+ Map(const InputIt& first, const InputIt& last, bool old_style = false)
: arena_(NULL),
default_enum_value_(0),
old_style_(old_style) {
@@ -615,7 +615,6 @@ class Map {
#if __cplusplus >= 201103L && !defined(GOOGLE_PROTOBUF_OS_APPLE) && \
!defined(GOOGLE_PROTOBUF_OS_NACL) && \
- !defined(GOOGLE_PROTOBUF_OS_ANDROID) && \
!defined(GOOGLE_PROTOBUF_OS_EMSCRIPTEN)
template<class NodeType, class... Args>
void construct(NodeType* p, Args&&... args) {
@@ -654,7 +653,8 @@ class Map {
// To support Visual Studio 2008
size_type max_size() const {
- return std::numeric_limits<size_type>::max();
+ // parentheses around (std::...:max) prevents macro warning of max()
+ return (std::numeric_limits<size_type>::max)();
}
// To support gcc-4.4, which does not properly
@@ -1084,8 +1084,9 @@ class Map {
// index_of_first_non_null_, so we skip the code to update it.
return InsertUniqueInTree(b, node);
}
+ // parentheses around (std::min) prevents macro expansion of min(...)
index_of_first_non_null_ =
- std::min(index_of_first_non_null_, result.bucket_index_);
+ (std::min)(index_of_first_non_null_, result.bucket_index_);
return result;
}
@@ -1532,8 +1533,9 @@ class Map {
// Lookup
size_type count(const key_type& key) const {
- if (find(key) != end()) assert(key == find(key)->first);
- return find(key) == end() ? 0 : 1;
+ const_iterator it = find(key);
+ GOOGLE_DCHECK(it == end() || key == it->first);
+ return it == end() ? 0 : 1;
}
const_iterator find(const key_type& key) const {
return old_style_ ? const_iterator(deprecated_elements_->find(key))
diff --git a/src/google/protobuf/map_entry.h b/src/google/protobuf/map_entry.h
index abcd4529..d7db9b0f 100644
--- a/src/google/protobuf/map_entry.h
+++ b/src/google/protobuf/map_entry.h
@@ -244,14 +244,18 @@ class MapEntry : public MapEntryBase {
// to distinguish instances of the same MapEntry class.
static MapEntry* CreateDefaultInstance(const Descriptor* descriptor) {
MapEntry* entry = new MapEntry;
- const Reflection* reflection = new GeneratedMessageReflection(
- descriptor, entry, offsets_,
+ ReflectionSchema schema = {
+ entry,
+ offsets_,
+ has_bits_,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, entry_lite_._has_bits_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, _unknown_fields_), -1,
- DescriptorPool::generated_pool(),
- ::google::protobuf::MessageFactory::generated_factory(),
- sizeof(MapEntry),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, _internal_metadata_));
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, _internal_metadata_),
+ -1,
+ -1,
+ sizeof(MapEntry)};
+ const Reflection* reflection = new GeneratedMessageReflection(
+ descriptor, schema, DescriptorPool::generated_pool(),
+ MessageFactory::generated_factory());
entry->descriptor_ = descriptor;
entry->reflection_ = reflection;
entry->set_default_instance(entry);
@@ -278,8 +282,8 @@ class MapEntry : public MapEntryBase {
entry_lite_.set_default_instance(&default_instance->entry_lite_);
}
- static int offsets_[2];
- UnknownFieldSet _unknown_fields_;
+ static uint32 offsets_[2];
+ static uint32 has_bits_[2];
InternalMetadataWithArena _internal_metadata_;
MapEntry* default_instance_;
EntryLiteType entry_lite_;
@@ -297,12 +301,17 @@ class MapEntry : public MapEntryBase {
template <typename Key, typename Value, WireFormatLite::FieldType kKeyFieldType,
WireFormatLite::FieldType kValueFieldType, int default_enum_value>
-int MapEntry<Key, Value, kKeyFieldType, kValueFieldType,
+uint32 MapEntry<Key, Value, kKeyFieldType, kValueFieldType,
default_enum_value>::offsets_[2] = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, entry_lite_.key_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, entry_lite_.value_),
};
+template <typename Key, typename Value, WireFormatLite::FieldType kKeyFieldType,
+ WireFormatLite::FieldType kValueFieldType, int default_enum_value>
+uint32 MapEntry<Key, Value, kKeyFieldType, kValueFieldType,
+ default_enum_value>::has_bits_[2] = {0, 1};
+
} // namespace internal
} // namespace protobuf
diff --git a/src/google/protobuf/map_entry_lite.h b/src/google/protobuf/map_entry_lite.h
index 3fb58220..1243911b 100644
--- a/src/google/protobuf/map_entry_lite.h
+++ b/src/google/protobuf/map_entry_lite.h
@@ -171,7 +171,7 @@ class MapEntryLite : public MessageLite {
// need to care whether the value is unknown enum;
// 4) missing key/value: missed key/value will have default value. caller
// should take this entry as if key/value is set to default value.
- tag = input->ReadTag();
+ tag = input->ReadTagNoLastTag();
switch (tag) {
case kKeyTag:
if (!KeyTypeHandler::Read(input, mutable_key())) {
@@ -221,9 +221,8 @@ class MapEntryLite : public MessageLite {
deterministic, output);
return output;
}
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
+
+ // Don't override SerializeWithCachedSizesToArray. Use MessageLite's.
int GetCachedSize() const {
int size = 0;
@@ -333,7 +332,7 @@ class MapEntryLite : public MessageLite {
int size;
input->GetDirectBufferPointerInline(&data, &size);
// We could use memcmp here, but we don't bother. The tag is one byte.
- assert(kTagSize == 1);
+ GOOGLE_COMPILE_ASSERT(kTagSize == 1, tag_size_error);
if (size > 0 && *reinterpret_cast<const char*>(data) == kValueTag) {
typename Map::size_type size = map_->size();
value_ptr_ = &(*map_)[key_];
@@ -357,15 +356,17 @@ class MapEntryLite : public MessageLite {
entry_.reset(mf_->NewEntry());
*entry_->mutable_key() = key_;
- if (!entry_->MergePartialFromCodedStream(input)) return false;
- return UseKeyAndValueFromEntry();
+ const bool result = entry_->MergePartialFromCodedStream(input);
+ if (result) UseKeyAndValueFromEntry();
+ if (entry_->GetArena() != NULL) entry_.release();
+ return result;
}
const Key& key() const { return key_; }
const Value& value() const { return *value_ptr_; }
private:
- bool UseKeyAndValueFromEntry() GOOGLE_ATTRIBUTE_COLD {
+ void UseKeyAndValueFromEntry() GOOGLE_ATTRIBUTE_COLD {
// Update key_ in case we need it later (because key() is called).
// This is potentially inefficient, especially if the key is
// expensive to copy (e.g., a long string), but this is a cold
@@ -377,8 +378,6 @@ class MapEntryLite : public MessageLite {
ValueTypeHandler::kWireType ==
WireFormatLite::WIRETYPE_LENGTH_DELIMITED,
Value>::Move(entry_->mutable_value(), value_ptr_);
- if (entry_->GetArena() != NULL) entry_.release();
- return true;
}
// After reading a key and value successfully, and inserting that data
@@ -400,15 +399,18 @@ class MapEntryLite : public MessageLite {
ValueMover::Move(value_ptr_, entry_->mutable_value());
map_->erase(key_);
KeyMover::Move(&key_, entry_->mutable_key());
- if (!entry_->MergePartialFromCodedStream(input)) return false;
- return UseKeyAndValueFromEntry();
+ const bool result = entry_->MergePartialFromCodedStream(input);
+ if (result) UseKeyAndValueFromEntry();
+ if (entry_->GetArena() != NULL) entry_.release();
+ return result;
}
MapField* const mf_;
Map* const map_;
Key key_;
Value* value_ptr_;
- // On the fast path entry_ is not used.
+ // On the fast path entry_ is not used. And, when entry_ is used, it's set
+ // to mf_->NewEntry(), so in the arena case we must call entry_.release.
google::protobuf::scoped_ptr<MapEntryLite> entry_;
};
diff --git a/src/google/protobuf/map_field_lite.h b/src/google/protobuf/map_field_lite.h
index a9f30f59..cb0a4a45 100644
--- a/src/google/protobuf/map_field_lite.h
+++ b/src/google/protobuf/map_field_lite.h
@@ -68,13 +68,14 @@ class MapFieldLite {
// Set default enum value only for proto2 map field whose value is enum type.
void SetDefaultEnumValue();
- // Used in the implementation of parsing. Caller should take the ownership.
+ // Used in the implementation of parsing. Caller should take the ownership iff
+ // arena_ is NULL.
EntryType* NewEntry() const;
// Used in the implementation of serializing enum value type. Caller should
- // take the ownership.
+ // take the ownership iff arena_ is NULL.
EntryType* NewEnumEntryWrapper(const Key& key, const T t) const;
// Used in the implementation of serializing other value types. Caller should
- // take the ownership.
+ // take the ownership iff arena_ is NULL.
EntryType* NewEntryWrapper(const Key& key, const T& t) const;
protected:
diff --git a/src/google/protobuf/map_proto2_unittest.proto b/src/google/protobuf/map_proto2_unittest.proto
index ddc2a582..e9360a5a 100644
--- a/src/google/protobuf/map_proto2_unittest.proto
+++ b/src/google/protobuf/map_proto2_unittest.proto
@@ -29,7 +29,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
-
+option cc_enable_arenas = true;
import "google/protobuf/unittest_import.proto";
diff --git a/src/google/protobuf/map_test.cc b/src/google/protobuf/map_test.cc
index 03954e75..43fe0f44 100644
--- a/src/google/protobuf/map_test.cc
+++ b/src/google/protobuf/map_test.cc
@@ -91,6 +91,10 @@ using google::protobuf::unittest::TestRecursiveMapMessage;
namespace protobuf {
namespace internal {
+void MapTestForceDeterministic() {
+ ::google::protobuf::io::CodedOutputStream::SetDefaultSerializationDeterministic();
+}
+
// Map API Test =====================================================
// Parameterized tests on whether to use old style maps.
@@ -298,7 +302,7 @@ TEST_P(MapImplTest, IteratorBasic) {
template <typename Iterator>
static int64 median(Iterator i0, Iterator i1) {
- vector<int64> v(i0, i1);
+ std::vector<int64> v(i0, i1);
std::nth_element(v.begin(), v.begin() + v.size() / 2, v.end());
return v[v.size() / 2];
}
@@ -334,7 +338,7 @@ TEST_P(MapImplTest, BeginIsFast) {
GOOGLE_DCHECK_GE(last_key, 0);
map[last_key] = last_key ^ 1;
}
- vector<int64> times;
+ std::vector<int64> times;
// We're going to do map.erase(map.begin()) over and over again. But,
// just in case one iteration is fast compared to the granularity of
// our time keeping, we measure kChunkSize iterations per outer-loop iter.
@@ -379,7 +383,7 @@ TEST_P(MapImplTest, HashFlood) {
// 1024 (or 512 or 2048 or ...) entries. This assumes that map_ uses powers
// of 2 for table sizes, and that it's sufficient to "flood" with respect to
// the low bits of the output of map_.hash_function().
- vector<int64> times;
+ std::vector<int64> times;
std::set<int>::iterator it = s.begin();
int count = 0;
do {
@@ -506,7 +510,7 @@ static void StressTestIterators(int n, bool test_old_style_proto2_maps) {
// Finally, ensure erase(iterator) doesn't reorder anything, because that is
// what its documentation says.
m[last_key] = m[last_key ^ 999] = 0;
- vector<Map<int, int>::iterator> v;
+ std::vector<Map<int, int>::iterator> v;
v.reserve(m.size());
int position_of_last_key = 0;
for (Map<int, int>::iterator it = m.begin(); it != m.end(); ++it) {
@@ -563,7 +567,7 @@ TEST_P(MapImplTest, EraseRevalidates) {
map_[3] = map_[13] = map_[20] = 0;
const int initial_size = map_.size();
EXPECT_EQ(3, initial_size);
- vector<Map<int, int>::iterator> v;
+ std::vector<Map<int, int>::iterator> v;
for (Map<int, int>::iterator it = map_.begin(); it != map_.end(); ++it) {
v.push_back(it);
}
@@ -2437,7 +2441,7 @@ TEST(GeneratedMapFieldReflectionTest, SwapFields) {
MapTestUtil::SetMapFields(&message2);
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
const Reflection* reflection = message1.GetReflection();
reflection->ListFields(message2, &fields);
reflection->SwapFields(&message1, &message2, fields);
@@ -2844,7 +2848,7 @@ TEST(WireFormatForMapFieldTest, MapParseHelpers) {
{
// Test ParseFromIstream.
protobuf_unittest::TestMap message;
- stringstream stream(data);
+ std::stringstream stream(data);
EXPECT_TRUE(message.ParseFromIstream(&stream));
EXPECT_TRUE(stream.eof());
MapTestUtil::ExpectMapFieldsSet(message);
@@ -2873,6 +2877,33 @@ TEST(WireFormatForMapFieldTest, MapParseHelpers) {
// Deterministic Serialization Test ==========================================
template <typename T>
+static string DeterministicSerializationWithSerializePartialToCodedStream(
+ const T& t) {
+ const int size = t.ByteSize();
+ string result(size, '\0');
+ io::ArrayOutputStream array_stream(string_as_array(&result), size);
+ io::CodedOutputStream output_stream(&array_stream);
+ output_stream.SetSerializationDeterministic(true);
+ t.SerializePartialToCodedStream(&output_stream);
+ EXPECT_FALSE(output_stream.HadError());
+ EXPECT_EQ(size, output_stream.ByteCount());
+ return result;
+}
+
+template <typename T>
+static string DeterministicSerializationWithSerializeToCodedStream(const T& t) {
+ const int size = t.ByteSize();
+ string result(size, '\0');
+ io::ArrayOutputStream array_stream(string_as_array(&result), size);
+ io::CodedOutputStream output_stream(&array_stream);
+ output_stream.SetSerializationDeterministic(true);
+ t.SerializeToCodedStream(&output_stream);
+ EXPECT_FALSE(output_stream.HadError());
+ EXPECT_EQ(size, output_stream.ByteCount());
+ return result;
+}
+
+template <typename T>
static string DeterministicSerialization(const T& t) {
const int size = t.ByteSize();
string result(size, '\0');
@@ -2882,6 +2913,9 @@ static string DeterministicSerialization(const T& t) {
t.SerializeWithCachedSizes(&output_stream);
EXPECT_FALSE(output_stream.HadError());
EXPECT_EQ(size, output_stream.ByteCount());
+ EXPECT_EQ(result, DeterministicSerializationWithSerializeToCodedStream(t));
+ EXPECT_EQ(result,
+ DeterministicSerializationWithSerializePartialToCodedStream(t));
return result;
}
@@ -2983,6 +3017,18 @@ TEST(TextFormatMapTest, Sorted) {
EXPECT_EQ(message2.DebugString(), expected_text);
}
+TEST(TextFormatMapTest, ParseCorruptedString) {
+ string serialized_message;
+ GOOGLE_CHECK_OK(File::GetContents(
+ TestSourceDir() +
+ "/google/protobuf/testdata/golden_message_maps",
+ &serialized_message, true));
+ protobuf_unittest::TestMaps message;
+ GOOGLE_CHECK(message.ParseFromString(serialized_message));
+ TestParseCorruptedString<protobuf_unittest::TestMaps, true>(message);
+ TestParseCorruptedString<protobuf_unittest::TestMaps, false>(message);
+}
+
// arena support =================================================
TEST(ArenaTest, ParsingAndSerializingNoHeapAllocation) {
diff --git a/src/google/protobuf/map_test_util.cc b/src/google/protobuf/map_test_util.cc
index ae094647..3dd6aae5 100644
--- a/src/google/protobuf/map_test_util.cc
+++ b/src/google/protobuf/map_test_util.cc
@@ -867,7 +867,7 @@ void MapReflectionTester::RemoveLastMapsViaReflection(
Message* message) {
const Reflection* reflection = message->GetReflection();
- vector<const FieldDescriptor*> output;
+ std::vector<const FieldDescriptor*> output;
reflection->ListFields(*message, &output);
for (int i = 0; i < output.size(); ++i) {
const FieldDescriptor* field = output[i];
@@ -880,7 +880,7 @@ void MapReflectionTester::ReleaseLastMapsViaReflection(
Message* message) {
const Reflection* reflection = message->GetReflection();
- vector<const FieldDescriptor*> output;
+ std::vector<const FieldDescriptor*> output;
reflection->ListFields(*message, &output);
for (int i = 0; i < output.size(); ++i) {
const FieldDescriptor* field = output[i];
@@ -896,7 +896,7 @@ void MapReflectionTester::ReleaseLastMapsViaReflection(
void MapReflectionTester::SwapMapsViaReflection(Message* message) {
const Reflection* reflection = message->GetReflection();
- vector<const FieldDescriptor*> output;
+ std::vector<const FieldDescriptor*> output;
reflection->ListFields(*message, &output);
for (int i = 0; i < output.size(); ++i) {
const FieldDescriptor* field = output[i];
diff --git a/src/google/protobuf/map_type_handler.h b/src/google/protobuf/map_type_handler.h
index a21c92d9..ac987cbc 100644
--- a/src/google/protobuf/map_type_handler.h
+++ b/src/google/protobuf/map_type_handler.h
@@ -556,7 +556,7 @@ inline bool MapTypeHandler<WireFormatLite::TYPE_MESSAGE,
Type>::MapEntryAccessorType& \
MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
Type>::GetExternalReference(const TypeOnMemory& value) { \
- return value.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); \
+ return value.Get(); \
} \
template <typename Type> \
inline int \
@@ -581,11 +581,9 @@ inline bool MapTypeHandler<WireFormatLite::TYPE_MESSAGE,
arena); \
} \
template <typename Type> \
- inline void \
- MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
- Type>::ClearMaybeByDefaultEnum(TypeOnMemory* value, \
- Arena* arena, \
- int default_enum) { \
+ inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>:: \
+ ClearMaybeByDefaultEnum(TypeOnMemory* value, Arena* arena, \
+ int default_enum) { \
Clear(value, arena); \
} \
template <typename Type> \
@@ -609,11 +607,9 @@ inline bool MapTypeHandler<WireFormatLite::TYPE_MESSAGE,
&::google::protobuf::internal::GetEmptyStringAlreadyInited()); \
} \
template <typename Type> \
- inline void \
- MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
- Type>::InitializeMaybeByDefaultEnum(TypeOnMemory* value, \
- int default_enum_value, \
- Arena* arena) { \
+ inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>:: \
+ InitializeMaybeByDefaultEnum(TypeOnMemory* value, \
+ int default_enum_value, Arena* arena) { \
Initialize(value, arena); \
} \
template <typename Type> \
@@ -631,7 +627,7 @@ inline bool MapTypeHandler<WireFormatLite::TYPE_MESSAGE,
Type>::DefaultIfNotInitialized(const TypeOnMemory& value, \
const TypeOnMemory& \
default_value) { \
- return value.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); \
+ return value.Get(); \
} \
template <typename Type> \
inline bool MapTypeHandler<WireFormatLite::TYPE_##FieldType, \
diff --git a/src/google/protobuf/message.cc b/src/google/protobuf/message.cc
index c8de458c..b799dead 100644
--- a/src/google/protobuf/message.cc
+++ b/src/google/protobuf/message.cc
@@ -96,12 +96,12 @@ bool Message::IsInitialized() const {
return ReflectionOps::IsInitialized(*this);
}
-void Message::FindInitializationErrors(vector<string>* errors) const {
+void Message::FindInitializationErrors(std::vector<string>* errors) const {
return ReflectionOps::FindInitializationErrors(*this, "", errors);
}
string Message::InitializationErrorString() const {
- vector<string> errors;
+ std::vector<string> errors;
FindInitializationErrors(&errors);
return Join(errors, ", ");
}
@@ -130,12 +130,12 @@ bool Message::ParsePartialFromFileDescriptor(int file_descriptor) {
return ParsePartialFromZeroCopyStream(&input) && input.GetErrno() == 0;
}
-bool Message::ParseFromIstream(istream* input) {
+bool Message::ParseFromIstream(std::istream* input) {
io::IstreamInputStream zero_copy_input(input);
return ParseFromZeroCopyStream(&zero_copy_input) && input->eof();
}
-bool Message::ParsePartialFromIstream(istream* input) {
+bool Message::ParsePartialFromIstream(std::istream* input) {
io::IstreamInputStream zero_copy_input(input);
return ParsePartialFromZeroCopyStream(&zero_copy_input) && input->eof();
}
@@ -172,7 +172,7 @@ bool Message::SerializePartialToFileDescriptor(int file_descriptor) const {
return SerializePartialToZeroCopyStream(&output);
}
-bool Message::SerializeToOstream(ostream* output) const {
+bool Message::SerializeToOstream(std::ostream* output) const {
{
io::OstreamOutputStream zero_copy_output(output);
if (!SerializeToZeroCopyStream(&zero_copy_output)) return false;
@@ -180,7 +180,7 @@ bool Message::SerializeToOstream(ostream* output) const {
return output->good();
}
-bool Message::SerializePartialToOstream(ostream* output) const {
+bool Message::SerializePartialToOstream(std::ostream* output) const {
io::OstreamOutputStream zero_copy_output(output);
return SerializePartialToZeroCopyStream(&zero_copy_output);
}
@@ -225,38 +225,6 @@ void* Reflection::MutableRawRepeatedString(
}
-// Default EnumValue API implementations. Real reflection implementations should
-// override these. However, there are several legacy implementations that do
-// not, and cannot easily be changed at the same time as the Reflection API, so
-// we provide these for now.
-// TODO: Remove these once all Reflection implementations are updated.
-int Reflection::GetEnumValue(const Message& message,
- const FieldDescriptor* field) const {
- GOOGLE_LOG(FATAL) << "Unimplemented EnumValue API.";
- return 0;
-}
-void Reflection::SetEnumValue(Message* message,
- const FieldDescriptor* field,
- int value) const {
- GOOGLE_LOG(FATAL) << "Unimplemented EnumValue API.";
-}
-int Reflection::GetRepeatedEnumValue(
- const Message& message,
- const FieldDescriptor* field, int index) const {
- GOOGLE_LOG(FATAL) << "Unimplemented EnumValue API.";
- return 0;
-}
-void Reflection::SetRepeatedEnumValue(Message* message,
- const FieldDescriptor* field, int index,
- int value) const {
- GOOGLE_LOG(FATAL) << "Unimplemented EnumValue API.";
-}
-void Reflection::AddEnumValue(Message* message,
- const FieldDescriptor* field,
- int value) const {
- GOOGLE_LOG(FATAL) << "Unimplemented EnumValue API.";
-}
-
MapIterator Reflection::MapBegin(
Message* message,
const FieldDescriptor* field) const {
diff --git a/src/google/protobuf/message.h b/src/google/protobuf/message.h
index bee25f77..4d14584d 100644
--- a/src/google/protobuf/message.h
+++ b/src/google/protobuf/message.h
@@ -519,7 +519,7 @@ class LIBPROTOBUF_EXPORT Reflection {
// will only be present when the new unknown-enum-value semantics are enabled
// for a message.)
virtual int GetEnumValue(
- const Message& message, const FieldDescriptor* field) const;
+ const Message& message, const FieldDescriptor* field) const = 0;
// See MutableMessage() for the meaning of the "factory" parameter.
virtual const Message& GetMessage(const Message& message,
@@ -575,7 +575,7 @@ class LIBPROTOBUF_EXPORT Reflection {
// messages with new unknown-enum-value semantics.
virtual void SetEnumValue(Message* message,
const FieldDescriptor* field,
- int value) const;
+ int value) const = 0;
// Get a mutable pointer to a field with a message type. If a MessageFactory
// is provided, it will be used to construct instances of the sub-message;
@@ -646,7 +646,7 @@ class LIBPROTOBUF_EXPORT Reflection {
// for a message.)
virtual int GetRepeatedEnumValue(
const Message& message,
- const FieldDescriptor* field, int index) const;
+ const FieldDescriptor* field, int index) const = 0;
virtual const Message& GetRepeatedMessage(
const Message& message,
const FieldDescriptor* field, int index) const = 0;
@@ -693,7 +693,7 @@ class LIBPROTOBUF_EXPORT Reflection {
// messages with new unknown-enum-value semantics.
virtual void SetRepeatedEnumValue(Message* message,
const FieldDescriptor* field, int index,
- int value) const;
+ int value) const = 0;
// Get a mutable pointer to an element of a repeated field with a message
// type.
virtual Message* MutableRepeatedMessage(
@@ -729,7 +729,7 @@ class LIBPROTOBUF_EXPORT Reflection {
// messages with new unknown-enum-value semantics.
virtual void AddEnumValue(Message* message,
const FieldDescriptor* field,
- int value) const;
+ int value) const = 0;
// See MutableMessage() for comments on the "factory" parameter.
virtual Message* AddMessage(Message* message,
const FieldDescriptor* field,
@@ -848,34 +848,31 @@ class LIBPROTOBUF_EXPORT Reflection {
// downgrade to a compatible value or use the UnknownFieldSet if not. For
// example:
//
- // int new_value = GetValueFromApplicationLogic();
- // if (reflection->SupportsUnknownEnumValues()) {
+ // int new_value = GetValueFromApplicationLogic();
+ // if (reflection->SupportsUnknownEnumValues()) {
// reflection->SetEnumValue(message, field, new_value);
- // } else {
+ // } else {
// if (field_descriptor->enum_type()->
- // FindValueByNumver(new_value) != NULL) {
- // reflection->SetEnumValue(message, field, new_value);
+ // FindValueByNumber(new_value) != NULL) {
+ // reflection->SetEnumValue(message, field, new_value);
// } else if (emit_unknown_enum_values) {
- // reflection->MutableUnknownFields(message)->AddVarint(
- // field->number(),
- // new_value);
+ // reflection->MutableUnknownFields(message)->AddVarint(
+ // field->number(), new_value);
// } else {
- // // convert value to a compatible/default value.
- // new_value = CompatibleDowngrade(new_value);
- // reflection->SetEnumValue(message, field, new_value);
+ // // convert value to a compatible/default value.
+ // new_value = CompatibleDowngrade(new_value);
+ // reflection->SetEnumValue(message, field, new_value);
// }
- // }
+ // }
virtual bool SupportsUnknownEnumValues() const { return false; }
// Returns the MessageFactory associated with this message. This can be
// useful for determining if a message is a generated message or not, for
// example:
- //
- // if (message->GetReflection()->GetMessageFactory() ==
- // google::protobuf::MessageFactory::generated_factory()) {
- // // This is a generated message.
- // }
- //
+ // if (message->GetReflection()->GetMessageFactory() ==
+ // google::protobuf::MessageFactory::generated_factory()) {
+ // // This is a generated message.
+ // }
// It can also be used to create more messages of this type, though
// Message::New() is an easier way to accomplish this.
virtual MessageFactory* GetMessageFactory() const;
diff --git a/src/google/protobuf/message_lite.cc b/src/google/protobuf/message_lite.cc
index 9d6da264..b8cb3f4c 100644
--- a/src/google/protobuf/message_lite.cc
+++ b/src/google/protobuf/message_lite.cc
@@ -33,6 +33,8 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
+#include <climits>
+
#include <google/protobuf/arena.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/message_lite.h>
@@ -227,6 +229,7 @@ uint8* MessageLite::InternalSerializeWithCachedSizesToArray(
int size = GetCachedSize();
io::ArrayOutputStream out(target, size);
io::CodedOutputStream coded_out(&out);
+ coded_out.SetSerializationDeterministic(deterministic);
SerializeWithCachedSizes(&coded_out);
GOOGLE_CHECK(!coded_out.HadError());
return target + size;
@@ -237,21 +240,18 @@ bool MessageLite::SerializeToCodedStream(io::CodedOutputStream* output) const {
return SerializePartialToCodedStream(output);
}
-size_t MessageLite::ByteSizeLong() const {
- return internal::FromIntSize(ByteSize());
-}
-
bool MessageLite::SerializePartialToCodedStream(
io::CodedOutputStream* output) const {
const size_t size = ByteSizeLong(); // Force size to be cached.
if (size > INT_MAX) {
- GOOGLE_LOG(ERROR) << "Exceeded maximum protobuf size of 2GB.";
+ GOOGLE_LOG(ERROR) << "Exceeded maximum protobuf size of 2GB: " << size;
return false;
}
uint8* buffer = output->GetDirectBufferForNBytesAndAdvance(size);
if (buffer != NULL) {
- uint8* end = SerializeWithCachedSizesToArray(buffer);
+ uint8* end = InternalSerializeWithCachedSizesToArray(
+ output->IsSerializationDeterministic(), buffer);
if (end - buffer != size) {
ByteSizeConsistencyError(size, ByteSizeLong(), end - buffer, *this);
}
@@ -294,7 +294,7 @@ bool MessageLite::AppendPartialToString(string* output) const {
size_t old_size = output->size();
size_t byte_size = ByteSizeLong();
if (byte_size > INT_MAX) {
- GOOGLE_LOG(ERROR) << "Exceeded maximum protobuf size of 2GB.";
+ GOOGLE_LOG(ERROR) << "Exceeded maximum protobuf size of 2GB: " << byte_size;
return false;
}
diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h
index 88455669..5e5ed306 100644
--- a/src/google/protobuf/message_lite.h
+++ b/src/google/protobuf/message_lite.h
@@ -39,7 +39,9 @@
#ifndef GOOGLE_PROTOBUF_MESSAGE_LITE_H__
#define GOOGLE_PROTOBUF_MESSAGE_LITE_H__
+#include <climits>
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/stubs/logging.h>
namespace google {
@@ -239,17 +241,22 @@ class LIBPROTOBUF_EXPORT MessageLite {
bool AppendPartialToString(string* output) const;
// Computes the serialized size of the message. This recursively calls
- // ByteSize() on all embedded messages. Subclasses MUST override either
- // ByteSize() or ByteSizeLong() (overriding both is fine).
+ // ByteSizeLong() on all embedded messages.
//
- // ByteSize() is generally linear in the number of fields defined for the
+ // ByteSizeLong() is generally linear in the number of fields defined for the
// proto.
- virtual int ByteSize() const { return static_cast<int>(ByteSizeLong()); }
- virtual size_t ByteSizeLong() const;
+ virtual size_t ByteSizeLong() const = 0;
- // Serializes the message without recomputing the size. The message must
- // not have changed since the last call to ByteSize(); if it has, the results
- // are undefined.
+ // Legacy ByteSize() API.
+ int ByteSize() const {
+ size_t result = ByteSizeLong();
+ GOOGLE_DCHECK_LE(result, static_cast<size_t>(INT_MAX));
+ return static_cast<int>(result);
+ }
+
+ // Serializes the message without recomputing the size. The message must not
+ // have changed since the last call to ByteSize(), and the value returned by
+ // ByteSize must be non-negative. Otherwise the results are undefined.
virtual void SerializeWithCachedSizes(
io::CodedOutputStream* output) const = 0;
diff --git a/src/google/protobuf/message_unittest.cc b/src/google/protobuf/message_unittest.cc
index 3af05808..c1b05bc1 100644
--- a/src/google/protobuf/message_unittest.cc
+++ b/src/google/protobuf/message_unittest.cc
@@ -48,6 +48,7 @@
#include <google/protobuf/test_util.h>
#include <google/protobuf/unittest.pb.h>
#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/descriptor.h>
@@ -76,7 +77,7 @@ TEST(MessageTest, SerializeHelpers) {
protobuf_unittest::TestAllTypes message;
TestUtil::SetAllFields(&message);
- stringstream stream;
+ std::stringstream stream;
string str1("foo");
string str2("bar");
@@ -100,7 +101,7 @@ TEST(MessageTest, SerializeHelpers) {
}
TEST(MessageTest, SerializeToBrokenOstream) {
- ofstream out;
+ std::ofstream out;
protobuf_unittest::TestAllTypes message;
message.set_optional_int32(123);
@@ -154,7 +155,7 @@ TEST(MessageTest, ParseHelpers) {
{
// Test ParseFromIstream.
protobuf_unittest::TestAllTypes message;
- stringstream stream(data);
+ std::stringstream stream(data);
EXPECT_TRUE(message.ParseFromIstream(&stream));
EXPECT_TRUE(stream.eof());
TestUtil::ExpectAllFieldsSet(message);
@@ -182,7 +183,7 @@ TEST(MessageTest, ParseHelpers) {
TEST(MessageTest, ParseFailsIfNotInitialized) {
unittest::TestRequired message;
- vector<string> errors;
+ std::vector<string> errors;
{
ScopedMemoryLog log;
@@ -286,28 +287,96 @@ TEST(MessageTest, CheckBigOverflow) {
#endif // PROTOBUF_HAS_DEATH_TEST
namespace {
-
-class NegativeByteSize : public unittest::TestRequired {
+// An input stream that repeats a string's content for a number of times. It
+// helps us create a really large input without consuming too much memory. Used
+// to test the parsing behavior when the input size exceeds 2G or close to it.
+class RepeatedInputStream : public io::ZeroCopyInputStream {
public:
- virtual int ByteSize() const { return -1; }
+ RepeatedInputStream(const string& data, size_t count)
+ : data_(data), count_(count), position_(0), total_byte_count_(0) {}
+
+ virtual bool Next(const void** data, int* size) {
+ if (position_ == data_.size()) {
+ if (--count_ == 0) {
+ return false;
+ }
+ position_ = 0;
+ }
+ *data = &data_[position_];
+ *size = static_cast<int>(data_.size() - position_);
+ position_ = data_.size();
+ total_byte_count_ += *size;
+ return true;
+ }
- // The implementation of ByteSizeLong() from MessageLite, to simulate what
- // would happen if TestRequired *hadn't* overridden it already.
- virtual size_t ByteSizeLong() const {
- return static_cast<unsigned int>(ByteSize());
+ virtual void BackUp(int count) {
+ position_ -= static_cast<size_t>(count);
+ total_byte_count_ -= count;
}
-};
+ virtual bool Skip(int count) {
+ while (count > 0) {
+ const void* data;
+ int size;
+ if (!Next(&data, &size)) {
+ break;
+ }
+ if (size >= count) {
+ BackUp(size - count);
+ return true;
+ } else {
+ count -= size;
+ }
+ }
+ return false;
+ }
+
+ virtual int64 ByteCount() const { return total_byte_count_; }
+
+ private:
+ string data_;
+ size_t count_; // The number of strings that haven't been consuemd.
+ size_t position_; // Position in the string for the next read.
+ int64 total_byte_count_;
+};
} // namespace
-TEST(MessageTest, SerializationFailsOnNegativeByteSize) {
- NegativeByteSize message;
- string string_output;
- EXPECT_FALSE(message.AppendPartialToString(&string_output));
+TEST(MessageTest, TestParseMessagesCloseTo2G) {
+ // Create a message with a large string field.
+ string value = string(64 * 1024 * 1024, 'x');
+ protobuf_unittest::TestAllTypes message;
+ message.set_optional_string(value);
+
+ // Repeat this message in the input stream to make the total input size
+ // close to 2G.
+ string data = message.SerializeAsString();
+ size_t count = static_cast<size_t>(kint32max) / data.size();
+ RepeatedInputStream input(data, count);
+
+ // The parsing should succeed.
+ protobuf_unittest::TestAllTypes result;
+ EXPECT_TRUE(result.ParseFromZeroCopyStream(&input));
+
+ // When there are multiple occurences of a singulr field, the last one
+ // should win.
+ EXPECT_EQ(value, result.optional_string());
+}
+
+TEST(MessageTest, TestParseMessagesOver2G) {
+ // Create a message with a large string field.
+ string value = string(64 * 1024 * 1024, 'x');
+ protobuf_unittest::TestAllTypes message;
+ message.set_optional_string(value);
+
+ // Repeat this message in the input stream to make the total input size
+ // larger than 2G.
+ string data = message.SerializeAsString();
+ size_t count = static_cast<size_t>(kint32max) / data.size() + 1;
+ RepeatedInputStream input(data, count);
- io::ArrayOutputStream coded_raw_output(NULL, 100);
- io::CodedOutputStream coded_output(&coded_raw_output);
- EXPECT_FALSE(message.SerializePartialToCodedStream(&coded_output));
+ // The parsing should fail.
+ protobuf_unittest::TestAllTypes result;
+ EXPECT_FALSE(result.ParseFromZeroCopyStream(&input));
}
TEST(MessageTest, BypassInitializationCheckOnSerialize) {
@@ -319,7 +388,7 @@ TEST(MessageTest, BypassInitializationCheckOnSerialize) {
TEST(MessageTest, FindInitializationErrors) {
unittest::TestRequired message;
- vector<string> errors;
+ std::vector<string> errors;
message.FindInitializationErrors(&errors);
ASSERT_EQ(3, errors.size());
EXPECT_EQ("a", errors[0]);
diff --git a/src/google/protobuf/metadata.h b/src/google/protobuf/metadata.h
index 6e3eef63..dca1fa45 100644
--- a/src/google/protobuf/metadata.h
+++ b/src/google/protobuf/metadata.h
@@ -40,6 +40,8 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/arena.h>
+#include <google/protobuf/arenastring.h>
+#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/unknown_field_set.h>
namespace google {
@@ -56,30 +58,30 @@ namespace internal {
// The tagged pointer uses the LSB to disambiguate cases, and uses bit 0 == 0 to
// indicate an arena pointer and bit 0 == 1 to indicate a UFS+Arena-container
// pointer.
-class LIBPROTOBUF_EXPORT InternalMetadataWithArena {
+template <class T, class Derived>
+class InternalMetadataWithArenaBase {
public:
- InternalMetadataWithArena() : ptr_(NULL) {}
- explicit InternalMetadataWithArena(Arena* arena)
- : ptr_ (arena) {}
+ InternalMetadataWithArenaBase() : ptr_(NULL) {}
+ explicit InternalMetadataWithArenaBase(Arena* arena) : ptr_(arena) {}
- ~InternalMetadataWithArena() {
+ ~InternalMetadataWithArenaBase() {
if (have_unknown_fields() && arena() == NULL) {
delete PtrValue<Container>();
}
ptr_ = NULL;
}
- GOOGLE_ATTRIBUTE_ALWAYS_INLINE const UnknownFieldSet& unknown_fields() const {
+ GOOGLE_ATTRIBUTE_ALWAYS_INLINE const T& unknown_fields() const {
if (GOOGLE_PREDICT_FALSE(have_unknown_fields())) {
- return PtrValue<Container>()->unknown_fields_;
+ return PtrValue<Container>()->unknown_fields;
} else {
- return *UnknownFieldSet::default_instance();
+ return Derived::default_instance();
}
}
- GOOGLE_ATTRIBUTE_ALWAYS_INLINE UnknownFieldSet* mutable_unknown_fields() {
+ GOOGLE_ATTRIBUTE_ALWAYS_INLINE T* mutable_unknown_fields() {
if (GOOGLE_PREDICT_TRUE(have_unknown_fields())) {
- return &PtrValue<Container>()->unknown_fields_;
+ return &PtrValue<Container>()->unknown_fields;
} else {
return mutable_unknown_fields_slow();
}
@@ -87,7 +89,7 @@ class LIBPROTOBUF_EXPORT InternalMetadataWithArena {
GOOGLE_ATTRIBUTE_ALWAYS_INLINE Arena* arena() const {
if (GOOGLE_PREDICT_FALSE(have_unknown_fields())) {
- return PtrValue<Container>()->arena_;
+ return PtrValue<Container>()->arena;
} else {
return PtrValue<Arena>();
}
@@ -97,7 +99,7 @@ class LIBPROTOBUF_EXPORT InternalMetadataWithArena {
return PtrTag() == kTagContainer;
}
- GOOGLE_ATTRIBUTE_ALWAYS_INLINE void Swap(InternalMetadataWithArena* other) {
+ GOOGLE_ATTRIBUTE_ALWAYS_INLINE void Swap(Derived* other) {
// Semantics here are that we swap only the unknown fields, not the arena
// pointer. We cannot simply swap ptr_ with other->ptr_ because we need to
// maintain our own arena ptr. Also, our ptr_ and other's ptr_ may be in
@@ -105,7 +107,19 @@ class LIBPROTOBUF_EXPORT InternalMetadataWithArena {
// cannot simply swap ptr_ and then restore the arena pointers. We reuse
// UFS's swap implementation instead.
if (have_unknown_fields() || other->have_unknown_fields()) {
- mutable_unknown_fields()->Swap(other->mutable_unknown_fields());
+ static_cast<Derived*>(this)->DoSwap(other->mutable_unknown_fields());
+ }
+ }
+
+ GOOGLE_ATTRIBUTE_ALWAYS_INLINE void MergeFrom(const Derived& other) {
+ if (other.have_unknown_fields()) {
+ static_cast<Derived*>(this)->DoMergeFrom(other.unknown_fields());
+ }
+ }
+
+ GOOGLE_ATTRIBUTE_ALWAYS_INLINE void Clear() {
+ if (have_unknown_fields()) {
+ static_cast<Derived*>(this)->DoClear();
}
}
@@ -131,24 +145,80 @@ class LIBPROTOBUF_EXPORT InternalMetadataWithArena {
return reinterpret_cast<intptr_t>(ptr_) & kPtrTagMask;
}
- template<typename T> T* PtrValue() const {
- return reinterpret_cast<T*>(
+ template<typename U> U* PtrValue() const {
+ return reinterpret_cast<U*>(
reinterpret_cast<intptr_t>(ptr_) & kPtrValueMask);
}
// If ptr_'s tag is kTagContainer, it points to an instance of this struct.
struct Container {
- UnknownFieldSet unknown_fields_;
- Arena* arena_;
+ T unknown_fields;
+ Arena* arena;
};
- GOOGLE_ATTRIBUTE_NOINLINE UnknownFieldSet* mutable_unknown_fields_slow() {
+ GOOGLE_ATTRIBUTE_NOINLINE T* mutable_unknown_fields_slow() {
Arena* my_arena = arena();
Container* container = Arena::Create<Container>(my_arena);
ptr_ = reinterpret_cast<void*>(
reinterpret_cast<intptr_t>(container) | kTagContainer);
- container->arena_ = my_arena;
- return &(container->unknown_fields_);
+ container->arena = my_arena;
+ return &(container->unknown_fields);
+ }
+};
+
+class InternalMetadataWithArena
+ : public InternalMetadataWithArenaBase<UnknownFieldSet,
+ InternalMetadataWithArena> {
+ public:
+ InternalMetadataWithArena() {}
+ explicit InternalMetadataWithArena(Arena* arena)
+ : InternalMetadataWithArenaBase<UnknownFieldSet,
+ InternalMetadataWithArena>(arena) {}
+
+ void DoSwap(UnknownFieldSet* other) {
+ mutable_unknown_fields()->Swap(other);
+ }
+
+ void DoMergeFrom(const UnknownFieldSet& other) {
+ mutable_unknown_fields()->MergeFrom(other);
+ }
+
+ void DoClear() {
+ mutable_unknown_fields()->Clear();
+ }
+
+ static const UnknownFieldSet& default_instance() {
+ return *UnknownFieldSet::default_instance();
+ }
+};
+
+// We store unknown fields as a string right now, because there is currently no
+// good interface for reading unknown fields into an ArenaString. We may want
+// to revisit this to allow unknown fields to be parsed onto the Arena.
+class InternalMetadataWithArenaLite
+ : public InternalMetadataWithArenaBase<string,
+ InternalMetadataWithArenaLite> {
+ public:
+ InternalMetadataWithArenaLite() {}
+
+ explicit InternalMetadataWithArenaLite(Arena* arena)
+ : InternalMetadataWithArenaBase<string,
+ InternalMetadataWithArenaLite>(arena) {}
+
+ void DoSwap(string* other) {
+ mutable_unknown_fields()->swap(*other);
+ }
+
+ void DoMergeFrom(const string& other) {
+ mutable_unknown_fields()->append(other);
+ }
+
+ void DoClear() {
+ mutable_unknown_fields()->clear();
+ }
+
+ static const string& default_instance() {
+ return GetEmptyStringAlreadyInited();
}
};
diff --git a/src/google/protobuf/reflection_ops.cc b/src/google/protobuf/reflection_ops.cc
index 4629dec2..bb9c7f8b 100644
--- a/src/google/protobuf/reflection_ops.cc
+++ b/src/google/protobuf/reflection_ops.cc
@@ -63,7 +63,7 @@ void ReflectionOps::Merge(const Message& from, Message* to) {
const Reflection* from_reflection = from.GetReflection();
const Reflection* to_reflection = to->GetReflection();
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
from_reflection->ListFields(from, &fields);
for (int i = 0; i < fields.size(); i++) {
const FieldDescriptor* field = fields[i];
@@ -129,7 +129,7 @@ void ReflectionOps::Merge(const Message& from, Message* to) {
void ReflectionOps::Clear(Message* message) {
const Reflection* reflection = message->GetReflection();
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
reflection->ListFields(*message, &fields);
for (int i = 0; i < fields.size(); i++) {
reflection->ClearField(message, fields[i]);
@@ -152,7 +152,7 @@ bool ReflectionOps::IsInitialized(const Message& message) {
}
// Check that sub-messages are initialized.
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
reflection->ListFields(message, &fields);
for (int i = 0; i < fields.size(); i++) {
const FieldDescriptor* field = fields[i];
@@ -183,7 +183,7 @@ void ReflectionOps::DiscardUnknownFields(Message* message) {
reflection->MutableUnknownFields(message)->Clear();
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
reflection->ListFields(*message, &fields);
for (int i = 0; i < fields.size(); i++) {
const FieldDescriptor* field = fields[i];
@@ -224,7 +224,7 @@ static string SubMessagePrefix(const string& prefix,
void ReflectionOps::FindInitializationErrors(
const Message& message,
const string& prefix,
- vector<string>* errors) {
+ std::vector<string>* errors) {
const Descriptor* descriptor = message.GetDescriptor();
const Reflection* reflection = message.GetReflection();
@@ -238,7 +238,7 @@ void ReflectionOps::FindInitializationErrors(
}
// Check sub-messages.
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
reflection->ListFields(message, &fields);
for (int i = 0; i < fields.size(); i++) {
const FieldDescriptor* field = fields[i];
diff --git a/src/google/protobuf/reflection_ops_unittest.cc b/src/google/protobuf/reflection_ops_unittest.cc
index 88d6bfb6..86453170 100644
--- a/src/google/protobuf/reflection_ops_unittest.cc
+++ b/src/google/protobuf/reflection_ops_unittest.cc
@@ -419,7 +419,7 @@ TEST(ReflectionOpsTest, OneofIsInitialized) {
}
static string FindInitializationErrors(const Message& message) {
- vector<string> errors;
+ std::vector<string> errors;
ReflectionOps::FindInitializationErrors(message, "", &errors);
return Join(errors, ",");
}
diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h
index 0a41495f..4e5bcf51 100644
--- a/src/google/protobuf/repeated_field.h
+++ b/src/google/protobuf/repeated_field.h
@@ -61,8 +61,9 @@
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/message_lite.h>
-namespace google {
+// Forward-declare these so that we can make them friends.
+namespace google {
namespace upb {
namespace google_opensource {
class GMR_Handlers;
@@ -104,7 +105,7 @@ inline int CalculateReserve(Iter begin, Iter end) {
// not ever use a RepeatedField directly; they will use the get-by-index,
// set-by-index, and add accessors that are generated for all repeated fields.
template <typename Element>
-class RepeatedField {
+class RepeatedField PROTOBUF_FINAL {
public:
RepeatedField();
explicit RepeatedField(Arena* arena);
@@ -126,6 +127,8 @@ class RepeatedField {
void Set(int index, const Element& value);
void Add(const Element& value);
+ // Appends a new element and return a pointer to it.
+ // The new element is uninitialized if |Element| is a POD type.
Element* Add();
// Remove the last element in the array.
void RemoveLast();
@@ -138,7 +141,6 @@ class RepeatedField {
void Clear();
void MergeFrom(const RepeatedField& other);
- void UnsafeMergeFrom(const RepeatedField& other);
void CopyFrom(const RepeatedField& other);
// Reserve space to expand the field to at least the given size. If the
@@ -149,6 +151,9 @@ class RepeatedField {
void Truncate(int new_size);
void AddAlreadyReserved(const Element& value);
+ // Appends a new element and return a pointer to it.
+ // The new element is uninitialized if |Element| is a POD type.
+ // Should be called only if Capacity() > Size().
Element* AddAlreadyReserved();
int Capacity() const;
@@ -311,7 +316,7 @@ template <typename It, typename VoidPtr> class RepeatedPtrOverPtrsIterator;
namespace internal {
-// This is a helper template to copy an array of elements effeciently when they
+// This is a helper template to copy an array of elements efficiently when they
// have a trivial copy constructor, and correctly otherwise. This really
// shouldn't be necessary, but our compiler doesn't optimize std::copy very
// effectively.
@@ -418,6 +423,11 @@ class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase {
void Delete(int index);
template <typename TypeHandler>
typename TypeHandler::Type* Add(typename TypeHandler::Type* prototype = NULL);
+#if LANG_CXX11
+ template <typename TypeHandler>
+ void Add(typename TypeHandler::Type&& value,
+ std::enable_if<TypeHandler::Moveable>* dummy = NULL);
+#endif
template <typename TypeHandler>
void RemoveLast();
@@ -570,6 +580,9 @@ template <typename GenericType>
class GenericTypeHandler {
public:
typedef GenericType Type;
+#if LANG_CXX11
+ static const bool Moveable = false;
+#endif
static inline GenericType* New(Arena* arena) {
return ::google::protobuf::Arena::CreateMaybeMessage<Type>(
arena, static_cast<GenericType*>(0));
@@ -682,22 +695,23 @@ inline const Message& GenericTypeHandler<Message>::default_instance() {
}
-// HACK: If a class is declared as DLL-exported in MSVC, it insists on
-// generating copies of all its methods -- even inline ones -- to include
-// in the DLL. But SpaceUsed() calls StringSpaceUsedExcludingSelf() which
-// isn't in the lite library, therefore the lite library cannot link if
-// StringTypeHandler is exported. So, we factor out StringTypeHandlerBase,
-// export that, then make StringTypeHandler be a subclass which is NOT
-// exported.
-// TODO(kenton): Now that StringSpaceUsedExcludingSelf() is in the lite
-// library, this can be cleaned up.
-class LIBPROTOBUF_EXPORT StringTypeHandlerBase {
+class StringTypeHandler {
public:
typedef string Type;
+#if LANG_CXX11
+ static const bool Moveable =
+ std::is_move_constructible<Type>::value &&
+ std::is_move_assignable<Type>::value;
+#endif
static inline string* New(Arena* arena) {
return Arena::Create<string>(arena);
}
+#if LANG_CXX11
+ static inline string* New(Arena* arena, std::string&& value) {
+ return Arena::Create<string>(arena, std::move(value));
+ }
+#endif
static inline string* NewFromPrototype(const string*,
::google::protobuf::Arena* arena) {
return New(arena);
@@ -718,10 +732,6 @@ class LIBPROTOBUF_EXPORT StringTypeHandlerBase {
static inline const Type& default_instance() {
return ::google::protobuf::internal::GetEmptyString();
}
-};
-
-class StringTypeHandler : public StringTypeHandlerBase {
- public:
static int SpaceUsed(const string& value) {
return static_cast<int>(sizeof(value)) + StringSpaceUsedExcludingSelf(value);
}
@@ -733,7 +743,7 @@ class StringTypeHandler : public StringTypeHandlerBase {
// RepeatedPtrField is like RepeatedField, but used for repeated strings or
// Messages.
template <typename Element>
-class RepeatedPtrField : public internal::RepeatedPtrFieldBase {
+class RepeatedPtrField PROTOBUF_FINAL : public internal::RepeatedPtrFieldBase {
public:
RepeatedPtrField();
explicit RepeatedPtrField(::google::protobuf::Arena* arena);
@@ -751,6 +761,9 @@ class RepeatedPtrField : public internal::RepeatedPtrFieldBase {
const Element& Get(int index) const;
Element* Mutable(int index);
Element* Add();
+#if LANG_CXX11
+ void Add(Element&& value);
+#endif
const Element& operator[](int index) const { return Get(index); }
Element& operator[](int index) { return *Mutable(index); }
@@ -766,7 +779,6 @@ class RepeatedPtrField : public internal::RepeatedPtrFieldBase {
void Clear();
void MergeFrom(const RepeatedPtrField& other);
- void UnsafeMergeFrom(const RepeatedPtrField& other) { MergeFrom(other); }
void CopyFrom(const RepeatedPtrField& other);
// Reserve space to expand the field to at least the given size. This only
@@ -873,10 +885,10 @@ class RepeatedPtrField : public internal::RepeatedPtrFieldBase {
// RepeatedPtrField.
// It is also useful in legacy code that uses temporary ownership to avoid
// copies. Example:
- // RepeatedPtrField<T> temp_field;
- // temp_field.AddAllocated(new T);
- // ... // Do something with temp_field
- // temp_field.ExtractSubrange(0, temp_field.size(), NULL);
+ // RepeatedPtrField<T> temp_field;
+ // temp_field.AddAllocated(new T);
+ // ... // Do something with temp_field
+ // temp_field.ExtractSubrange(0, temp_field.size(), NULL);
// If you put temp_field on the arena this fails, because the ownership
// transfers to the arena at the "AddAllocated" call and is not released
// anymore causing a double delete. UnsafeArenaAddAllocated prevents this.
@@ -958,17 +970,13 @@ class RepeatedPtrField : public internal::RepeatedPtrFieldBase {
return GetArenaNoVirtual();
}
- protected:
- // Note: RepeatedPtrField SHOULD NOT be subclassed by users. We only
- // subclass it in one place as a hack for compatibility with proto1. The
- // subclass needs to know about TypeHandler in order to call protected
- // methods on RepeatedPtrFieldBase.
+ private:
+ // Note: RepeatedPtrField SHOULD NOT be subclassed by users.
class TypeHandler;
// Internal arena accessor expected by helpers in Arena.
inline Arena* GetArenaNoVirtual() const;
- private:
// Implementations for ExtractSubrange(). The copying behavior must be
// included only if the type supports the necessary operations (e.g.,
// MergeFrom()), so we must resolve this at compile time. ExtractSubrange()
@@ -997,13 +1005,13 @@ inline RepeatedField<Element>::RepeatedField(Arena* arena)
: current_size_(0),
total_size_(0),
rep_(NULL) {
- // In case arena is NULL, then we do not create rep_, as code has an invariant
- // `rep_ == NULL then arena == NULL`.
- if (arena != NULL) {
- rep_ = reinterpret_cast<Rep*>(
- ::google::protobuf::Arena::CreateArray<char>(arena, kRepHeaderSize));
- rep_->arena = arena;
- }
+ // In case arena is NULL, then we do not create rep_, as code has an invariant
+ // `rep_ == NULL then arena == NULL`.
+ if (arena != NULL) {
+ rep_ = reinterpret_cast<Rep*>(
+ ::google::protobuf::Arena::CreateArray<char>(arena, kRepHeaderSize));
+ rep_->arena = arena;
+ }
}
template <typename Element>
@@ -1011,7 +1019,12 @@ inline RepeatedField<Element>::RepeatedField(const RepeatedField& other)
: current_size_(0),
total_size_(0),
rep_(NULL) {
- CopyFrom(other);
+ if (other.current_size_ != 0) {
+ Reserve(other.current_size_);
+ CopyArray(rep_->elements,
+ other.rep_->elements, other.current_size_);
+ current_size_ = other.current_size_;
+ }
}
template <typename Element>
@@ -1152,7 +1165,8 @@ inline void RepeatedField<Element>::Clear() {
}
template <typename Element>
-inline void RepeatedField<Element>::UnsafeMergeFrom(const RepeatedField& other) {
+inline void RepeatedField<Element>::MergeFrom(const RepeatedField& other) {
+ GOOGLE_DCHECK_NE(&other, this);
if (other.current_size_ != 0) {
Reserve(current_size_ + other.current_size_);
CopyArray(rep_->elements + current_size_,
@@ -1162,12 +1176,6 @@ inline void RepeatedField<Element>::UnsafeMergeFrom(const RepeatedField& other)
}
template <typename Element>
-inline void RepeatedField<Element>::MergeFrom(const RepeatedField& other) {
- GOOGLE_CHECK_NE(&other, this);
- UnsafeMergeFrom(other);
-}
-
-template <typename Element>
inline void RepeatedField<Element>::CopyFrom(const RepeatedField& other) {
if (&other == this) return;
Clear();
@@ -1306,7 +1314,7 @@ void RepeatedField<Element>::Reserve(int new_size) {
Element* e = &rep_->elements[0];
Element* limit = &rep_->elements[total_size_];
for (; e < limit; e++) {
- new (e) Element();
+ new (e) Element;
}
if (current_size_ > 0) {
MoveArray(rep_->elements, old_rep->elements, current_size_);
@@ -1464,6 +1472,25 @@ inline typename TypeHandler::Type* RepeatedPtrFieldBase::Add(
return result;
}
+#if LANG_CXX11
+template <typename TypeHandler>
+inline void RepeatedPtrFieldBase::Add(
+ typename TypeHandler::Type&& value,
+ std::enable_if<TypeHandler::Moveable>*) {
+ if (rep_ != NULL && current_size_ < rep_->allocated_size) {
+ cast<TypeHandler>(rep_->elements[current_size_++]) = std::move(value);
+ }
+ if (!rep_ || rep_->allocated_size == total_size_) {
+ Reserve(total_size_ + 1);
+ }
+ ++rep_->allocated_size;
+ typename TypeHandler::Type* result =
+ TypeHandler::New(arena_, std::move(value));
+ rep_->elements[current_size_++] = result;
+ return result;
+}
+#endif
+
template <typename TypeHandler>
inline void RepeatedPtrFieldBase::RemoveLast() {
GOOGLE_DCHECK_GT(current_size_, 0);
@@ -1806,7 +1833,7 @@ template <typename Element>
inline RepeatedPtrField<Element>::RepeatedPtrField(
const RepeatedPtrField& other)
: RepeatedPtrFieldBase() {
- CopyFrom(other);
+ MergeFrom(other);
}
template <typename Element>
@@ -1861,6 +1888,13 @@ inline Element* RepeatedPtrField<Element>::Add() {
return RepeatedPtrFieldBase::Add<TypeHandler>();
}
+#if LANG_CXX11
+template <typename Element>
+inline void RepeatedPtrField<Element>::Add(Element&& value) {
+ RepeatedPtrFieldBase::Add<TypeHandler>(std::move(value));
+}
+#endif
+
template <typename Element>
inline void RepeatedPtrField<Element>::RemoveLast() {
RepeatedPtrFieldBase::RemoveLast<TypeHandler>();
@@ -2483,10 +2517,10 @@ AllocatedRepeatedPtrFieldBackInserter(
// UnsafeArenaAddAllocated instead of AddAllocated.
// This is slightly faster if that matters. It is also useful in legacy code
// that uses temporary ownership to avoid copies. Example:
-// RepeatedPtrField<T> temp_field;
-// temp_field.AddAllocated(new T);
-// ... // Do something with temp_field
-// temp_field.ExtractSubrange(0, temp_field.size(), NULL);
+// RepeatedPtrField<T> temp_field;
+// temp_field.AddAllocated(new T);
+// ... // Do something with temp_field
+// temp_field.ExtractSubrange(0, temp_field.size(), NULL);
// If you put temp_field on the arena this fails, because the ownership
// transfers to the arena at the "AddAllocated" call and is not released anymore
// causing a double delete. Using UnsafeArenaAddAllocated prevents this.
diff --git a/src/google/protobuf/repeated_field_unittest.cc b/src/google/protobuf/repeated_field_unittest.cc
index 33547146..ec1074c9 100644
--- a/src/google/protobuf/repeated_field_unittest.cc
+++ b/src/google/protobuf/repeated_field_unittest.cc
@@ -268,11 +268,13 @@ TEST(RepeatedField, MergeFrom) {
}
#ifdef PROTOBUF_HAS_DEATH_TEST
+#ifndef NDEBUG
TEST(RepeatedField, MergeFromSelf) {
RepeatedField<int> me;
me.Add(3);
EXPECT_DEATH(me.MergeFrom(me), "");
}
+#endif // NDEBUG
#endif // PROTOBUF_HAS_DEATH_TEST
TEST(RepeatedField, CopyFrom) {
@@ -344,7 +346,7 @@ TEST(RepeatedField, CopyConstruct) {
}
TEST(RepeatedField, IteratorConstruct) {
- vector<int> values;
+ std::vector<int> values;
values.push_back(1);
values.push_back(2);
@@ -858,7 +860,7 @@ TEST(RepeatedPtrField, CopyConstruct) {
}
TEST(RepeatedPtrField, IteratorConstruct_String) {
- vector<string> values;
+ std::vector<string> values;
values.push_back("1");
values.push_back("2");
@@ -875,7 +877,7 @@ TEST(RepeatedPtrField, IteratorConstruct_String) {
TEST(RepeatedPtrField, IteratorConstruct_Proto) {
typedef TestAllTypes::NestedMessage Nested;
- vector<Nested> values;
+ std::vector<Nested> values;
values.push_back(Nested());
values.back().set_bb(1);
values.push_back(Nested());
@@ -949,7 +951,7 @@ TEST(RepeatedPtrField, ExtractSubrange) {
for (int num = 0; num <= sz; ++num) {
for (int start = 0; start < sz - num; ++start) {
for (int extra = 0; extra < 4; ++extra) {
- vector<string*> subject;
+ std::vector<string*> subject;
// Create an array with "sz" elements and "extra" cleared elements.
RepeatedPtrField<string> field;
@@ -1511,7 +1513,7 @@ TEST_F(RepeatedFieldInsertionIteratorsTest, Nesteds) {
TEST_F(RepeatedFieldInsertionIteratorsTest,
AllocatedRepeatedPtrFieldWithStringIntData) {
- vector<Nested*> data;
+ std::vector<Nested*> data;
TestAllTypes goldenproto;
for (int i = 0; i < 10; ++i) {
Nested* new_data = new Nested;
@@ -1530,7 +1532,7 @@ TEST_F(RepeatedFieldInsertionIteratorsTest,
TEST_F(RepeatedFieldInsertionIteratorsTest,
AllocatedRepeatedPtrFieldWithString) {
- vector<string*> data;
+ std::vector<string*> data;
TestAllTypes goldenproto;
for (int i = 0; i < 10; ++i) {
string* new_data = new string;
@@ -1548,7 +1550,7 @@ TEST_F(RepeatedFieldInsertionIteratorsTest,
TEST_F(RepeatedFieldInsertionIteratorsTest,
UnsafeArenaAllocatedRepeatedPtrFieldWithStringIntData) {
- vector<Nested*> data;
+ std::vector<Nested*> data;
TestAllTypes goldenproto;
for (int i = 0; i < 10; ++i) {
Nested* new_data = new Nested;
@@ -1567,7 +1569,7 @@ TEST_F(RepeatedFieldInsertionIteratorsTest,
TEST_F(RepeatedFieldInsertionIteratorsTest,
UnsafeArenaAllocatedRepeatedPtrFieldWithString) {
- vector<string*> data;
+ std::vector<string*> data;
TestAllTypes goldenproto;
for (int i = 0; i < 10; ++i) {
string* new_data = new string;
diff --git a/src/google/protobuf/source_context.pb.cc b/src/google/protobuf/source_context.pb.cc
index 951a0bcc..b6f5cfce 100644
--- a/src/google/protobuf/source_context.pb.cc
+++ b/src/google/protobuf/source_context.pb.cc
@@ -19,109 +19,103 @@
namespace google {
namespace protobuf {
+class SourceContextDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<SourceContext> {
+} _SourceContext_default_instance_;
+
+namespace protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto {
+
namespace {
-const ::google::protobuf::Descriptor* SourceContext_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- SourceContext_reflection_ = NULL;
+::google::protobuf::Metadata file_level_metadata[1];
} // namespace
+const ::google::protobuf::uint32 TableStruct::offsets[] = {
+ ~0u, // no _has_bits_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceContext, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceContext, file_name_),
+};
-void protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto() GOOGLE_ATTRIBUTE_COLD;
-void protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto() {
- protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto();
- const ::google::protobuf::FileDescriptor* file =
- ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
- "google/protobuf/source_context.proto");
- GOOGLE_CHECK(file != NULL);
- SourceContext_descriptor_ = file->message_type(0);
- static const int SourceContext_offsets_[1] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceContext, file_name_),
- };
- SourceContext_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- SourceContext_descriptor_,
- SourceContext::internal_default_instance(),
- SourceContext_offsets_,
- -1,
- -1,
- -1,
- sizeof(SourceContext),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceContext, _internal_metadata_));
-}
+static const ::google::protobuf::internal::MigrationSchema schemas[] = {
+ { 0, -1, sizeof(SourceContext)},
+};
+
+static ::google::protobuf::Message const * const file_default_instances[] = {
+ reinterpret_cast<const ::google::protobuf::Message*>(&_SourceContext_default_instance_),
+};
namespace {
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
+void protobuf_AssignDescriptors() {
+ AddDescriptors();
+ ::google::protobuf::MessageFactory* factory = NULL;
+ AssignDescriptors(
+ "google/protobuf/source_context.proto", schemas, file_default_instances, TableStruct::offsets, factory,
+ file_level_metadata, NULL, NULL);
+}
+
void protobuf_AssignDescriptorsOnce() {
- ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
- &protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto);
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);
}
void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;
void protobuf_RegisterTypes(const ::std::string&) {
protobuf_AssignDescriptorsOnce();
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- SourceContext_descriptor_, SourceContext::internal_default_instance());
+ ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1);
}
} // namespace
-void protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto() {
- SourceContext_default_instance_.Shutdown();
- delete SourceContext_reflection_;
+void TableStruct::Shutdown() {
+ _SourceContext_default_instance_.Shutdown();
+ delete file_level_metadata[0].reflection;
}
-void protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_impl() {
+void TableStruct::InitDefaultsImpl() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
- ::google::protobuf::internal::GetEmptyString();
- SourceContext_default_instance_.DefaultConstruct();
- SourceContext_default_instance_.get_mutable()->InitAsDefaultInstance();
+ ::google::protobuf::internal::InitProtobufDefaults();
+ _SourceContext_default_instance_.DefaultConstruct();
}
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_once_);
-void protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto() {
- ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_once_,
- &protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_impl);
+void InitDefaults() {
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);
}
-void protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_impl() {
- GOOGLE_PROTOBUF_VERIFY_VERSION;
-
- protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto();
+void AddDescriptorsImpl() {
+ InitDefaults();
+ static const char descriptor[] = {
+ "\n$google/protobuf/source_context.proto\022\017"
+ "google.protobuf\"\"\n\rSourceContext\022\021\n\tfile"
+ "_name\030\001 \001(\tB\225\001\n\023com.google.protobufB\022Sou"
+ "rceContextProtoP\001ZAgoogle.golang.org/gen"
+ "proto/protobuf/source_context;source_con"
+ "text\242\002\003GPB\252\002\036Google.Protobuf.WellKnownTy"
+ "pesb\006proto3"
+ };
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
- "\n$google/protobuf/source_context.proto\022\017"
- "google.protobuf\"\"\n\rSourceContext\022\021\n\tfile"
- "_name\030\001 \001(\tBR\n\023com.google.protobufB\022Sour"
- "ceContextProtoP\001\242\002\003GPB\252\002\036Google.Protobuf"
- ".WellKnownTypesb\006proto3", 183);
+ descriptor, 251);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"google/protobuf/source_context.proto", &protobuf_RegisterTypes);
- ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto);
+ ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);
}
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_once_);
-void protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto() {
- ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_once_,
- &protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_impl);
+void AddDescriptors() {
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
}
// Force AddDescriptors() to be called at static initialization time.
-struct StaticDescriptorInitializer_google_2fprotobuf_2fsource_5fcontext_2eproto {
- StaticDescriptorInitializer_google_2fprotobuf_2fsource_5fcontext_2eproto() {
- protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto();
+struct StaticDescriptorInitializer {
+ StaticDescriptorInitializer() {
+ AddDescriptors();
}
-} static_descriptor_initializer_google_2fprotobuf_2fsource_5fcontext_2eproto_;
+} static_descriptor_initializer;
-namespace {
-
-static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN;
-static void MergeFromFail(int line) {
- ::google::protobuf::internal::MergeFromFail(__FILE__, line);
-}
-
-} // namespace
+} // namespace protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto
// ===================================================================
@@ -132,19 +126,21 @@ const int SourceContext::kFileNameFieldNumber;
SourceContext::SourceContext()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.SourceContext)
}
-
-void SourceContext::InitAsDefaultInstance() {
-}
-
SourceContext::SourceContext(const SourceContext& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ file_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.file_name().size() > 0) {
+ file_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.file_name_);
+ }
// @@protoc_insertion_point(copy_constructor:google.protobuf.SourceContext)
}
@@ -168,17 +164,15 @@ void SourceContext::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* SourceContext::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return SourceContext_descriptor_;
+ protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::file_level_metadata[0].descriptor;
}
const SourceContext& SourceContext::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto();
+ protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<SourceContext> SourceContext_default_instance_;
-
SourceContext* SourceContext::New(::google::protobuf::Arena* arena) const {
SourceContext* n = new SourceContext;
if (arena != NULL) {
@@ -198,13 +192,14 @@ bool SourceContext::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.SourceContext)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional string file_name = 1;
+ // string file_name = 1;
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_file_name()));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
@@ -214,7 +209,6 @@ bool SourceContext::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -242,7 +236,7 @@ failure:
void SourceContext::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.SourceContext)
- // optional string file_name = 1;
+ // string file_name = 1;
if (this->file_name().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->file_name().data(), this->file_name().length(),
@@ -257,9 +251,9 @@ void SourceContext::SerializeWithCachedSizes(
::google::protobuf::uint8* SourceContext::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.SourceContext)
- // optional string file_name = 1;
+ // string file_name = 1;
if (this->file_name().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->file_name().data(), this->file_name().length(),
@@ -278,7 +272,7 @@ size_t SourceContext::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceContext)
size_t total_size = 0;
- // optional string file_name = 1;
+ // string file_name = 1;
if (this->file_name().size() > 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
@@ -294,7 +288,7 @@ size_t SourceContext::ByteSizeLong() const {
void SourceContext::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.SourceContext)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const SourceContext* source =
::google::protobuf::internal::DynamicCastToGenerated<const SourceContext>(
&from);
@@ -303,21 +297,14 @@ void SourceContext::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.SourceContext)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void SourceContext::MergeFrom(const SourceContext& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceContext)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void SourceContext::UnsafeMergeFrom(const SourceContext& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
if (from.file_name().size() > 0) {
file_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.file_name_);
@@ -335,11 +322,10 @@ void SourceContext::CopyFrom(const SourceContext& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.SourceContext)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool SourceContext::IsInitialized() const {
-
return true;
}
@@ -349,34 +335,38 @@ void SourceContext::Swap(SourceContext* other) {
}
void SourceContext::InternalSwap(SourceContext* other) {
file_name_.Swap(&other->file_name_);
- _internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata SourceContext::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = SourceContext_descriptor_;
- metadata.reflection = SourceContext_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::file_level_metadata[0];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// SourceContext
-// optional string file_name = 1;
+// string file_name = 1;
void SourceContext::clear_file_name() {
file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
const ::std::string& SourceContext::file_name() const {
// @@protoc_insertion_point(field_get:google.protobuf.SourceContext.file_name)
- return file_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return file_name_.GetNoArena();
}
void SourceContext::set_file_name(const ::std::string& value) {
file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.SourceContext.file_name)
}
+#if LANG_CXX11
+void SourceContext::set_file_name(::std::string&& value) {
+
+ file_name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceContext.file_name)
+}
+#endif
void SourceContext::set_file_name(const char* value) {
file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -408,9 +398,6 @@ void SourceContext::set_allocated_file_name(::std::string* file_name) {
// @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceContext.file_name)
}
-inline const SourceContext* SourceContext::internal_default_instance() {
- return &SourceContext_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// @@protoc_insertion_point(namespace_scope)
diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h
index 18a56941..10888385 100644
--- a/src/google/protobuf/source_context.pb.h
+++ b/src/google/protobuf/source_context.pb.h
@@ -8,37 +8,48 @@
#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3001000
+#if GOOGLE_PROTOBUF_VERSION < 3002000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
#endif
+#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata.h>
#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/extension_set.h>
+#include <google/protobuf/repeated_field.h> // IWYU pragma: export
+#include <google/protobuf/extension_set.h> // IWYU pragma: export
#include <google/protobuf/unknown_field_set.h>
// @@protoc_insertion_point(includes)
+namespace google {
+namespace protobuf {
+class SourceContext;
+class SourceContextDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern SourceContextDefaultTypeInternal _SourceContext_default_instance_;
+} // namespace protobuf
+} // namespace google
namespace google {
namespace protobuf {
+namespace protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto {
// Internal implementation detail -- do not call these.
-void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto();
-void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto();
-void protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto();
-void protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto();
-
-class SourceContext;
+struct LIBPROTOBUF_EXPORT TableStruct {
+ static const ::google::protobuf::uint32 offsets[];
+ static void InitDefaultsImpl();
+ static void Shutdown();
+};
+void LIBPROTOBUF_EXPORT AddDescriptors();
+void LIBPROTOBUF_EXPORT InitDefaults();
+} // namespace protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto
// ===================================================================
@@ -57,59 +68,66 @@ class LIBPROTOBUF_EXPORT SourceContext : public ::google::protobuf::Message /* @
static const ::google::protobuf::Descriptor* descriptor();
static const SourceContext& default_instance();
- static const SourceContext* internal_default_instance();
+ static inline const SourceContext* internal_default_instance() {
+ return reinterpret_cast<const SourceContext*>(
+ &_SourceContext_default_instance_);
+ }
void Swap(SourceContext* other);
// implements Message ----------------------------------------------
- inline SourceContext* New() const { return New(NULL); }
+ inline SourceContext* New() const PROTOBUF_FINAL { return New(NULL); }
- SourceContext* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ SourceContext* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const SourceContext& from);
void MergeFrom(const SourceContext& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(SourceContext* other);
- void UnsafeMergeFrom(const SourceContext& from);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
+ return NULL;
}
inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
+ return NULL;
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
- // optional string file_name = 1;
+ // string file_name = 1;
void clear_file_name();
static const int kFileNameFieldNumber = 1;
const ::std::string& file_name() const;
void set_file_name(const ::std::string& value);
+ #if LANG_CXX11
+ void set_file_name(::std::string&& value);
+ #endif
void set_file_name(const char* value);
void set_file_name(const char* value, size_t size);
::std::string* mutable_file_name();
@@ -122,15 +140,8 @@ class LIBPROTOBUF_EXPORT SourceContext : public ::google::protobuf::Message /* @
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::google::protobuf::internal::ArenaStringPtr file_name_;
mutable int _cached_size_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<SourceContext> SourceContext_default_instance_;
-
// ===================================================================
@@ -139,19 +150,27 @@ extern ::google::protobuf::internal::ExplicitlyConstructed<SourceContext> Source
#if !PROTOBUF_INLINE_NOT_IN_HEADERS
// SourceContext
-// optional string file_name = 1;
+// string file_name = 1;
inline void SourceContext::clear_file_name() {
file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline const ::std::string& SourceContext::file_name() const {
// @@protoc_insertion_point(field_get:google.protobuf.SourceContext.file_name)
- return file_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return file_name_.GetNoArena();
}
inline void SourceContext::set_file_name(const ::std::string& value) {
file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:google.protobuf.SourceContext.file_name)
}
+#if LANG_CXX11
+inline void SourceContext::set_file_name(::std::string&& value) {
+
+ file_name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.SourceContext.file_name)
+}
+#endif
inline void SourceContext::set_file_name(const char* value) {
file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
@@ -183,13 +202,11 @@ inline void SourceContext::set_allocated_file_name(::std::string* file_name) {
// @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceContext.file_name)
}
-inline const SourceContext* SourceContext::internal_default_instance() {
- return &SourceContext_default_instance_.get();
-}
#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS
// @@protoc_insertion_point(namespace_scope)
+
} // namespace protobuf
} // namespace google
diff --git a/src/google/protobuf/source_context.proto b/src/google/protobuf/source_context.proto
index 79137ce8..f3b2c966 100644
--- a/src/google/protobuf/source_context.proto
+++ b/src/google/protobuf/source_context.proto
@@ -37,6 +37,7 @@ option java_package = "com.google.protobuf";
option java_outer_classname = "SourceContextProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
+option go_package = "google.golang.org/genproto/protobuf/source_context;source_context";
// `SourceContext` represents information about the source of a
// protobuf element, like the file in which it is defined.
diff --git a/src/google/protobuf/struct.pb.cc b/src/google/protobuf/struct.pb.cc
index c8f5af90..1350085c 100644
--- a/src/google/protobuf/struct.pb.cc
+++ b/src/google/protobuf/struct.pb.cc
@@ -19,193 +19,174 @@
namespace google {
namespace protobuf {
-
-namespace {
-
-const ::google::protobuf::Descriptor* Struct_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- Struct_reflection_ = NULL;
-const ::google::protobuf::Descriptor* Struct_FieldsEntry_descriptor_ = NULL;
-const ::google::protobuf::Descriptor* Value_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- Value_reflection_ = NULL;
-struct ValueOneofInstance {
+class StructDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Struct> {
+} _Struct_default_instance_;
+class ValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Value> {
+ public:
int null_value_;
double number_value_;
::google::protobuf::internal::ArenaStringPtr string_value_;
bool bool_value_;
const ::google::protobuf::Struct* struct_value_;
const ::google::protobuf::ListValue* list_value_;
-}* Value_default_oneof_instance_ = NULL;
-const ::google::protobuf::Descriptor* ListValue_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- ListValue_reflection_ = NULL;
-const ::google::protobuf::EnumDescriptor* NullValue_descriptor_ = NULL;
+} _Value_default_instance_;
+class ListValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<ListValue> {
+} _ListValue_default_instance_;
-} // namespace
+namespace protobuf_google_2fprotobuf_2fstruct_2eproto {
-void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto() GOOGLE_ATTRIBUTE_COLD;
-void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto() {
- protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto();
- const ::google::protobuf::FileDescriptor* file =
- ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
- "google/protobuf/struct.proto");
- GOOGLE_CHECK(file != NULL);
- Struct_descriptor_ = file->message_type(0);
- static const int Struct_offsets_[1] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Struct, fields_),
- };
- Struct_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- Struct_descriptor_,
- Struct::internal_default_instance(),
- Struct_offsets_,
- -1,
- -1,
- -1,
- sizeof(Struct),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Struct, _internal_metadata_));
- Struct_FieldsEntry_descriptor_ = Struct_descriptor_->nested_type(0);
- Value_descriptor_ = file->message_type(1);
- static const int Value_offsets_[7] = {
- PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(Value_default_oneof_instance_, null_value_),
- PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(Value_default_oneof_instance_, number_value_),
- PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(Value_default_oneof_instance_, string_value_),
- PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(Value_default_oneof_instance_, bool_value_),
- PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(Value_default_oneof_instance_, struct_value_),
- PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(Value_default_oneof_instance_, list_value_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, kind_),
- };
- Value_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- Value_descriptor_,
- Value::internal_default_instance(),
- Value_offsets_,
- -1,
- -1,
- -1,
- Value_default_oneof_instance_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, _oneof_case_[0]),
- sizeof(Value),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, _internal_metadata_));
- ListValue_descriptor_ = file->message_type(2);
- static const int ListValue_offsets_[1] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListValue, values_),
- };
- ListValue_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- ListValue_descriptor_,
- ListValue::internal_default_instance(),
- ListValue_offsets_,
- -1,
- -1,
- -1,
- sizeof(ListValue),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListValue, _internal_metadata_));
- NullValue_descriptor_ = file->enum_type(0);
-}
+namespace {
+
+::google::protobuf::Metadata file_level_metadata[4];
+const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors[1];
+
+} // namespace
+
+const ::google::protobuf::uint32 TableStruct::offsets[] = {
+ ~0u, // no _has_bits_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Struct, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Struct, fields_),
+ ~0u, // no _has_bits_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, _internal_metadata_),
+ ~0u, // no _extensions_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, _oneof_case_[0]),
+ PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&_Value_default_instance_), null_value_),
+ PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&_Value_default_instance_), number_value_),
+ PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&_Value_default_instance_), string_value_),
+ PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&_Value_default_instance_), bool_value_),
+ PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&_Value_default_instance_), struct_value_),
+ PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&_Value_default_instance_), list_value_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, kind_),
+ ~0u, // no _has_bits_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListValue, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListValue, values_),
+};
+
+static const ::google::protobuf::internal::MigrationSchema schemas[] = {
+ { 0, -1, sizeof(Struct)},
+ { 5, -1, sizeof(Value)},
+ { 16, -1, sizeof(ListValue)},
+};
+
+static ::google::protobuf::Message const * const file_default_instances[] = {
+ reinterpret_cast<const ::google::protobuf::Message*>(&_Struct_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_Value_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_ListValue_default_instance_),
+};
namespace {
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
+void protobuf_AssignDescriptors() {
+ AddDescriptors();
+ ::google::protobuf::MessageFactory* factory = NULL;
+ AssignDescriptors(
+ "google/protobuf/struct.proto", schemas, file_default_instances, TableStruct::offsets, factory,
+ file_level_metadata, file_level_enum_descriptors, NULL);
+}
+
void protobuf_AssignDescriptorsOnce() {
- ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
- &protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto);
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);
}
void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;
void protobuf_RegisterTypes(const ::std::string&) {
protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 4);
+ const ::google::protobuf::Descriptor* Struct_FieldsEntry_descriptor = protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[0].descriptor;
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- Struct_descriptor_, Struct::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- Struct_FieldsEntry_descriptor_,
+ Struct_FieldsEntry_descriptor,
::google::protobuf::internal::MapEntry<
::std::string,
::google::protobuf::Value,
::google::protobuf::internal::WireFormatLite::TYPE_STRING,
::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE,
0>::CreateDefaultInstance(
- Struct_FieldsEntry_descriptor_));
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- Value_descriptor_, Value::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- ListValue_descriptor_, ListValue::internal_default_instance());
+ Struct_FieldsEntry_descriptor));
}
} // namespace
-void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto() {
- Struct_default_instance_.Shutdown();
- delete Struct_reflection_;
- Value_default_instance_.Shutdown();
- delete Value_default_oneof_instance_;
- delete Value_reflection_;
- ListValue_default_instance_.Shutdown();
- delete ListValue_reflection_;
+void TableStruct::Shutdown() {
+ _Struct_default_instance_.Shutdown();
+ delete file_level_metadata[1].reflection;
+ _Value_default_instance_.Shutdown();
+ delete file_level_metadata[2].reflection;
+ _ListValue_default_instance_.Shutdown();
+ delete file_level_metadata[3].reflection;
}
-void protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl() {
+void TableStruct::InitDefaultsImpl() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
- ::google::protobuf::internal::GetEmptyString();
- Struct_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- Value_default_instance_.DefaultConstruct();
- Value_default_oneof_instance_ = new ValueOneofInstance();
- ListValue_default_instance_.DefaultConstruct();
- Struct_default_instance_.get_mutable()->InitAsDefaultInstance();
- Value_default_instance_.get_mutable()->InitAsDefaultInstance();
- ListValue_default_instance_.get_mutable()->InitAsDefaultInstance();
-}
-
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_once_);
-void protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto() {
- ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_once_,
- &protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl);
+ ::google::protobuf::internal::InitProtobufDefaults();
+ _Struct_default_instance_.DefaultConstruct();
+ _Value_default_instance_.DefaultConstruct();
+ _ListValue_default_instance_.DefaultConstruct();
+ _Value_default_instance_.null_value_ = 0;
+ _Value_default_instance_.number_value_ = 0;
+ _Value_default_instance_.string_value_.UnsafeSetDefault(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ _Value_default_instance_.bool_value_ = false;
+ _Value_default_instance_.struct_value_ = const_cast< ::google::protobuf::Struct*>(
+ ::google::protobuf::Struct::internal_default_instance());
+ _Value_default_instance_.list_value_ = const_cast< ::google::protobuf::ListValue*>(
+ ::google::protobuf::ListValue::internal_default_instance());
}
-void protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl() {
- GOOGLE_PROTOBUF_VERIFY_VERSION;
- protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto();
+void InitDefaults() {
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);
+}
+void AddDescriptorsImpl() {
+ InitDefaults();
+ static const char descriptor[] = {
+ "\n\034google/protobuf/struct.proto\022\017google.p"
+ "rotobuf\"\204\001\n\006Struct\0223\n\006fields\030\001 \003(\0132#.goo"
+ "gle.protobuf.Struct.FieldsEntry\032E\n\013Field"
+ "sEntry\022\013\n\003key\030\001 \001(\t\022%\n\005value\030\002 \001(\0132\026.goo"
+ "gle.protobuf.Value:\0028\001\"\352\001\n\005Value\0220\n\nnull"
+ "_value\030\001 \001(\0162\032.google.protobuf.NullValue"
+ "H\000\022\026\n\014number_value\030\002 \001(\001H\000\022\026\n\014string_val"
+ "ue\030\003 \001(\tH\000\022\024\n\nbool_value\030\004 \001(\010H\000\022/\n\014stru"
+ "ct_value\030\005 \001(\0132\027.google.protobuf.StructH"
+ "\000\0220\n\nlist_value\030\006 \001(\0132\032.google.protobuf."
+ "ListValueH\000B\006\n\004kind\"3\n\tListValue\022&\n\006valu"
+ "es\030\001 \003(\0132\026.google.protobuf.Value*\033\n\tNull"
+ "Value\022\016\n\nNULL_VALUE\020\000B\201\001\n\023com.google.pro"
+ "tobufB\013StructProtoP\001Z1github.com/golang/"
+ "protobuf/ptypes/struct;structpb\370\001\001\242\002\003GPB"
+ "\252\002\036Google.Protobuf.WellKnownTypesb\006proto"
+ "3"
+ };
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
- "\n\034google/protobuf/struct.proto\022\017google.p"
- "rotobuf\"\204\001\n\006Struct\0223\n\006fields\030\001 \003(\0132#.goo"
- "gle.protobuf.Struct.FieldsEntry\032E\n\013Field"
- "sEntry\022\013\n\003key\030\001 \001(\t\022%\n\005value\030\002 \001(\0132\026.goo"
- "gle.protobuf.Value:\0028\001\"\352\001\n\005Value\0220\n\nnull"
- "_value\030\001 \001(\0162\032.google.protobuf.NullValue"
- "H\000\022\026\n\014number_value\030\002 \001(\001H\000\022\026\n\014string_val"
- "ue\030\003 \001(\tH\000\022\024\n\nbool_value\030\004 \001(\010H\000\022/\n\014stru"
- "ct_value\030\005 \001(\0132\027.google.protobuf.StructH"
- "\000\0220\n\nlist_value\030\006 \001(\0132\032.google.protobuf."
- "ListValueH\000B\006\n\004kind\"3\n\tListValue\022&\n\006valu"
- "es\030\001 \003(\0132\026.google.protobuf.Value*\033\n\tNull"
- "Value\022\016\n\nNULL_VALUE\020\000B\201\001\n\023com.google.pro"
- "tobufB\013StructProtoP\001Z1github.com/golang/"
- "protobuf/ptypes/struct;structpb\370\001\001\242\002\003GPB"
- "\252\002\036Google.Protobuf.WellKnownTypesb\006proto"
- "3", 641);
+ descriptor, 641);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"google/protobuf/struct.proto", &protobuf_RegisterTypes);
- ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto);
+ ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);
}
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_once_);
-void protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto() {
- ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_once_,
- &protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl);
+void AddDescriptors() {
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
}
// Force AddDescriptors() to be called at static initialization time.
-struct StaticDescriptorInitializer_google_2fprotobuf_2fstruct_2eproto {
- StaticDescriptorInitializer_google_2fprotobuf_2fstruct_2eproto() {
- protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto();
+struct StaticDescriptorInitializer {
+ StaticDescriptorInitializer() {
+ AddDescriptors();
}
-} static_descriptor_initializer_google_2fprotobuf_2fstruct_2eproto_;
+} static_descriptor_initializer;
+
+} // namespace protobuf_google_2fprotobuf_2fstruct_2eproto
+
const ::google::protobuf::EnumDescriptor* NullValue_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return NullValue_descriptor_;
+ protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_enum_descriptors[0];
}
bool NullValue_IsValid(int value) {
switch (value) {
@@ -217,15 +198,10 @@ bool NullValue_IsValid(int value) {
}
-namespace {
-
-static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN;
-static void MergeFromFail(int line) {
- ::google::protobuf::internal::MergeFromFail(__FILE__, line);
-}
-
-} // namespace
+// ===================================================================
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -235,7 +211,9 @@ const int Struct::kFieldsFieldNumber;
Struct::Struct()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.Struct)
}
@@ -244,29 +222,32 @@ Struct::Struct(::google::protobuf::Arena* arena)
_internal_metadata_(arena),
fields_(arena) {
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto();
+ protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults();
#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Struct)
}
-
-void Struct::InitAsDefaultInstance() {
-}
-
Struct::Struct(const Struct& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ const ::google::protobuf::Descriptor*& Struct_FieldsEntry_descriptor = protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[0].descriptor;
+ fields_.SetAssignDescriptorCallback(
+ protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce);
+ fields_.SetEntryDescriptor(
+ &Struct_FieldsEntry_descriptor);
+ fields_.MergeFrom(from.fields_);
// @@protoc_insertion_point(copy_constructor:google.protobuf.Struct)
}
void Struct::SharedCtor() {
+ const ::google::protobuf::Descriptor*& Struct_FieldsEntry_descriptor = protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[0].descriptor;
fields_.SetAssignDescriptorCallback(
- protobuf_AssignDescriptorsOnce);
+ protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce);
fields_.SetEntryDescriptor(
- &::google::protobuf::Struct_FieldsEntry_descriptor_);
+ &Struct_FieldsEntry_descriptor);
_cached_size_ = 0;
}
@@ -295,17 +276,15 @@ void Struct::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* Struct::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return Struct_descriptor_;
+ protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[1].descriptor;
}
const Struct& Struct::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto();
+ protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<Struct> Struct_default_instance_;
-
Struct* Struct::New(::google::protobuf::Arena* arena) const {
return ::google::protobuf::Arena::CreateMessage<Struct>(arena);
}
@@ -321,15 +300,15 @@ bool Struct::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Struct)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// map<string, .google.protobuf.Value> fields = 1;
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_fields:
Struct_FieldsEntry::Parser< ::google::protobuf::internal::MapField<
::std::string, ::google::protobuf::Value,
::google::protobuf::internal::WireFormatLite::TYPE_STRING,
@@ -345,9 +324,7 @@ bool Struct::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(10)) goto parse_loop_fields;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -390,7 +367,7 @@ void Struct::SerializeWithCachedSizes(
}
};
- if (output->IsSerializationDeterminstic() &&
+ if (output->IsSerializationDeterministic() &&
this->fields().size() > 1) {
::google::protobuf::scoped_array<SortItem> items(
new SortItem[this->fields().size()]);
@@ -435,7 +412,7 @@ void Struct::SerializeWithCachedSizes(
::google::protobuf::uint8* Struct::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Struct)
// map<string, .google.protobuf.Value> fields = 1;
if (!this->fields().empty()) {
@@ -533,7 +510,7 @@ size_t Struct::ByteSizeLong() const {
void Struct::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Struct)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const Struct* source =
::google::protobuf::internal::DynamicCastToGenerated<const Struct>(
&from);
@@ -542,21 +519,14 @@ void Struct::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Struct)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void Struct::MergeFrom(const Struct& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Struct)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void Struct::UnsafeMergeFrom(const Struct& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
fields_.MergeFrom(from.fields_);
}
@@ -571,11 +541,10 @@ void Struct::CopyFrom(const Struct& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Struct)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool Struct::IsInitialized() const {
-
return true;
}
@@ -584,10 +553,13 @@ void Struct::Swap(Struct* other) {
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
- Struct temp;
- temp.UnsafeMergeFrom(*this);
- CopyFrom(*other);
- other->CopyFrom(temp);
+ Struct* temp = New(GetArenaNoVirtual());
+ temp->MergeFrom(*other);
+ other->CopyFrom(*this);
+ InternalSwap(temp);
+ if (GetArenaNoVirtual() == NULL) {
+ delete temp;
+ }
}
}
void Struct::UnsafeArenaSwap(Struct* other) {
@@ -597,16 +569,12 @@ void Struct::UnsafeArenaSwap(Struct* other) {
}
void Struct::InternalSwap(Struct* other) {
fields_.Swap(&other->fields_);
- _internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata Struct::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = Struct_descriptor_;
- metadata.reflection = Struct_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[1];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -630,9 +598,6 @@ Struct::mutable_fields() {
return fields_.MutableMap();
}
-inline const Struct* Struct::internal_default_instance() {
- return &Struct_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -648,7 +613,9 @@ const int Value::kListValueFieldNumber;
Value::Value()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.Value)
}
@@ -656,29 +623,47 @@ Value::Value(::google::protobuf::Arena* arena)
: ::google::protobuf::Message(),
_internal_metadata_(arena) {
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto();
+ protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults();
#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Value)
}
-
-void Value::InitAsDefaultInstance() {
- Value_default_oneof_instance_->null_value_ = 0;
- Value_default_oneof_instance_->number_value_ = 0;
- Value_default_oneof_instance_->string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- Value_default_oneof_instance_->bool_value_ = false;
- Value_default_oneof_instance_->struct_value_ = const_cast< ::google::protobuf::Struct*>(
- ::google::protobuf::Struct::internal_default_instance());
- Value_default_oneof_instance_->list_value_ = const_cast< ::google::protobuf::ListValue*>(
- ::google::protobuf::ListValue::internal_default_instance());
-}
-
Value::Value(const Value& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ clear_has_kind();
+ switch (from.kind_case()) {
+ case kNullValue: {
+ set_null_value(from.null_value());
+ break;
+ }
+ case kNumberValue: {
+ set_number_value(from.number_value());
+ break;
+ }
+ case kStringValue: {
+ set_string_value(from.string_value());
+ break;
+ }
+ case kBoolValue: {
+ set_bool_value(from.bool_value());
+ break;
+ }
+ case kStructValue: {
+ mutable_struct_value()->::google::protobuf::Struct::MergeFrom(from.struct_value());
+ break;
+ }
+ case kListValue: {
+ mutable_list_value()->::google::protobuf::ListValue::MergeFrom(from.list_value());
+ break;
+ }
+ case KIND_NOT_SET: {
+ break;
+ }
+ }
// @@protoc_insertion_point(copy_constructor:google.protobuf.Value)
}
@@ -715,17 +700,15 @@ void Value::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* Value::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return Value_descriptor_;
+ protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[2].descriptor;
}
const Value& Value::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto();
+ protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<Value> Value_default_instance_;
-
Value* Value::New(::google::protobuf::Arena* arena) const {
return ::google::protobuf::Arena::CreateMessage<Value>(arena);
}
@@ -781,13 +764,14 @@ bool Value::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Value)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional .google.protobuf.NullValue null_value = 1;
+ // .google.protobuf.NullValue null_value = 1;
case 1: {
- if (tag == 8) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(8u)) {
int value;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
@@ -796,13 +780,13 @@ bool Value::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- goto after_list_value;
break;
}
- // optional double number_value = 2;
+ // double number_value = 2;
case 2: {
- if (tag == 17) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(17u)) {
clear_kind();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>(
@@ -811,13 +795,13 @@ bool Value::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- goto after_list_value;
break;
}
- // optional string string_value = 3;
+ // string string_value = 3;
case 3: {
- if (tag == 26) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(26u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_string_value()));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
@@ -827,13 +811,13 @@ bool Value::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- goto after_list_value;
break;
}
- // optional bool bool_value = 4;
+ // bool bool_value = 4;
case 4: {
- if (tag == 32) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(32u)) {
clear_kind();
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -842,33 +826,30 @@ bool Value::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- goto after_list_value;
break;
}
- // optional .google.protobuf.Struct struct_value = 5;
+ // .google.protobuf.Struct struct_value = 5;
case 5: {
- if (tag == 42) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(42u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_struct_value()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(50)) goto parse_list_value;
break;
}
- // optional .google.protobuf.ListValue list_value = 6;
+ // .google.protobuf.ListValue list_value = 6;
case 6: {
- if (tag == 50) {
- parse_list_value:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(50u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_list_value()));
} else {
goto handle_unusual;
}
- after_list_value:
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -896,18 +877,18 @@ failure:
void Value::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.Value)
- // optional .google.protobuf.NullValue null_value = 1;
+ // .google.protobuf.NullValue null_value = 1;
if (has_null_value()) {
::google::protobuf::internal::WireFormatLite::WriteEnum(
1, this->null_value(), output);
}
- // optional double number_value = 2;
+ // double number_value = 2;
if (has_number_value()) {
::google::protobuf::internal::WireFormatLite::WriteDouble(2, this->number_value(), output);
}
- // optional string string_value = 3;
+ // string string_value = 3;
if (has_string_value()) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->string_value().data(), this->string_value().length(),
@@ -917,18 +898,18 @@ void Value::SerializeWithCachedSizes(
3, this->string_value(), output);
}
- // optional bool bool_value = 4;
+ // bool bool_value = 4;
if (has_bool_value()) {
::google::protobuf::internal::WireFormatLite::WriteBool(4, this->bool_value(), output);
}
- // optional .google.protobuf.Struct struct_value = 5;
+ // .google.protobuf.Struct struct_value = 5;
if (has_struct_value()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
5, *kind_.struct_value_, output);
}
- // optional .google.protobuf.ListValue list_value = 6;
+ // .google.protobuf.ListValue list_value = 6;
if (has_list_value()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
6, *kind_.list_value_, output);
@@ -939,20 +920,20 @@ void Value::SerializeWithCachedSizes(
::google::protobuf::uint8* Value::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Value)
- // optional .google.protobuf.NullValue null_value = 1;
+ // .google.protobuf.NullValue null_value = 1;
if (has_null_value()) {
target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
1, this->null_value(), target);
}
- // optional double number_value = 2;
+ // double number_value = 2;
if (has_number_value()) {
target = ::google::protobuf::internal::WireFormatLite::WriteDoubleToArray(2, this->number_value(), target);
}
- // optional string string_value = 3;
+ // string string_value = 3;
if (has_string_value()) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->string_value().data(), this->string_value().length(),
@@ -963,19 +944,19 @@ void Value::SerializeWithCachedSizes(
3, this->string_value(), target);
}
- // optional bool bool_value = 4;
+ // bool bool_value = 4;
if (has_bool_value()) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(4, this->bool_value(), target);
}
- // optional .google.protobuf.Struct struct_value = 5;
+ // .google.protobuf.Struct struct_value = 5;
if (has_struct_value()) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
5, *kind_.struct_value_, false, target);
}
- // optional .google.protobuf.ListValue list_value = 6;
+ // .google.protobuf.ListValue list_value = 6;
if (has_list_value()) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
@@ -991,37 +972,37 @@ size_t Value::ByteSizeLong() const {
size_t total_size = 0;
switch (kind_case()) {
- // optional .google.protobuf.NullValue null_value = 1;
+ // .google.protobuf.NullValue null_value = 1;
case kNullValue: {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::EnumSize(this->null_value());
break;
}
- // optional double number_value = 2;
+ // double number_value = 2;
case kNumberValue: {
total_size += 1 + 8;
break;
}
- // optional string string_value = 3;
+ // string string_value = 3;
case kStringValue: {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->string_value());
break;
}
- // optional bool bool_value = 4;
+ // bool bool_value = 4;
case kBoolValue: {
total_size += 1 + 1;
break;
}
- // optional .google.protobuf.Struct struct_value = 5;
+ // .google.protobuf.Struct struct_value = 5;
case kStructValue: {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
*kind_.struct_value_);
break;
}
- // optional .google.protobuf.ListValue list_value = 6;
+ // .google.protobuf.ListValue list_value = 6;
case kListValue: {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
@@ -1041,7 +1022,7 @@ size_t Value::ByteSizeLong() const {
void Value::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Value)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const Value* source =
::google::protobuf::internal::DynamicCastToGenerated<const Value>(
&from);
@@ -1050,21 +1031,14 @@ void Value::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Value)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void Value::MergeFrom(const Value& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Value)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void Value::UnsafeMergeFrom(const Value& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
switch (from.kind_case()) {
case kNullValue: {
set_null_value(from.null_value());
@@ -1107,11 +1081,10 @@ void Value::CopyFrom(const Value& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Value)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool Value::IsInitialized() const {
-
return true;
}
@@ -1120,10 +1093,13 @@ void Value::Swap(Value* other) {
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
- Value temp;
- temp.UnsafeMergeFrom(*this);
- CopyFrom(*other);
- other->CopyFrom(temp);
+ Value* temp = New(GetArenaNoVirtual());
+ temp->MergeFrom(*other);
+ other->CopyFrom(*this);
+ InternalSwap(temp);
+ if (GetArenaNoVirtual() == NULL) {
+ delete temp;
+ }
}
}
void Value::UnsafeArenaSwap(Value* other) {
@@ -1134,22 +1110,18 @@ void Value::UnsafeArenaSwap(Value* other) {
void Value::InternalSwap(Value* other) {
std::swap(kind_, other->kind_);
std::swap(_oneof_case_[0], other->_oneof_case_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata Value::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = Value_descriptor_;
- metadata.reflection = Value_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[2];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// Value
-// optional .google.protobuf.NullValue null_value = 1;
+// .google.protobuf.NullValue null_value = 1;
bool Value::has_null_value() const {
return kind_case() == kNullValue;
}
@@ -1178,7 +1150,7 @@ void Value::set_null_value(::google::protobuf::NullValue value) {
// @@protoc_insertion_point(field_set:google.protobuf.Value.null_value)
}
-// optional double number_value = 2;
+// double number_value = 2;
bool Value::has_number_value() const {
return kind_case() == kNumberValue;
}
@@ -1207,7 +1179,7 @@ void Value::set_number_value(double value) {
// @@protoc_insertion_point(field_set:google.protobuf.Value.number_value)
}
-// optional string string_value = 3;
+// string string_value = 3;
bool Value::has_string_value() const {
return kind_case() == kStringValue;
}
@@ -1224,7 +1196,7 @@ void Value::clear_string_value() {
const ::std::string& Value::string_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.Value.string_value)
if (has_string_value()) {
- return kind_.string_value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return kind_.string_value_.Get();
}
return *&::google::protobuf::internal::GetEmptyStringAlreadyInited();
}
@@ -1316,7 +1288,7 @@ void Value::unsafe_arena_set_allocated_string_value(::std::string* string_value)
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.string_value)
}
-// optional bool bool_value = 4;
+// bool bool_value = 4;
bool Value::has_bool_value() const {
return kind_case() == kBoolValue;
}
@@ -1345,7 +1317,7 @@ void Value::set_bool_value(bool value) {
// @@protoc_insertion_point(field_set:google.protobuf.Value.bool_value)
}
-// optional .google.protobuf.Struct struct_value = 5;
+// .google.protobuf.Struct struct_value = 5;
bool Value::has_struct_value() const {
return kind_case() == kStructValue;
}
@@ -1433,7 +1405,7 @@ void Value::set_allocated_struct_value(::google::protobuf::Struct* struct_value)
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.struct_value)
}
-// optional .google.protobuf.ListValue list_value = 6;
+// .google.protobuf.ListValue list_value = 6;
bool Value::has_list_value() const {
return kind_case() == kListValue;
}
@@ -1530,9 +1502,6 @@ void Value::clear_has_kind() {
Value::KindCase Value::kind_case() const {
return Value::KindCase(_oneof_case_[0]);
}
-inline const Value* Value::internal_default_instance() {
- return &Value_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -1543,7 +1512,9 @@ const int ListValue::kValuesFieldNumber;
ListValue::ListValue()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.ListValue)
}
@@ -1552,21 +1523,18 @@ ListValue::ListValue(::google::protobuf::Arena* arena)
_internal_metadata_(arena),
values_(arena) {
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto();
+ protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults();
#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.ListValue)
}
-
-void ListValue::InitAsDefaultInstance() {
-}
-
ListValue::ListValue(const ListValue& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ values_(from.values_),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:google.protobuf.ListValue)
}
@@ -1599,17 +1567,15 @@ void ListValue::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* ListValue::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return ListValue_descriptor_;
+ protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[3].descriptor;
}
const ListValue& ListValue::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto();
+ protobuf_google_2fprotobuf_2fstruct_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<ListValue> ListValue_default_instance_;
-
ListValue* ListValue::New(::google::protobuf::Arena* arena) const {
return ::google::protobuf::Arena::CreateMessage<ListValue>(arena);
}
@@ -1625,23 +1591,21 @@ bool ListValue::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.ListValue)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// repeated .google.protobuf.Value values = 1;
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_values:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_values()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(10)) goto parse_loop_values;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -1680,7 +1644,7 @@ void ListValue::SerializeWithCachedSizes(
::google::protobuf::uint8* ListValue::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.ListValue)
// repeated .google.protobuf.Value values = 1;
for (unsigned int i = 0, n = this->values_size(); i < n; i++) {
@@ -1717,7 +1681,7 @@ size_t ListValue::ByteSizeLong() const {
void ListValue::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.ListValue)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const ListValue* source =
::google::protobuf::internal::DynamicCastToGenerated<const ListValue>(
&from);
@@ -1726,21 +1690,14 @@ void ListValue::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.ListValue)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void ListValue::MergeFrom(const ListValue& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ListValue)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void ListValue::UnsafeMergeFrom(const ListValue& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
values_.MergeFrom(from.values_);
}
@@ -1755,11 +1712,10 @@ void ListValue::CopyFrom(const ListValue& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.ListValue)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool ListValue::IsInitialized() const {
-
return true;
}
@@ -1768,10 +1724,13 @@ void ListValue::Swap(ListValue* other) {
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
- ListValue temp;
- temp.UnsafeMergeFrom(*this);
- CopyFrom(*other);
- other->CopyFrom(temp);
+ ListValue* temp = New(GetArenaNoVirtual());
+ temp->MergeFrom(*other);
+ other->CopyFrom(*this);
+ InternalSwap(temp);
+ if (GetArenaNoVirtual() == NULL) {
+ delete temp;
+ }
}
}
void ListValue::UnsafeArenaSwap(ListValue* other) {
@@ -1781,16 +1740,12 @@ void ListValue::UnsafeArenaSwap(ListValue* other) {
}
void ListValue::InternalSwap(ListValue* other) {
values_.UnsafeArenaSwap(&other->values_);
- _internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata ListValue::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = ListValue_descriptor_;
- metadata.reflection = ListValue_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fstruct_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fstruct_2eproto::file_level_metadata[3];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -1826,9 +1781,6 @@ ListValue::values() const {
return values_;
}
-inline const ListValue* ListValue::internal_default_instance() {
- return &ListValue_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// @@protoc_insertion_point(namespace_scope)
diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h
index ff77bb45..043f0c32 100644
--- a/src/google/protobuf/struct.pb.h
+++ b/src/google/protobuf/struct.pb.h
@@ -8,42 +8,57 @@
#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3001000
+#if GOOGLE_PROTOBUF_VERSION < 3002000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
#endif
+#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata.h>
#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/extension_set.h>
+#include <google/protobuf/repeated_field.h> // IWYU pragma: export
+#include <google/protobuf/extension_set.h> // IWYU pragma: export
#include <google/protobuf/map.h>
#include <google/protobuf/map_field_inl.h>
#include <google/protobuf/generated_enum_reflection.h>
#include <google/protobuf/unknown_field_set.h>
// @@protoc_insertion_point(includes)
-
namespace google {
namespace protobuf {
-
-// Internal implementation detail -- do not call these.
-void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto();
-void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto();
-void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto();
-void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto();
-
class ListValue;
+class ListValueDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern ListValueDefaultTypeInternal _ListValue_default_instance_;
class Struct;
+class StructDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern StructDefaultTypeInternal _Struct_default_instance_;
class Value;
+class ValueDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern ValueDefaultTypeInternal _Value_default_instance_;
+} // namespace protobuf
+} // namespace google
+
+namespace google {
+namespace protobuf {
+
+namespace protobuf_google_2fprotobuf_2fstruct_2eproto {
+// Internal implementation detail -- do not call these.
+struct LIBPROTOBUF_EXPORT TableStruct {
+ static const ::google::protobuf::uint32 offsets[];
+ static void InitDefaultsImpl();
+ static void Shutdown();
+};
+void LIBPROTOBUF_EXPORT AddDescriptors();
+void LIBPROTOBUF_EXPORT InitDefaults();
+} // namespace protobuf_google_2fprotobuf_2fstruct_2eproto
enum NullValue {
NULL_VALUE = 0,
@@ -67,6 +82,9 @@ inline bool NullValue_Parse(
}
// ===================================================================
+
+// -------------------------------------------------------------------
+
class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Struct) */ {
public:
Struct();
@@ -79,47 +97,53 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc
return *this;
}
- inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }
- inline void* GetMaybeArenaPointer() const {
+ inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {
+ return GetArenaNoVirtual();
+ }
+ inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {
return MaybeArenaPtr();
}
static const ::google::protobuf::Descriptor* descriptor();
static const Struct& default_instance();
- static const Struct* internal_default_instance();
+ static inline const Struct* internal_default_instance() {
+ return reinterpret_cast<const Struct*>(
+ &_Struct_default_instance_);
+ }
void UnsafeArenaSwap(Struct* other);
void Swap(Struct* other);
// implements Message ----------------------------------------------
- inline Struct* New() const { return New(NULL); }
+ inline Struct* New() const PROTOBUF_FINAL { return New(NULL); }
- Struct* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ Struct* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Struct& from);
void MergeFrom(const Struct& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(Struct* other);
- void UnsafeMergeFrom(const Struct& from);
protected:
explicit Struct(::google::protobuf::Arena* arena);
private:
@@ -134,7 +158,7 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
@@ -169,15 +193,8 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc
::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE,
0 > fields_;
mutable int _cached_size_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fstruct_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<Struct> Struct_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Value) */ {
@@ -192,8 +209,10 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_
return *this;
}
- inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }
- inline void* GetMaybeArenaPointer() const {
+ inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {
+ return GetArenaNoVirtual();
+ }
+ inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {
return MaybeArenaPtr();
}
static const ::google::protobuf::Descriptor* descriptor();
@@ -209,40 +228,44 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_
KIND_NOT_SET = 0,
};
- static const Value* internal_default_instance();
+ static inline const Value* internal_default_instance() {
+ return reinterpret_cast<const Value*>(
+ &_Value_default_instance_);
+ }
void UnsafeArenaSwap(Value* other);
void Swap(Value* other);
// implements Message ----------------------------------------------
- inline Value* New() const { return New(NULL); }
+ inline Value* New() const PROTOBUF_FINAL { return New(NULL); }
- Value* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Value& from);
void MergeFrom(const Value& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(Value* other);
- void UnsafeMergeFrom(const Value& from);
protected:
explicit Value(::google::protobuf::Arena* arena);
private:
@@ -257,13 +280,13 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
- // optional .google.protobuf.NullValue null_value = 1;
+ // .google.protobuf.NullValue null_value = 1;
private:
bool has_null_value() const;
public:
@@ -272,7 +295,7 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_
::google::protobuf::NullValue null_value() const;
void set_null_value(::google::protobuf::NullValue value);
- // optional double number_value = 2;
+ // double number_value = 2;
private:
bool has_number_value() const;
public:
@@ -281,7 +304,7 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_
double number_value() const;
void set_number_value(double value);
- // optional string string_value = 3;
+ // string string_value = 3;
private:
bool has_string_value() const;
public:
@@ -298,7 +321,7 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_
void unsafe_arena_set_allocated_string_value(
::std::string* string_value);
- // optional bool bool_value = 4;
+ // bool bool_value = 4;
private:
bool has_bool_value() const;
public:
@@ -307,7 +330,7 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_
bool bool_value() const;
void set_bool_value(bool value);
- // optional .google.protobuf.Struct struct_value = 5;
+ // .google.protobuf.Struct struct_value = 5;
bool has_struct_value() const;
void clear_struct_value();
static const int kStructValueFieldNumber = 5;
@@ -325,7 +348,7 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_
void unsafe_arena_set_allocated_struct_value(
::google::protobuf::Struct* struct_value);
- // optional .google.protobuf.ListValue list_value = 6;
+ // .google.protobuf.ListValue list_value = 6;
bool has_list_value() const;
void clear_list_value();
static const int kListValueFieldNumber = 6;
@@ -346,12 +369,12 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_
KindCase kind_case() const;
// @@protoc_insertion_point(class_scope:google.protobuf.Value)
private:
- inline void set_has_null_value();
- inline void set_has_number_value();
- inline void set_has_string_value();
- inline void set_has_bool_value();
- inline void set_has_struct_value();
- inline void set_has_list_value();
+ void set_has_null_value();
+ void set_has_number_value();
+ void set_has_string_value();
+ void set_has_bool_value();
+ void set_has_struct_value();
+ void set_has_list_value();
inline bool has_kind() const;
void clear_kind();
@@ -373,15 +396,8 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_
mutable int _cached_size_;
::google::protobuf::uint32 _oneof_case_[1];
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fstruct_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<Value> Value_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ListValue) */ {
@@ -396,47 +412,53 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro
return *this;
}
- inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }
- inline void* GetMaybeArenaPointer() const {
+ inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {
+ return GetArenaNoVirtual();
+ }
+ inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {
return MaybeArenaPtr();
}
static const ::google::protobuf::Descriptor* descriptor();
static const ListValue& default_instance();
- static const ListValue* internal_default_instance();
+ static inline const ListValue* internal_default_instance() {
+ return reinterpret_cast<const ListValue*>(
+ &_ListValue_default_instance_);
+ }
void UnsafeArenaSwap(ListValue* other);
void Swap(ListValue* other);
// implements Message ----------------------------------------------
- inline ListValue* New() const { return New(NULL); }
+ inline ListValue* New() const PROTOBUF_FINAL { return New(NULL); }
- ListValue* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ ListValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const ListValue& from);
void MergeFrom(const ListValue& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(ListValue* other);
- void UnsafeMergeFrom(const ListValue& from);
protected:
explicit ListValue(::google::protobuf::Arena* arena);
private:
@@ -451,7 +473,7 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
@@ -478,21 +500,16 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro
typedef void DestructorSkippable_;
::google::protobuf::RepeatedPtrField< ::google::protobuf::Value > values_;
mutable int _cached_size_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fstruct_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<ListValue> ListValue_default_instance_;
-
// ===================================================================
// ===================================================================
#if !PROTOBUF_INLINE_NOT_IN_HEADERS
+// -------------------------------------------------------------------
+
// Struct
// map<string, .google.protobuf.Value> fields = 1;
@@ -513,14 +530,11 @@ Struct::mutable_fields() {
return fields_.MutableMap();
}
-inline const Struct* Struct::internal_default_instance() {
- return &Struct_default_instance_.get();
-}
// -------------------------------------------------------------------
// Value
-// optional .google.protobuf.NullValue null_value = 1;
+// .google.protobuf.NullValue null_value = 1;
inline bool Value::has_null_value() const {
return kind_case() == kNullValue;
}
@@ -549,7 +563,7 @@ inline void Value::set_null_value(::google::protobuf::NullValue value) {
// @@protoc_insertion_point(field_set:google.protobuf.Value.null_value)
}
-// optional double number_value = 2;
+// double number_value = 2;
inline bool Value::has_number_value() const {
return kind_case() == kNumberValue;
}
@@ -578,7 +592,7 @@ inline void Value::set_number_value(double value) {
// @@protoc_insertion_point(field_set:google.protobuf.Value.number_value)
}
-// optional string string_value = 3;
+// string string_value = 3;
inline bool Value::has_string_value() const {
return kind_case() == kStringValue;
}
@@ -595,7 +609,7 @@ inline void Value::clear_string_value() {
inline const ::std::string& Value::string_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.Value.string_value)
if (has_string_value()) {
- return kind_.string_value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return kind_.string_value_.Get();
}
return *&::google::protobuf::internal::GetEmptyStringAlreadyInited();
}
@@ -687,7 +701,7 @@ inline void Value::unsafe_arena_set_allocated_string_value(::std::string* string
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.string_value)
}
-// optional bool bool_value = 4;
+// bool bool_value = 4;
inline bool Value::has_bool_value() const {
return kind_case() == kBoolValue;
}
@@ -716,7 +730,7 @@ inline void Value::set_bool_value(bool value) {
// @@protoc_insertion_point(field_set:google.protobuf.Value.bool_value)
}
-// optional .google.protobuf.Struct struct_value = 5;
+// .google.protobuf.Struct struct_value = 5;
inline bool Value::has_struct_value() const {
return kind_case() == kStructValue;
}
@@ -804,7 +818,7 @@ inline void Value::unsafe_arena_set_allocated_struct_value(::google::protobuf::
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.struct_value)
}
-// optional .google.protobuf.ListValue list_value = 6;
+// .google.protobuf.ListValue list_value = 6;
inline bool Value::has_list_value() const {
return kind_case() == kListValue;
}
@@ -901,9 +915,6 @@ inline void Value::clear_has_kind() {
inline Value::KindCase Value::kind_case() const {
return Value::KindCase(_oneof_case_[0]);
}
-inline const Value* Value::internal_default_instance() {
- return &Value_default_instance_.get();
-}
// -------------------------------------------------------------------
// ListValue
@@ -938,17 +949,17 @@ ListValue::values() const {
return values_;
}
-inline const ListValue* ListValue::internal_default_instance() {
- return &ListValue_default_instance_.get();
-}
#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS
// -------------------------------------------------------------------
// -------------------------------------------------------------------
+// -------------------------------------------------------------------
+
// @@protoc_insertion_point(namespace_scope)
+
} // namespace protobuf
} // namespace google
diff --git a/src/google/protobuf/stubs/atomicops.h b/src/google/protobuf/stubs/atomicops.h
index 10a71ed4..75aee306 100644
--- a/src/google/protobuf/stubs/atomicops.h
+++ b/src/google/protobuf/stubs/atomicops.h
@@ -123,8 +123,8 @@ Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
// ensure that no later memory access can be reordered ahead of the operation.
// "Release" operations ensure that no previous memory access can be reordered
// after the operation. "Barrier" operations have both "Acquire" and "Release"
-// semantics. A MemoryBarrier() has "Barrier" semantics, but does no memory
-// access.
+// semantics. A MemoryBarrierInternal() has "Barrier" semantics, but does no
+// memory access.
Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
Atomic32 old_value,
Atomic32 new_value);
@@ -132,10 +132,10 @@ Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
Atomic32 old_value,
Atomic32 new_value);
-#if defined(__MINGW32__) && defined(MemoryBarrier)
-#undef MemoryBarrier
-#endif
-void MemoryBarrier();
+// This function was renamed from MemoryBarrier to MemoryBarrierInternal
+// because MemoryBarrier is a define in Windows ARM builds and we do not
+// undefine it because we call it from this function.
+void MemoryBarrierInternal();
void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value);
void Acquire_Store(volatile Atomic32* ptr, Atomic32 value);
void Release_Store(volatile Atomic32* ptr, Atomic32 value);
@@ -180,7 +180,7 @@ Atomic64 Release_Load(volatile const Atomic64* ptr);
#include <google/protobuf/stubs/atomicops_internals_tsan.h>
// MSVC.
#elif defined(_MSC_VER)
-#if defined(GOOGLE_PROTOBUF_ARCH_IA32) || defined(GOOGLE_PROTOBUF_ARCH_X64)
+#if defined(GOOGLE_PROTOBUF_ARCH_IA32) || defined(GOOGLE_PROTOBUF_ARCH_X64) || defined(GOOGLE_PROTOBUF_ARCH_ARM)
#include <google/protobuf/stubs/atomicops_internals_x86_msvc.h>
#else
#error GOOGLE_PROTOBUF_ATOMICOPS_ERROR
@@ -194,14 +194,6 @@ Atomic64 Release_Load(volatile const Atomic64* ptr);
#elif defined(GOOGLE_PROTOBUF_OS_AIX)
#include <google/protobuf/stubs/atomicops_internals_power.h>
-// Apple.
-#elif defined(GOOGLE_PROTOBUF_OS_APPLE)
-#if __has_feature(cxx_atomic) || _GNUC_VER >= 407
-#include <google/protobuf/stubs/atomicops_internals_generic_c11_atomic.h>
-#else // __has_feature(cxx_atomic) || _GNUC_VER >= 407
-#include <google/protobuf/stubs/atomicops_internals_macosx.h>
-#endif // __has_feature(cxx_atomic) || _GNUC_VER >= 407
-
// GCC.
#elif defined(__GNUC__)
#if defined(GOOGLE_PROTOBUF_ARCH_IA32) || defined(GOOGLE_PROTOBUF_ARCH_X64)
@@ -221,6 +213,9 @@ Atomic64 Release_Load(volatile const Atomic64* ptr);
#elif defined(GOOGLE_PROTOBUF_ARCH_POWER)
#include <google/protobuf/stubs/atomicops_internals_power.h>
#elif defined(__native_client__)
+// The static_asserts in the C++11 atomics implementation cause it to fail
+// with certain compilers, e.g. nvcc on macOS. Don't use elsewhere unless
+// the TODO in that file is addressed.
#include <google/protobuf/stubs/atomicops_internals_generic_c11_atomic.h>
#elif defined(GOOGLE_PROTOBUF_ARCH_PPC)
#include <google/protobuf/stubs/atomicops_internals_ppc_gcc.h>
diff --git a/src/google/protobuf/stubs/atomicops_internals_arm64_gcc.h b/src/google/protobuf/stubs/atomicops_internals_arm64_gcc.h
index 0a2d2b89..9a69d21a 100644
--- a/src/google/protobuf/stubs/atomicops_internals_arm64_gcc.h
+++ b/src/google/protobuf/stubs/atomicops_internals_arm64_gcc.h
@@ -37,7 +37,7 @@ namespace google {
namespace protobuf {
namespace internal {
-inline void MemoryBarrier() {
+inline void MemoryBarrierInternal() {
__asm__ __volatile__ ("dmb ish" ::: "memory"); // NOLINT
}
@@ -117,9 +117,9 @@ inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
Atomic32 increment) {
- MemoryBarrier();
+ MemoryBarrierInternal();
Atomic32 result = NoBarrier_AtomicIncrement(ptr, increment);
- MemoryBarrier();
+ MemoryBarrierInternal();
return result;
}
@@ -128,7 +128,7 @@ inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
Atomic32 old_value,
Atomic32 new_value) {
Atomic32 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
- MemoryBarrier();
+ MemoryBarrierInternal();
return prev;
}
@@ -136,7 +136,7 @@ inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
Atomic32 old_value,
Atomic32 new_value) {
- MemoryBarrier();
+ MemoryBarrierInternal();
Atomic32 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
return prev;
@@ -148,7 +148,7 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
*ptr = value;
- MemoryBarrier();
+ MemoryBarrierInternal();
}
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
@@ -178,7 +178,7 @@ inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
}
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
- MemoryBarrier();
+ MemoryBarrierInternal();
return *ptr;
}
@@ -253,9 +253,9 @@ inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,
inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,
Atomic64 increment) {
- MemoryBarrier();
+ MemoryBarrierInternal();
Atomic64 result = NoBarrier_AtomicIncrement(ptr, increment);
- MemoryBarrier();
+ MemoryBarrierInternal();
return result;
}
@@ -264,7 +264,7 @@ inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
Atomic64 old_value,
Atomic64 new_value) {
Atomic64 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
- MemoryBarrier();
+ MemoryBarrierInternal();
return prev;
}
@@ -272,7 +272,7 @@ inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
Atomic64 old_value,
Atomic64 new_value) {
- MemoryBarrier();
+ MemoryBarrierInternal();
Atomic64 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
return prev;
@@ -284,7 +284,7 @@ inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {
inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
*ptr = value;
- MemoryBarrier();
+ MemoryBarrierInternal();
}
inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
@@ -314,7 +314,7 @@ inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
}
inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
- MemoryBarrier();
+ MemoryBarrierInternal();
return *ptr;
}
diff --git a/src/google/protobuf/stubs/atomicops_internals_arm_gcc.h b/src/google/protobuf/stubs/atomicops_internals_arm_gcc.h
index 90e727b0..6e2de67f 100644
--- a/src/google/protobuf/stubs/atomicops_internals_arm_gcc.h
+++ b/src/google/protobuf/stubs/atomicops_internals_arm_gcc.h
@@ -115,17 +115,17 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
*ptr = value;
}
-inline void MemoryBarrier() {
+inline void MemoryBarrierInternal() {
pLinuxKernelMemoryBarrier();
}
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
*ptr = value;
- MemoryBarrier();
+ MemoryBarrierInternal();
}
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
- MemoryBarrier();
+ MemoryBarrierInternal();
*ptr = value;
}
@@ -135,12 +135,12 @@ inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
Atomic32 value = *ptr;
- MemoryBarrier();
+ MemoryBarrierInternal();
return value;
}
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
- MemoryBarrier();
+ MemoryBarrierInternal();
return *ptr;
}
diff --git a/src/google/protobuf/stubs/atomicops_internals_arm_qnx.h b/src/google/protobuf/stubs/atomicops_internals_arm_qnx.h
index 17dfaa51..cd97e0c9 100644
--- a/src/google/protobuf/stubs/atomicops_internals_arm_qnx.h
+++ b/src/google/protobuf/stubs/atomicops_internals_arm_qnx.h
@@ -110,17 +110,17 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
*ptr = value;
}
-inline void MemoryBarrier() {
+inline void MemoryBarrierInternal() {
__sync_synchronize();
}
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
*ptr = value;
- MemoryBarrier();
+ MemoryBarrierInternal();
}
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
- MemoryBarrier();
+ MemoryBarrierInternal();
*ptr = value;
}
@@ -130,12 +130,12 @@ inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
Atomic32 value = *ptr;
- MemoryBarrier();
+ MemoryBarrierInternal();
return value;
}
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
- MemoryBarrier();
+ MemoryBarrierInternal();
return *ptr;
}
diff --git a/src/google/protobuf/stubs/atomicops_internals_generic_c11_atomic.h b/src/google/protobuf/stubs/atomicops_internals_generic_c11_atomic.h
index 7bc584eb..44ef9c9e 100644
--- a/src/google/protobuf/stubs/atomicops_internals_generic_c11_atomic.h
+++ b/src/google/protobuf/stubs/atomicops_internals_generic_c11_atomic.h
@@ -52,7 +52,7 @@ typedef volatile std::atomic<Atomic32>* AtomicLocation32;
static_assert(sizeof(*(AtomicLocation32) nullptr) == sizeof(Atomic32),
"incompatible 32-bit atomic layout");
-inline void MemoryBarrier() {
+inline void MemoryBarrierInternal() {
#if defined(__GLIBCXX__)
// Work around libstdc++ bug 51038 where atomic_thread_fence was declared but
// not defined, leading to the linker complaining about undefined references.
@@ -119,7 +119,7 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
((AtomicLocation32)ptr)->store(value, std::memory_order_relaxed);
- MemoryBarrier();
+ MemoryBarrierInternal();
}
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
@@ -135,7 +135,7 @@ inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
}
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
- MemoryBarrier();
+ MemoryBarrierInternal();
return ((AtomicLocation32)ptr)->load(std::memory_order_relaxed);
}
@@ -202,7 +202,7 @@ inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {
inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
((AtomicLocation64)ptr)->store(value, std::memory_order_relaxed);
- MemoryBarrier();
+ MemoryBarrierInternal();
}
inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
@@ -218,7 +218,7 @@ inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
}
inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
- MemoryBarrier();
+ MemoryBarrierInternal();
return ((AtomicLocation64)ptr)->load(std::memory_order_relaxed);
}
diff --git a/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h b/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h
index 7f17b30d..0b0b06ce 100644
--- a/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h
+++ b/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h
@@ -78,7 +78,7 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
__atomic_store_n(ptr, value, __ATOMIC_RELAXED);
}
-inline void MemoryBarrier() {
+inline void MemoryBarrierInternal() {
__sync_synchronize();
}
diff --git a/src/google/protobuf/stubs/atomicops_internals_macosx.h b/src/google/protobuf/stubs/atomicops_internals_macosx.h
deleted file mode 100644
index 79633241..00000000
--- a/src/google/protobuf/stubs/atomicops_internals_macosx.h
+++ /dev/null
@@ -1,225 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2012 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// This file is an internal atomic implementation, use atomicops.h instead.
-
-#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_MACOSX_H_
-#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_MACOSX_H_
-
-#include <libkern/OSAtomic.h>
-
-namespace google {
-namespace protobuf {
-namespace internal {
-
-inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
- Atomic32 old_value,
- Atomic32 new_value) {
- Atomic32 prev_value;
- do {
- if (OSAtomicCompareAndSwap32(old_value, new_value,
- const_cast<Atomic32*>(ptr))) {
- return old_value;
- }
- prev_value = *ptr;
- } while (prev_value == old_value);
- return prev_value;
-}
-
-inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
- Atomic32 new_value) {
- Atomic32 old_value;
- do {
- old_value = *ptr;
- } while (!OSAtomicCompareAndSwap32(old_value, new_value,
- const_cast<Atomic32*>(ptr)));
- return old_value;
-}
-
-inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
- Atomic32 increment) {
- return OSAtomicAdd32(increment, const_cast<Atomic32*>(ptr));
-}
-
-inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
- Atomic32 increment) {
- return OSAtomicAdd32Barrier(increment, const_cast<Atomic32*>(ptr));
-}
-
-inline void MemoryBarrier() {
- OSMemoryBarrier();
-}
-
-inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
- Atomic32 old_value,
- Atomic32 new_value) {
- Atomic32 prev_value;
- do {
- if (OSAtomicCompareAndSwap32Barrier(old_value, new_value,
- const_cast<Atomic32*>(ptr))) {
- return old_value;
- }
- prev_value = *ptr;
- } while (prev_value == old_value);
- return prev_value;
-}
-
-inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
- Atomic32 old_value,
- Atomic32 new_value) {
- return Acquire_CompareAndSwap(ptr, old_value, new_value);
-}
-
-inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
- *ptr = value;
-}
-
-inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
- *ptr = value;
- MemoryBarrier();
-}
-
-inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
- MemoryBarrier();
- *ptr = value;
-}
-
-inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
- return *ptr;
-}
-
-inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
- Atomic32 value = *ptr;
- MemoryBarrier();
- return value;
-}
-
-inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
- MemoryBarrier();
- return *ptr;
-}
-
-#ifdef __LP64__
-
-// 64-bit implementation on 64-bit platform
-
-inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,
- Atomic64 old_value,
- Atomic64 new_value) {
- Atomic64 prev_value;
- do {
- if (OSAtomicCompareAndSwap64(old_value, new_value,
- reinterpret_cast<volatile int64_t*>(ptr))) {
- return old_value;
- }
- prev_value = *ptr;
- } while (prev_value == old_value);
- return prev_value;
-}
-
-inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr,
- Atomic64 new_value) {
- Atomic64 old_value;
- do {
- old_value = *ptr;
- } while (!OSAtomicCompareAndSwap64(old_value, new_value,
- reinterpret_cast<volatile int64_t*>(ptr)));
- return old_value;
-}
-
-inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,
- Atomic64 increment) {
- return OSAtomicAdd64(increment, reinterpret_cast<volatile int64_t*>(ptr));
-}
-
-inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,
- Atomic64 increment) {
- return OSAtomicAdd64Barrier(increment,
- reinterpret_cast<volatile int64_t*>(ptr));
-}
-
-inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
- Atomic64 old_value,
- Atomic64 new_value) {
- Atomic64 prev_value;
- do {
- if (OSAtomicCompareAndSwap64Barrier(
- old_value, new_value, reinterpret_cast<volatile int64_t*>(ptr))) {
- return old_value;
- }
- prev_value = *ptr;
- } while (prev_value == old_value);
- return prev_value;
-}
-
-inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
- Atomic64 old_value,
- Atomic64 new_value) {
- // The lib kern interface does not distinguish between
- // Acquire and Release memory barriers; they are equivalent.
- return Acquire_CompareAndSwap(ptr, old_value, new_value);
-}
-
-inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {
- *ptr = value;
-}
-
-inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
- *ptr = value;
- MemoryBarrier();
-}
-
-inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
- MemoryBarrier();
- *ptr = value;
-}
-
-inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {
- return *ptr;
-}
-
-inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
- Atomic64 value = *ptr;
- MemoryBarrier();
- return value;
-}
-
-inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
- MemoryBarrier();
- return *ptr;
-}
-
-#endif // defined(__LP64__)
-
-} // namespace internal
-} // namespace protobuf
-} // namespace google
-
-#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_MACOSX_H_
diff --git a/src/google/protobuf/stubs/atomicops_internals_mips_gcc.h b/src/google/protobuf/stubs/atomicops_internals_mips_gcc.h
index f5837c9e..6ce6820e 100644
--- a/src/google/protobuf/stubs/atomicops_internals_mips_gcc.h
+++ b/src/google/protobuf/stubs/atomicops_internals_mips_gcc.h
@@ -125,8 +125,8 @@ inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
// ensure that no later memory access can be reordered ahead of the operation.
// "Release" operations ensure that no previous memory access can be reordered
// after the operation. "Barrier" operations have both "Acquire" and "Release"
-// semantics. A MemoryBarrier() has "Barrier" semantics, but does no memory
-// access.
+// semantics. A MemoryBarrierInternal() has "Barrier" semantics, but does no
+// memory access.
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
Atomic32 old_value,
Atomic32 new_value) {
@@ -149,17 +149,17 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
*ptr = value;
}
-inline void MemoryBarrier() {
+inline void MemoryBarrierInternal() {
__asm__ __volatile__("sync" : : : "memory");
}
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
*ptr = value;
- MemoryBarrier();
+ MemoryBarrierInternal();
}
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
- MemoryBarrier();
+ MemoryBarrierInternal();
*ptr = value;
}
@@ -169,12 +169,12 @@ inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
Atomic32 value = *ptr;
- MemoryBarrier();
+ MemoryBarrierInternal();
return value;
}
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
- MemoryBarrier();
+ MemoryBarrierInternal();
return *ptr;
}
@@ -247,9 +247,9 @@ inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,
inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,
Atomic64 increment) {
- MemoryBarrier();
+ MemoryBarrierInternal();
Atomic64 res = NoBarrier_AtomicIncrement(ptr, increment);
- MemoryBarrier();
+ MemoryBarrierInternal();
return res;
}
@@ -257,20 +257,20 @@ inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,
// ensure that no later memory access can be reordered ahead of the operation.
// "Release" operations ensure that no previous memory access can be reordered
// after the operation. "Barrier" operations have both "Acquire" and "Release"
-// semantics. A MemoryBarrier() has "Barrier" semantics, but does no memory
-// access.
+// semantics. A MemoryBarrierInternal() has "Barrier" semantics, but does no
+// memory access.
inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
Atomic64 old_value,
Atomic64 new_value) {
Atomic64 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
- MemoryBarrier();
+ MemoryBarrierInternal();
return res;
}
inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
Atomic64 old_value,
Atomic64 new_value) {
- MemoryBarrier();
+ MemoryBarrierInternal();
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
}
@@ -280,11 +280,11 @@ inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {
inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
*ptr = value;
- MemoryBarrier();
+ MemoryBarrierInternal();
}
inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
- MemoryBarrier();
+ MemoryBarrierInternal();
*ptr = value;
}
@@ -294,12 +294,12 @@ inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {
inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
Atomic64 value = *ptr;
- MemoryBarrier();
+ MemoryBarrierInternal();
return value;
}
inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
- MemoryBarrier();
+ MemoryBarrierInternal();
return *ptr;
}
#endif
diff --git a/src/google/protobuf/stubs/atomicops_internals_power.h b/src/google/protobuf/stubs/atomicops_internals_power.h
index b8a42f21..cad9f1e3 100644
--- a/src/google/protobuf/stubs/atomicops_internals_power.h
+++ b/src/google/protobuf/stubs/atomicops_internals_power.h
@@ -93,7 +93,7 @@ inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
return result;
}
-inline void MemoryBarrier(void) {
+inline void MemoryBarrierInternal(void) {
asm volatile (
" lwsync \n\t"
" isync \n\t"
diff --git a/src/google/protobuf/stubs/atomicops_internals_ppc_gcc.h b/src/google/protobuf/stubs/atomicops_internals_ppc_gcc.h
index 8231a578..d477dc6d 100644
--- a/src/google/protobuf/stubs/atomicops_internals_ppc_gcc.h
+++ b/src/google/protobuf/stubs/atomicops_internals_ppc_gcc.h
@@ -97,22 +97,22 @@ inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32 *ptr,
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32 *ptr,
Atomic32 increment) {
- MemoryBarrier();
+ MemoryBarrierInternal();
Atomic32 res = NoBarrier_AtomicIncrement(ptr, increment);
- MemoryBarrier();
+ MemoryBarrierInternal();
return res;
}
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32 *ptr,
Atomic32 old_value, Atomic32 new_value) {
Atomic32 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
- MemoryBarrier();
+ MemoryBarrierInternal();
return res;
}
inline Atomic32 Release_CompareAndSwap(volatile Atomic32 *ptr,
Atomic32 old_value, Atomic32 new_value) {
- MemoryBarrier();
+ MemoryBarrierInternal();
Atomic32 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
return res;
}
@@ -121,15 +121,15 @@ inline void NoBarrier_Store(volatile Atomic32 *ptr, Atomic32 value) {
*ptr = value;
}
-inline void MemoryBarrier() { __asm__ __volatile__("sync" : : : "memory"); }
+inline void MemoryBarrierInternal() { __asm__ __volatile__("sync" : : : "memory"); }
inline void Acquire_Store(volatile Atomic32 *ptr, Atomic32 value) {
*ptr = value;
- MemoryBarrier();
+ MemoryBarrierInternal();
}
inline void Release_Store(volatile Atomic32 *ptr, Atomic32 value) {
- MemoryBarrier();
+ MemoryBarrierInternal();
*ptr = value;
}
@@ -137,12 +137,12 @@ inline Atomic32 NoBarrier_Load(volatile const Atomic32 *ptr) { return *ptr; }
inline Atomic32 Acquire_Load(volatile const Atomic32 *ptr) {
Atomic32 value = *ptr;
- MemoryBarrier();
+ MemoryBarrierInternal();
return value;
}
inline Atomic32 Release_Load(volatile const Atomic32 *ptr) {
- MemoryBarrier();
+ MemoryBarrierInternal();
return *ptr;
}
diff --git a/src/google/protobuf/stubs/atomicops_internals_solaris.h b/src/google/protobuf/stubs/atomicops_internals_solaris.h
index d8057ecd..baecb993 100644
--- a/src/google/protobuf/stubs/atomicops_internals_solaris.h
+++ b/src/google/protobuf/stubs/atomicops_internals_solaris.h
@@ -54,16 +54,16 @@ inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
return (Atomic32)atomic_add_32_nv((volatile uint32_t*)ptr, (uint32_t)increment);
}
-inline void MemoryBarrier(void) {
+inline void MemoryBarrierInternal(void) {
membar_producer();
membar_consumer();
}
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
Atomic32 increment) {
- MemoryBarrier();
+ MemoryBarrierInternal();
Atomic32 ret = NoBarrier_AtomicIncrement(ptr, increment);
- MemoryBarrier();
+ MemoryBarrierInternal();
return ret;
}
@@ -72,7 +72,7 @@ inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
Atomic32 old_value,
Atomic32 new_value) {
Atomic32 ret = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
- MemoryBarrier();
+ MemoryBarrierInternal();
return ret;
}
@@ -80,7 +80,7 @@ inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
Atomic32 old_value,
Atomic32 new_value) {
- MemoryBarrier();
+ MemoryBarrierInternal();
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
}
@@ -129,9 +129,9 @@ inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 incre
}
inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment) {
- MemoryBarrier();
+ MemoryBarrierInternal();
Atomic64 ret = atomic_add_64_nv((volatile uint64_t*)ptr, increment);
- MemoryBarrier();
+ MemoryBarrierInternal();
return ret;
}
@@ -139,14 +139,14 @@ inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
Atomic64 old_value,
Atomic64 new_value) {
Atomic64 ret = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
- MemoryBarrier();
+ MemoryBarrierInternal();
return ret;
}
inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
Atomic64 old_value,
Atomic64 new_value) {
- MemoryBarrier();
+ MemoryBarrierInternal();
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
}
diff --git a/src/google/protobuf/stubs/atomicops_internals_tsan.h b/src/google/protobuf/stubs/atomicops_internals_tsan.h
index 0c903545..676380b1 100644
--- a/src/google/protobuf/stubs/atomicops_internals_tsan.h
+++ b/src/google/protobuf/stubs/atomicops_internals_tsan.h
@@ -206,7 +206,7 @@ inline Atomic64 Release_CompareAndSwap(volatile Atomic64 *ptr,
return cmp;
}
-inline void MemoryBarrier() {
+inline void MemoryBarrierInternal() {
__tsan_atomic_thread_fence(__tsan_memory_order_seq_cst);
}
diff --git a/src/google/protobuf/stubs/atomicops_internals_x86_gcc.h b/src/google/protobuf/stubs/atomicops_internals_x86_gcc.h
index edccc59d..e80121fd 100644
--- a/src/google/protobuf/stubs/atomicops_internals_x86_gcc.h
+++ b/src/google/protobuf/stubs/atomicops_internals_x86_gcc.h
@@ -119,18 +119,18 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
// 64-bit implementations of memory barrier can be simpler, because it
// "mfence" is guaranteed to exist.
-inline void MemoryBarrier() {
+inline void MemoryBarrierInternal() {
__asm__ __volatile__("mfence" : : : "memory");
}
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
*ptr = value;
- MemoryBarrier();
+ MemoryBarrierInternal();
}
#else
-inline void MemoryBarrier() {
+inline void MemoryBarrierInternal() {
if (AtomicOps_Internalx86CPUFeatures.has_sse2) {
__asm__ __volatile__("mfence" : : : "memory");
} else { // mfence is faster but not present on PIII
@@ -168,7 +168,7 @@ inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
}
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
- MemoryBarrier();
+ MemoryBarrierInternal();
return *ptr;
}
@@ -225,7 +225,7 @@ inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {
inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
*ptr = value;
- MemoryBarrier();
+ MemoryBarrierInternal();
}
inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
@@ -262,7 +262,7 @@ inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
}
inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
- MemoryBarrier();
+ MemoryBarrierInternal();
return *ptr;
}
diff --git a/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc b/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc
index 741b164f..74a1bd4e 100644
--- a/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc
+++ b/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc
@@ -44,9 +44,10 @@ namespace google {
namespace protobuf {
namespace internal {
-inline void MemoryBarrier() {
- // We use MemoryBarrier from WinNT.h
- ::MemoryBarrier();
+inline void MemoryBarrierInternal() {
+ // On ARM this is a define while on x86/x64 this is
+ // a function declared in WinNT.h
+ MemoryBarrier();
}
Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
diff --git a/src/google/protobuf/stubs/atomicops_internals_x86_msvc.h b/src/google/protobuf/stubs/atomicops_internals_x86_msvc.h
index e53a641f..34d60d98 100644
--- a/src/google/protobuf/stubs/atomicops_internals_x86_msvc.h
+++ b/src/google/protobuf/stubs/atomicops_internals_x86_msvc.h
@@ -82,7 +82,7 @@ inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
}
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
- MemoryBarrier();
+ MemoryBarrierInternal();
return *ptr;
}
@@ -125,7 +125,7 @@ inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
}
inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
- MemoryBarrier();
+ MemoryBarrierInternal();
return *ptr;
}
diff --git a/src/google/protobuf/stubs/callback.h b/src/google/protobuf/stubs/callback.h
index bbd507a8..9ec04979 100644
--- a/src/google/protobuf/stubs/callback.h
+++ b/src/google/protobuf/stubs/callback.h
@@ -346,6 +346,29 @@ struct InternalConstRef {
typedef const base_type& type;
};
+template<typename R, typename T>
+class MethodResultCallback_0_0 : public ResultCallback<R> {
+ public:
+ typedef R (T::*MethodType)();
+ MethodResultCallback_0_0(T* object, MethodType method, bool self_deleting)
+ : object_(object),
+ method_(method),
+ self_deleting_(self_deleting) {}
+ ~MethodResultCallback_0_0() {}
+
+ R Run() {
+ bool needs_delete = self_deleting_;
+ R result = (object_->*method_)();
+ if (needs_delete) delete this;
+ return result;
+ }
+
+ private:
+ T* object_;
+ MethodType method_;
+ bool self_deleting_;
+};
+
template <typename R, typename T, typename P1, typename P2, typename P3,
typename P4, typename P5, typename A1, typename A2>
class MethodResultCallback_5_2 : public ResultCallback2<R, A1, A2> {
@@ -520,6 +543,13 @@ inline ResultCallback1<R, A1>* NewPermanentCallback(
function, false, p1);
}
+// See MethodResultCallback_0_0
+template <typename R, typename T1, typename T2>
+inline ResultCallback<R>* NewPermanentCallback(
+ T1* object, R (T2::*function)()) {
+ return new internal::MethodResultCallback_0_0<R, T1>(object, function, false);
+}
+
// See MethodResultCallback_5_2
template <typename R, typename T, typename P1, typename P2, typename P3,
typename P4, typename P5, typename A1, typename A2>
diff --git a/src/google/protobuf/stubs/common.cc b/src/google/protobuf/stubs/common.cc
index 54dbafab..14655916 100644
--- a/src/google/protobuf/stubs/common.cc
+++ b/src/google/protobuf/stubs/common.cc
@@ -108,11 +108,17 @@ string VersionString(int version) {
// ===================================================================
// emulates google3/base/logging.cc
+// If the minimum logging level is not set, we default to logging messages for
+// all levels.
+#ifndef GOOGLE_PROTOBUF_MIN_LOG_LEVEL
+#define GOOGLE_PROTOBUF_MIN_LOG_LEVEL LOGLEVEL_INFO
+#endif
+
namespace internal {
+
#if defined(__ANDROID__)
inline void DefaultLogHandler(LogLevel level, const char* filename, int line,
const string& message) {
-#ifdef GOOGLE_PROTOBUF_MIN_LOG_LEVEL
if (level < GOOGLE_PROTOBUF_MIN_LOG_LEVEL) {
return;
}
@@ -143,11 +149,14 @@ inline void DefaultLogHandler(LogLevel level, const char* filename, int line,
__android_log_write(ANDROID_LOG_FATAL, "libprotobuf-native",
"terminating.\n");
}
-#endif
}
+
#else
void DefaultLogHandler(LogLevel level, const char* filename, int line,
const string& message) {
+ if (level < GOOGLE_PROTOBUF_MIN_LOG_LEVEL) {
+ return;
+ }
static const char* level_names[] = { "INFO", "WARNING", "ERROR", "FATAL" };
// We use fprintf() instead of cerr because we want this to work at static
diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h
index 43e88ff2..d2611498 100644
--- a/src/google/protobuf/stubs/common.h
+++ b/src/google/protobuf/stubs/common.h
@@ -96,24 +96,27 @@ namespace internal {
// The current version, represented as a single integer to make comparison
// easier: major * 10^6 + minor * 10^3 + micro
-#define GOOGLE_PROTOBUF_VERSION 3001000
+#define GOOGLE_PROTOBUF_VERSION 3002000
+
+// A suffix string for alpha, beta or rc releases. Empty for stable releases.
+#define GOOGLE_PROTOBUF_VERSION_SUFFIX ""
// The minimum library version which works with the current version of the
// headers.
-#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3001000
+#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3002000
// The minimum header version which works with the current version of
// the library. This constant should only be used by protoc's C++ code
// generator.
-static const int kMinHeaderVersionForLibrary = 3001000;
+static const int kMinHeaderVersionForLibrary = 3002000;
// The minimum protoc version which works with the current version of the
// headers.
-#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3001000
+#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3002000
// The minimum header version which works with the current version of
// protoc. This constant should only be used in VerifyVersion().
-static const int kMinHeaderVersionForProtoc = 3001000;
+static const int kMinHeaderVersionForProtoc = 3002000;
// Verifies that the headers and libraries are compatible. Use the macro
// below to call this.
diff --git a/src/google/protobuf/stubs/hash.h b/src/google/protobuf/stubs/hash.h
index 4eac7d5d..bf0b88b4 100644
--- a/src/google/protobuf/stubs/hash.h
+++ b/src/google/protobuf/stubs/hash.h
@@ -41,15 +41,10 @@
#define GOOGLE_PROTOBUF_HAVE_HASH_MAP 1
#define GOOGLE_PROTOBUF_HAVE_HASH_SET 1
-// Android
-#if defined(__ANDROID__)
-# undef GOOGLE_PROTOBUF_HAVE_HASH_MAP
-# undef GOOGLE_PROTOBUF_HAVE_HASH_MAP
-
// Use C++11 unordered_{map|set} if available.
-#elif ((_LIBCPP_STD_VER >= 11) || \
- (((__cplusplus >= 201103L) || defined(__GXX_EXPERIMENTAL_CXX0X)) && \
- (__GLIBCXX__ > 20090421)))
+#if ((_LIBCPP_STD_VER >= 11) || \
+ (((__cplusplus >= 201103L) || defined(__GXX_EXPERIMENTAL_CXX0X)) && \
+ (__GLIBCXX__ > 20090421)))
# define GOOGLE_PROTOBUF_HAS_CXX11_HASH
// For XCode >= 4.6: the compiler is clang with libc++.
diff --git a/src/google/protobuf/stubs/mathlimits.h b/src/google/protobuf/stubs/mathlimits.h
index 70e47bff..275d9539 100644
--- a/src/google/protobuf/stubs/mathlimits.h
+++ b/src/google/protobuf/stubs/mathlimits.h
@@ -43,12 +43,18 @@
#ifndef UTIL_MATH_MATHLIMITS_H__
#define UTIL_MATH_MATHLIMITS_H__
-// <math.h> lacks a lot of prototypes. However, this file needs <math.h> to
-// access old-fashioned isinf et al. Even worse more: this file must not
-// include <cmath> because that breaks the definition of isinf with gcc 4.9.
-//
-// TODO(mec): after C++11 everywhere, use <cmath> and std::isinf in this file.
+// GCC 4.9 has a bug that makes it impossible to use isinf and isnan when both
+// <math.h> and <cmath> get pulled into the same translation unit.
+// Unfortunately it is difficult to prevent this from happening, so to work
+// around the problem we use std::isinf and std::isnan from <cmath> for C++11
+// builds and otherwise use the plain isinf and isnan functions from <math.h>.
+// Note that for Windows we do something different because it does not support
+// the plain isinf and isnan.
+#if __cplusplus >= 201103L
+#include <cmath>
+#else
#include <math.h>
+#endif
#include <string.h>
#include <cfloat>
@@ -220,6 +226,17 @@ DECL_UNSIGNED_INT_LIMITS(unsigned long long int)
#undef UNSIGNED_MAX_10_EXP
#undef DECL_INT_LIMIT_FUNCS
+// For non-Windows builds we use the std:: versions of isinf and isnan if they
+// are available; see the comment about <cmath> at the top of this file for the
+// details on why we need to do this.
+#if __cplusplus >= 201103L
+#define ISINF std::isinf
+#define ISNAN std::isnan
+#else
+#define ISINF isinf
+#define ISNAN isnan
+#endif
+
// ========================================================================= //
#ifdef WIN32 // Lacks built-in isnan() and isinf()
#define DECL_FP_LIMIT_FUNCS \
@@ -230,11 +247,11 @@ DECL_UNSIGNED_INT_LIMITS(unsigned long long int)
static bool IsNegInf(const Type x) { return _fpclass(x) == _FPCLASS_NINF; }
#else
#define DECL_FP_LIMIT_FUNCS \
- static bool IsFinite(const Type x) { return !isinf(x) && !isnan(x); } \
- static bool IsNaN(const Type x) { return isnan(x); } \
- static bool IsInf(const Type x) { return isinf(x); } \
- static bool IsPosInf(const Type x) { return isinf(x) && x > 0; } \
- static bool IsNegInf(const Type x) { return isinf(x) && x < 0; }
+ static bool IsFinite(const Type x) { return !ISINF(x) && !ISNAN(x); } \
+ static bool IsNaN(const Type x) { return ISNAN(x); } \
+ static bool IsInf(const Type x) { return ISINF(x); } \
+ static bool IsPosInf(const Type x) { return ISINF(x) && x > 0; } \
+ static bool IsNegInf(const Type x) { return ISINF(x) && x < 0; }
#endif
// We can't put floating-point constant values in the header here because
@@ -269,6 +286,8 @@ DECL_FP_LIMITS(float, FLT)
DECL_FP_LIMITS(double, DBL)
DECL_FP_LIMITS(long double, LDBL)
+#undef ISINF
+#undef ISNAN
#undef DECL_FP_LIMITS
#undef DECL_FP_LIMIT_FUNCS
diff --git a/src/google/protobuf/stubs/mathutil.h b/src/google/protobuf/stubs/mathutil.h
index 27956a8e..8a9f69a0 100644
--- a/src/google/protobuf/stubs/mathutil.h
+++ b/src/google/protobuf/stubs/mathutil.h
@@ -41,27 +41,6 @@ namespace google {
namespace protobuf {
namespace internal {
template<typename T>
-bool IsNan(T value) {
- return false;
-}
-template<>
-inline bool IsNan(float value) {
-#ifdef _MSC_VER
- return _isnan(value);
-#else
- return isnan(value);
-#endif
-}
-template<>
-inline bool IsNan(double value) {
-#ifdef _MSC_VER
- return _isnan(value);
-#else
- return isnan(value);
-#endif
-}
-
-template<typename T>
bool AlmostEquals(T a, T b) {
return a == b;
}
@@ -80,7 +59,7 @@ class MathUtil {
public:
template<typename T>
static T Sign(T value) {
- if (value == T(0) || ::google::protobuf::internal::IsNan<T>(value)) {
+ if (value == T(0) || MathLimits<T>::IsNaN(value)) {
return value;
}
return value > T(0) ? 1 : -1;
diff --git a/src/google/protobuf/stubs/platform_macros.h b/src/google/protobuf/stubs/platform_macros.h
index 8b7f224f..7a54060d 100644
--- a/src/google/protobuf/stubs/platform_macros.h
+++ b/src/google/protobuf/stubs/platform_macros.h
@@ -47,7 +47,7 @@
#elif defined(__QNX__)
#define GOOGLE_PROTOBUF_ARCH_ARM_QNX 1
#define GOOGLE_PROTOBUF_ARCH_32_BIT 1
-#elif defined(__ARMEL__)
+#elif defined(_M_ARM) || defined(__ARMEL__)
#define GOOGLE_PROTOBUF_ARCH_ARM 1
#define GOOGLE_PROTOBUF_ARCH_32_BIT 1
#elif defined(__aarch64__)
diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h
index 376be5f7..d37e8130 100644
--- a/src/google/protobuf/stubs/port.h
+++ b/src/google/protobuf/stubs/port.h
@@ -60,8 +60,12 @@
#endif
#else
#include <sys/param.h> // __BYTE_ORDER
+ #if defined(__OpenBSD__)
+ #include <endian.h>
+ #endif
#if ((defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) || \
- (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN)) && \
+ (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN) || \
+ (defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN)) && \
!defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST)
#define PROTOBUF_LITTLE_ENDIAN 1
#endif
@@ -93,6 +97,15 @@
// ===================================================================
// from google3/base/port.h
+
+#if (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L || \
+ (defined(_MSC_VER) && _MSC_VER >= 1900))
+// Define this to 1 if the code is compiled in C++11 mode; leave it
+// undefined otherwise. Do NOT define it to 0 -- that causes
+// '#ifdef LANG_CXX11' to behave differently from '#if LANG_CXX11'.
+#define LANG_CXX11 1
+#endif
+
namespace google {
namespace protobuf {
@@ -441,7 +454,6 @@ class BigEndian {
}
};
-
} // namespace protobuf
} // namespace google
diff --git a/src/google/protobuf/stubs/strutil.cc b/src/google/protobuf/stubs/strutil.cc
index 4fa8e99f..15b6e53f 100644
--- a/src/google/protobuf/stubs/strutil.cc
+++ b/src/google/protobuf/stubs/strutil.cc
@@ -981,7 +981,7 @@ static const char two_ASCII_digits[100][2] = {
};
char* FastUInt32ToBufferLeft(uint32 u, char* buffer) {
- int digits;
+ uint32 digits;
const char *ASCII_digits = NULL;
// The idea of this implementation is to trim the number of divides to as few
// as possible by using multiplication and subtraction rather than mod (%),
diff --git a/src/google/protobuf/test_messages_proto3.proto b/src/google/protobuf/test_messages_proto3.proto
new file mode 100644
index 00000000..79230334
--- /dev/null
+++ b/src/google/protobuf/test_messages_proto3.proto
@@ -0,0 +1,227 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Test schema for proto3 messages. This test schema is used by:
+//
+// - benchmarks
+// - fuzz tests
+// - conformance tests
+//
+
+syntax = "proto3";
+
+package protobuf_test_messages.proto3;
+option java_package = "com.google.protobuf_test_messages.proto3";
+
+// This is the default, but we specify it here explicitly.
+option optimize_for = SPEED;
+
+import "google/protobuf/any.proto";
+import "google/protobuf/duration.proto";
+import "google/protobuf/field_mask.proto";
+import "google/protobuf/struct.proto";
+import "google/protobuf/timestamp.proto";
+import "google/protobuf/wrappers.proto";
+
+option cc_enable_arenas = true;
+
+// This proto includes every type of field in both singular and repeated
+// forms.
+//
+// Also, crucially, all messages and enums in this file are eventually
+// submessages of this message. So for example, a fuzz test of TestAllTypes
+// could trigger bugs that occur in any message type in this file. We verify
+// this stays true in a unit test.
+message TestAllTypes {
+ message NestedMessage {
+ int32 a = 1;
+ TestAllTypes corecursive = 2;
+ }
+
+ enum NestedEnum {
+ FOO = 0;
+ BAR = 1;
+ BAZ = 2;
+ NEG = -1; // Intentionally negative.
+ }
+
+ // Singular
+ int32 optional_int32 = 1;
+ int64 optional_int64 = 2;
+ uint32 optional_uint32 = 3;
+ uint64 optional_uint64 = 4;
+ sint32 optional_sint32 = 5;
+ sint64 optional_sint64 = 6;
+ fixed32 optional_fixed32 = 7;
+ fixed64 optional_fixed64 = 8;
+ sfixed32 optional_sfixed32 = 9;
+ sfixed64 optional_sfixed64 = 10;
+ float optional_float = 11;
+ double optional_double = 12;
+ bool optional_bool = 13;
+ string optional_string = 14;
+ bytes optional_bytes = 15;
+
+ NestedMessage optional_nested_message = 18;
+ ForeignMessage optional_foreign_message = 19;
+
+ NestedEnum optional_nested_enum = 21;
+ ForeignEnum optional_foreign_enum = 22;
+
+ string optional_string_piece = 24 [ctype=STRING_PIECE];
+ string optional_cord = 25 [ctype=CORD];
+
+ TestAllTypes recursive_message = 27;
+
+ // Repeated
+ repeated int32 repeated_int32 = 31;
+ repeated int64 repeated_int64 = 32;
+ repeated uint32 repeated_uint32 = 33;
+ repeated uint64 repeated_uint64 = 34;
+ repeated sint32 repeated_sint32 = 35;
+ repeated sint64 repeated_sint64 = 36;
+ repeated fixed32 repeated_fixed32 = 37;
+ repeated fixed64 repeated_fixed64 = 38;
+ repeated sfixed32 repeated_sfixed32 = 39;
+ repeated sfixed64 repeated_sfixed64 = 40;
+ repeated float repeated_float = 41;
+ repeated double repeated_double = 42;
+ repeated bool repeated_bool = 43;
+ repeated string repeated_string = 44;
+ repeated bytes repeated_bytes = 45;
+
+ repeated NestedMessage repeated_nested_message = 48;
+ repeated ForeignMessage repeated_foreign_message = 49;
+
+ repeated NestedEnum repeated_nested_enum = 51;
+ repeated ForeignEnum repeated_foreign_enum = 52;
+
+ repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
+ repeated string repeated_cord = 55 [ctype=CORD];
+
+ // Map
+ map < int32, int32> map_int32_int32 = 56;
+ map < int64, int64> map_int64_int64 = 57;
+ map < uint32, uint32> map_uint32_uint32 = 58;
+ map < uint64, uint64> map_uint64_uint64 = 59;
+ map < sint32, sint32> map_sint32_sint32 = 60;
+ map < sint64, sint64> map_sint64_sint64 = 61;
+ map < fixed32, fixed32> map_fixed32_fixed32 = 62;
+ map < fixed64, fixed64> map_fixed64_fixed64 = 63;
+ map <sfixed32, sfixed32> map_sfixed32_sfixed32 = 64;
+ map <sfixed64, sfixed64> map_sfixed64_sfixed64 = 65;
+ map < int32, float> map_int32_float = 66;
+ map < int32, double> map_int32_double = 67;
+ map < bool, bool> map_bool_bool = 68;
+ map < string, string> map_string_string = 69;
+ map < string, bytes> map_string_bytes = 70;
+ map < string, NestedMessage> map_string_nested_message = 71;
+ map < string, ForeignMessage> map_string_foreign_message = 72;
+ map < string, NestedEnum> map_string_nested_enum = 73;
+ map < string, ForeignEnum> map_string_foreign_enum = 74;
+
+ oneof oneof_field {
+ uint32 oneof_uint32 = 111;
+ NestedMessage oneof_nested_message = 112;
+ string oneof_string = 113;
+ bytes oneof_bytes = 114;
+ bool oneof_bool = 115;
+ uint64 oneof_uint64 = 116;
+ float oneof_float = 117;
+ double oneof_double = 118;
+ NestedEnum oneof_enum = 119;
+ }
+
+ // Well-known types
+ google.protobuf.BoolValue optional_bool_wrapper = 201;
+ google.protobuf.Int32Value optional_int32_wrapper = 202;
+ google.protobuf.Int64Value optional_int64_wrapper = 203;
+ google.protobuf.UInt32Value optional_uint32_wrapper = 204;
+ google.protobuf.UInt64Value optional_uint64_wrapper = 205;
+ google.protobuf.FloatValue optional_float_wrapper = 206;
+ google.protobuf.DoubleValue optional_double_wrapper = 207;
+ google.protobuf.StringValue optional_string_wrapper = 208;
+ google.protobuf.BytesValue optional_bytes_wrapper = 209;
+
+ repeated google.protobuf.BoolValue repeated_bool_wrapper = 211;
+ repeated google.protobuf.Int32Value repeated_int32_wrapper = 212;
+ repeated google.protobuf.Int64Value repeated_int64_wrapper = 213;
+ repeated google.protobuf.UInt32Value repeated_uint32_wrapper = 214;
+ repeated google.protobuf.UInt64Value repeated_uint64_wrapper = 215;
+ repeated google.protobuf.FloatValue repeated_float_wrapper = 216;
+ repeated google.protobuf.DoubleValue repeated_double_wrapper = 217;
+ repeated google.protobuf.StringValue repeated_string_wrapper = 218;
+ repeated google.protobuf.BytesValue repeated_bytes_wrapper = 219;
+
+ google.protobuf.Duration optional_duration = 301;
+ google.protobuf.Timestamp optional_timestamp = 302;
+ google.protobuf.FieldMask optional_field_mask = 303;
+ google.protobuf.Struct optional_struct = 304;
+ google.protobuf.Any optional_any = 305;
+ google.protobuf.Value optional_value = 306;
+
+ repeated google.protobuf.Duration repeated_duration = 311;
+ repeated google.protobuf.Timestamp repeated_timestamp = 312;
+ repeated google.protobuf.FieldMask repeated_fieldmask = 313;
+ repeated google.protobuf.Struct repeated_struct = 324;
+ repeated google.protobuf.Any repeated_any = 315;
+ repeated google.protobuf.Value repeated_value = 316;
+
+ // Test field-name-to-JSON-name convention.
+ // (protobuf says names can be any valid C/C++ identifier.)
+ int32 fieldname1 = 401;
+ int32 field_name2 = 402;
+ int32 _field_name3 = 403;
+ int32 field__name4_ = 404;
+ int32 field0name5 = 405;
+ int32 field_0_name6 = 406;
+ int32 fieldName7 = 407;
+ int32 FieldName8 = 408;
+ int32 field_Name9 = 409;
+ int32 Field_Name10 = 410;
+ int32 FIELD_NAME11 = 411;
+ int32 FIELD_name12 = 412;
+ int32 __field_name13 = 413;
+ int32 __Field_name14 = 414;
+ int32 field__name15 = 415;
+ int32 field__Name16 = 416;
+ int32 field_name17__ = 417;
+ int32 Field_name18__ = 418;
+}
+
+message ForeignMessage {
+ int32 c = 1;
+}
+
+enum ForeignEnum {
+ FOREIGN_FOO = 0;
+ FOREIGN_BAR = 1;
+ FOREIGN_BAZ = 2;
+}
diff --git a/src/google/protobuf/test_util.cc b/src/google/protobuf/test_util.cc
index 658c8ee2..4e02a85d 100644
--- a/src/google/protobuf/test_util.cc
+++ b/src/google/protobuf/test_util.cc
@@ -3230,7 +3230,7 @@ void TestUtil::ReflectionTester::RemoveLastRepeatedsViaReflection(
Message* message) {
const Reflection* reflection = message->GetReflection();
- vector<const FieldDescriptor*> output;
+ std::vector<const FieldDescriptor*> output;
reflection->ListFields(*message, &output);
for (int i=0; i<output.size(); ++i) {
const FieldDescriptor* field = output[i];
@@ -3244,7 +3244,7 @@ void TestUtil::ReflectionTester::ReleaseLastRepeatedsViaReflection(
Message* message, bool expect_extensions_notnull) {
const Reflection* reflection = message->GetReflection();
- vector<const FieldDescriptor*> output;
+ std::vector<const FieldDescriptor*> output;
reflection->ListFields(*message, &output);
for (int i=0; i<output.size(); ++i) {
const FieldDescriptor* field = output[i];
@@ -3263,7 +3263,7 @@ void TestUtil::ReflectionTester::ReleaseLastRepeatedsViaReflection(
void TestUtil::ReflectionTester::SwapRepeatedsViaReflection(Message* message) {
const Reflection* reflection = message->GetReflection();
- vector<const FieldDescriptor*> output;
+ std::vector<const FieldDescriptor*> output;
reflection->ListFields(*message, &output);
for (int i=0; i<output.size(); ++i) {
const FieldDescriptor* field = output[i];
@@ -3278,7 +3278,7 @@ SetAllocatedOptionalMessageFieldsToNullViaReflection(
Message* message) {
const Reflection* reflection = message->GetReflection();
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
reflection->ListFields(*message, &fields);
for (int i = 0; i < fields.size(); ++i) {
@@ -3298,7 +3298,7 @@ SetAllocatedOptionalMessageFieldsToMessageViaReflection(
const Reflection* from_reflection = from_message->GetReflection();
const Reflection* to_reflection = to_message->GetReflection();
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
from_reflection->ListFields(*from_message, &fields);
for (int i = 0; i < fields.size(); ++i) {
diff --git a/src/google/protobuf/text_format.cc b/src/google/protobuf/text_format.cc
index 5192eca9..778b878e 100644
--- a/src/google/protobuf/text_format.cc
+++ b/src/google/protobuf/text_format.cc
@@ -154,7 +154,7 @@ TextFormat::ParseInfoTree* TextFormat::ParseInfoTree::CreateNested(
const FieldDescriptor* field) {
// Owned by us in the map.
TextFormat::ParseInfoTree* instance = new TextFormat::ParseInfoTree();
- vector<TextFormat::ParseInfoTree*>* trees = &nested_[field];
+ std::vector<TextFormat::ParseInfoTree*>* trees = &nested_[field];
GOOGLE_CHECK(trees);
trees->push_back(instance);
return instance;
@@ -177,7 +177,7 @@ TextFormat::ParseLocation TextFormat::ParseInfoTree::GetLocation(
CheckFieldIndex(field, index);
if (index == -1) { index = 0; }
- const vector<TextFormat::ParseLocation>* locations =
+ const std::vector<TextFormat::ParseLocation>* locations =
FindOrNull(locations_, field);
if (locations == NULL || index >= locations->size()) {
return TextFormat::ParseLocation();
@@ -191,7 +191,8 @@ TextFormat::ParseInfoTree* TextFormat::ParseInfoTree::GetTreeForNested(
CheckFieldIndex(field, index);
if (index == -1) { index = 0; }
- const vector<TextFormat::ParseInfoTree*>* trees = FindOrNull(nested_, field);
+ const std::vector<TextFormat::ParseInfoTree*>* trees =
+ FindOrNull(nested_, field);
if (trees == NULL || index >= trees->size()) {
return NULL;
}
@@ -518,7 +519,14 @@ class TextFormat::Parser::ParserImpl {
// Perform special handling for embedded message types.
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
// ':' is optional here.
- TryConsume(":");
+ bool consumed_semicolon = TryConsume(":");
+ if (consumed_semicolon && field->options().weak() && LookingAtType(io::Tokenizer::TYPE_STRING)) {
+ // we are getting a bytes string for a weak field.
+ string tmp;
+ DO(ConsumeString(&tmp));
+ reflection->MutableMessage(message, field)->ParseFromString(tmp);
+ goto label_skip_parsing;
+ }
} else {
// ':' is required here.
DO(Consume(":"));
@@ -546,7 +554,7 @@ class TextFormat::Parser::ParserImpl {
} else {
DO(ConsumeFieldValue(message, reflection, field));
}
-
+label_skip_parsing:
// For historical reasons, fields may optionally be separated by commas or
// semicolons.
TryConsume(";") || TryConsume(",");
@@ -1336,7 +1344,7 @@ bool TextFormat::Parser::MergeUsingImpl(io::ZeroCopyInputStream* /* input */,
ParserImpl* parser_impl) {
if (!parser_impl->Parse(output)) return false;
if (!allow_partial_ && !output->IsInitialized()) {
- vector<string> missing_fields;
+ std::vector<string> missing_fields;
output->FindInitializationErrors(&missing_fields);
parser_impl->ReportError(-1, 0, "Message missing required fields: " +
Join(missing_fields, ", "));
@@ -1610,7 +1618,7 @@ void TextFormat::Printer::Print(const Message& message,
PrintAny(message, generator)) {
return;
}
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
reflection->ListFields(message, &fields);
if (print_message_fields_in_index_order_) {
std::sort(fields.begin(), fields.end(), FieldIndexSorter());
@@ -1638,54 +1646,6 @@ void TextFormat::Printer::PrintFieldValueToString(
PrintFieldValue(message, message.GetReflection(), field, index, generator);
}
-class MapEntryMessageComparator {
- public:
- explicit MapEntryMessageComparator(const Descriptor* descriptor)
- : field_(descriptor->field(0)) {}
-
- bool operator()(const Message* a, const Message* b) {
- const Reflection* reflection = a->GetReflection();
- switch (field_->cpp_type()) {
- case FieldDescriptor::CPPTYPE_BOOL: {
- bool first = reflection->GetBool(*a, field_);
- bool second = reflection->GetBool(*b, field_);
- return first < second;
- }
- case FieldDescriptor::CPPTYPE_INT32: {
- int32 first = reflection->GetInt32(*a, field_);
- int32 second = reflection->GetInt32(*b, field_);
- return first < second;
- }
- case FieldDescriptor::CPPTYPE_INT64: {
- int64 first = reflection->GetInt64(*a, field_);
- int64 second = reflection->GetInt64(*b, field_);
- return first < second;
- }
- case FieldDescriptor::CPPTYPE_UINT32: {
- uint32 first = reflection->GetUInt32(*a, field_);
- uint32 second = reflection->GetUInt32(*b, field_);
- return first < second;
- }
- case FieldDescriptor::CPPTYPE_UINT64: {
- uint64 first = reflection->GetUInt64(*a, field_);
- uint64 second = reflection->GetUInt64(*b, field_);
- return first < second;
- }
- case FieldDescriptor::CPPTYPE_STRING: {
- string first = reflection->GetString(*a, field_);
- string second = reflection->GetString(*b, field_);
- return first < second;
- }
- default:
- GOOGLE_LOG(DFATAL) << "Invalid key for map field.";
- return true;
- }
- }
-
- private:
- const FieldDescriptor* field_;
-};
-
void TextFormat::Printer::PrintField(const Message& message,
const Reflection* reflection,
const FieldDescriptor* field,
@@ -1706,19 +1666,10 @@ void TextFormat::Printer::PrintField(const Message& message,
count = 1;
}
- std::vector<const Message*> sorted_map_field;
- if (field->is_map()) {
- const RepeatedPtrField<Message>& map_field =
- reflection->GetRepeatedPtrField<Message>(message, field);
- for (RepeatedPtrField<Message>::const_pointer_iterator it =
- map_field.pointer_begin();
- it != map_field.pointer_end(); ++it) {
- sorted_map_field.push_back(*it);
- }
-
- MapEntryMessageComparator comparator(field->message_type());
- std::stable_sort(sorted_map_field.begin(), sorted_map_field.end(),
- comparator);
+ std::vector<const Message*> map_entries;
+ const bool is_map = field->is_map();
+ if (is_map) {
+ map_entries = DynamicMapSorter::Sort(message, count, reflection, field);
}
for (int j = 0; j < count; ++j) {
@@ -1731,9 +1682,8 @@ void TextFormat::Printer::PrintField(const Message& message,
custom_printers_, field, default_field_value_printer_.get());
const Message& sub_message =
field->is_repeated()
- ? (field->is_map()
- ? *sorted_map_field[j]
- : reflection->GetRepeatedMessage(message, field, j))
+ ? (is_map ? *map_entries[j]
+ : reflection->GetRepeatedMessage(message, field, j))
: reflection->GetMessage(message, field);
generator.Print(
printer->PrintMessageStart(
diff --git a/src/google/protobuf/text_format_unittest.cc b/src/google/protobuf/text_format_unittest.cc
index 2f1bd455..e6441339 100644
--- a/src/google/protobuf/text_format_unittest.cc
+++ b/src/google/protobuf/text_format_unittest.cc
@@ -993,10 +993,14 @@ TEST_F(TextFormatTest, ParseExotic) {
EXPECT_EQ(1.235E22 , message.repeated_double(4));
EXPECT_EQ(1.235E-18 , message.repeated_double(5));
EXPECT_EQ(123.456789, message.repeated_double(6));
- EXPECT_EQ(message.repeated_double(7), numeric_limits<double>::infinity());
- EXPECT_EQ(message.repeated_double(8), numeric_limits<double>::infinity());
- EXPECT_EQ(message.repeated_double(9), -numeric_limits<double>::infinity());
- EXPECT_EQ(message.repeated_double(10), -numeric_limits<double>::infinity());
+ EXPECT_EQ(message.repeated_double(7),
+ std::numeric_limits<double>::infinity());
+ EXPECT_EQ(message.repeated_double(8),
+ std::numeric_limits<double>::infinity());
+ EXPECT_EQ(message.repeated_double(9),
+ -std::numeric_limits<double>::infinity());
+ EXPECT_EQ(message.repeated_double(10),
+ -std::numeric_limits<double>::infinity());
EXPECT_TRUE(MathLimits<double>::IsNaN(message.repeated_double(11)));
EXPECT_TRUE(MathLimits<double>::IsNaN(message.repeated_double(12)));
@@ -1500,7 +1504,7 @@ TEST_F(TextFormatParserTest, ExplicitDelimiters) {
}
TEST_F(TextFormatParserTest, PrintErrorsToStderr) {
- vector<string> errors;
+ std::vector<string> errors;
{
ScopedMemoryLog log;
@@ -1517,7 +1521,7 @@ TEST_F(TextFormatParserTest, PrintErrorsToStderr) {
}
TEST_F(TextFormatParserTest, FailsOnTokenizationError) {
- vector<string> errors;
+ std::vector<string> errors;
{
ScopedMemoryLog log;
@@ -1576,7 +1580,7 @@ TEST_F(TextFormatMessageSetTest, Deserialize) {
protobuf_unittest::TestMessageSetExtension2::message_set_extension).str());
// Ensure that these are the only entries present.
- vector<const FieldDescriptor*> descriptors;
+ std::vector<const FieldDescriptor*> descriptors;
proto.message_set().GetReflection()->ListFields(
proto.message_set(), &descriptors);
EXPECT_EQ(2, descriptors.size());
diff --git a/src/google/protobuf/timestamp.pb.cc b/src/google/protobuf/timestamp.pb.cc
index b4258ae4..e21117b6 100644
--- a/src/google/protobuf/timestamp.pb.cc
+++ b/src/google/protobuf/timestamp.pb.cc
@@ -19,110 +19,103 @@
namespace google {
namespace protobuf {
+class TimestampDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Timestamp> {
+} _Timestamp_default_instance_;
+
+namespace protobuf_google_2fprotobuf_2ftimestamp_2eproto {
+
namespace {
-const ::google::protobuf::Descriptor* Timestamp_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- Timestamp_reflection_ = NULL;
+::google::protobuf::Metadata file_level_metadata[1];
} // namespace
+const ::google::protobuf::uint32 TableStruct::offsets[] = {
+ ~0u, // no _has_bits_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, seconds_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, nanos_),
+};
-void protobuf_AssignDesc_google_2fprotobuf_2ftimestamp_2eproto() GOOGLE_ATTRIBUTE_COLD;
-void protobuf_AssignDesc_google_2fprotobuf_2ftimestamp_2eproto() {
- protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto();
- const ::google::protobuf::FileDescriptor* file =
- ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
- "google/protobuf/timestamp.proto");
- GOOGLE_CHECK(file != NULL);
- Timestamp_descriptor_ = file->message_type(0);
- static const int Timestamp_offsets_[2] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, seconds_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, nanos_),
- };
- Timestamp_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- Timestamp_descriptor_,
- Timestamp::internal_default_instance(),
- Timestamp_offsets_,
- -1,
- -1,
- -1,
- sizeof(Timestamp),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, _internal_metadata_));
-}
+static const ::google::protobuf::internal::MigrationSchema schemas[] = {
+ { 0, -1, sizeof(Timestamp)},
+};
+
+static ::google::protobuf::Message const * const file_default_instances[] = {
+ reinterpret_cast<const ::google::protobuf::Message*>(&_Timestamp_default_instance_),
+};
namespace {
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
+void protobuf_AssignDescriptors() {
+ AddDescriptors();
+ ::google::protobuf::MessageFactory* factory = NULL;
+ AssignDescriptors(
+ "google/protobuf/timestamp.proto", schemas, file_default_instances, TableStruct::offsets, factory,
+ file_level_metadata, NULL, NULL);
+}
+
void protobuf_AssignDescriptorsOnce() {
- ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
- &protobuf_AssignDesc_google_2fprotobuf_2ftimestamp_2eproto);
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);
}
void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;
void protobuf_RegisterTypes(const ::std::string&) {
protobuf_AssignDescriptorsOnce();
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- Timestamp_descriptor_, Timestamp::internal_default_instance());
+ ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1);
}
} // namespace
-void protobuf_ShutdownFile_google_2fprotobuf_2ftimestamp_2eproto() {
- Timestamp_default_instance_.Shutdown();
- delete Timestamp_reflection_;
+void TableStruct::Shutdown() {
+ _Timestamp_default_instance_.Shutdown();
+ delete file_level_metadata[0].reflection;
}
-void protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto_impl() {
+void TableStruct::InitDefaultsImpl() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
- Timestamp_default_instance_.DefaultConstruct();
- Timestamp_default_instance_.get_mutable()->InitAsDefaultInstance();
+ ::google::protobuf::internal::InitProtobufDefaults();
+ _Timestamp_default_instance_.DefaultConstruct();
}
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto_once_);
-void protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto() {
- ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto_once_,
- &protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto_impl);
+void InitDefaults() {
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);
}
-void protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto_impl() {
- GOOGLE_PROTOBUF_VERIFY_VERSION;
-
- protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto();
+void AddDescriptorsImpl() {
+ InitDefaults();
+ static const char descriptor[] = {
+ "\n\037google/protobuf/timestamp.proto\022\017googl"
+ "e.protobuf\"+\n\tTimestamp\022\017\n\007seconds\030\001 \001(\003"
+ "\022\r\n\005nanos\030\002 \001(\005B~\n\023com.google.protobufB\016"
+ "TimestampProtoP\001Z+github.com/golang/prot"
+ "obuf/ptypes/timestamp\370\001\001\242\002\003GPB\252\002\036Google."
+ "Protobuf.WellKnownTypesb\006proto3"
+ };
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
- "\n\037google/protobuf/timestamp.proto\022\017googl"
- "e.protobuf\"+\n\tTimestamp\022\017\n\007seconds\030\001 \001(\003"
- "\022\r\n\005nanos\030\002 \001(\005B~\n\023com.google.protobufB\016"
- "TimestampProtoP\001Z+github.com/golang/prot"
- "obuf/ptypes/timestamp\370\001\001\242\002\003GPB\252\002\036Google."
- "Protobuf.WellKnownTypesb\006proto3", 231);
+ descriptor, 231);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"google/protobuf/timestamp.proto", &protobuf_RegisterTypes);
- ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2ftimestamp_2eproto);
+ ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);
}
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto_once_);
-void protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto() {
- ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto_once_,
- &protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto_impl);
+void AddDescriptors() {
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
}
// Force AddDescriptors() to be called at static initialization time.
-struct StaticDescriptorInitializer_google_2fprotobuf_2ftimestamp_2eproto {
- StaticDescriptorInitializer_google_2fprotobuf_2ftimestamp_2eproto() {
- protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto();
+struct StaticDescriptorInitializer {
+ StaticDescriptorInitializer() {
+ AddDescriptors();
}
-} static_descriptor_initializer_google_2fprotobuf_2ftimestamp_2eproto_;
+} static_descriptor_initializer;
-namespace {
-
-static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN;
-static void MergeFromFail(int line) {
- ::google::protobuf::internal::MergeFromFail(__FILE__, line);
-}
-
-} // namespace
+} // namespace protobuf_google_2fprotobuf_2ftimestamp_2eproto
// ===================================================================
@@ -134,7 +127,9 @@ const int Timestamp::kNanosFieldNumber;
Timestamp::Timestamp()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2ftimestamp_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.Timestamp)
}
@@ -142,21 +137,20 @@ Timestamp::Timestamp(::google::protobuf::Arena* arena)
: ::google::protobuf::Message(),
_internal_metadata_(arena) {
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto();
+ protobuf_google_2fprotobuf_2ftimestamp_2eproto::InitDefaults();
#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Timestamp)
}
-
-void Timestamp::InitAsDefaultInstance() {
-}
-
Timestamp::Timestamp(const Timestamp& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ ::memcpy(&seconds_, &from.seconds_,
+ reinterpret_cast<char*>(&nanos_) -
+ reinterpret_cast<char*>(&seconds_) + sizeof(nanos_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.Timestamp)
}
@@ -191,44 +185,23 @@ void Timestamp::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* Timestamp::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return Timestamp_descriptor_;
+ protobuf_google_2fprotobuf_2ftimestamp_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2ftimestamp_2eproto::file_level_metadata[0].descriptor;
}
const Timestamp& Timestamp::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto();
+ protobuf_google_2fprotobuf_2ftimestamp_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<Timestamp> Timestamp_default_instance_;
-
Timestamp* Timestamp::New(::google::protobuf::Arena* arena) const {
return ::google::protobuf::Arena::CreateMessage<Timestamp>(arena);
}
void Timestamp::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Timestamp)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(Timestamp, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<Timestamp*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- ZR_(seconds_, nanos_);
-
-#undef ZR_HELPER_
-#undef ZR_
-
+ ::memset(&seconds_, 0, reinterpret_cast<char*>(&nanos_) -
+ reinterpret_cast<char*>(&seconds_) + sizeof(nanos_));
}
bool Timestamp::MergePartialFromCodedStream(
@@ -237,13 +210,14 @@ bool Timestamp::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Timestamp)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional int64 seconds = 1;
+ // int64 seconds = 1;
case 1: {
- if (tag == 8) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(8u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(
@@ -251,14 +225,13 @@ bool Timestamp::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(16)) goto parse_nanos;
break;
}
- // optional int32 nanos = 2;
+ // int32 nanos = 2;
case 2: {
- if (tag == 16) {
- parse_nanos:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(16u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
@@ -266,7 +239,6 @@ bool Timestamp::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -294,12 +266,12 @@ failure:
void Timestamp::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.Timestamp)
- // optional int64 seconds = 1;
+ // int64 seconds = 1;
if (this->seconds() != 0) {
::google::protobuf::internal::WireFormatLite::WriteInt64(1, this->seconds(), output);
}
- // optional int32 nanos = 2;
+ // int32 nanos = 2;
if (this->nanos() != 0) {
::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->nanos(), output);
}
@@ -309,14 +281,14 @@ void Timestamp::SerializeWithCachedSizes(
::google::protobuf::uint8* Timestamp::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Timestamp)
- // optional int64 seconds = 1;
+ // int64 seconds = 1;
if (this->seconds() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(1, this->seconds(), target);
}
- // optional int32 nanos = 2;
+ // int32 nanos = 2;
if (this->nanos() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->nanos(), target);
}
@@ -329,14 +301,14 @@ size_t Timestamp::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Timestamp)
size_t total_size = 0;
- // optional int64 seconds = 1;
+ // int64 seconds = 1;
if (this->seconds() != 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int64Size(
this->seconds());
}
- // optional int32 nanos = 2;
+ // int32 nanos = 2;
if (this->nanos() != 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
@@ -352,7 +324,7 @@ size_t Timestamp::ByteSizeLong() const {
void Timestamp::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Timestamp)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const Timestamp* source =
::google::protobuf::internal::DynamicCastToGenerated<const Timestamp>(
&from);
@@ -361,21 +333,14 @@ void Timestamp::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Timestamp)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void Timestamp::MergeFrom(const Timestamp& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Timestamp)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void Timestamp::UnsafeMergeFrom(const Timestamp& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
if (from.seconds() != 0) {
set_seconds(from.seconds());
}
@@ -395,11 +360,10 @@ void Timestamp::CopyFrom(const Timestamp& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Timestamp)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool Timestamp::IsInitialized() const {
-
return true;
}
@@ -408,10 +372,13 @@ void Timestamp::Swap(Timestamp* other) {
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
- Timestamp temp;
- temp.UnsafeMergeFrom(*this);
- CopyFrom(*other);
- other->CopyFrom(temp);
+ Timestamp* temp = New(GetArenaNoVirtual());
+ temp->MergeFrom(*other);
+ other->CopyFrom(*this);
+ InternalSwap(temp);
+ if (GetArenaNoVirtual() == NULL) {
+ delete temp;
+ }
}
}
void Timestamp::UnsafeArenaSwap(Timestamp* other) {
@@ -422,22 +389,18 @@ void Timestamp::UnsafeArenaSwap(Timestamp* other) {
void Timestamp::InternalSwap(Timestamp* other) {
std::swap(seconds_, other->seconds_);
std::swap(nanos_, other->nanos_);
- _internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata Timestamp::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = Timestamp_descriptor_;
- metadata.reflection = Timestamp_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2ftimestamp_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2ftimestamp_2eproto::file_level_metadata[0];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// Timestamp
-// optional int64 seconds = 1;
+// int64 seconds = 1;
void Timestamp::clear_seconds() {
seconds_ = GOOGLE_LONGLONG(0);
}
@@ -451,7 +414,7 @@ void Timestamp::set_seconds(::google::protobuf::int64 value) {
// @@protoc_insertion_point(field_set:google.protobuf.Timestamp.seconds)
}
-// optional int32 nanos = 2;
+// int32 nanos = 2;
void Timestamp::clear_nanos() {
nanos_ = 0;
}
@@ -465,9 +428,6 @@ void Timestamp::set_nanos(::google::protobuf::int32 value) {
// @@protoc_insertion_point(field_set:google.protobuf.Timestamp.nanos)
}
-inline const Timestamp* Timestamp::internal_default_instance() {
- return &Timestamp_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// @@protoc_insertion_point(namespace_scope)
diff --git a/src/google/protobuf/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h
index 1abe8d0c..e6fc09a1 100644
--- a/src/google/protobuf/timestamp.pb.h
+++ b/src/google/protobuf/timestamp.pb.h
@@ -8,37 +8,48 @@
#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3001000
+#if GOOGLE_PROTOBUF_VERSION < 3002000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
#endif
+#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata.h>
#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/extension_set.h>
+#include <google/protobuf/repeated_field.h> // IWYU pragma: export
+#include <google/protobuf/extension_set.h> // IWYU pragma: export
#include <google/protobuf/unknown_field_set.h>
// @@protoc_insertion_point(includes)
+namespace google {
+namespace protobuf {
+class Timestamp;
+class TimestampDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern TimestampDefaultTypeInternal _Timestamp_default_instance_;
+} // namespace protobuf
+} // namespace google
namespace google {
namespace protobuf {
+namespace protobuf_google_2fprotobuf_2ftimestamp_2eproto {
// Internal implementation detail -- do not call these.
-void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto();
-void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto();
-void protobuf_AssignDesc_google_2fprotobuf_2ftimestamp_2eproto();
-void protobuf_ShutdownFile_google_2fprotobuf_2ftimestamp_2eproto();
-
-class Timestamp;
+struct LIBPROTOBUF_EXPORT TableStruct {
+ static const ::google::protobuf::uint32 offsets[];
+ static void InitDefaultsImpl();
+ static void Shutdown();
+};
+void LIBPROTOBUF_EXPORT AddDescriptors();
+void LIBPROTOBUF_EXPORT InitDefaults();
+} // namespace protobuf_google_2fprotobuf_2ftimestamp_2eproto
// ===================================================================
@@ -54,47 +65,53 @@ class LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@pro
return *this;
}
- inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }
- inline void* GetMaybeArenaPointer() const {
+ inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {
+ return GetArenaNoVirtual();
+ }
+ inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {
return MaybeArenaPtr();
}
static const ::google::protobuf::Descriptor* descriptor();
static const Timestamp& default_instance();
- static const Timestamp* internal_default_instance();
+ static inline const Timestamp* internal_default_instance() {
+ return reinterpret_cast<const Timestamp*>(
+ &_Timestamp_default_instance_);
+ }
void UnsafeArenaSwap(Timestamp* other);
void Swap(Timestamp* other);
// implements Message ----------------------------------------------
- inline Timestamp* New() const { return New(NULL); }
+ inline Timestamp* New() const PROTOBUF_FINAL { return New(NULL); }
- Timestamp* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ Timestamp* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Timestamp& from);
void MergeFrom(const Timestamp& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(Timestamp* other);
- void UnsafeMergeFrom(const Timestamp& from);
protected:
explicit Timestamp(::google::protobuf::Arena* arena);
private:
@@ -109,19 +126,19 @@ class LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@pro
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
- // optional int64 seconds = 1;
+ // int64 seconds = 1;
void clear_seconds();
static const int kSecondsFieldNumber = 1;
::google::protobuf::int64 seconds() const;
void set_seconds(::google::protobuf::int64 value);
- // optional int32 nanos = 2;
+ // int32 nanos = 2;
void clear_nanos();
static const int kNanosFieldNumber = 2;
::google::protobuf::int32 nanos() const;
@@ -137,15 +154,8 @@ class LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@pro
::google::protobuf::int64 seconds_;
::google::protobuf::int32 nanos_;
mutable int _cached_size_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2ftimestamp_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2ftimestamp_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2ftimestamp_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<Timestamp> Timestamp_default_instance_;
-
// ===================================================================
@@ -154,7 +164,7 @@ extern ::google::protobuf::internal::ExplicitlyConstructed<Timestamp> Timestamp_
#if !PROTOBUF_INLINE_NOT_IN_HEADERS
// Timestamp
-// optional int64 seconds = 1;
+// int64 seconds = 1;
inline void Timestamp::clear_seconds() {
seconds_ = GOOGLE_LONGLONG(0);
}
@@ -168,7 +178,7 @@ inline void Timestamp::set_seconds(::google::protobuf::int64 value) {
// @@protoc_insertion_point(field_set:google.protobuf.Timestamp.seconds)
}
-// optional int32 nanos = 2;
+// int32 nanos = 2;
inline void Timestamp::clear_nanos() {
nanos_ = 0;
}
@@ -182,13 +192,11 @@ inline void Timestamp::set_nanos(::google::protobuf::int32 value) {
// @@protoc_insertion_point(field_set:google.protobuf.Timestamp.nanos)
}
-inline const Timestamp* Timestamp::internal_default_instance() {
- return &Timestamp_default_instance_.get();
-}
#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS
// @@protoc_insertion_point(namespace_scope)
+
} // namespace protobuf
} // namespace google
diff --git a/src/google/protobuf/type.pb.cc b/src/google/protobuf/type.pb.cc
index cc80dd92..8bf57ecf 100644
--- a/src/google/protobuf/type.pb.cc
+++ b/src/google/protobuf/type.pb.cc
@@ -19,284 +19,310 @@
namespace google {
namespace protobuf {
+class TypeDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Type> {
+} _Type_default_instance_;
+class FieldDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Field> {
+} _Field_default_instance_;
+class EnumDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Enum> {
+} _Enum_default_instance_;
+class EnumValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumValue> {
+} _EnumValue_default_instance_;
+class OptionDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Option> {
+} _Option_default_instance_;
+
+namespace protobuf_google_2fprotobuf_2ftype_2eproto {
+
namespace {
-const ::google::protobuf::Descriptor* Type_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- Type_reflection_ = NULL;
-const ::google::protobuf::Descriptor* Field_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- Field_reflection_ = NULL;
-const ::google::protobuf::EnumDescriptor* Field_Kind_descriptor_ = NULL;
-const ::google::protobuf::EnumDescriptor* Field_Cardinality_descriptor_ = NULL;
-const ::google::protobuf::Descriptor* Enum_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- Enum_reflection_ = NULL;
-const ::google::protobuf::Descriptor* EnumValue_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- EnumValue_reflection_ = NULL;
-const ::google::protobuf::Descriptor* Option_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- Option_reflection_ = NULL;
-const ::google::protobuf::EnumDescriptor* Syntax_descriptor_ = NULL;
+::google::protobuf::Metadata file_level_metadata[5];
+const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors[3];
} // namespace
-
-void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto() GOOGLE_ATTRIBUTE_COLD;
-void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto() {
- protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto();
- const ::google::protobuf::FileDescriptor* file =
- ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
- "google/protobuf/type.proto");
- GOOGLE_CHECK(file != NULL);
- Type_descriptor_ = file->message_type(0);
- static const int Type_offsets_[6] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, fields_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, oneofs_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, options_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, source_context_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, syntax_),
- };
- Type_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- Type_descriptor_,
- Type::internal_default_instance(),
- Type_offsets_,
- -1,
- -1,
- -1,
- sizeof(Type),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, _internal_metadata_));
- Field_descriptor_ = file->message_type(1);
- static const int Field_offsets_[10] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, kind_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, cardinality_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, number_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, type_url_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, oneof_index_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, packed_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, options_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, json_name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, default_value_),
- };
- Field_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- Field_descriptor_,
- Field::internal_default_instance(),
- Field_offsets_,
- -1,
- -1,
- -1,
- sizeof(Field),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, _internal_metadata_));
- Field_Kind_descriptor_ = Field_descriptor_->enum_type(0);
- Field_Cardinality_descriptor_ = Field_descriptor_->enum_type(1);
- Enum_descriptor_ = file->message_type(2);
- static const int Enum_offsets_[5] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, enumvalue_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, options_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, source_context_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, syntax_),
- };
- Enum_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- Enum_descriptor_,
- Enum::internal_default_instance(),
- Enum_offsets_,
- -1,
- -1,
- -1,
- sizeof(Enum),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, _internal_metadata_));
- EnumValue_descriptor_ = file->message_type(3);
- static const int EnumValue_offsets_[3] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, number_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, options_),
- };
- EnumValue_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- EnumValue_descriptor_,
- EnumValue::internal_default_instance(),
- EnumValue_offsets_,
- -1,
- -1,
- -1,
- sizeof(EnumValue),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, _internal_metadata_));
- Option_descriptor_ = file->message_type(4);
- static const int Option_offsets_[2] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, value_),
- };
- Option_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- Option_descriptor_,
- Option::internal_default_instance(),
- Option_offsets_,
- -1,
- -1,
- -1,
- sizeof(Option),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, _internal_metadata_));
- Syntax_descriptor_ = file->enum_type(0);
-}
+const ::google::protobuf::uint32 TableStruct::offsets[] = {
+ ~0u, // no _has_bits_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, fields_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, oneofs_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, options_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, source_context_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, syntax_),
+ ~0u, // no _has_bits_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, kind_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, cardinality_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, number_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, type_url_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, oneof_index_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, packed_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, options_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, json_name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, default_value_),
+ ~0u, // no _has_bits_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, enumvalue_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, options_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, source_context_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, syntax_),
+ ~0u, // no _has_bits_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, number_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, options_),
+ ~0u, // no _has_bits_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, value_),
+};
+
+static const ::google::protobuf::internal::MigrationSchema schemas[] = {
+ { 0, -1, sizeof(Type)},
+ { 10, -1, sizeof(Field)},
+ { 24, -1, sizeof(Enum)},
+ { 33, -1, sizeof(EnumValue)},
+ { 40, -1, sizeof(Option)},
+};
+
+static ::google::protobuf::Message const * const file_default_instances[] = {
+ reinterpret_cast<const ::google::protobuf::Message*>(&_Type_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_Field_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_Enum_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_EnumValue_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_Option_default_instance_),
+};
namespace {
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
+void protobuf_AssignDescriptors() {
+ AddDescriptors();
+ ::google::protobuf::MessageFactory* factory = NULL;
+ AssignDescriptors(
+ "google/protobuf/type.proto", schemas, file_default_instances, TableStruct::offsets, factory,
+ file_level_metadata, file_level_enum_descriptors, NULL);
+}
+
void protobuf_AssignDescriptorsOnce() {
- ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
- &protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto);
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);
}
void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;
void protobuf_RegisterTypes(const ::std::string&) {
protobuf_AssignDescriptorsOnce();
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- Type_descriptor_, Type::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- Field_descriptor_, Field::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- Enum_descriptor_, Enum::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- EnumValue_descriptor_, EnumValue::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- Option_descriptor_, Option::internal_default_instance());
+ ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 5);
}
} // namespace
-void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto() {
- Type_default_instance_.Shutdown();
- delete Type_reflection_;
- Field_default_instance_.Shutdown();
- delete Field_reflection_;
- Enum_default_instance_.Shutdown();
- delete Enum_reflection_;
- EnumValue_default_instance_.Shutdown();
- delete EnumValue_reflection_;
- Option_default_instance_.Shutdown();
- delete Option_reflection_;
+void TableStruct::Shutdown() {
+ _Type_default_instance_.Shutdown();
+ delete file_level_metadata[0].reflection;
+ _Field_default_instance_.Shutdown();
+ delete file_level_metadata[1].reflection;
+ _Enum_default_instance_.Shutdown();
+ delete file_level_metadata[2].reflection;
+ _EnumValue_default_instance_.Shutdown();
+ delete file_level_metadata[3].reflection;
+ _Option_default_instance_.Shutdown();
+ delete file_level_metadata[4].reflection;
}
-void protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl() {
+void TableStruct::InitDefaultsImpl() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
- ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto();
- ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto();
- ::google::protobuf::internal::GetEmptyString();
- Type_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- Field_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- Enum_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- EnumValue_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- Option_default_instance_.DefaultConstruct();
- Type_default_instance_.get_mutable()->InitAsDefaultInstance();
- Field_default_instance_.get_mutable()->InitAsDefaultInstance();
- Enum_default_instance_.get_mutable()->InitAsDefaultInstance();
- EnumValue_default_instance_.get_mutable()->InitAsDefaultInstance();
- Option_default_instance_.get_mutable()->InitAsDefaultInstance();
-}
-
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_once_);
-void protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto() {
- ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_once_,
- &protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl);
-}
-void protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl() {
- GOOGLE_PROTOBUF_VERIFY_VERSION;
+ ::google::protobuf::internal::InitProtobufDefaults();
+ ::google::protobuf::protobuf_google_2fprotobuf_2fany_2eproto::InitDefaults();
+ ::google::protobuf::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::InitDefaults();
+ _Type_default_instance_.DefaultConstruct();
+ _Field_default_instance_.DefaultConstruct();
+ _Enum_default_instance_.DefaultConstruct();
+ _EnumValue_default_instance_.DefaultConstruct();
+ _Option_default_instance_.DefaultConstruct();
+ _Type_default_instance_.get_mutable()->source_context_ = const_cast< ::google::protobuf::SourceContext*>(
+ ::google::protobuf::SourceContext::internal_default_instance());
+ _Enum_default_instance_.get_mutable()->source_context_ = const_cast< ::google::protobuf::SourceContext*>(
+ ::google::protobuf::SourceContext::internal_default_instance());
+ _Option_default_instance_.get_mutable()->value_ = const_cast< ::google::protobuf::Any*>(
+ ::google::protobuf::Any::internal_default_instance());
+}
- protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+void InitDefaults() {
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);
+}
+void AddDescriptorsImpl() {
+ InitDefaults();
+ static const char descriptor[] = {
+ "\n\032google/protobuf/type.proto\022\017google.pro"
+ "tobuf\032\031google/protobuf/any.proto\032$google"
+ "/protobuf/source_context.proto\"\327\001\n\004Type\022"
+ "\014\n\004name\030\001 \001(\t\022&\n\006fields\030\002 \003(\0132\026.google.p"
+ "rotobuf.Field\022\016\n\006oneofs\030\003 \003(\t\022(\n\007options"
+ "\030\004 \003(\0132\027.google.protobuf.Option\0226\n\016sourc"
+ "e_context\030\005 \001(\0132\036.google.protobuf.Source"
+ "Context\022\'\n\006syntax\030\006 \001(\0162\027.google.protobu"
+ "f.Syntax\"\325\005\n\005Field\022)\n\004kind\030\001 \001(\0162\033.googl"
+ "e.protobuf.Field.Kind\0227\n\013cardinality\030\002 \001"
+ "(\0162\".google.protobuf.Field.Cardinality\022\016"
+ "\n\006number\030\003 \001(\005\022\014\n\004name\030\004 \001(\t\022\020\n\010type_url"
+ "\030\006 \001(\t\022\023\n\013oneof_index\030\007 \001(\005\022\016\n\006packed\030\010 "
+ "\001(\010\022(\n\007options\030\t \003(\0132\027.google.protobuf.O"
+ "ption\022\021\n\tjson_name\030\n \001(\t\022\025\n\rdefault_valu"
+ "e\030\013 \001(\t\"\310\002\n\004Kind\022\020\n\014TYPE_UNKNOWN\020\000\022\017\n\013TY"
+ "PE_DOUBLE\020\001\022\016\n\nTYPE_FLOAT\020\002\022\016\n\nTYPE_INT6"
+ "4\020\003\022\017\n\013TYPE_UINT64\020\004\022\016\n\nTYPE_INT32\020\005\022\020\n\014"
+ "TYPE_FIXED64\020\006\022\020\n\014TYPE_FIXED32\020\007\022\r\n\tTYPE"
+ "_BOOL\020\010\022\017\n\013TYPE_STRING\020\t\022\016\n\nTYPE_GROUP\020\n"
+ "\022\020\n\014TYPE_MESSAGE\020\013\022\016\n\nTYPE_BYTES\020\014\022\017\n\013TY"
+ "PE_UINT32\020\r\022\r\n\tTYPE_ENUM\020\016\022\021\n\rTYPE_SFIXE"
+ "D32\020\017\022\021\n\rTYPE_SFIXED64\020\020\022\017\n\013TYPE_SINT32\020"
+ "\021\022\017\n\013TYPE_SINT64\020\022\"t\n\013Cardinality\022\027\n\023CAR"
+ "DINALITY_UNKNOWN\020\000\022\030\n\024CARDINALITY_OPTION"
+ "AL\020\001\022\030\n\024CARDINALITY_REQUIRED\020\002\022\030\n\024CARDIN"
+ "ALITY_REPEATED\020\003\"\316\001\n\004Enum\022\014\n\004name\030\001 \001(\t\022"
+ "-\n\tenumvalue\030\002 \003(\0132\032.google.protobuf.Enu"
+ "mValue\022(\n\007options\030\003 \003(\0132\027.google.protobu"
+ "f.Option\0226\n\016source_context\030\004 \001(\0132\036.googl"
+ "e.protobuf.SourceContext\022\'\n\006syntax\030\005 \001(\016"
+ "2\027.google.protobuf.Syntax\"S\n\tEnumValue\022\014"
+ "\n\004name\030\001 \001(\t\022\016\n\006number\030\002 \001(\005\022(\n\007options\030"
+ "\003 \003(\0132\027.google.protobuf.Option\";\n\006Option"
+ "\022\014\n\004name\030\001 \001(\t\022#\n\005value\030\002 \001(\0132\024.google.p"
+ "rotobuf.Any*.\n\006Syntax\022\021\n\rSYNTAX_PROTO2\020\000"
+ "\022\021\n\rSYNTAX_PROTO3\020\001B}\n\023com.google.protob"
+ "ufB\tTypeProtoP\001Z/google.golang.org/genpr"
+ "oto/protobuf/ptype;ptype\370\001\001\242\002\003GPB\252\002\036Goog"
+ "le.Protobuf.WellKnownTypesb\006proto3"
+ };
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
- "\n\032google/protobuf/type.proto\022\017google.pro"
- "tobuf\032\031google/protobuf/any.proto\032$google"
- "/protobuf/source_context.proto\"\327\001\n\004Type\022"
- "\014\n\004name\030\001 \001(\t\022&\n\006fields\030\002 \003(\0132\026.google.p"
- "rotobuf.Field\022\016\n\006oneofs\030\003 \003(\t\022(\n\007options"
- "\030\004 \003(\0132\027.google.protobuf.Option\0226\n\016sourc"
- "e_context\030\005 \001(\0132\036.google.protobuf.Source"
- "Context\022\'\n\006syntax\030\006 \001(\0162\027.google.protobu"
- "f.Syntax\"\325\005\n\005Field\022)\n\004kind\030\001 \001(\0162\033.googl"
- "e.protobuf.Field.Kind\0227\n\013cardinality\030\002 \001"
- "(\0162\".google.protobuf.Field.Cardinality\022\016"
- "\n\006number\030\003 \001(\005\022\014\n\004name\030\004 \001(\t\022\020\n\010type_url"
- "\030\006 \001(\t\022\023\n\013oneof_index\030\007 \001(\005\022\016\n\006packed\030\010 "
- "\001(\010\022(\n\007options\030\t \003(\0132\027.google.protobuf.O"
- "ption\022\021\n\tjson_name\030\n \001(\t\022\025\n\rdefault_valu"
- "e\030\013 \001(\t\"\310\002\n\004Kind\022\020\n\014TYPE_UNKNOWN\020\000\022\017\n\013TY"
- "PE_DOUBLE\020\001\022\016\n\nTYPE_FLOAT\020\002\022\016\n\nTYPE_INT6"
- "4\020\003\022\017\n\013TYPE_UINT64\020\004\022\016\n\nTYPE_INT32\020\005\022\020\n\014"
- "TYPE_FIXED64\020\006\022\020\n\014TYPE_FIXED32\020\007\022\r\n\tTYPE"
- "_BOOL\020\010\022\017\n\013TYPE_STRING\020\t\022\016\n\nTYPE_GROUP\020\n"
- "\022\020\n\014TYPE_MESSAGE\020\013\022\016\n\nTYPE_BYTES\020\014\022\017\n\013TY"
- "PE_UINT32\020\r\022\r\n\tTYPE_ENUM\020\016\022\021\n\rTYPE_SFIXE"
- "D32\020\017\022\021\n\rTYPE_SFIXED64\020\020\022\017\n\013TYPE_SINT32\020"
- "\021\022\017\n\013TYPE_SINT64\020\022\"t\n\013Cardinality\022\027\n\023CAR"
- "DINALITY_UNKNOWN\020\000\022\030\n\024CARDINALITY_OPTION"
- "AL\020\001\022\030\n\024CARDINALITY_REQUIRED\020\002\022\030\n\024CARDIN"
- "ALITY_REPEATED\020\003\"\316\001\n\004Enum\022\014\n\004name\030\001 \001(\t\022"
- "-\n\tenumvalue\030\002 \003(\0132\032.google.protobuf.Enu"
- "mValue\022(\n\007options\030\003 \003(\0132\027.google.protobu"
- "f.Option\0226\n\016source_context\030\004 \001(\0132\036.googl"
- "e.protobuf.SourceContext\022\'\n\006syntax\030\005 \001(\016"
- "2\027.google.protobuf.Syntax\"S\n\tEnumValue\022\014"
- "\n\004name\030\001 \001(\t\022\016\n\006number\030\002 \001(\005\022(\n\007options\030"
- "\003 \003(\0132\027.google.protobuf.Option\";\n\006Option"
- "\022\014\n\004name\030\001 \001(\t\022#\n\005value\030\002 \001(\0132\024.google.p"
- "rotobuf.Any*.\n\006Syntax\022\021\n\rSYNTAX_PROTO2\020\000"
- "\022\021\n\rSYNTAX_PROTO3\020\001BL\n\023com.google.protob"
- "ufB\tTypeProtoP\001\370\001\001\242\002\003GPB\252\002\036Google.Protob"
- "uf.WellKnownTypesb\006proto3", 1545);
+ descriptor, 1594);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"google/protobuf/type.proto", &protobuf_RegisterTypes);
- ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fany_2eproto();
- ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto();
- ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto);
+ ::google::protobuf::protobuf_google_2fprotobuf_2fany_2eproto::AddDescriptors();
+ ::google::protobuf::protobuf_google_2fprotobuf_2fsource_5fcontext_2eproto::AddDescriptors();
+ ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);
}
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_once_);
-void protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto() {
- ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_once_,
- &protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl);
+void AddDescriptors() {
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
}
// Force AddDescriptors() to be called at static initialization time.
-struct StaticDescriptorInitializer_google_2fprotobuf_2ftype_2eproto {
- StaticDescriptorInitializer_google_2fprotobuf_2ftype_2eproto() {
- protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto();
+struct StaticDescriptorInitializer {
+ StaticDescriptorInitializer() {
+ AddDescriptors();
}
-} static_descriptor_initializer_google_2fprotobuf_2ftype_2eproto_;
-const ::google::protobuf::EnumDescriptor* Syntax_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return Syntax_descriptor_;
+} static_descriptor_initializer;
+
+} // namespace protobuf_google_2fprotobuf_2ftype_2eproto
+
+const ::google::protobuf::EnumDescriptor* Field_Kind_descriptor() {
+ protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_enum_descriptors[0];
}
-bool Syntax_IsValid(int value) {
+bool Field_Kind_IsValid(int value) {
switch (value) {
case 0:
case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ case 10:
+ case 11:
+ case 12:
+ case 13:
+ case 14:
+ case 15:
+ case 16:
+ case 17:
+ case 18:
return true;
default:
return false;
}
}
-
-namespace {
-
-static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN;
-static void MergeFromFail(int line) {
- ::google::protobuf::internal::MergeFromFail(__FILE__, line);
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const Field_Kind Field::TYPE_UNKNOWN;
+const Field_Kind Field::TYPE_DOUBLE;
+const Field_Kind Field::TYPE_FLOAT;
+const Field_Kind Field::TYPE_INT64;
+const Field_Kind Field::TYPE_UINT64;
+const Field_Kind Field::TYPE_INT32;
+const Field_Kind Field::TYPE_FIXED64;
+const Field_Kind Field::TYPE_FIXED32;
+const Field_Kind Field::TYPE_BOOL;
+const Field_Kind Field::TYPE_STRING;
+const Field_Kind Field::TYPE_GROUP;
+const Field_Kind Field::TYPE_MESSAGE;
+const Field_Kind Field::TYPE_BYTES;
+const Field_Kind Field::TYPE_UINT32;
+const Field_Kind Field::TYPE_ENUM;
+const Field_Kind Field::TYPE_SFIXED32;
+const Field_Kind Field::TYPE_SFIXED64;
+const Field_Kind Field::TYPE_SINT32;
+const Field_Kind Field::TYPE_SINT64;
+const Field_Kind Field::Kind_MIN;
+const Field_Kind Field::Kind_MAX;
+const int Field::Kind_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+const ::google::protobuf::EnumDescriptor* Field_Cardinality_descriptor() {
+ protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_enum_descriptors[1];
+}
+bool Field_Cardinality_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ return true;
+ default:
+ return false;
+ }
}
-} // namespace
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const Field_Cardinality Field::CARDINALITY_UNKNOWN;
+const Field_Cardinality Field::CARDINALITY_OPTIONAL;
+const Field_Cardinality Field::CARDINALITY_REQUIRED;
+const Field_Cardinality Field::CARDINALITY_REPEATED;
+const Field_Cardinality Field::Cardinality_MIN;
+const Field_Cardinality Field::Cardinality_MAX;
+const int Field::Cardinality_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+const ::google::protobuf::EnumDescriptor* Syntax_descriptor() {
+ protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_enum_descriptors[2];
+}
+bool Syntax_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ return true;
+ default:
+ return false;
+ }
+}
// ===================================================================
@@ -345,7 +371,9 @@ const int Type::kSyntaxFieldNumber;
Type::Type()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.Type)
}
@@ -356,30 +384,38 @@ Type::Type(::google::protobuf::Arena* arena)
oneofs_(arena),
options_(arena) {
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+ protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Type)
}
-
-void Type::InitAsDefaultInstance() {
- source_context_ = const_cast< ::google::protobuf::SourceContext*>(
- ::google::protobuf::SourceContext::internal_default_instance());
-}
-
Type::Type(const Type& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ fields_(from.fields_),
+ oneofs_(from.oneofs_),
+ options_(from.options_),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.name().size() > 0) {
+ name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name(),
+ GetArenaNoVirtual());
+ }
+ if (from.has_source_context()) {
+ source_context_ = new ::google::protobuf::SourceContext(*from.source_context_);
+ } else {
+ source_context_ = NULL;
+ }
+ syntax_ = from.syntax_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.Type)
}
void Type::SharedCtor() {
name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- source_context_ = NULL;
- syntax_ = 0;
+ ::memset(&source_context_, 0, reinterpret_cast<char*>(&syntax_) -
+ reinterpret_cast<char*>(&source_context_) + sizeof(syntax_));
_cached_size_ = 0;
}
@@ -395,7 +431,7 @@ void Type::SharedDtor() {
}
name_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena);
- if (this != &Type_default_instance_.get()) {
+ if (this != internal_default_instance()) {
delete source_context_;
}
}
@@ -412,30 +448,30 @@ void Type::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* Type::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return Type_descriptor_;
+ protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[0].descriptor;
}
const Type& Type::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+ protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<Type> Type_default_instance_;
-
Type* Type::New(::google::protobuf::Arena* arena) const {
return ::google::protobuf::Arena::CreateMessage<Type>(arena);
}
void Type::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Type)
- name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
- if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_;
- source_context_ = NULL;
- syntax_ = 0;
fields_.Clear();
oneofs_.Clear();
options_.Clear();
+ name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
+ if (GetArenaNoVirtual() == NULL && source_context_ != NULL) {
+ delete source_context_;
+ }
+ source_context_ = NULL;
+ syntax_ = 0;
}
bool Type::MergePartialFromCodedStream(
@@ -444,13 +480,14 @@ bool Type::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Type)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional string name = 1;
+ // string name = 1;
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name()));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
@@ -460,31 +497,27 @@ bool Type::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(18)) goto parse_fields;
break;
}
// repeated .google.protobuf.Field fields = 2;
case 2: {
- if (tag == 18) {
- parse_fields:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(18u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_fields:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_fields()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(18)) goto parse_loop_fields;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectTag(26)) goto parse_oneofs;
break;
}
// repeated string oneofs = 3;
case 3: {
- if (tag == 26) {
- parse_oneofs:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(26u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->add_oneofs()));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
@@ -495,45 +528,39 @@ bool Type::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(26)) goto parse_oneofs;
- if (input->ExpectTag(34)) goto parse_options;
break;
}
// repeated .google.protobuf.Option options = 4;
case 4: {
- if (tag == 34) {
- parse_options:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(34u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_options:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_options()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(34)) goto parse_loop_options;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectTag(42)) goto parse_source_context;
break;
}
- // optional .google.protobuf.SourceContext source_context = 5;
+ // .google.protobuf.SourceContext source_context = 5;
case 5: {
- if (tag == 42) {
- parse_source_context:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(42u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_source_context()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(48)) goto parse_syntax;
break;
}
- // optional .google.protobuf.Syntax syntax = 6;
+ // .google.protobuf.Syntax syntax = 6;
case 6: {
- if (tag == 48) {
- parse_syntax:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(48u)) {
int value;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
@@ -542,7 +569,6 @@ bool Type::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -570,7 +596,7 @@ failure:
void Type::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.Type)
- // optional string name = 1;
+ // string name = 1;
if (this->name().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->name().data(), this->name().length(),
@@ -587,7 +613,7 @@ void Type::SerializeWithCachedSizes(
}
// repeated string oneofs = 3;
- for (int i = 0; i < this->oneofs_size(); i++) {
+ for (int i = 0, n = this->oneofs_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->oneofs(i).data(), this->oneofs(i).length(),
::google::protobuf::internal::WireFormatLite::SERIALIZE,
@@ -602,13 +628,13 @@ void Type::SerializeWithCachedSizes(
4, this->options(i), output);
}
- // optional .google.protobuf.SourceContext source_context = 5;
+ // .google.protobuf.SourceContext source_context = 5;
if (this->has_source_context()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
5, *this->source_context_, output);
}
- // optional .google.protobuf.Syntax syntax = 6;
+ // .google.protobuf.Syntax syntax = 6;
if (this->syntax() != 0) {
::google::protobuf::internal::WireFormatLite::WriteEnum(
6, this->syntax(), output);
@@ -619,9 +645,9 @@ void Type::SerializeWithCachedSizes(
::google::protobuf::uint8* Type::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Type)
- // optional string name = 1;
+ // string name = 1;
if (this->name().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->name().data(), this->name().length(),
@@ -640,7 +666,7 @@ void Type::SerializeWithCachedSizes(
}
// repeated string oneofs = 3;
- for (int i = 0; i < this->oneofs_size(); i++) {
+ for (int i = 0, n = this->oneofs_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->oneofs(i).data(), this->oneofs(i).length(),
::google::protobuf::internal::WireFormatLite::SERIALIZE,
@@ -656,14 +682,14 @@ void Type::SerializeWithCachedSizes(
4, this->options(i), false, target);
}
- // optional .google.protobuf.SourceContext source_context = 5;
+ // .google.protobuf.SourceContext source_context = 5;
if (this->has_source_context()) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
5, *this->source_context_, false, target);
}
- // optional .google.protobuf.Syntax syntax = 6;
+ // .google.protobuf.Syntax syntax = 6;
if (this->syntax() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
6, this->syntax(), target);
@@ -677,26 +703,6 @@ size_t Type::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Type)
size_t total_size = 0;
- // optional string name = 1;
- if (this->name().size() > 0) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->name());
- }
-
- // optional .google.protobuf.SourceContext source_context = 5;
- if (this->has_source_context()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->source_context_);
- }
-
- // optional .google.protobuf.Syntax syntax = 6;
- if (this->syntax() != 0) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->syntax());
- }
-
// repeated .google.protobuf.Field fields = 2;
{
unsigned int count = this->fields_size();
@@ -711,7 +717,7 @@ size_t Type::ByteSizeLong() const {
// repeated string oneofs = 3;
total_size += 1 *
::google::protobuf::internal::FromIntSize(this->oneofs_size());
- for (int i = 0; i < this->oneofs_size(); i++) {
+ for (int i = 0, n = this->oneofs_size(); i < n; i++) {
total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
this->oneofs(i));
}
@@ -727,6 +733,26 @@ size_t Type::ByteSizeLong() const {
}
}
+ // string name = 1;
+ if (this->name().size() > 0) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->name());
+ }
+
+ // .google.protobuf.SourceContext source_context = 5;
+ if (this->has_source_context()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->source_context_);
+ }
+
+ // .google.protobuf.Syntax syntax = 6;
+ if (this->syntax() != 0) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->syntax());
+ }
+
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
@@ -736,7 +762,7 @@ size_t Type::ByteSizeLong() const {
void Type::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Type)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const Type* source =
::google::protobuf::internal::DynamicCastToGenerated<const Type>(
&from);
@@ -745,23 +771,16 @@ void Type::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Type)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void Type::MergeFrom(const Type& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Type)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void Type::UnsafeMergeFrom(const Type& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
fields_.MergeFrom(from.fields_);
- oneofs_.UnsafeMergeFrom(from.oneofs_);
+ oneofs_.MergeFrom(from.oneofs_);
options_.MergeFrom(from.options_);
if (from.name().size() > 0) {
set_name(from.name());
@@ -785,11 +804,10 @@ void Type::CopyFrom(const Type& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Type)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool Type::IsInitialized() const {
-
return true;
}
@@ -798,10 +816,13 @@ void Type::Swap(Type* other) {
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
- Type temp;
- temp.UnsafeMergeFrom(*this);
- CopyFrom(*other);
- other->CopyFrom(temp);
+ Type* temp = New(GetArenaNoVirtual());
+ temp->MergeFrom(*other);
+ other->CopyFrom(*this);
+ InternalSwap(temp);
+ if (GetArenaNoVirtual() == NULL) {
+ delete temp;
+ }
}
}
void Type::UnsafeArenaSwap(Type* other) {
@@ -810,34 +831,30 @@ void Type::UnsafeArenaSwap(Type* other) {
InternalSwap(other);
}
void Type::InternalSwap(Type* other) {
- name_.Swap(&other->name_);
fields_.UnsafeArenaSwap(&other->fields_);
oneofs_.UnsafeArenaSwap(&other->oneofs_);
options_.UnsafeArenaSwap(&other->options_);
+ name_.Swap(&other->name_);
std::swap(source_context_, other->source_context_);
std::swap(syntax_, other->syntax_);
- _internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata Type::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = Type_descriptor_;
- metadata.reflection = Type_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[0];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// Type
-// optional string name = 1;
+// string name = 1;
void Type::clear_name() {
name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
}
const ::std::string& Type::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.Type.name)
- return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.Get();
}
void Type::set_name(const ::std::string& value) {
@@ -946,6 +963,12 @@ void Type::set_oneofs(int index, const ::std::string& value) {
// @@protoc_insertion_point(field_set:google.protobuf.Type.oneofs)
oneofs_.Mutable(index)->assign(value);
}
+#if LANG_CXX11
+void Type::set_oneofs(int index, ::std::string&& value) {
+ // @@protoc_insertion_point(field_set:google.protobuf.Type.oneofs)
+ oneofs_.Mutable(index)->assign(std::move(value));
+}
+#endif
void Type::set_oneofs(int index, const char* value) {
oneofs_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set_char:google.protobuf.Type.oneofs)
@@ -963,6 +986,12 @@ void Type::add_oneofs(const ::std::string& value) {
oneofs_.Add()->assign(value);
// @@protoc_insertion_point(field_add:google.protobuf.Type.oneofs)
}
+#if LANG_CXX11
+void Type::add_oneofs(::std::string&& value) {
+ oneofs_.Add()->assign(std::move(value));
+ // @@protoc_insertion_point(field_add:google.protobuf.Type.oneofs)
+}
+#endif
void Type::add_oneofs(const char* value) {
oneofs_.Add()->assign(value);
// @@protoc_insertion_point(field_add_char:google.protobuf.Type.oneofs)
@@ -1012,7 +1041,7 @@ Type::options() const {
return options_;
}
-// optional .google.protobuf.SourceContext source_context = 5;
+// .google.protobuf.SourceContext source_context = 5;
bool Type::has_source_context() const {
return this != internal_default_instance() && source_context_ != NULL;
}
@@ -1063,7 +1092,7 @@ const ::google::protobuf::SourceContext& Type::source_context() const {
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.source_context)
}
-// optional .google.protobuf.Syntax syntax = 6;
+// .google.protobuf.Syntax syntax = 6;
void Type::clear_syntax() {
syntax_ = 0;
}
@@ -1077,93 +1106,10 @@ void Type::set_syntax(::google::protobuf::Syntax value) {
// @@protoc_insertion_point(field_set:google.protobuf.Type.syntax)
}
-inline const Type* Type::internal_default_instance() {
- return &Type_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
-const ::google::protobuf::EnumDescriptor* Field_Kind_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return Field_Kind_descriptor_;
-}
-bool Field_Kind_IsValid(int value) {
- switch (value) {
- case 0:
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- case 10:
- case 11:
- case 12:
- case 13:
- case 14:
- case 15:
- case 16:
- case 17:
- case 18:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const Field_Kind Field::TYPE_UNKNOWN;
-const Field_Kind Field::TYPE_DOUBLE;
-const Field_Kind Field::TYPE_FLOAT;
-const Field_Kind Field::TYPE_INT64;
-const Field_Kind Field::TYPE_UINT64;
-const Field_Kind Field::TYPE_INT32;
-const Field_Kind Field::TYPE_FIXED64;
-const Field_Kind Field::TYPE_FIXED32;
-const Field_Kind Field::TYPE_BOOL;
-const Field_Kind Field::TYPE_STRING;
-const Field_Kind Field::TYPE_GROUP;
-const Field_Kind Field::TYPE_MESSAGE;
-const Field_Kind Field::TYPE_BYTES;
-const Field_Kind Field::TYPE_UINT32;
-const Field_Kind Field::TYPE_ENUM;
-const Field_Kind Field::TYPE_SFIXED32;
-const Field_Kind Field::TYPE_SFIXED64;
-const Field_Kind Field::TYPE_SINT32;
-const Field_Kind Field::TYPE_SINT64;
-const Field_Kind Field::Kind_MIN;
-const Field_Kind Field::Kind_MAX;
-const int Field::Kind_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-const ::google::protobuf::EnumDescriptor* Field_Cardinality_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return Field_Cardinality_descriptor_;
-}
-bool Field_Cardinality_IsValid(int value) {
- switch (value) {
- case 0:
- case 1:
- case 2:
- case 3:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const Field_Cardinality Field::CARDINALITY_UNKNOWN;
-const Field_Cardinality Field::CARDINALITY_OPTIONAL;
-const Field_Cardinality Field::CARDINALITY_REQUIRED;
-const Field_Cardinality Field::CARDINALITY_REPEATED;
-const Field_Cardinality Field::Cardinality_MIN;
-const Field_Cardinality Field::Cardinality_MAX;
-const int Field::Cardinality_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int Field::kKindFieldNumber;
const int Field::kCardinalityFieldNumber;
@@ -1179,7 +1125,9 @@ const int Field::kDefaultValueFieldNumber;
Field::Field()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.Field)
}
@@ -1188,21 +1136,41 @@ Field::Field(::google::protobuf::Arena* arena)
_internal_metadata_(arena),
options_(arena) {
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+ protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Field)
}
-
-void Field::InitAsDefaultInstance() {
-}
-
Field::Field(const Field& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ options_(from.options_),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.name().size() > 0) {
+ name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name(),
+ GetArenaNoVirtual());
+ }
+ type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.type_url().size() > 0) {
+ type_url_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_url(),
+ GetArenaNoVirtual());
+ }
+ json_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.json_name().size() > 0) {
+ json_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.json_name(),
+ GetArenaNoVirtual());
+ }
+ default_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.default_value().size() > 0) {
+ default_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.default_value(),
+ GetArenaNoVirtual());
+ }
+ ::memcpy(&kind_, &from.kind_,
+ reinterpret_cast<char*>(&packed_) -
+ reinterpret_cast<char*>(&kind_) + sizeof(packed_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.Field)
}
@@ -1245,49 +1213,28 @@ void Field::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* Field::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return Field_descriptor_;
+ protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[1].descriptor;
}
const Field& Field::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+ protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<Field> Field_default_instance_;
-
Field* Field::New(::google::protobuf::Arena* arena) const {
return ::google::protobuf::Arena::CreateMessage<Field>(arena);
}
void Field::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Field)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(Field, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<Field*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- ZR_(kind_, packed_);
+ options_.Clear();
name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
type_url_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
json_name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
default_value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
-
-#undef ZR_HELPER_
-#undef ZR_
-
- options_.Clear();
+ ::memset(&kind_, 0, reinterpret_cast<char*>(&packed_) -
+ reinterpret_cast<char*>(&kind_) + sizeof(packed_));
}
bool Field::MergePartialFromCodedStream(
@@ -1296,13 +1243,14 @@ bool Field::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Field)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional .google.protobuf.Field.Kind kind = 1;
+ // .google.protobuf.Field.Kind kind = 1;
case 1: {
- if (tag == 8) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(8u)) {
int value;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
@@ -1311,14 +1259,13 @@ bool Field::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(16)) goto parse_cardinality;
break;
}
- // optional .google.protobuf.Field.Cardinality cardinality = 2;
+ // .google.protobuf.Field.Cardinality cardinality = 2;
case 2: {
- if (tag == 16) {
- parse_cardinality:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(16u)) {
int value;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
@@ -1327,14 +1274,13 @@ bool Field::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(24)) goto parse_number;
break;
}
- // optional int32 number = 3;
+ // int32 number = 3;
case 3: {
- if (tag == 24) {
- parse_number:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(24u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
@@ -1342,14 +1288,13 @@ bool Field::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(34)) goto parse_name;
break;
}
- // optional string name = 4;
+ // string name = 4;
case 4: {
- if (tag == 34) {
- parse_name:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(34u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name()));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
@@ -1359,14 +1304,13 @@ bool Field::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(50)) goto parse_type_url;
break;
}
- // optional string type_url = 6;
+ // string type_url = 6;
case 6: {
- if (tag == 50) {
- parse_type_url:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(50u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_type_url()));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
@@ -1376,14 +1320,13 @@ bool Field::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(56)) goto parse_oneof_index;
break;
}
- // optional int32 oneof_index = 7;
+ // int32 oneof_index = 7;
case 7: {
- if (tag == 56) {
- parse_oneof_index:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(56u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
@@ -1391,14 +1334,13 @@ bool Field::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(64)) goto parse_packed;
break;
}
- // optional bool packed = 8;
+ // bool packed = 8;
case 8: {
- if (tag == 64) {
- parse_packed:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(64u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -1406,31 +1348,27 @@ bool Field::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(74)) goto parse_options;
break;
}
// repeated .google.protobuf.Option options = 9;
case 9: {
- if (tag == 74) {
- parse_options:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(74u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_options:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_options()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(74)) goto parse_loop_options;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectTag(82)) goto parse_json_name;
break;
}
- // optional string json_name = 10;
+ // string json_name = 10;
case 10: {
- if (tag == 82) {
- parse_json_name:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(82u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_json_name()));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
@@ -1440,14 +1378,13 @@ bool Field::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(90)) goto parse_default_value;
break;
}
- // optional string default_value = 11;
+ // string default_value = 11;
case 11: {
- if (tag == 90) {
- parse_default_value:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(90u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_default_value()));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
@@ -1457,7 +1394,6 @@ bool Field::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -1485,24 +1421,24 @@ failure:
void Field::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.Field)
- // optional .google.protobuf.Field.Kind kind = 1;
+ // .google.protobuf.Field.Kind kind = 1;
if (this->kind() != 0) {
::google::protobuf::internal::WireFormatLite::WriteEnum(
1, this->kind(), output);
}
- // optional .google.protobuf.Field.Cardinality cardinality = 2;
+ // .google.protobuf.Field.Cardinality cardinality = 2;
if (this->cardinality() != 0) {
::google::protobuf::internal::WireFormatLite::WriteEnum(
2, this->cardinality(), output);
}
- // optional int32 number = 3;
+ // int32 number = 3;
if (this->number() != 0) {
::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->number(), output);
}
- // optional string name = 4;
+ // string name = 4;
if (this->name().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->name().data(), this->name().length(),
@@ -1512,7 +1448,7 @@ void Field::SerializeWithCachedSizes(
4, this->name(), output);
}
- // optional string type_url = 6;
+ // string type_url = 6;
if (this->type_url().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->type_url().data(), this->type_url().length(),
@@ -1522,12 +1458,12 @@ void Field::SerializeWithCachedSizes(
6, this->type_url(), output);
}
- // optional int32 oneof_index = 7;
+ // int32 oneof_index = 7;
if (this->oneof_index() != 0) {
::google::protobuf::internal::WireFormatLite::WriteInt32(7, this->oneof_index(), output);
}
- // optional bool packed = 8;
+ // bool packed = 8;
if (this->packed() != 0) {
::google::protobuf::internal::WireFormatLite::WriteBool(8, this->packed(), output);
}
@@ -1538,7 +1474,7 @@ void Field::SerializeWithCachedSizes(
9, this->options(i), output);
}
- // optional string json_name = 10;
+ // string json_name = 10;
if (this->json_name().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->json_name().data(), this->json_name().length(),
@@ -1548,7 +1484,7 @@ void Field::SerializeWithCachedSizes(
10, this->json_name(), output);
}
- // optional string default_value = 11;
+ // string default_value = 11;
if (this->default_value().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->default_value().data(), this->default_value().length(),
@@ -1563,26 +1499,26 @@ void Field::SerializeWithCachedSizes(
::google::protobuf::uint8* Field::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Field)
- // optional .google.protobuf.Field.Kind kind = 1;
+ // .google.protobuf.Field.Kind kind = 1;
if (this->kind() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
1, this->kind(), target);
}
- // optional .google.protobuf.Field.Cardinality cardinality = 2;
+ // .google.protobuf.Field.Cardinality cardinality = 2;
if (this->cardinality() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
2, this->cardinality(), target);
}
- // optional int32 number = 3;
+ // int32 number = 3;
if (this->number() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->number(), target);
}
- // optional string name = 4;
+ // string name = 4;
if (this->name().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->name().data(), this->name().length(),
@@ -1593,7 +1529,7 @@ void Field::SerializeWithCachedSizes(
4, this->name(), target);
}
- // optional string type_url = 6;
+ // string type_url = 6;
if (this->type_url().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->type_url().data(), this->type_url().length(),
@@ -1604,12 +1540,12 @@ void Field::SerializeWithCachedSizes(
6, this->type_url(), target);
}
- // optional int32 oneof_index = 7;
+ // int32 oneof_index = 7;
if (this->oneof_index() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(7, this->oneof_index(), target);
}
- // optional bool packed = 8;
+ // bool packed = 8;
if (this->packed() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(8, this->packed(), target);
}
@@ -1621,7 +1557,7 @@ void Field::SerializeWithCachedSizes(
9, this->options(i), false, target);
}
- // optional string json_name = 10;
+ // string json_name = 10;
if (this->json_name().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->json_name().data(), this->json_name().length(),
@@ -1632,7 +1568,7 @@ void Field::SerializeWithCachedSizes(
10, this->json_name(), target);
}
- // optional string default_value = 11;
+ // string default_value = 11;
if (this->default_value().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->default_value().data(), this->default_value().length(),
@@ -1651,74 +1587,74 @@ size_t Field::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Field)
size_t total_size = 0;
- // optional .google.protobuf.Field.Kind kind = 1;
- if (this->kind() != 0) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->kind());
+ // repeated .google.protobuf.Option options = 9;
+ {
+ unsigned int count = this->options_size();
+ total_size += 1UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->options(i));
+ }
}
- // optional .google.protobuf.Field.Cardinality cardinality = 2;
- if (this->cardinality() != 0) {
+ // string name = 4;
+ if (this->name().size() > 0) {
total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->cardinality());
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->name());
}
- // optional int32 number = 3;
- if (this->number() != 0) {
+ // string type_url = 6;
+ if (this->type_url().size() > 0) {
total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->number());
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->type_url());
}
- // optional string name = 4;
- if (this->name().size() > 0) {
+ // string json_name = 10;
+ if (this->json_name().size() > 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
- this->name());
+ this->json_name());
}
- // optional string type_url = 6;
- if (this->type_url().size() > 0) {
+ // string default_value = 11;
+ if (this->default_value().size() > 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
- this->type_url());
+ this->default_value());
}
- // optional int32 oneof_index = 7;
- if (this->oneof_index() != 0) {
+ // .google.protobuf.Field.Kind kind = 1;
+ if (this->kind() != 0) {
total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->oneof_index());
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->kind());
}
- // optional bool packed = 8;
- if (this->packed() != 0) {
- total_size += 1 + 1;
+ // .google.protobuf.Field.Cardinality cardinality = 2;
+ if (this->cardinality() != 0) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->cardinality());
}
- // optional string json_name = 10;
- if (this->json_name().size() > 0) {
+ // int32 number = 3;
+ if (this->number() != 0) {
total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->json_name());
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->number());
}
- // optional string default_value = 11;
- if (this->default_value().size() > 0) {
+ // int32 oneof_index = 7;
+ if (this->oneof_index() != 0) {
total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->default_value());
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->oneof_index());
}
- // repeated .google.protobuf.Option options = 9;
- {
- unsigned int count = this->options_size();
- total_size += 1UL * count;
- for (unsigned int i = 0; i < count; i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->options(i));
- }
+ // bool packed = 8;
+ if (this->packed() != 0) {
+ total_size += 1 + 1;
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
@@ -1730,7 +1666,7 @@ size_t Field::ByteSizeLong() const {
void Field::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Field)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const Field* source =
::google::protobuf::internal::DynamicCastToGenerated<const Field>(
&from);
@@ -1739,22 +1675,27 @@ void Field::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Field)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void Field::MergeFrom(const Field& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Field)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void Field::UnsafeMergeFrom(const Field& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
options_.MergeFrom(from.options_);
+ if (from.name().size() > 0) {
+ set_name(from.name());
+ }
+ if (from.type_url().size() > 0) {
+ set_type_url(from.type_url());
+ }
+ if (from.json_name().size() > 0) {
+ set_json_name(from.json_name());
+ }
+ if (from.default_value().size() > 0) {
+ set_default_value(from.default_value());
+ }
if (from.kind() != 0) {
set_kind(from.kind());
}
@@ -1764,24 +1705,12 @@ void Field::UnsafeMergeFrom(const Field& from) {
if (from.number() != 0) {
set_number(from.number());
}
- if (from.name().size() > 0) {
- set_name(from.name());
- }
- if (from.type_url().size() > 0) {
- set_type_url(from.type_url());
- }
if (from.oneof_index() != 0) {
set_oneof_index(from.oneof_index());
}
if (from.packed() != 0) {
set_packed(from.packed());
}
- if (from.json_name().size() > 0) {
- set_json_name(from.json_name());
- }
- if (from.default_value().size() > 0) {
- set_default_value(from.default_value());
- }
}
void Field::CopyFrom(const ::google::protobuf::Message& from) {
@@ -1795,11 +1724,10 @@ void Field::CopyFrom(const Field& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Field)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool Field::IsInitialized() const {
-
return true;
}
@@ -1808,10 +1736,13 @@ void Field::Swap(Field* other) {
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
- Field temp;
- temp.UnsafeMergeFrom(*this);
- CopyFrom(*other);
- other->CopyFrom(temp);
+ Field* temp = New(GetArenaNoVirtual());
+ temp->MergeFrom(*other);
+ other->CopyFrom(*this);
+ InternalSwap(temp);
+ if (GetArenaNoVirtual() == NULL) {
+ delete temp;
+ }
}
}
void Field::UnsafeArenaSwap(Field* other) {
@@ -1820,32 +1751,28 @@ void Field::UnsafeArenaSwap(Field* other) {
InternalSwap(other);
}
void Field::InternalSwap(Field* other) {
+ options_.UnsafeArenaSwap(&other->options_);
+ name_.Swap(&other->name_);
+ type_url_.Swap(&other->type_url_);
+ json_name_.Swap(&other->json_name_);
+ default_value_.Swap(&other->default_value_);
std::swap(kind_, other->kind_);
std::swap(cardinality_, other->cardinality_);
std::swap(number_, other->number_);
- name_.Swap(&other->name_);
- type_url_.Swap(&other->type_url_);
std::swap(oneof_index_, other->oneof_index_);
std::swap(packed_, other->packed_);
- options_.UnsafeArenaSwap(&other->options_);
- json_name_.Swap(&other->json_name_);
- default_value_.Swap(&other->default_value_);
- _internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata Field::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = Field_descriptor_;
- metadata.reflection = Field_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[1];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// Field
-// optional .google.protobuf.Field.Kind kind = 1;
+// .google.protobuf.Field.Kind kind = 1;
void Field::clear_kind() {
kind_ = 0;
}
@@ -1859,7 +1786,7 @@ void Field::set_kind(::google::protobuf::Field_Kind value) {
// @@protoc_insertion_point(field_set:google.protobuf.Field.kind)
}
-// optional .google.protobuf.Field.Cardinality cardinality = 2;
+// .google.protobuf.Field.Cardinality cardinality = 2;
void Field::clear_cardinality() {
cardinality_ = 0;
}
@@ -1873,7 +1800,7 @@ void Field::set_cardinality(::google::protobuf::Field_Cardinality value) {
// @@protoc_insertion_point(field_set:google.protobuf.Field.cardinality)
}
-// optional int32 number = 3;
+// int32 number = 3;
void Field::clear_number() {
number_ = 0;
}
@@ -1887,13 +1814,13 @@ void Field::set_number(::google::protobuf::int32 value) {
// @@protoc_insertion_point(field_set:google.protobuf.Field.number)
}
-// optional string name = 4;
+// string name = 4;
void Field::clear_name() {
name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
}
const ::std::string& Field::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.Field.name)
- return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.Get();
}
void Field::set_name(const ::std::string& value) {
@@ -1953,13 +1880,13 @@ void Field::unsafe_arena_set_allocated_name(
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.name)
}
-// optional string type_url = 6;
+// string type_url = 6;
void Field::clear_type_url() {
type_url_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
}
const ::std::string& Field::type_url() const {
// @@protoc_insertion_point(field_get:google.protobuf.Field.type_url)
- return type_url_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return type_url_.Get();
}
void Field::set_type_url(const ::std::string& value) {
@@ -2019,7 +1946,7 @@ void Field::unsafe_arena_set_allocated_type_url(
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.type_url)
}
-// optional int32 oneof_index = 7;
+// int32 oneof_index = 7;
void Field::clear_oneof_index() {
oneof_index_ = 0;
}
@@ -2033,7 +1960,7 @@ void Field::set_oneof_index(::google::protobuf::int32 value) {
// @@protoc_insertion_point(field_set:google.protobuf.Field.oneof_index)
}
-// optional bool packed = 8;
+// bool packed = 8;
void Field::clear_packed() {
packed_ = false;
}
@@ -2077,13 +2004,13 @@ Field::options() const {
return options_;
}
-// optional string json_name = 10;
+// string json_name = 10;
void Field::clear_json_name() {
json_name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
}
const ::std::string& Field::json_name() const {
// @@protoc_insertion_point(field_get:google.protobuf.Field.json_name)
- return json_name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return json_name_.Get();
}
void Field::set_json_name(const ::std::string& value) {
@@ -2143,13 +2070,13 @@ void Field::unsafe_arena_set_allocated_json_name(
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.json_name)
}
-// optional string default_value = 11;
+// string default_value = 11;
void Field::clear_default_value() {
default_value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
}
const ::std::string& Field::default_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.Field.default_value)
- return default_value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return default_value_.Get();
}
void Field::set_default_value(const ::std::string& value) {
@@ -2209,9 +2136,6 @@ void Field::unsafe_arena_set_allocated_default_value(
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.default_value)
}
-inline const Field* Field::internal_default_instance() {
- return &Field_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -2259,7 +2183,9 @@ const int Enum::kSyntaxFieldNumber;
Enum::Enum()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.Enum)
}
@@ -2269,30 +2195,37 @@ Enum::Enum(::google::protobuf::Arena* arena)
enumvalue_(arena),
options_(arena) {
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+ protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Enum)
}
-
-void Enum::InitAsDefaultInstance() {
- source_context_ = const_cast< ::google::protobuf::SourceContext*>(
- ::google::protobuf::SourceContext::internal_default_instance());
-}
-
Enum::Enum(const Enum& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ enumvalue_(from.enumvalue_),
+ options_(from.options_),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.name().size() > 0) {
+ name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name(),
+ GetArenaNoVirtual());
+ }
+ if (from.has_source_context()) {
+ source_context_ = new ::google::protobuf::SourceContext(*from.source_context_);
+ } else {
+ source_context_ = NULL;
+ }
+ syntax_ = from.syntax_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.Enum)
}
void Enum::SharedCtor() {
name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- source_context_ = NULL;
- syntax_ = 0;
+ ::memset(&source_context_, 0, reinterpret_cast<char*>(&syntax_) -
+ reinterpret_cast<char*>(&source_context_) + sizeof(syntax_));
_cached_size_ = 0;
}
@@ -2308,7 +2241,7 @@ void Enum::SharedDtor() {
}
name_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena);
- if (this != &Enum_default_instance_.get()) {
+ if (this != internal_default_instance()) {
delete source_context_;
}
}
@@ -2325,29 +2258,29 @@ void Enum::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* Enum::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return Enum_descriptor_;
+ protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[2].descriptor;
}
const Enum& Enum::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+ protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<Enum> Enum_default_instance_;
-
Enum* Enum::New(::google::protobuf::Arena* arena) const {
return ::google::protobuf::Arena::CreateMessage<Enum>(arena);
}
void Enum::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Enum)
+ enumvalue_.Clear();
+ options_.Clear();
name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
- if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_;
+ if (GetArenaNoVirtual() == NULL && source_context_ != NULL) {
+ delete source_context_;
+ }
source_context_ = NULL;
syntax_ = 0;
- enumvalue_.Clear();
- options_.Clear();
}
bool Enum::MergePartialFromCodedStream(
@@ -2356,13 +2289,14 @@ bool Enum::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Enum)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional string name = 1;
+ // string name = 1;
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name()));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
@@ -2372,60 +2306,53 @@ bool Enum::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(18)) goto parse_enumvalue;
break;
}
// repeated .google.protobuf.EnumValue enumvalue = 2;
case 2: {
- if (tag == 18) {
- parse_enumvalue:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(18u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_enumvalue:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_enumvalue()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(18)) goto parse_loop_enumvalue;
- if (input->ExpectTag(26)) goto parse_loop_options;
input->UnsafeDecrementRecursionDepth();
break;
}
// repeated .google.protobuf.Option options = 3;
case 3: {
- if (tag == 26) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(26u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_options:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_options()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(26)) goto parse_loop_options;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectTag(34)) goto parse_source_context;
break;
}
- // optional .google.protobuf.SourceContext source_context = 4;
+ // .google.protobuf.SourceContext source_context = 4;
case 4: {
- if (tag == 34) {
- parse_source_context:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(34u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_source_context()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(40)) goto parse_syntax;
break;
}
- // optional .google.protobuf.Syntax syntax = 5;
+ // .google.protobuf.Syntax syntax = 5;
case 5: {
- if (tag == 40) {
- parse_syntax:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(40u)) {
int value;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
@@ -2434,7 +2361,6 @@ bool Enum::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -2462,7 +2388,7 @@ failure:
void Enum::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.Enum)
- // optional string name = 1;
+ // string name = 1;
if (this->name().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->name().data(), this->name().length(),
@@ -2484,13 +2410,13 @@ void Enum::SerializeWithCachedSizes(
3, this->options(i), output);
}
- // optional .google.protobuf.SourceContext source_context = 4;
+ // .google.protobuf.SourceContext source_context = 4;
if (this->has_source_context()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
4, *this->source_context_, output);
}
- // optional .google.protobuf.Syntax syntax = 5;
+ // .google.protobuf.Syntax syntax = 5;
if (this->syntax() != 0) {
::google::protobuf::internal::WireFormatLite::WriteEnum(
5, this->syntax(), output);
@@ -2501,9 +2427,9 @@ void Enum::SerializeWithCachedSizes(
::google::protobuf::uint8* Enum::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Enum)
- // optional string name = 1;
+ // string name = 1;
if (this->name().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->name().data(), this->name().length(),
@@ -2528,14 +2454,14 @@ void Enum::SerializeWithCachedSizes(
3, this->options(i), false, target);
}
- // optional .google.protobuf.SourceContext source_context = 4;
+ // .google.protobuf.SourceContext source_context = 4;
if (this->has_source_context()) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
4, *this->source_context_, false, target);
}
- // optional .google.protobuf.Syntax syntax = 5;
+ // .google.protobuf.Syntax syntax = 5;
if (this->syntax() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
5, this->syntax(), target);
@@ -2549,26 +2475,6 @@ size_t Enum::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Enum)
size_t total_size = 0;
- // optional string name = 1;
- if (this->name().size() > 0) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->name());
- }
-
- // optional .google.protobuf.SourceContext source_context = 4;
- if (this->has_source_context()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->source_context_);
- }
-
- // optional .google.protobuf.Syntax syntax = 5;
- if (this->syntax() != 0) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->syntax());
- }
-
// repeated .google.protobuf.EnumValue enumvalue = 2;
{
unsigned int count = this->enumvalue_size();
@@ -2591,6 +2497,26 @@ size_t Enum::ByteSizeLong() const {
}
}
+ // string name = 1;
+ if (this->name().size() > 0) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->name());
+ }
+
+ // .google.protobuf.SourceContext source_context = 4;
+ if (this->has_source_context()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->source_context_);
+ }
+
+ // .google.protobuf.Syntax syntax = 5;
+ if (this->syntax() != 0) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->syntax());
+ }
+
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
@@ -2600,7 +2526,7 @@ size_t Enum::ByteSizeLong() const {
void Enum::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Enum)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const Enum* source =
::google::protobuf::internal::DynamicCastToGenerated<const Enum>(
&from);
@@ -2609,21 +2535,14 @@ void Enum::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Enum)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void Enum::MergeFrom(const Enum& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Enum)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void Enum::UnsafeMergeFrom(const Enum& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
enumvalue_.MergeFrom(from.enumvalue_);
options_.MergeFrom(from.options_);
if (from.name().size() > 0) {
@@ -2648,11 +2567,10 @@ void Enum::CopyFrom(const Enum& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Enum)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool Enum::IsInitialized() const {
-
return true;
}
@@ -2661,10 +2579,13 @@ void Enum::Swap(Enum* other) {
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
- Enum temp;
- temp.UnsafeMergeFrom(*this);
- CopyFrom(*other);
- other->CopyFrom(temp);
+ Enum* temp = New(GetArenaNoVirtual());
+ temp->MergeFrom(*other);
+ other->CopyFrom(*this);
+ InternalSwap(temp);
+ if (GetArenaNoVirtual() == NULL) {
+ delete temp;
+ }
}
}
void Enum::UnsafeArenaSwap(Enum* other) {
@@ -2673,33 +2594,29 @@ void Enum::UnsafeArenaSwap(Enum* other) {
InternalSwap(other);
}
void Enum::InternalSwap(Enum* other) {
- name_.Swap(&other->name_);
enumvalue_.UnsafeArenaSwap(&other->enumvalue_);
options_.UnsafeArenaSwap(&other->options_);
+ name_.Swap(&other->name_);
std::swap(source_context_, other->source_context_);
std::swap(syntax_, other->syntax_);
- _internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata Enum::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = Enum_descriptor_;
- metadata.reflection = Enum_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[2];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// Enum
-// optional string name = 1;
+// string name = 1;
void Enum::clear_name() {
name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
}
const ::std::string& Enum::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.Enum.name)
- return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.Get();
}
void Enum::set_name(const ::std::string& value) {
@@ -2819,7 +2736,7 @@ Enum::options() const {
return options_;
}
-// optional .google.protobuf.SourceContext source_context = 4;
+// .google.protobuf.SourceContext source_context = 4;
bool Enum::has_source_context() const {
return this != internal_default_instance() && source_context_ != NULL;
}
@@ -2870,7 +2787,7 @@ const ::google::protobuf::SourceContext& Enum::source_context() const {
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.source_context)
}
-// optional .google.protobuf.Syntax syntax = 5;
+// .google.protobuf.Syntax syntax = 5;
void Enum::clear_syntax() {
syntax_ = 0;
}
@@ -2884,9 +2801,6 @@ void Enum::set_syntax(::google::protobuf::Syntax value) {
// @@protoc_insertion_point(field_set:google.protobuf.Enum.syntax)
}
-inline const Enum* Enum::internal_default_instance() {
- return &Enum_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -2899,7 +2813,9 @@ const int EnumValue::kOptionsFieldNumber;
EnumValue::EnumValue()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.EnumValue)
}
@@ -2908,21 +2824,24 @@ EnumValue::EnumValue(::google::protobuf::Arena* arena)
_internal_metadata_(arena),
options_(arena) {
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+ protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.EnumValue)
}
-
-void EnumValue::InitAsDefaultInstance() {
-}
-
EnumValue::EnumValue(const EnumValue& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ options_(from.options_),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.name().size() > 0) {
+ name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name(),
+ GetArenaNoVirtual());
+ }
+ number_ = from.number_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValue)
}
@@ -2958,26 +2877,24 @@ void EnumValue::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* EnumValue::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return EnumValue_descriptor_;
+ protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[3].descriptor;
}
const EnumValue& EnumValue::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+ protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<EnumValue> EnumValue_default_instance_;
-
EnumValue* EnumValue::New(::google::protobuf::Arena* arena) const {
return ::google::protobuf::Arena::CreateMessage<EnumValue>(arena);
}
void EnumValue::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValue)
+ options_.Clear();
name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
number_ = 0;
- options_.Clear();
}
bool EnumValue::MergePartialFromCodedStream(
@@ -2986,13 +2903,14 @@ bool EnumValue::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.EnumValue)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional string name = 1;
+ // string name = 1;
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name()));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
@@ -3002,14 +2920,13 @@ bool EnumValue::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(16)) goto parse_number;
break;
}
- // optional int32 number = 2;
+ // int32 number = 2;
case 2: {
- if (tag == 16) {
- parse_number:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(16u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
@@ -3017,24 +2934,20 @@ bool EnumValue::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(26)) goto parse_options;
break;
}
// repeated .google.protobuf.Option options = 3;
case 3: {
- if (tag == 26) {
- parse_options:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(26u)) {
DO_(input->IncrementRecursionDepth());
- parse_loop_options:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
input, add_options()));
} else {
goto handle_unusual;
}
- if (input->ExpectTag(26)) goto parse_loop_options;
input->UnsafeDecrementRecursionDepth();
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -3062,7 +2975,7 @@ failure:
void EnumValue::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.EnumValue)
- // optional string name = 1;
+ // string name = 1;
if (this->name().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->name().data(), this->name().length(),
@@ -3072,7 +2985,7 @@ void EnumValue::SerializeWithCachedSizes(
1, this->name(), output);
}
- // optional int32 number = 2;
+ // int32 number = 2;
if (this->number() != 0) {
::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->number(), output);
}
@@ -3088,9 +3001,9 @@ void EnumValue::SerializeWithCachedSizes(
::google::protobuf::uint8* EnumValue::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumValue)
- // optional string name = 1;
+ // string name = 1;
if (this->name().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->name().data(), this->name().length(),
@@ -3101,7 +3014,7 @@ void EnumValue::SerializeWithCachedSizes(
1, this->name(), target);
}
- // optional int32 number = 2;
+ // int32 number = 2;
if (this->number() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->number(), target);
}
@@ -3121,31 +3034,31 @@ size_t EnumValue::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumValue)
size_t total_size = 0;
- // optional string name = 1;
+ // repeated .google.protobuf.Option options = 3;
+ {
+ unsigned int count = this->options_size();
+ total_size += 1UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->options(i));
+ }
+ }
+
+ // string name = 1;
if (this->name().size() > 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->name());
}
- // optional int32 number = 2;
+ // int32 number = 2;
if (this->number() != 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
this->number());
}
- // repeated .google.protobuf.Option options = 3;
- {
- unsigned int count = this->options_size();
- total_size += 1UL * count;
- for (unsigned int i = 0; i < count; i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->options(i));
- }
- }
-
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = cached_size;
@@ -3155,7 +3068,7 @@ size_t EnumValue::ByteSizeLong() const {
void EnumValue::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumValue)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const EnumValue* source =
::google::protobuf::internal::DynamicCastToGenerated<const EnumValue>(
&from);
@@ -3164,21 +3077,14 @@ void EnumValue::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumValue)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void EnumValue::MergeFrom(const EnumValue& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValue)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void EnumValue::UnsafeMergeFrom(const EnumValue& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
options_.MergeFrom(from.options_);
if (from.name().size() > 0) {
set_name(from.name());
@@ -3199,11 +3105,10 @@ void EnumValue::CopyFrom(const EnumValue& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumValue)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool EnumValue::IsInitialized() const {
-
return true;
}
@@ -3212,10 +3117,13 @@ void EnumValue::Swap(EnumValue* other) {
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
- EnumValue temp;
- temp.UnsafeMergeFrom(*this);
- CopyFrom(*other);
- other->CopyFrom(temp);
+ EnumValue* temp = New(GetArenaNoVirtual());
+ temp->MergeFrom(*other);
+ other->CopyFrom(*this);
+ InternalSwap(temp);
+ if (GetArenaNoVirtual() == NULL) {
+ delete temp;
+ }
}
}
void EnumValue::UnsafeArenaSwap(EnumValue* other) {
@@ -3224,31 +3132,27 @@ void EnumValue::UnsafeArenaSwap(EnumValue* other) {
InternalSwap(other);
}
void EnumValue::InternalSwap(EnumValue* other) {
+ options_.UnsafeArenaSwap(&other->options_);
name_.Swap(&other->name_);
std::swap(number_, other->number_);
- options_.UnsafeArenaSwap(&other->options_);
- _internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata EnumValue::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = EnumValue_descriptor_;
- metadata.reflection = EnumValue_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[3];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// EnumValue
-// optional string name = 1;
+// string name = 1;
void EnumValue::clear_name() {
name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
}
const ::std::string& EnumValue::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumValue.name)
- return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.Get();
}
void EnumValue::set_name(const ::std::string& value) {
@@ -3308,7 +3212,7 @@ void EnumValue::unsafe_arena_set_allocated_name(
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.EnumValue.name)
}
-// optional int32 number = 2;
+// int32 number = 2;
void EnumValue::clear_number() {
number_ = 0;
}
@@ -3352,9 +3256,6 @@ EnumValue::options() const {
return options_;
}
-inline const EnumValue* EnumValue::internal_default_instance() {
- return &EnumValue_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -3399,7 +3300,9 @@ const int Option::kValueFieldNumber;
Option::Option()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.Option)
}
@@ -3407,23 +3310,27 @@ Option::Option(::google::protobuf::Arena* arena)
: ::google::protobuf::Message(),
_internal_metadata_(arena) {
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+ protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Option)
}
-
-void Option::InitAsDefaultInstance() {
- value_ = const_cast< ::google::protobuf::Any*>(
- ::google::protobuf::Any::internal_default_instance());
-}
-
Option::Option(const Option& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.name().size() > 0) {
+ name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name(),
+ GetArenaNoVirtual());
+ }
+ if (from.has_value()) {
+ value_ = new ::google::protobuf::Any(*from.value_);
+ } else {
+ value_ = NULL;
+ }
// @@protoc_insertion_point(copy_constructor:google.protobuf.Option)
}
@@ -3445,7 +3352,7 @@ void Option::SharedDtor() {
}
name_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena);
- if (this != &Option_default_instance_.get()) {
+ if (this != internal_default_instance()) {
delete value_;
}
}
@@ -3462,17 +3369,15 @@ void Option::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* Option::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return Option_descriptor_;
+ protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[4].descriptor;
}
const Option& Option::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
+ protobuf_google_2fprotobuf_2ftype_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<Option> Option_default_instance_;
-
Option* Option::New(::google::protobuf::Arena* arena) const {
return ::google::protobuf::Arena::CreateMessage<Option>(arena);
}
@@ -3480,7 +3385,9 @@ Option* Option::New(::google::protobuf::Arena* arena) const {
void Option::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Option)
name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
- if (GetArenaNoVirtual() == NULL && value_ != NULL) delete value_;
+ if (GetArenaNoVirtual() == NULL && value_ != NULL) {
+ delete value_;
+ }
value_ = NULL;
}
@@ -3490,13 +3397,14 @@ bool Option::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Option)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional string name = 1;
+ // string name = 1;
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name()));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
@@ -3506,20 +3414,18 @@ bool Option::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectTag(18)) goto parse_value;
break;
}
- // optional .google.protobuf.Any value = 2;
+ // .google.protobuf.Any value = 2;
case 2: {
- if (tag == 18) {
- parse_value:
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(18u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_value()));
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -3547,7 +3453,7 @@ failure:
void Option::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.Option)
- // optional string name = 1;
+ // string name = 1;
if (this->name().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->name().data(), this->name().length(),
@@ -3557,7 +3463,7 @@ void Option::SerializeWithCachedSizes(
1, this->name(), output);
}
- // optional .google.protobuf.Any value = 2;
+ // .google.protobuf.Any value = 2;
if (this->has_value()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
2, *this->value_, output);
@@ -3568,9 +3474,9 @@ void Option::SerializeWithCachedSizes(
::google::protobuf::uint8* Option::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Option)
- // optional string name = 1;
+ // string name = 1;
if (this->name().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->name().data(), this->name().length(),
@@ -3581,7 +3487,7 @@ void Option::SerializeWithCachedSizes(
1, this->name(), target);
}
- // optional .google.protobuf.Any value = 2;
+ // .google.protobuf.Any value = 2;
if (this->has_value()) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
@@ -3596,14 +3502,14 @@ size_t Option::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Option)
size_t total_size = 0;
- // optional string name = 1;
+ // string name = 1;
if (this->name().size() > 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->name());
}
- // optional .google.protobuf.Any value = 2;
+ // .google.protobuf.Any value = 2;
if (this->has_value()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
@@ -3619,7 +3525,7 @@ size_t Option::ByteSizeLong() const {
void Option::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Option)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const Option* source =
::google::protobuf::internal::DynamicCastToGenerated<const Option>(
&from);
@@ -3628,21 +3534,14 @@ void Option::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Option)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void Option::MergeFrom(const Option& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Option)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void Option::UnsafeMergeFrom(const Option& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
if (from.name().size() > 0) {
set_name(from.name());
}
@@ -3662,11 +3561,10 @@ void Option::CopyFrom(const Option& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Option)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool Option::IsInitialized() const {
-
return true;
}
@@ -3675,10 +3573,13 @@ void Option::Swap(Option* other) {
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
- Option temp;
- temp.UnsafeMergeFrom(*this);
- CopyFrom(*other);
- other->CopyFrom(temp);
+ Option* temp = New(GetArenaNoVirtual());
+ temp->MergeFrom(*other);
+ other->CopyFrom(*this);
+ InternalSwap(temp);
+ if (GetArenaNoVirtual() == NULL) {
+ delete temp;
+ }
}
}
void Option::UnsafeArenaSwap(Option* other) {
@@ -3689,28 +3590,24 @@ void Option::UnsafeArenaSwap(Option* other) {
void Option::InternalSwap(Option* other) {
name_.Swap(&other->name_);
std::swap(value_, other->value_);
- _internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata Option::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = Option_descriptor_;
- metadata.reflection = Option_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2ftype_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2ftype_2eproto::file_level_metadata[4];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// Option
-// optional string name = 1;
+// string name = 1;
void Option::clear_name() {
name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
}
const ::std::string& Option::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.Option.name)
- return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.Get();
}
void Option::set_name(const ::std::string& value) {
@@ -3770,7 +3667,7 @@ void Option::unsafe_arena_set_allocated_name(
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Option.name)
}
-// optional .google.protobuf.Any value = 2;
+// .google.protobuf.Any value = 2;
bool Option::has_value() const {
return this != internal_default_instance() && value_ != NULL;
}
@@ -3821,9 +3718,6 @@ const ::google::protobuf::Any& Option::value() const {
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Option.value)
}
-inline const Option* Option::internal_default_instance() {
- return &Option_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// @@protoc_insertion_point(namespace_scope)
diff --git a/src/google/protobuf/type.pb.h b/src/google/protobuf/type.pb.h
index 1b6d3410..ae816008 100644
--- a/src/google/protobuf/type.pb.h
+++ b/src/google/protobuf/type.pb.h
@@ -8,44 +8,69 @@
#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3001000
+#if GOOGLE_PROTOBUF_VERSION < 3002000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
#endif
+#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata.h>
#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/extension_set.h>
+#include <google/protobuf/repeated_field.h> // IWYU pragma: export
+#include <google/protobuf/extension_set.h> // IWYU pragma: export
#include <google/protobuf/generated_enum_reflection.h>
#include <google/protobuf/unknown_field_set.h>
#include <google/protobuf/any.pb.h>
#include <google/protobuf/source_context.pb.h>
// @@protoc_insertion_point(includes)
-
namespace google {
namespace protobuf {
-
-// Internal implementation detail -- do not call these.
-void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto();
-void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto();
-void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto();
-void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto();
-
+class Any;
+class AnyDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern AnyDefaultTypeInternal _Any_default_instance_;
class Enum;
+class EnumDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern EnumDefaultTypeInternal _Enum_default_instance_;
class EnumValue;
+class EnumValueDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern EnumValueDefaultTypeInternal _EnumValue_default_instance_;
class Field;
+class FieldDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern FieldDefaultTypeInternal _Field_default_instance_;
class Option;
+class OptionDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern OptionDefaultTypeInternal _Option_default_instance_;
+class SourceContext;
+class SourceContextDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern SourceContextDefaultTypeInternal _SourceContext_default_instance_;
class Type;
+class TypeDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern TypeDefaultTypeInternal _Type_default_instance_;
+} // namespace protobuf
+} // namespace google
+
+namespace google {
+namespace protobuf {
+
+namespace protobuf_google_2fprotobuf_2ftype_2eproto {
+// Internal implementation detail -- do not call these.
+struct LIBPROTOBUF_EXPORT TableStruct {
+ static const ::google::protobuf::uint32 offsets[];
+ static void InitDefaultsImpl();
+ static void Shutdown();
+};
+void LIBPROTOBUF_EXPORT AddDescriptors();
+void LIBPROTOBUF_EXPORT InitDefaults();
+} // namespace protobuf_google_2fprotobuf_2ftype_2eproto
enum Field_Kind {
Field_Kind_TYPE_UNKNOWN = 0,
@@ -143,47 +168,53 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i
return *this;
}
- inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }
- inline void* GetMaybeArenaPointer() const {
+ inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {
+ return GetArenaNoVirtual();
+ }
+ inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {
return MaybeArenaPtr();
}
static const ::google::protobuf::Descriptor* descriptor();
static const Type& default_instance();
- static const Type* internal_default_instance();
+ static inline const Type* internal_default_instance() {
+ return reinterpret_cast<const Type*>(
+ &_Type_default_instance_);
+ }
void UnsafeArenaSwap(Type* other);
void Swap(Type* other);
// implements Message ----------------------------------------------
- inline Type* New() const { return New(NULL); }
+ inline Type* New() const PROTOBUF_FINAL { return New(NULL); }
- Type* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ Type* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Type& from);
void MergeFrom(const Type& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(Type* other);
- void UnsafeMergeFrom(const Type& from);
protected:
explicit Type(::google::protobuf::Arena* arena);
private:
@@ -198,26 +229,12 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
- // optional string name = 1;
- void clear_name();
- static const int kNameFieldNumber = 1;
- const ::std::string& name() const;
- void set_name(const ::std::string& value);
- void set_name(const char* value);
- void set_name(const char* value, size_t size);
- ::std::string* mutable_name();
- ::std::string* release_name();
- void set_allocated_name(::std::string* name);
- ::std::string* unsafe_arena_release_name();
- void unsafe_arena_set_allocated_name(
- ::std::string* name);
-
// repeated .google.protobuf.Field fields = 2;
int fields_size() const;
void clear_fields();
@@ -237,10 +254,16 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i
const ::std::string& oneofs(int index) const;
::std::string* mutable_oneofs(int index);
void set_oneofs(int index, const ::std::string& value);
+ #if LANG_CXX11
+ void set_oneofs(int index, ::std::string&& value);
+ #endif
void set_oneofs(int index, const char* value);
void set_oneofs(int index, const char* value, size_t size);
::std::string* add_oneofs();
void add_oneofs(const ::std::string& value);
+ #if LANG_CXX11
+ void add_oneofs(::std::string&& value);
+ #endif
void add_oneofs(const char* value);
void add_oneofs(const char* value, size_t size);
const ::google::protobuf::RepeatedPtrField< ::std::string>& oneofs() const;
@@ -258,7 +281,21 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
options() const;
- // optional .google.protobuf.SourceContext source_context = 5;
+ // string name = 1;
+ void clear_name();
+ static const int kNameFieldNumber = 1;
+ const ::std::string& name() const;
+ void set_name(const ::std::string& value);
+ void set_name(const char* value);
+ void set_name(const char* value, size_t size);
+ ::std::string* mutable_name();
+ ::std::string* release_name();
+ void set_allocated_name(::std::string* name);
+ ::std::string* unsafe_arena_release_name();
+ void unsafe_arena_set_allocated_name(
+ ::std::string* name);
+
+ // .google.protobuf.SourceContext source_context = 5;
bool has_source_context() const;
void clear_source_context();
static const int kSourceContextFieldNumber = 5;
@@ -274,7 +311,7 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i
void unsafe_arena_set_allocated_source_context(
::google::protobuf::SourceContext* source_context);
- // optional .google.protobuf.Syntax syntax = 6;
+ // .google.protobuf.Syntax syntax = 6;
void clear_syntax();
static const int kSyntaxFieldNumber = 6;
::google::protobuf::Syntax syntax() const;
@@ -294,15 +331,8 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i
::google::protobuf::SourceContext* source_context_;
int syntax_;
mutable int _cached_size_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2ftype_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<Type> Type_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Field) */ {
@@ -317,47 +347,53 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_
return *this;
}
- inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }
- inline void* GetMaybeArenaPointer() const {
+ inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {
+ return GetArenaNoVirtual();
+ }
+ inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {
return MaybeArenaPtr();
}
static const ::google::protobuf::Descriptor* descriptor();
static const Field& default_instance();
- static const Field* internal_default_instance();
+ static inline const Field* internal_default_instance() {
+ return reinterpret_cast<const Field*>(
+ &_Field_default_instance_);
+ }
void UnsafeArenaSwap(Field* other);
void Swap(Field* other);
// implements Message ----------------------------------------------
- inline Field* New() const { return New(NULL); }
+ inline Field* New() const PROTOBUF_FINAL { return New(NULL); }
- Field* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ Field* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Field& from);
void MergeFrom(const Field& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(Field* other);
- void UnsafeMergeFrom(const Field& from);
protected:
explicit Field(::google::protobuf::Arena* arena);
private:
@@ -372,7 +408,7 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
@@ -468,25 +504,19 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_
// accessors -------------------------------------------------------
- // optional .google.protobuf.Field.Kind kind = 1;
- void clear_kind();
- static const int kKindFieldNumber = 1;
- ::google::protobuf::Field_Kind kind() const;
- void set_kind(::google::protobuf::Field_Kind value);
-
- // optional .google.protobuf.Field.Cardinality cardinality = 2;
- void clear_cardinality();
- static const int kCardinalityFieldNumber = 2;
- ::google::protobuf::Field_Cardinality cardinality() const;
- void set_cardinality(::google::protobuf::Field_Cardinality value);
-
- // optional int32 number = 3;
- void clear_number();
- static const int kNumberFieldNumber = 3;
- ::google::protobuf::int32 number() const;
- void set_number(::google::protobuf::int32 value);
+ // repeated .google.protobuf.Option options = 9;
+ int options_size() const;
+ void clear_options();
+ static const int kOptionsFieldNumber = 9;
+ const ::google::protobuf::Option& options(int index) const;
+ ::google::protobuf::Option* mutable_options(int index);
+ ::google::protobuf::Option* add_options();
+ ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*
+ mutable_options();
+ const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
+ options() const;
- // optional string name = 4;
+ // string name = 4;
void clear_name();
static const int kNameFieldNumber = 4;
const ::std::string& name() const;
@@ -500,7 +530,7 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_
void unsafe_arena_set_allocated_name(
::std::string* name);
- // optional string type_url = 6;
+ // string type_url = 6;
void clear_type_url();
static const int kTypeUrlFieldNumber = 6;
const ::std::string& type_url() const;
@@ -514,31 +544,7 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_
void unsafe_arena_set_allocated_type_url(
::std::string* type_url);
- // optional int32 oneof_index = 7;
- void clear_oneof_index();
- static const int kOneofIndexFieldNumber = 7;
- ::google::protobuf::int32 oneof_index() const;
- void set_oneof_index(::google::protobuf::int32 value);
-
- // optional bool packed = 8;
- void clear_packed();
- static const int kPackedFieldNumber = 8;
- bool packed() const;
- void set_packed(bool value);
-
- // repeated .google.protobuf.Option options = 9;
- int options_size() const;
- void clear_options();
- static const int kOptionsFieldNumber = 9;
- const ::google::protobuf::Option& options(int index) const;
- ::google::protobuf::Option* mutable_options(int index);
- ::google::protobuf::Option* add_options();
- ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*
- mutable_options();
- const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
- options() const;
-
- // optional string json_name = 10;
+ // string json_name = 10;
void clear_json_name();
static const int kJsonNameFieldNumber = 10;
const ::std::string& json_name() const;
@@ -552,7 +558,7 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_
void unsafe_arena_set_allocated_json_name(
::std::string* json_name);
- // optional string default_value = 11;
+ // string default_value = 11;
void clear_default_value();
static const int kDefaultValueFieldNumber = 11;
const ::std::string& default_value() const;
@@ -566,6 +572,36 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_
void unsafe_arena_set_allocated_default_value(
::std::string* default_value);
+ // .google.protobuf.Field.Kind kind = 1;
+ void clear_kind();
+ static const int kKindFieldNumber = 1;
+ ::google::protobuf::Field_Kind kind() const;
+ void set_kind(::google::protobuf::Field_Kind value);
+
+ // .google.protobuf.Field.Cardinality cardinality = 2;
+ void clear_cardinality();
+ static const int kCardinalityFieldNumber = 2;
+ ::google::protobuf::Field_Cardinality cardinality() const;
+ void set_cardinality(::google::protobuf::Field_Cardinality value);
+
+ // int32 number = 3;
+ void clear_number();
+ static const int kNumberFieldNumber = 3;
+ ::google::protobuf::int32 number() const;
+ void set_number(::google::protobuf::int32 value);
+
+ // int32 oneof_index = 7;
+ void clear_oneof_index();
+ static const int kOneofIndexFieldNumber = 7;
+ ::google::protobuf::int32 oneof_index() const;
+ void set_oneof_index(::google::protobuf::int32 value);
+
+ // bool packed = 8;
+ void clear_packed();
+ static const int kPackedFieldNumber = 8;
+ bool packed() const;
+ void set_packed(bool value);
+
// @@protoc_insertion_point(class_scope:google.protobuf.Field)
private:
@@ -584,15 +620,8 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_
::google::protobuf::int32 oneof_index_;
bool packed_;
mutable int _cached_size_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2ftype_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<Field> Field_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Enum) */ {
@@ -607,47 +636,53 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i
return *this;
}
- inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }
- inline void* GetMaybeArenaPointer() const {
+ inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {
+ return GetArenaNoVirtual();
+ }
+ inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {
return MaybeArenaPtr();
}
static const ::google::protobuf::Descriptor* descriptor();
static const Enum& default_instance();
- static const Enum* internal_default_instance();
+ static inline const Enum* internal_default_instance() {
+ return reinterpret_cast<const Enum*>(
+ &_Enum_default_instance_);
+ }
void UnsafeArenaSwap(Enum* other);
void Swap(Enum* other);
// implements Message ----------------------------------------------
- inline Enum* New() const { return New(NULL); }
+ inline Enum* New() const PROTOBUF_FINAL { return New(NULL); }
- Enum* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ Enum* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Enum& from);
void MergeFrom(const Enum& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(Enum* other);
- void UnsafeMergeFrom(const Enum& from);
protected:
explicit Enum(::google::protobuf::Arena* arena);
private:
@@ -662,26 +697,12 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
- // optional string name = 1;
- void clear_name();
- static const int kNameFieldNumber = 1;
- const ::std::string& name() const;
- void set_name(const ::std::string& value);
- void set_name(const char* value);
- void set_name(const char* value, size_t size);
- ::std::string* mutable_name();
- ::std::string* release_name();
- void set_allocated_name(::std::string* name);
- ::std::string* unsafe_arena_release_name();
- void unsafe_arena_set_allocated_name(
- ::std::string* name);
-
// repeated .google.protobuf.EnumValue enumvalue = 2;
int enumvalue_size() const;
void clear_enumvalue();
@@ -706,7 +727,21 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i
const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
options() const;
- // optional .google.protobuf.SourceContext source_context = 4;
+ // string name = 1;
+ void clear_name();
+ static const int kNameFieldNumber = 1;
+ const ::std::string& name() const;
+ void set_name(const ::std::string& value);
+ void set_name(const char* value);
+ void set_name(const char* value, size_t size);
+ ::std::string* mutable_name();
+ ::std::string* release_name();
+ void set_allocated_name(::std::string* name);
+ ::std::string* unsafe_arena_release_name();
+ void unsafe_arena_set_allocated_name(
+ ::std::string* name);
+
+ // .google.protobuf.SourceContext source_context = 4;
bool has_source_context() const;
void clear_source_context();
static const int kSourceContextFieldNumber = 4;
@@ -722,7 +757,7 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i
void unsafe_arena_set_allocated_source_context(
::google::protobuf::SourceContext* source_context);
- // optional .google.protobuf.Syntax syntax = 5;
+ // .google.protobuf.Syntax syntax = 5;
void clear_syntax();
static const int kSyntaxFieldNumber = 5;
::google::protobuf::Syntax syntax() const;
@@ -741,15 +776,8 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i
::google::protobuf::SourceContext* source_context_;
int syntax_;
mutable int _cached_size_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2ftype_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<Enum> Enum_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValue) */ {
@@ -764,47 +792,53 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro
return *this;
}
- inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }
- inline void* GetMaybeArenaPointer() const {
+ inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {
+ return GetArenaNoVirtual();
+ }
+ inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {
return MaybeArenaPtr();
}
static const ::google::protobuf::Descriptor* descriptor();
static const EnumValue& default_instance();
- static const EnumValue* internal_default_instance();
+ static inline const EnumValue* internal_default_instance() {
+ return reinterpret_cast<const EnumValue*>(
+ &_EnumValue_default_instance_);
+ }
void UnsafeArenaSwap(EnumValue* other);
void Swap(EnumValue* other);
// implements Message ----------------------------------------------
- inline EnumValue* New() const { return New(NULL); }
+ inline EnumValue* New() const PROTOBUF_FINAL { return New(NULL); }
- EnumValue* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ EnumValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const EnumValue& from);
void MergeFrom(const EnumValue& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(EnumValue* other);
- void UnsafeMergeFrom(const EnumValue& from);
protected:
explicit EnumValue(::google::protobuf::Arena* arena);
private:
@@ -819,13 +853,25 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
- // optional string name = 1;
+ // repeated .google.protobuf.Option options = 3;
+ int options_size() const;
+ void clear_options();
+ static const int kOptionsFieldNumber = 3;
+ const ::google::protobuf::Option& options(int index) const;
+ ::google::protobuf::Option* mutable_options(int index);
+ ::google::protobuf::Option* add_options();
+ ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*
+ mutable_options();
+ const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
+ options() const;
+
+ // string name = 1;
void clear_name();
static const int kNameFieldNumber = 1;
const ::std::string& name() const;
@@ -839,24 +885,12 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro
void unsafe_arena_set_allocated_name(
::std::string* name);
- // optional int32 number = 2;
+ // int32 number = 2;
void clear_number();
static const int kNumberFieldNumber = 2;
::google::protobuf::int32 number() const;
void set_number(::google::protobuf::int32 value);
- // repeated .google.protobuf.Option options = 3;
- int options_size() const;
- void clear_options();
- static const int kOptionsFieldNumber = 3;
- const ::google::protobuf::Option& options(int index) const;
- ::google::protobuf::Option* mutable_options(int index);
- ::google::protobuf::Option* add_options();
- ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*
- mutable_options();
- const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&
- options() const;
-
// @@protoc_insertion_point(class_scope:google.protobuf.EnumValue)
private:
@@ -868,15 +902,8 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro
::google::protobuf::internal::ArenaStringPtr name_;
::google::protobuf::int32 number_;
mutable int _cached_size_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2ftype_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<EnumValue> EnumValue_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Option) */ {
@@ -891,47 +918,53 @@ class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc
return *this;
}
- inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }
- inline void* GetMaybeArenaPointer() const {
+ inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {
+ return GetArenaNoVirtual();
+ }
+ inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {
return MaybeArenaPtr();
}
static const ::google::protobuf::Descriptor* descriptor();
static const Option& default_instance();
- static const Option* internal_default_instance();
+ static inline const Option* internal_default_instance() {
+ return reinterpret_cast<const Option*>(
+ &_Option_default_instance_);
+ }
void UnsafeArenaSwap(Option* other);
void Swap(Option* other);
// implements Message ----------------------------------------------
- inline Option* New() const { return New(NULL); }
+ inline Option* New() const PROTOBUF_FINAL { return New(NULL); }
- Option* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ Option* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Option& from);
void MergeFrom(const Option& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(Option* other);
- void UnsafeMergeFrom(const Option& from);
protected:
explicit Option(::google::protobuf::Arena* arena);
private:
@@ -946,13 +979,13 @@ class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
- // optional string name = 1;
+ // string name = 1;
void clear_name();
static const int kNameFieldNumber = 1;
const ::std::string& name() const;
@@ -966,7 +999,7 @@ class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc
void unsafe_arena_set_allocated_name(
::std::string* name);
- // optional .google.protobuf.Any value = 2;
+ // .google.protobuf.Any value = 2;
bool has_value() const;
void clear_value();
static const int kValueFieldNumber = 2;
@@ -992,15 +1025,8 @@ class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc
::google::protobuf::internal::ArenaStringPtr name_;
::google::protobuf::Any* value_;
mutable int _cached_size_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2ftype_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<Option> Option_default_instance_;
-
// ===================================================================
@@ -1009,13 +1035,13 @@ extern ::google::protobuf::internal::ExplicitlyConstructed<Option> Option_defaul
#if !PROTOBUF_INLINE_NOT_IN_HEADERS
// Type
-// optional string name = 1;
+// string name = 1;
inline void Type::clear_name() {
name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
}
inline const ::std::string& Type::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.Type.name)
- return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.Get();
}
inline void Type::set_name(const ::std::string& value) {
@@ -1124,6 +1150,12 @@ inline void Type::set_oneofs(int index, const ::std::string& value) {
// @@protoc_insertion_point(field_set:google.protobuf.Type.oneofs)
oneofs_.Mutable(index)->assign(value);
}
+#if LANG_CXX11
+inline void Type::set_oneofs(int index, ::std::string&& value) {
+ // @@protoc_insertion_point(field_set:google.protobuf.Type.oneofs)
+ oneofs_.Mutable(index)->assign(std::move(value));
+}
+#endif
inline void Type::set_oneofs(int index, const char* value) {
oneofs_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set_char:google.protobuf.Type.oneofs)
@@ -1141,6 +1173,12 @@ inline void Type::add_oneofs(const ::std::string& value) {
oneofs_.Add()->assign(value);
// @@protoc_insertion_point(field_add:google.protobuf.Type.oneofs)
}
+#if LANG_CXX11
+inline void Type::add_oneofs(::std::string&& value) {
+ oneofs_.Add()->assign(std::move(value));
+ // @@protoc_insertion_point(field_add:google.protobuf.Type.oneofs)
+}
+#endif
inline void Type::add_oneofs(const char* value) {
oneofs_.Add()->assign(value);
// @@protoc_insertion_point(field_add_char:google.protobuf.Type.oneofs)
@@ -1190,7 +1228,7 @@ Type::options() const {
return options_;
}
-// optional .google.protobuf.SourceContext source_context = 5;
+// .google.protobuf.SourceContext source_context = 5;
inline bool Type::has_source_context() const {
return this != internal_default_instance() && source_context_ != NULL;
}
@@ -1241,7 +1279,7 @@ inline void Type::set_allocated_source_context(::google::protobuf::SourceContex
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.source_context)
}
-// optional .google.protobuf.Syntax syntax = 6;
+// .google.protobuf.Syntax syntax = 6;
inline void Type::clear_syntax() {
syntax_ = 0;
}
@@ -1255,14 +1293,11 @@ inline void Type::set_syntax(::google::protobuf::Syntax value) {
// @@protoc_insertion_point(field_set:google.protobuf.Type.syntax)
}
-inline const Type* Type::internal_default_instance() {
- return &Type_default_instance_.get();
-}
// -------------------------------------------------------------------
// Field
-// optional .google.protobuf.Field.Kind kind = 1;
+// .google.protobuf.Field.Kind kind = 1;
inline void Field::clear_kind() {
kind_ = 0;
}
@@ -1276,7 +1311,7 @@ inline void Field::set_kind(::google::protobuf::Field_Kind value) {
// @@protoc_insertion_point(field_set:google.protobuf.Field.kind)
}
-// optional .google.protobuf.Field.Cardinality cardinality = 2;
+// .google.protobuf.Field.Cardinality cardinality = 2;
inline void Field::clear_cardinality() {
cardinality_ = 0;
}
@@ -1290,7 +1325,7 @@ inline void Field::set_cardinality(::google::protobuf::Field_Cardinality value)
// @@protoc_insertion_point(field_set:google.protobuf.Field.cardinality)
}
-// optional int32 number = 3;
+// int32 number = 3;
inline void Field::clear_number() {
number_ = 0;
}
@@ -1304,13 +1339,13 @@ inline void Field::set_number(::google::protobuf::int32 value) {
// @@protoc_insertion_point(field_set:google.protobuf.Field.number)
}
-// optional string name = 4;
+// string name = 4;
inline void Field::clear_name() {
name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
}
inline const ::std::string& Field::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.Field.name)
- return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.Get();
}
inline void Field::set_name(const ::std::string& value) {
@@ -1370,13 +1405,13 @@ inline void Field::unsafe_arena_set_allocated_name(
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.name)
}
-// optional string type_url = 6;
+// string type_url = 6;
inline void Field::clear_type_url() {
type_url_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
}
inline const ::std::string& Field::type_url() const {
// @@protoc_insertion_point(field_get:google.protobuf.Field.type_url)
- return type_url_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return type_url_.Get();
}
inline void Field::set_type_url(const ::std::string& value) {
@@ -1436,7 +1471,7 @@ inline void Field::unsafe_arena_set_allocated_type_url(
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.type_url)
}
-// optional int32 oneof_index = 7;
+// int32 oneof_index = 7;
inline void Field::clear_oneof_index() {
oneof_index_ = 0;
}
@@ -1450,7 +1485,7 @@ inline void Field::set_oneof_index(::google::protobuf::int32 value) {
// @@protoc_insertion_point(field_set:google.protobuf.Field.oneof_index)
}
-// optional bool packed = 8;
+// bool packed = 8;
inline void Field::clear_packed() {
packed_ = false;
}
@@ -1494,13 +1529,13 @@ Field::options() const {
return options_;
}
-// optional string json_name = 10;
+// string json_name = 10;
inline void Field::clear_json_name() {
json_name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
}
inline const ::std::string& Field::json_name() const {
// @@protoc_insertion_point(field_get:google.protobuf.Field.json_name)
- return json_name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return json_name_.Get();
}
inline void Field::set_json_name(const ::std::string& value) {
@@ -1560,13 +1595,13 @@ inline void Field::unsafe_arena_set_allocated_json_name(
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.json_name)
}
-// optional string default_value = 11;
+// string default_value = 11;
inline void Field::clear_default_value() {
default_value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
}
inline const ::std::string& Field::default_value() const {
// @@protoc_insertion_point(field_get:google.protobuf.Field.default_value)
- return default_value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return default_value_.Get();
}
inline void Field::set_default_value(const ::std::string& value) {
@@ -1626,20 +1661,17 @@ inline void Field::unsafe_arena_set_allocated_default_value(
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.default_value)
}
-inline const Field* Field::internal_default_instance() {
- return &Field_default_instance_.get();
-}
// -------------------------------------------------------------------
// Enum
-// optional string name = 1;
+// string name = 1;
inline void Enum::clear_name() {
name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
}
inline const ::std::string& Enum::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.Enum.name)
- return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.Get();
}
inline void Enum::set_name(const ::std::string& value) {
@@ -1759,7 +1791,7 @@ Enum::options() const {
return options_;
}
-// optional .google.protobuf.SourceContext source_context = 4;
+// .google.protobuf.SourceContext source_context = 4;
inline bool Enum::has_source_context() const {
return this != internal_default_instance() && source_context_ != NULL;
}
@@ -1810,7 +1842,7 @@ inline void Enum::set_allocated_source_context(::google::protobuf::SourceContex
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.source_context)
}
-// optional .google.protobuf.Syntax syntax = 5;
+// .google.protobuf.Syntax syntax = 5;
inline void Enum::clear_syntax() {
syntax_ = 0;
}
@@ -1824,20 +1856,17 @@ inline void Enum::set_syntax(::google::protobuf::Syntax value) {
// @@protoc_insertion_point(field_set:google.protobuf.Enum.syntax)
}
-inline const Enum* Enum::internal_default_instance() {
- return &Enum_default_instance_.get();
-}
// -------------------------------------------------------------------
// EnumValue
-// optional string name = 1;
+// string name = 1;
inline void EnumValue::clear_name() {
name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
}
inline const ::std::string& EnumValue::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.EnumValue.name)
- return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.Get();
}
inline void EnumValue::set_name(const ::std::string& value) {
@@ -1897,7 +1926,7 @@ inline void EnumValue::unsafe_arena_set_allocated_name(
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.EnumValue.name)
}
-// optional int32 number = 2;
+// int32 number = 2;
inline void EnumValue::clear_number() {
number_ = 0;
}
@@ -1941,20 +1970,17 @@ EnumValue::options() const {
return options_;
}
-inline const EnumValue* EnumValue::internal_default_instance() {
- return &EnumValue_default_instance_.get();
-}
// -------------------------------------------------------------------
// Option
-// optional string name = 1;
+// string name = 1;
inline void Option::clear_name() {
name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
}
inline const ::std::string& Option::name() const {
// @@protoc_insertion_point(field_get:google.protobuf.Option.name)
- return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return name_.Get();
}
inline void Option::set_name(const ::std::string& value) {
@@ -2014,7 +2040,7 @@ inline void Option::unsafe_arena_set_allocated_name(
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Option.name)
}
-// optional .google.protobuf.Any value = 2;
+// .google.protobuf.Any value = 2;
inline bool Option::has_value() const {
return this != internal_default_instance() && value_ != NULL;
}
@@ -2065,9 +2091,6 @@ inline void Option::set_allocated_value(::google::protobuf::Any* value) {
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Option.value)
}
-inline const Option* Option::internal_default_instance() {
- return &Option_default_instance_.get();
-}
#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS
// -------------------------------------------------------------------
@@ -2080,6 +2103,7 @@ inline const Option* Option::internal_default_instance() {
// @@protoc_insertion_point(namespace_scope)
+
} // namespace protobuf
} // namespace google
diff --git a/src/google/protobuf/type.proto b/src/google/protobuf/type.proto
index 504cd25d..624c15ee 100644
--- a/src/google/protobuf/type.proto
+++ b/src/google/protobuf/type.proto
@@ -41,6 +41,7 @@ option java_package = "com.google.protobuf";
option java_outer_classname = "TypeProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
+option go_package = "google.golang.org/genproto/protobuf/ptype;ptype";
// A protocol buffer message type.
message Type {
@@ -165,9 +166,15 @@ message EnumValue {
// A protocol buffer option, which can be attached to a message, field,
// enumeration, etc.
message Option {
- // The option's name. For example, `"java_package"`.
+ // The option's name. For protobuf built-in options (options defined in
+ // descriptor.proto), this is the short name. For example, `"map_entry"`.
+ // For custom options, it should be the fully-qualified name. For example,
+ // `"google.api.http"`.
string name = 1;
- // The option's value. For example, `"com.google.protobuf"`.
+ // The option's value packed in an Any message. If the value is a primitive,
+ // the corresponding wrapper type defined in google/protobuf/wrappers.proto
+ // should be used. If the value is an enum, it should be stored as an int32
+ // value using the google.protobuf.Int32Value type.
Any value = 2;
}
diff --git a/src/google/protobuf/unittest.proto b/src/google/protobuf/unittest.proto
index cc2f4b34..96289cc5 100644
--- a/src/google/protobuf/unittest.proto
+++ b/src/google/protobuf/unittest.proto
@@ -886,3 +886,34 @@ message TestJsonName {
optional int32 FIELD_NAME5 = 5;
optional int32 field_name6 = 6 [json_name = "@type"];
}
+
+message TestHugeFieldNumbers {
+ optional int32 optional_int32 = 536870000;
+ optional int32 fixed_32 = 536870001;
+ repeated int32 repeated_int32 = 536870002 [packed = false];
+ repeated int32 packed_int32 = 536870003 [packed = true];
+
+ optional ForeignEnum optional_enum = 536870004;
+ optional string optional_string = 536870005;
+ optional bytes optional_bytes = 536870006;
+ optional ForeignMessage optional_message = 536870007;
+
+ optional group OptionalGroup = 536870008 {
+ optional int32 group_a = 536870009;
+ }
+
+ map<string, string> string_string_map = 536870010;
+
+ oneof oneof_field {
+ uint32 oneof_uint32 = 536870011;
+ TestAllTypes oneof_test_all_types = 536870012;
+ string oneof_string = 536870013;
+ bytes oneof_bytes = 536870014;
+ }
+
+ extensions 536860000 to 536869999;
+}
+
+extend TestHugeFieldNumbers {
+ optional TestAllTypes test_all_types = 536860000;
+}
diff --git a/src/google/protobuf/unittest_lite.proto b/src/google/protobuf/unittest_lite.proto
index 878ec7c1..c39ac6b0 100644
--- a/src/google/protobuf/unittest_lite.proto
+++ b/src/google/protobuf/unittest_lite.proto
@@ -163,6 +163,9 @@ message TestAllTypesLite {
bytes oneof_bytes = 114;
NestedMessage oneof_lazy_nested_message = 115 [lazy = true];
}
+
+ // Tests toString for non-repeated fields with a list suffix
+ optional int32 deceptively_named_list = 116;
}
message ForeignMessageLite {
@@ -405,3 +408,34 @@ message V2MessageLite {
required int32 int_field = 1;
optional V2EnumLite enum_field = 2 [ default = V2_FIRST ];
}
+
+message TestHugeFieldNumbersLite {
+ optional int32 optional_int32 = 536870000;
+ optional int32 fixed_32 = 536870001;
+ repeated int32 repeated_int32 = 536870002 [packed = false];
+ repeated int32 packed_int32 = 536870003 [packed = true];
+
+ optional ForeignEnumLite optional_enum = 536870004;
+ optional string optional_string = 536870005;
+ optional bytes optional_bytes = 536870006;
+ optional ForeignMessageLite optional_message = 536870007;
+
+ optional group OptionalGroup = 536870008 {
+ optional int32 group_a = 536870009;
+ }
+
+ map<string, string> string_string_map = 536870010;
+
+ oneof oneof_field {
+ uint32 oneof_uint32 = 536870011;
+ TestAllTypesLite oneof_test_all_types = 536870012;
+ string oneof_string = 536870013;
+ bytes oneof_bytes = 536870014;
+ }
+
+ extensions 536860000 to 536869999;
+}
+
+extend TestHugeFieldNumbersLite {
+ optional TestAllTypesLite test_all_types_lite = 536860000;
+}
diff --git a/src/google/protobuf/unknown_field_set.cc b/src/google/protobuf/unknown_field_set.cc
index bca3fbf8..9472c4fa 100644
--- a/src/google/protobuf/unknown_field_set.cc
+++ b/src/google/protobuf/unknown_field_set.cc
@@ -83,7 +83,7 @@ void UnknownFieldSet::ClearFallback() {
void UnknownFieldSet::InternalMergeFrom(const UnknownFieldSet& other) {
int other_field_count = other.field_count();
if (other_field_count > 0) {
- fields_ = new vector<UnknownField>();
+ fields_ = new std::vector<UnknownField>();
for (int i = 0; i < other_field_count; i++) {
fields_->push_back((*other.fields_)[i]);
fields_->back().DeepCopy((*other.fields_)[i]);
@@ -94,7 +94,7 @@ void UnknownFieldSet::InternalMergeFrom(const UnknownFieldSet& other) {
void UnknownFieldSet::MergeFrom(const UnknownFieldSet& other) {
int other_field_count = other.field_count();
if (other_field_count > 0) {
- if (fields_ == NULL) fields_ = new vector<UnknownField>();
+ if (fields_ == NULL) fields_ = new std::vector<UnknownField>();
for (int i = 0; i < other_field_count; i++) {
fields_->push_back((*other.fields_)[i]);
fields_->back().DeepCopy((*other.fields_)[i]);
@@ -107,7 +107,7 @@ void UnknownFieldSet::MergeFrom(const UnknownFieldSet& other) {
void UnknownFieldSet::MergeFromAndDestroy(UnknownFieldSet* other) {
int other_field_count = other->field_count();
if (other_field_count > 0) {
- if (fields_ == NULL) fields_ = new vector<UnknownField>();
+ if (fields_ == NULL) fields_ = new std::vector<UnknownField>();
for (int i = 0; i < other_field_count; i++) {
fields_->push_back((*other->fields_)[i]);
(*other->fields_)[i].Reset();
@@ -155,7 +155,7 @@ void UnknownFieldSet::AddVarint(int number, uint64 value) {
field.number_ = number;
field.SetType(UnknownField::TYPE_VARINT);
field.varint_ = value;
- if (fields_ == NULL) fields_ = new vector<UnknownField>();
+ if (fields_ == NULL) fields_ = new std::vector<UnknownField>();
fields_->push_back(field);
}
@@ -164,7 +164,7 @@ void UnknownFieldSet::AddFixed32(int number, uint32 value) {
field.number_ = number;
field.SetType(UnknownField::TYPE_FIXED32);
field.fixed32_ = value;
- if (fields_ == NULL) fields_ = new vector<UnknownField>();
+ if (fields_ == NULL) fields_ = new std::vector<UnknownField>();
fields_->push_back(field);
}
@@ -173,7 +173,7 @@ void UnknownFieldSet::AddFixed64(int number, uint64 value) {
field.number_ = number;
field.SetType(UnknownField::TYPE_FIXED64);
field.fixed64_ = value;
- if (fields_ == NULL) fields_ = new vector<UnknownField>();
+ if (fields_ == NULL) fields_ = new std::vector<UnknownField>();
fields_->push_back(field);
}
@@ -182,7 +182,7 @@ string* UnknownFieldSet::AddLengthDelimited(int number) {
field.number_ = number;
field.SetType(UnknownField::TYPE_LENGTH_DELIMITED);
field.length_delimited_.string_value_ = new string;
- if (fields_ == NULL) fields_ = new vector<UnknownField>();
+ if (fields_ == NULL) fields_ = new std::vector<UnknownField>();
fields_->push_back(field);
return field.length_delimited_.string_value_;
}
@@ -193,13 +193,13 @@ UnknownFieldSet* UnknownFieldSet::AddGroup(int number) {
field.number_ = number;
field.SetType(UnknownField::TYPE_GROUP);
field.group_ = new UnknownFieldSet;
- if (fields_ == NULL) fields_ = new vector<UnknownField>();
+ if (fields_ == NULL) fields_ = new std::vector<UnknownField>();
fields_->push_back(field);
return field.group_;
}
void UnknownFieldSet::AddField(const UnknownField& field) {
- if (fields_ == NULL) fields_ = new vector<UnknownField>();
+ if (fields_ == NULL) fields_ = new std::vector<UnknownField>();
fields_->push_back(field);
fields_->back().DeepCopy(field);
}
diff --git a/src/google/protobuf/unknown_field_set_unittest.cc b/src/google/protobuf/unknown_field_set_unittest.cc
index 5de72630..e55bb012 100644
--- a/src/google/protobuf/unknown_field_set_unittest.cc
+++ b/src/google/protobuf/unknown_field_set_unittest.cc
@@ -488,7 +488,7 @@ TEST_F(UnknownFieldSetTest, UnknownEnumValue) {
TEST_F(UnknownFieldSetTest, SpaceUsedExcludingSelf) {
UnknownFieldSet empty;
empty.AddVarint(1, 0);
- EXPECT_EQ(sizeof(vector<UnknownField>) + sizeof(UnknownField),
+ EXPECT_EQ(sizeof(std::vector<UnknownField>) + sizeof(UnknownField),
empty.SpaceUsedExcludingSelf());
}
@@ -559,8 +559,9 @@ TEST_F(UnknownFieldSetTest, DeleteSubrange) {
}
}
-void CheckDeleteByNumber(const vector<int>& field_numbers, int deleted_number,
- const vector<int>& expected_field_nubmers) {
+void CheckDeleteByNumber(const std::vector<int>& field_numbers,
+ int deleted_number,
+ const std::vector<int>& expected_field_nubmers) {
UnknownFieldSet unknown_fields;
for (int i = 0; i < field_numbers.size(); ++i) {
unknown_fields.AddFixed32(field_numbers[i], i);
@@ -573,9 +574,9 @@ void CheckDeleteByNumber(const vector<int>& field_numbers, int deleted_number,
}
}
-#define MAKE_VECTOR(x) vector<int>(x, x + GOOGLE_ARRAYSIZE(x))
+#define MAKE_VECTOR(x) std::vector<int>(x, x + GOOGLE_ARRAYSIZE(x))
TEST_F(UnknownFieldSetTest, DeleteByNumber) {
- CheckDeleteByNumber(vector<int>(), 1, vector<int>());
+ CheckDeleteByNumber(std::vector<int>(), 1, std::vector<int>());
static const int kTestFieldNumbers1[] = {1, 2, 3};
static const int kFieldNumberToDelete1 = 1;
static const int kExpectedFieldNumbers1[] = {2, 3};
diff --git a/src/google/protobuf/util/field_comparator.h b/src/google/protobuf/util/field_comparator.h
index 3c70a314..ad560ebc 100644
--- a/src/google/protobuf/util/field_comparator.h
+++ b/src/google/protobuf/util/field_comparator.h
@@ -30,8 +30,6 @@
// Defines classes for field comparison.
-// Author: ksroka@google.com (Krzysztof Sroka)
-
#ifndef GOOGLE_PROTOBUF_UTIL_FIELD_COMPARATOR_H__
#define GOOGLE_PROTOBUF_UTIL_FIELD_COMPARATOR_H__
diff --git a/src/google/protobuf/util/field_comparator_test.cc b/src/google/protobuf/util/field_comparator_test.cc
index 6fd631d8..249b8d54 100644
--- a/src/google/protobuf/util/field_comparator_test.cc
+++ b/src/google/protobuf/util/field_comparator_test.cc
@@ -365,10 +365,10 @@ TEST_F(DefaultFieldComparatorTest,
// +inf should be equal even though they are not technically within margin or
// fraction.
- message_1_.set_optional_float(numeric_limits<float>::infinity());
- message_2_.set_optional_float(numeric_limits<float>::infinity());
- message_1_.set_optional_double(numeric_limits<double>::infinity());
- message_2_.set_optional_double(numeric_limits<double>::infinity());
+ message_1_.set_optional_float(std::numeric_limits<float>::infinity());
+ message_2_.set_optional_float(std::numeric_limits<float>::infinity());
+ message_1_.set_optional_double(std::numeric_limits<double>::infinity());
+ message_2_.set_optional_double(std::numeric_limits<double>::infinity());
comparator_.SetFractionAndMargin(field_float, 0.0, 0.0);
comparator_.SetFractionAndMargin(field_double, 0.0, 0.0);
EXPECT_EQ(FieldComparator::SAME,
@@ -380,10 +380,10 @@ TEST_F(DefaultFieldComparatorTest,
// -inf should be equal even though they are not technically within margin or
// fraction.
- message_1_.set_optional_float(-numeric_limits<float>::infinity());
- message_2_.set_optional_float(-numeric_limits<float>::infinity());
- message_1_.set_optional_double(-numeric_limits<double>::infinity());
- message_2_.set_optional_double(-numeric_limits<double>::infinity());
+ message_1_.set_optional_float(-std::numeric_limits<float>::infinity());
+ message_2_.set_optional_float(-std::numeric_limits<float>::infinity());
+ message_1_.set_optional_double(-std::numeric_limits<double>::infinity());
+ message_2_.set_optional_double(-std::numeric_limits<double>::infinity());
comparator_.SetFractionAndMargin(field_float, 0.0, 0.0);
comparator_.SetFractionAndMargin(field_double, 0.0, 0.0);
EXPECT_EQ(FieldComparator::SAME,
diff --git a/src/google/protobuf/util/field_mask_util.cc b/src/google/protobuf/util/field_mask_util.cc
index 9dfcbd72..85cecec5 100644
--- a/src/google/protobuf/util/field_mask_util.cc
+++ b/src/google/protobuf/util/field_mask_util.cc
@@ -45,7 +45,7 @@ string FieldMaskUtil::ToString(const FieldMask& mask) {
void FieldMaskUtil::FromString(StringPiece str, FieldMask* out) {
out->Clear();
- vector<string> paths = Split(str, ",");
+ std::vector<string> paths = Split(str, ",");
for (int i = 0; i < paths.size(); ++i) {
if (paths[i].empty()) continue;
out->add_paths(paths[i]);
@@ -116,7 +116,7 @@ bool FieldMaskUtil::ToJsonString(const FieldMask& mask, string* out) {
bool FieldMaskUtil::FromJsonString(StringPiece str, FieldMask* out) {
out->Clear();
- vector<string> paths = Split(str, ",");
+ std::vector<string> paths = Split(str, ",");
for (int i = 0; i < paths.size(); ++i) {
if (paths[i].empty()) continue;
string snakecase_path;
@@ -128,9 +128,13 @@ bool FieldMaskUtil::FromJsonString(StringPiece str, FieldMask* out) {
return true;
}
-bool FieldMaskUtil::InternalIsValidPath(const Descriptor* descriptor,
- StringPiece path) {
- vector<string> parts = Split(path, ".");
+bool FieldMaskUtil::GetFieldDescriptors(
+ const Descriptor* descriptor, StringPiece path,
+ std::vector<const FieldDescriptor*>* field_descriptors) {
+ if (field_descriptors != NULL) {
+ field_descriptors->clear();
+ }
+ std::vector<string> parts = Split(path, ".");
for (int i = 0; i < parts.size(); ++i) {
const string& field_name = parts[i];
if (descriptor == NULL) {
@@ -140,6 +144,9 @@ bool FieldMaskUtil::InternalIsValidPath(const Descriptor* descriptor,
if (field == NULL) {
return false;
}
+ if (field_descriptors != NULL) {
+ field_descriptors->push_back(field);
+ }
if (!field->is_repeated() &&
field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
descriptor = field->message_type();
@@ -216,14 +223,14 @@ class FieldMaskTree {
~Node() { ClearChildren(); }
void ClearChildren() {
- for (map<string, Node*>::iterator it = children.begin();
+ for (std::map<string, Node*>::iterator it = children.begin();
it != children.end(); ++it) {
delete it->second;
}
children.clear();
}
- map<string, Node*> children;
+ std::map<string, Node*> children;
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Node);
@@ -274,7 +281,7 @@ void FieldMaskTree::MergeToFieldMask(const string& prefix, const Node* node,
out->add_paths(prefix);
return;
}
- for (map<string, Node*>::const_iterator it = node->children.begin();
+ for (std::map<string, Node*>::const_iterator it = node->children.begin();
it != node->children.end(); ++it) {
string current_path = prefix.empty() ? it->first : prefix + "." + it->first;
MergeToFieldMask(current_path, it->second, out);
@@ -282,7 +289,7 @@ void FieldMaskTree::MergeToFieldMask(const string& prefix, const Node* node,
}
void FieldMaskTree::AddPath(const string& path) {
- vector<string> parts = Split(path, ".");
+ std::vector<string> parts = Split(path, ".");
if (parts.empty()) {
return;
}
@@ -309,7 +316,7 @@ void FieldMaskTree::AddPath(const string& path) {
}
void FieldMaskTree::IntersectPath(const string& path, FieldMaskTree* out) {
- vector<string> parts = Split(path, ".");
+ std::vector<string> parts = Split(path, ".");
if (parts.empty()) {
return;
}
@@ -339,7 +346,7 @@ void FieldMaskTree::MergeLeafNodesToTree(const string& prefix, const Node* node,
if (node->children.empty()) {
out->AddPath(prefix);
}
- for (map<string, Node*>::const_iterator it = node->children.begin();
+ for (std::map<string, Node*>::const_iterator it = node->children.begin();
it != node->children.end(); ++it) {
string current_path = prefix.empty() ? it->first : prefix + "." + it->first;
MergeLeafNodesToTree(current_path, it->second, out);
@@ -353,7 +360,7 @@ void FieldMaskTree::MergeMessage(const Node* node, const Message& source,
const Reflection* source_reflection = source.GetReflection();
const Reflection* destination_reflection = destination->GetReflection();
const Descriptor* descriptor = source.GetDescriptor();
- for (map<string, Node*>::const_iterator it = node->children.begin();
+ for (std::map<string, Node*>::const_iterator it = node->children.begin();
it != node->children.end(); ++it) {
const string& field_name = it->first;
const Node* child = it->second;
@@ -456,7 +463,8 @@ void FieldMaskTree::TrimMessage(const Node* node, Message* message) {
const int32 field_count = descriptor->field_count();
for (int index = 0; index < field_count; ++index) {
const FieldDescriptor* field = descriptor->field(index);
- map<string, Node*>::const_iterator it = node->children.find(field->name());
+ std::map<string, Node*>::const_iterator it =
+ node->children.find(field->name());
if (it == node->children.end()) {
reflection->ClearField(message, field);
} else {
diff --git a/src/google/protobuf/util/field_mask_util.h b/src/google/protobuf/util/field_mask_util.h
index 396c9aea..ab1f2e94 100644
--- a/src/google/protobuf/util/field_mask_util.h
+++ b/src/google/protobuf/util/field_mask_util.h
@@ -59,17 +59,26 @@ class LIBPROTOBUF_EXPORT FieldMaskUtil {
static bool ToJsonString(const FieldMask& mask, string* out);
static bool FromJsonString(StringPiece str, FieldMask* out);
+ // Get the descriptors of the fields which the given path from the message
+ // descriptor traverses, if field_descriptors is not null.
+ // Return false if the path is not valid, and the content of field_descriptors
+ // is unspecified.
+ static bool GetFieldDescriptors(
+ const Descriptor* descriptor, StringPiece path,
+ std::vector<const FieldDescriptor*>* field_descriptors);
+
// Checks whether the given path is valid for type T.
template <typename T>
static bool IsValidPath(StringPiece path) {
- return InternalIsValidPath(T::descriptor(), path);
+ return GetFieldDescriptors(T::descriptor(), path, NULL);
}
// Checks whether the given FieldMask is valid for type T.
template <typename T>
static bool IsValidFieldMask(const FieldMask& mask) {
for (int i = 0; i < mask.paths_size(); ++i) {
- if (!InternalIsValidPath(T::descriptor(), mask.paths(i))) return false;
+ if (!GetFieldDescriptors(T::descriptor(), mask.paths(i), NULL))
+ return false;
}
return true;
}
@@ -149,9 +158,6 @@ class LIBPROTOBUF_EXPORT FieldMaskUtil {
// successfully.
static bool CamelCaseToSnakeCase(StringPiece input, string* output);
- static bool InternalIsValidPath(const Descriptor* descriptor,
- StringPiece path);
-
static void InternalGetFieldMaskForAllFields(const Descriptor* descriptor,
FieldMask* out);
};
diff --git a/src/google/protobuf/util/field_mask_util_test.cc b/src/google/protobuf/util/field_mask_util_test.cc
index 43fb7905..f952786f 100644
--- a/src/google/protobuf/util/field_mask_util_test.cc
+++ b/src/google/protobuf/util/field_mask_util_test.cc
@@ -159,6 +159,27 @@ TEST(FieldMaskUtilTest, JsonStringFormat) {
EXPECT_EQ("baz_quz", mask.paths(1));
}
+TEST(FieldMaskUtilTest, GetFieldDescriptors) {
+ std::vector<const FieldDescriptor*> field_descriptors;
+ EXPECT_TRUE(FieldMaskUtil::GetFieldDescriptors(
+ TestAllTypes::descriptor(), "optional_int32", &field_descriptors));
+ EXPECT_EQ(1, field_descriptors.size());
+ EXPECT_EQ("optional_int32", field_descriptors[0]->name());
+ EXPECT_FALSE(FieldMaskUtil::GetFieldDescriptors(
+ TestAllTypes::descriptor(), "optional_nonexist", NULL));
+ EXPECT_TRUE(FieldMaskUtil::GetFieldDescriptors(TestAllTypes::descriptor(),
+ "optional_nested_message.bb",
+ &field_descriptors));
+ EXPECT_EQ(2, field_descriptors.size());
+ EXPECT_EQ("optional_nested_message", field_descriptors[0]->name());
+ EXPECT_EQ("bb", field_descriptors[1]->name());
+ EXPECT_FALSE(FieldMaskUtil::GetFieldDescriptors(
+ TestAllTypes::descriptor(), "optional_nested_message.nonexist", NULL));
+ // FieldMask cannot be used to specify sub-fields of a repeated message.
+ EXPECT_FALSE(FieldMaskUtil::GetFieldDescriptors(
+ TestAllTypes::descriptor(), "repeated_nested_message.bb", NULL));
+}
+
TEST(FieldMaskUtilTest, TestIsVaildPath) {
EXPECT_TRUE(FieldMaskUtil::IsValidPath<TestAllTypes>("optional_int32"));
EXPECT_FALSE(FieldMaskUtil::IsValidPath<TestAllTypes>("optional_nonexist"));
diff --git a/src/google/protobuf/util/internal/constants.h b/src/google/protobuf/util/internal/constants.h
index e556888c..a018a09e 100644
--- a/src/google/protobuf/util/internal/constants.h
+++ b/src/google/protobuf/util/internal/constants.h
@@ -50,16 +50,16 @@ const char kRfc3339TimeFormat[] = "%E4Y-%m-%dT%H:%M:%S";
const char kRfc3339TimeFormatNoPadding[] = "%Y-%m-%dT%H:%M:%S";
// Minimun seconds allowed in a google.protobuf.Timestamp value.
-const int64 kTimestampMinSeconds = -62135596800;
+const int64 kTimestampMinSeconds = -62135596800LL;
// Maximum seconds allowed in a google.protobuf.Timestamp value.
-const int64 kTimestampMaxSeconds = 253402300799;
+const int64 kTimestampMaxSeconds = 253402300799LL;
// Minimum seconds allowed in a google.protobuf.Duration value.
-const int64 kDurationMinSeconds = -315576000000;
+const int64 kDurationMinSeconds = -315576000000LL;
// Maximum seconds allowed in a google.protobuf.Duration value.
-const int64 kDurationMaxSeconds = 315576000000;
+const int64 kDurationMaxSeconds = 315576000000LL;
// Nano seconds in a second.
const int32 kNanosPerSecond = 1000000000;
diff --git a/src/google/protobuf/util/internal/datapiece.cc b/src/google/protobuf/util/internal/datapiece.cc
index eeb55c6b..213c2c40 100644
--- a/src/google/protobuf/util/internal/datapiece.cc
+++ b/src/google/protobuf/util/internal/datapiece.cc
@@ -94,19 +94,24 @@ StatusOr<To> FloatingPointToIntConvertAndCheck(From before) {
}
// For conversion between double and float only.
-template <typename To, typename From>
-StatusOr<To> FloatingPointConvertAndCheck(From before) {
- if (MathLimits<From>::IsNaN(before)) {
- return std::numeric_limits<To>::quiet_NaN();
- }
+StatusOr<double> FloatToDouble(float before) {
+ // Casting float to double should just work as double has more precision
+ // than float.
+ return static_cast<double>(before);
+}
- To after = static_cast<To>(before);
- if (MathUtil::AlmostEquals<To>(after, before)) {
- return after;
+StatusOr<float> DoubleToFloat(double before) {
+ if (MathLimits<double>::IsNaN(before)) {
+ return std::numeric_limits<float>::quiet_NaN();
+ } else if (!MathLimits<double>::IsFinite(before)) {
+ // Converting a double +inf/-inf to float should just work.
+ return static_cast<float>(before);
+ } else if (before > std::numeric_limits<float>::max() ||
+ before < -std::numeric_limits<float>::max()) {
+ // Double value outside of the range of float.
+ return InvalidArgument(DoubleAsString(before));
} else {
- return InvalidArgument(::google::protobuf::internal::is_same<From, double>::value
- ? DoubleAsString(before)
- : FloatAsString(before));
+ return static_cast<float>(before);
}
}
@@ -162,20 +167,27 @@ StatusOr<uint64> DataPiece::ToUint64() const {
StatusOr<double> DataPiece::ToDouble() const {
if (type_ == TYPE_FLOAT) {
- return FloatingPointConvertAndCheck<double, float>(float_);
+ return FloatToDouble(float_);
}
if (type_ == TYPE_STRING) {
if (str_ == "Infinity") return std::numeric_limits<double>::infinity();
if (str_ == "-Infinity") return -std::numeric_limits<double>::infinity();
if (str_ == "NaN") return std::numeric_limits<double>::quiet_NaN();
- return StringToNumber<double>(safe_strtod);
+ StatusOr<double> value = StringToNumber<double>(safe_strtod);
+ if (value.ok() && !MathLimits<double>::IsFinite(value.ValueOrDie())) {
+ // safe_strtod converts out-of-range values to +inf/-inf, but we want
+ // to report them as errors.
+ return InvalidArgument(StrCat("\"", str_, "\""));
+ } else {
+ return value;
+ }
}
return GenericConvert<double>();
}
StatusOr<float> DataPiece::ToFloat() const {
if (type_ == TYPE_DOUBLE) {
- return FloatingPointConvertAndCheck<float, double>(double_);
+ return DoubleToFloat(double_);
}
if (type_ == TYPE_STRING) {
if (str_ == "Infinity") return std::numeric_limits<float>::infinity();
diff --git a/src/google/protobuf/util/internal/default_value_objectwriter.cc b/src/google/protobuf/util/internal/default_value_objectwriter.cc
index ac1ed9ab..1772219a 100644
--- a/src/google/protobuf/util/internal/default_value_objectwriter.cc
+++ b/src/google/protobuf/util/internal/default_value_objectwriter.cc
@@ -190,7 +190,7 @@ void DefaultValueObjectWriter::RegisterFieldScrubCallBack(
DefaultValueObjectWriter::Node::Node(
const string& name, const google::protobuf::Type* type, NodeKind kind,
- const DataPiece& data, bool is_placeholder, const vector<string>& path,
+ const DataPiece& data, bool is_placeholder, const std::vector<string>& path,
bool suppress_empty_list, FieldScrubCallBack* field_scrub_callback)
: name_(name),
type_(type),
@@ -310,7 +310,7 @@ void DefaultValueObjectWriter::Node::PopulateChildren(
// This code is checking if the field to be added to the tree should be
// scrubbed or not by calling the field_scrub_callback_ callback function.
- vector<string> path;
+ std::vector<string> path;
if (!path_.empty()) {
path.insert(path.begin(), path_.begin(), path_.end());
}
@@ -466,7 +466,7 @@ DataPiece DefaultValueObjectWriter::CreateDefaultDataPieceForField(
DefaultValueObjectWriter* DefaultValueObjectWriter::StartObject(
StringPiece name) {
if (current_ == NULL) {
- vector<string> path;
+ std::vector<string> path;
root_.reset(new Node(name.ToString(), &type_, OBJECT, DataPiece::NullData(),
false, path, suppress_empty_list_,
field_scrub_callback_.get()));
@@ -514,7 +514,7 @@ DefaultValueObjectWriter* DefaultValueObjectWriter::EndObject() {
DefaultValueObjectWriter* DefaultValueObjectWriter::StartList(
StringPiece name) {
if (current_ == NULL) {
- vector<string> path;
+ std::vector<string> path;
root_.reset(new Node(name.ToString(), &type_, LIST, DataPiece::NullData(),
false, path, suppress_empty_list_,
field_scrub_callback_.get()));
diff --git a/src/google/protobuf/util/internal/default_value_objectwriter.h b/src/google/protobuf/util/internal/default_value_objectwriter.h
index 5f3b25f3..dc4551c9 100644
--- a/src/google/protobuf/util/internal/default_value_objectwriter.h
+++ b/src/google/protobuf/util/internal/default_value_objectwriter.h
@@ -139,8 +139,9 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
class LIBPROTOBUF_EXPORT Node {
public:
Node(const string& name, const google::protobuf::Type* type, NodeKind kind,
- const DataPiece& data, bool is_placeholder, const vector<string>& path,
- bool suppress_empty_list, FieldScrubCallBack* field_scrub_callback);
+ const DataPiece& data, bool is_placeholder,
+ const std::vector<string>& path, bool suppress_empty_list,
+ FieldScrubCallBack* field_scrub_callback);
virtual ~Node() {
for (int i = 0; i < children_.size(); ++i) {
delete children_[i];
@@ -166,7 +167,7 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
// Accessors
const string& name() const { return name_; }
- const vector<string>& path() const { return path_; }
+ const std::vector<string>& path() const { return path_; }
const google::protobuf::Type* type() const { return type_; }
@@ -255,7 +256,7 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
// google::protobuf::Type of the root message type.
const google::protobuf::Type& type_;
// Holds copies of strings passed to RenderString.
- vector<string*> string_values_;
+ std::vector<string*> string_values_;
// The current Node. Owned by its parents.
Node* current_;
diff --git a/src/google/protobuf/util/internal/field_mask_utility.cc b/src/google/protobuf/util/internal/field_mask_utility.cc
index f0e8fc88..53b90fb0 100644
--- a/src/google/protobuf/util/internal/field_mask_utility.cc
+++ b/src/google/protobuf/util/internal/field_mask_utility.cc
@@ -112,7 +112,7 @@ string ConvertFieldMaskPath(const StringPiece path,
util::Status DecodeCompactFieldMaskPaths(StringPiece paths,
PathSinkCallback path_sink) {
- stack<string> prefix;
+ std::stack<string> prefix;
int length = paths.length();
int previous_position = 0;
bool in_map_key = false;
diff --git a/src/google/protobuf/util/internal/json_escaping.cc b/src/google/protobuf/util/internal/json_escaping.cc
index 06d2791b..47e4dd6d 100644
--- a/src/google/protobuf/util/internal/json_escaping.cc
+++ b/src/google/protobuf/util/internal/json_escaping.cc
@@ -336,19 +336,19 @@ StringPiece EscapeCodePoint(uint32 cp, char* buffer, bool force_output) {
cp >>= 6;
if (cp <= 0x1f) {
buffer[4] = cp | 0xc0;
- sp.set(buffer + 4, 2);
+ sp = StringPiece(buffer + 4, 2);
return sp;
}
buffer[4] = (cp & 0x3f) | 0x80;
cp >>= 6;
if (cp <= 0x0f) {
buffer[3] = cp | 0xe0;
- sp.set(buffer + 3, 3);
+ sp = StringPiece(buffer + 3, 3);
return sp;
}
buffer[3] = (cp & 0x3f) | 0x80;
buffer[2] = ((cp >> 6) & 0x07) | 0xf0;
- sp.set(buffer + 2, 4);
+ sp = StringPiece(buffer + 2, 4);
}
return sp;
}
diff --git a/src/google/protobuf/util/internal/json_stream_parser.cc b/src/google/protobuf/util/internal/json_stream_parser.cc
index a8d48eff..b38030c3 100644
--- a/src/google/protobuf/util/internal/json_stream_parser.cc
+++ b/src/google/protobuf/util/internal/json_stream_parser.cc
@@ -45,6 +45,8 @@
#include <google/protobuf/util/internal/object_writer.h>
#include <google/protobuf/util/internal/json_escaping.h>
#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/stubs/mathlimits.h>
+
namespace google {
namespace protobuf {
@@ -54,6 +56,7 @@ namespace util {
// this file.
using util::Status;
namespace error {
+using util::error::CANCELLED;
using util::error::INTERNAL;
using util::error::INVALID_ARGUMENT;
} // namespace error
@@ -108,7 +111,8 @@ JsonStreamParser::JsonStreamParser(ObjectWriter* ow)
string_open_(0),
chunk_storage_(),
coerce_to_utf8_(false),
- allow_empty_null_(false) {
+ allow_empty_null_(false),
+ loose_float_number_conversion_(false) {
// Initialize the stack with a single value to be parsed.
stack_.push(VALUE);
}
@@ -243,7 +247,7 @@ util::Status JsonStreamParser::RunParser() {
}
if (!result.ok()) {
// If we were cancelled, save our state and try again later.
- if (!finishing_ && result == util::Status::CANCELLED) {
+ if (!finishing_ && result == util::Status(error::CANCELLED, "")) {
stack_.push(type);
// If we have a key we still need to render, make sure to save off the
// contents in our own storage.
@@ -287,7 +291,7 @@ util::Status JsonStreamParser::ParseValue(TokenType type) {
// don't know if the next char would be e, completing it, or something
// else, making it invalid.
if (!finishing_ && p_.length() < false_len) {
- return util::Status::CANCELLED;
+ return util::Status(error::CANCELLED, "");
}
return ReportFailure("Unexpected token.");
}
@@ -325,7 +329,7 @@ util::Status JsonStreamParser::ParseStringHelper() {
// depending on if we expect more data later.
if (p_.length() == 1) {
if (!finishing_) {
- return util::Status::CANCELLED;
+ return util::Status(error::CANCELLED, "");
}
return ReportFailure("Closing quote expected in string.");
}
@@ -393,7 +397,7 @@ util::Status JsonStreamParser::ParseStringHelper() {
}
// If we didn't find the closing quote but we expect more data, cancel for now
if (!finishing_) {
- return util::Status::CANCELLED;
+ return util::Status(error::CANCELLED, "");
}
// End of string reached without a closing quote, report an error.
string_open_ = 0;
@@ -410,7 +414,7 @@ util::Status JsonStreamParser::ParseStringHelper() {
util::Status JsonStreamParser::ParseUnicodeEscape() {
if (p_.length() < kUnicodeEscapedLength) {
if (!finishing_) {
- return util::Status::CANCELLED;
+ return util::Status(error::CANCELLED, "");
}
return ReportFailure("Illegal hex string.");
}
@@ -427,7 +431,7 @@ util::Status JsonStreamParser::ParseUnicodeEscape() {
code <= JsonEscaping::kMaxHighSurrogate) {
if (p_.length() < 2 * kUnicodeEscapedLength) {
if (!finishing_) {
- return util::Status::CANCELLED;
+ return util::Status(error::CANCELLED, "");
}
if (!coerce_to_utf8_) {
return ReportFailure("Missing low surrogate.");
@@ -521,7 +525,7 @@ util::Status JsonStreamParser::ParseNumberHelper(NumberResult* result) {
// If the entire input is a valid number, and we may have more content in the
// future, we abort for now and resume when we know more.
if (index == length && !finishing_) {
- return util::Status::CANCELLED;
+ return util::Status(error::CANCELLED, "");
}
// Create a string containing just the number, so we can use safe_strtoX
@@ -532,6 +536,10 @@ util::Status JsonStreamParser::ParseNumberHelper(NumberResult* result) {
if (!safe_strtod(number, &result->double_val)) {
return ReportFailure("Unable to parse number.");
}
+ if (!loose_float_number_conversion_ &&
+ !MathLimits<double>::IsFinite(result->double_val)) {
+ return ReportFailure("Number exceeds the range of double.");
+ }
result->type = NumberResult::DOUBLE;
p_.remove_prefix(index);
return util::Status::OK;
@@ -672,7 +680,7 @@ util::Status JsonStreamParser::ParseArrayValue(TokenType type) {
// empty-null array value is relying on this ARRAY_MID token.
stack_.push(ARRAY_MID);
util::Status result = ParseValue(type);
- if (result == util::Status::CANCELLED) {
+ if (result == util::Status(error::CANCELLED, "")) {
// If we were cancelled, pop back off the ARRAY_MID so we don't try to
// push it on again when we try over.
stack_.pop();
@@ -751,7 +759,7 @@ util::Status JsonStreamParser::ReportFailure(StringPiece message) {
util::Status JsonStreamParser::ReportUnknown(StringPiece message) {
// If we aren't finishing the parse, cancel parsing and try later.
if (!finishing_) {
- return util::Status::CANCELLED;
+ return util::Status(error::CANCELLED, "");
}
if (p_.empty()) {
return ReportFailure(StrCat("Unexpected end of string. ", message));
@@ -781,7 +789,7 @@ util::Status JsonStreamParser::ParseKey() {
// we can't know if the key was complete or not.
if (!finishing_ && p_.empty()) {
p_ = original;
- return util::Status::CANCELLED;
+ return util::Status(error::CANCELLED, "");
}
// Since we aren't using the key storage, clear it out.
key_storage_.clear();
diff --git a/src/google/protobuf/util/internal/json_stream_parser.h b/src/google/protobuf/util/internal/json_stream_parser.h
index 78b35cc2..6b9d46ee 100644
--- a/src/google/protobuf/util/internal/json_stream_parser.h
+++ b/src/google/protobuf/util/internal/json_stream_parser.h
@@ -255,6 +255,9 @@ class LIBPROTOBUF_EXPORT JsonStreamParser {
// value.
bool allow_empty_null_;
+ // Whether allows out-of-range floating point numbers or reject them.
+ bool loose_float_number_conversion_;
+
GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(JsonStreamParser);
};
diff --git a/src/google/protobuf/util/internal/json_stream_parser_test.cc b/src/google/protobuf/util/internal/json_stream_parser_test.cc
index eaa7e045..ca71ff24 100644
--- a/src/google/protobuf/util/internal/json_stream_parser_test.cc
+++ b/src/google/protobuf/util/internal/json_stream_parser_test.cc
@@ -89,7 +89,8 @@ class JsonStreamParserTest : public ::testing::Test {
virtual ~JsonStreamParserTest() {}
util::Status RunTest(StringPiece json, int split, bool coerce_utf8 = false,
- bool allow_empty_null = false) {
+ bool allow_empty_null = false,
+ bool loose_float_number_conversion = false) {
JsonStreamParser parser(&mock_);
// Special case for split == length, test parsing one character at a time.
@@ -120,9 +121,10 @@ class JsonStreamParserTest : public ::testing::Test {
}
void DoTest(StringPiece json, int split, bool coerce_utf8 = false,
- bool allow_empty_null = false) {
- util::Status result =
- RunTest(json, split, coerce_utf8, allow_empty_null);
+ bool allow_empty_null = false,
+ bool loose_float_number_conversion = false) {
+ util::Status result = RunTest(json, split, coerce_utf8, allow_empty_null,
+ loose_float_number_conversion);
if (!result.ok()) {
GOOGLE_LOG(WARNING) << result;
}
@@ -142,7 +144,7 @@ class JsonStreamParserTest : public ::testing::Test {
#ifndef _MSC_VER
// TODO(xiaofeng): We have to disable InSequence check for MSVC because it
// causes stack overflow due to its use of a linked list that is desctructed
- // recursively.
+ // recursively.
::testing::InSequence in_sequence_;
#endif // !_MSC_VER
MockObjectWriter mock_;
@@ -322,8 +324,7 @@ TEST_F(JsonStreamParserTest, ObjectKeyTypes) {
// - array containing primitive values (true, false, null, num, string)
TEST_F(JsonStreamParserTest, ArrayPrimitiveValues) {
- StringPiece str =
- "[true, false, null, 'one', \"two\"]";
+ StringPiece str = "[true, false, null, 'one', \"two\"]";
for (int i = 0; i <= str.length(); ++i) {
ow_.StartList("")
->RenderBool("", true)
@@ -710,17 +711,19 @@ TEST_F(JsonStreamParserTest, NegativeNumberTooBig) {
}
}
-/*
-TODO(sven): Fail parsing when parsing a double that is too large.
-
TEST_F(JsonStreamParserTest, DoubleTooBig) {
- StringPiece str = "[184464073709551232321616.45]";
+ StringPiece str = "[1.89769e+308]";
for (int i = 0; i <= str.length(); ++i) {
ow_.StartList("");
- DoErrorTest(str, i, "Unable to parse number");
+ DoErrorTest(str, i, "Number exceeds the range of double.");
+ }
+ str = "[-1.89769e+308]";
+ for (int i = 0; i <= str.length(); ++i) {
+ ow_.StartList("");
+ DoErrorTest(str, i, "Number exceeds the range of double.");
}
}
-*/
+
// invalid bare backslash.
TEST_F(JsonStreamParserTest, UnfinishedEscape) {
diff --git a/src/google/protobuf/util/internal/proto_writer.cc b/src/google/protobuf/util/internal/proto_writer.cc
index 4dcf4c3b..8bebf2ab 100644
--- a/src/google/protobuf/util/internal/proto_writer.cc
+++ b/src/google/protobuf/util/internal/proto_writer.cc
@@ -354,7 +354,7 @@ ProtoWriter::ProtoElement* ProtoWriter::ProtoElement::pop() {
if (!proto3_) {
// Calls the registered error listener for any required field(s) not yet
// seen.
- for (set<const google::protobuf::Field*>::iterator it =
+ for (std::set<const google::protobuf::Field*>::iterator it =
required_fields_.begin();
it != required_fields_.end(); ++it) {
ow_->MissingField((*it)->name());
diff --git a/src/google/protobuf/util/internal/protostream_objectsource.cc b/src/google/protobuf/util/internal/protostream_objectsource.cc
index 150f3cf1..f9fd7b01 100644
--- a/src/google/protobuf/util/internal/protostream_objectsource.cc
+++ b/src/google/protobuf/util/internal/protostream_objectsource.cc
@@ -85,7 +85,7 @@ const google::protobuf::EnumValue* FindEnumValueByNumber(
const google::protobuf::Enum& tech_enum, int number);
// Utility function to format nanos.
-const string FormatNanos(uint32 nanos);
+const string FormatNanos(uint32 nanos, bool with_trailing_zeros);
StatusOr<string> MapKeyDefaultValueAsString(
const google::protobuf::Field& field) {
@@ -120,9 +120,11 @@ ProtoStreamObjectSource::ProtoStreamObjectSource(
own_typeinfo_(true),
type_(type),
use_lower_camel_for_enums_(false),
+ use_ints_for_enums_(false),
recursion_depth_(0),
max_recursion_depth_(kDefaultMaxRecursionDepth),
- render_unknown_fields_(false) {
+ render_unknown_fields_(false),
+ add_trailing_zeros_for_timestamp_and_duration_(false) {
GOOGLE_LOG_IF(DFATAL, stream == NULL) << "Input stream is NULL.";
}
@@ -134,9 +136,11 @@ ProtoStreamObjectSource::ProtoStreamObjectSource(
own_typeinfo_(false),
type_(type),
use_lower_camel_for_enums_(false),
+ use_ints_for_enums_(false),
recursion_depth_(0),
max_recursion_depth_(kDefaultMaxRecursionDepth),
- render_unknown_fields_(false) {
+ render_unknown_fields_(false),
+ add_trailing_zeros_for_timestamp_and_duration_(false) {
GOOGLE_LOG_IF(DFATAL, stream == NULL) << "Input stream is NULL.";
}
@@ -318,7 +322,7 @@ Status ProtoStreamObjectSource::RenderPacked(
Status ProtoStreamObjectSource::RenderTimestamp(
const ProtoStreamObjectSource* os, const google::protobuf::Type& type,
StringPiece field_name, ObjectWriter* ow) {
- pair<int64, int32> p = os->ReadSecondsAndNanos(type);
+ std::pair<int64, int32> p = os->ReadSecondsAndNanos(type);
int64 seconds = p.first;
int32 nanos = p.second;
if (seconds > kTimestampMaxSeconds || seconds < kTimestampMinSeconds) {
@@ -342,7 +346,7 @@ Status ProtoStreamObjectSource::RenderTimestamp(
Status ProtoStreamObjectSource::RenderDuration(
const ProtoStreamObjectSource* os, const google::protobuf::Type& type,
StringPiece field_name, ObjectWriter* ow) {
- pair<int64, int32> p = os->ReadSecondsAndNanos(type);
+ std::pair<int64, int32> p = os->ReadSecondsAndNanos(type);
int64 seconds = p.first;
int32 nanos = p.second;
if (seconds > kDurationMaxSeconds || seconds < kDurationMinSeconds) {
@@ -372,8 +376,10 @@ Status ProtoStreamObjectSource::RenderDuration(
sign = "-";
nanos = -nanos;
}
- string formatted_duration = StringPrintf("%s%lld%ss", sign.c_str(), seconds,
- FormatNanos(nanos).c_str());
+ string formatted_duration = StringPrintf(
+ "%s%lld%ss", sign.c_str(), seconds,
+ FormatNanos(nanos, os->add_trailing_zeros_for_timestamp_and_duration_)
+ .c_str());
ow->RenderString(field_name, formatted_duration);
return Status::OK;
}
@@ -854,6 +860,12 @@ Status ProtoStreamObjectSource::RenderNonMessageField(
break;
}
+ // No need to lookup enum type if we need to render int.
+ if (use_ints_for_enums_) {
+ ow->RenderInt32(field_name, buffer32);
+ break;
+ }
+
// Get the nested enum type for this field.
// TODO(skarvaje): Avoid string manipulation. Find ways to speed this
// up.
@@ -1020,12 +1032,8 @@ bool ProtoStreamObjectSource::IsMap(
const google::protobuf::Field& field) const {
const google::protobuf::Type* field_type =
typeinfo_->GetTypeByTypeUrl(field.type_url());
-
- // TODO(xiaofeng): Unify option names.
return field.kind() == google::protobuf::Field_Kind_TYPE_MESSAGE &&
- (GetBoolOptionOrDefault(field_type->options(),
- "google.protobuf.MessageOptions.map_entry", false) ||
- GetBoolOptionOrDefault(field_type->options(), "map_entry", false));
+ google::protobuf::util::converter::IsMap(field, *field_type);
}
std::pair<int64, int32> ProtoStreamObjectSource::ReadSecondsAndNanos(
@@ -1103,8 +1111,10 @@ const google::protobuf::EnumValue* FindEnumValueByNumber(
// TODO(skarvaje): Look into optimizing this by not doing computation on
// double.
-const string FormatNanos(uint32 nanos) {
- if (nanos == 0) return "";
+const string FormatNanos(uint32 nanos, bool with_trailing_zeros) {
+ if (nanos == 0) {
+ return with_trailing_zeros ? ".000" : "";
+ }
const char* format =
(nanos % 1000 != 0) ? "%.9f" : (nanos % 1000000 != 0) ? "%.6f" : "%.3f";
diff --git a/src/google/protobuf/util/internal/protostream_objectsource.h b/src/google/protobuf/util/internal/protostream_objectsource.h
index adecfbd3..63d5f455 100644
--- a/src/google/protobuf/util/internal/protostream_objectsource.h
+++ b/src/google/protobuf/util/internal/protostream_objectsource.h
@@ -110,6 +110,12 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource {
use_lower_camel_for_enums_ = value;
}
+ // Sets whether to always output enums as ints, by default this is off, and
+ // enums are rendered as strings.
+ void set_use_ints_for_enums(bool value) {
+ use_ints_for_enums_ = value;
+ }
+
// Sets the max recursion depth of proto message to be deserialized. Proto
// messages over this depth will fail to be deserialized.
// Default value is 64.
@@ -285,6 +291,9 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource {
// Whether to render enums using lowerCamelCase. Defaults to false.
bool use_lower_camel_for_enums_;
+ // Whether to render enums as ints always. Defaults to false.
+ bool use_ints_for_enums_;
+
// Tracks current recursion depth.
mutable int recursion_depth_;
@@ -294,6 +303,9 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource {
// Whether to render unknown fields.
bool render_unknown_fields_;
+ // Whether to add trailing zeros for timestamp and duration.
+ bool add_trailing_zeros_for_timestamp_and_duration_;
+
GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(ProtoStreamObjectSource);
};
diff --git a/src/google/protobuf/util/internal/protostream_objectsource_test.cc b/src/google/protobuf/util/internal/protostream_objectsource_test.cc
index cac28a06..e215c4ab 100644
--- a/src/google/protobuf/util/internal/protostream_objectsource_test.cc
+++ b/src/google/protobuf/util/internal/protostream_objectsource_test.cc
@@ -101,7 +101,9 @@ class ProtostreamObjectSourceTest
: helper_(GetParam()),
mock_(),
ow_(&mock_),
- use_lower_camel_for_enums_(false) {
+ use_lower_camel_for_enums_(false),
+ use_ints_for_enums_(false),
+ add_trailing_zeros_(false) {
helper_.ResetTypeInfo(Book::descriptor(), Proto3Message::descriptor());
}
@@ -113,7 +115,7 @@ class ProtostreamObjectSourceTest
}
Status ExecuteTest(const Message& msg, const Descriptor* descriptor) {
- ostringstream oss;
+ std::ostringstream oss;
msg.SerializePartialToOstream(&oss);
string proto = oss.str();
ArrayInputStream arr_stream(proto.data(), proto.size());
@@ -122,6 +124,7 @@ class ProtostreamObjectSourceTest
google::protobuf::scoped_ptr<ProtoStreamObjectSource> os(
helper_.NewProtoSource(&in_stream, GetTypeUrl(descriptor)));
if (use_lower_camel_for_enums_) os->set_use_lower_camel_for_enums(true);
+ if (use_ints_for_enums_) os->set_use_ints_for_enums(true);
os->set_max_recursion_depth(64);
return os->WriteTo(&mock_);
}
@@ -269,11 +272,17 @@ class ProtostreamObjectSourceTest
void UseLowerCamelForEnums() { use_lower_camel_for_enums_ = true; }
+ void UseIntsForEnums() { use_ints_for_enums_ = true; }
+
+ void AddTrailingZeros() { add_trailing_zeros_ = true; }
+
testing::TypeInfoTestHelper helper_;
::testing::NiceMock<MockObjectWriter> mock_;
ExpectingObjectWriter ow_;
bool use_lower_camel_for_enums_;
+ bool use_ints_for_enums_;
+ bool add_trailing_zeros_;
};
INSTANTIATE_TEST_CASE_P(DifferentTypeInfoSourceTest,
@@ -494,6 +503,18 @@ TEST_P(ProtostreamObjectSourceTest, EnumCaseIsUnchangedByDefault) {
DoTest(book, Book::descriptor());
}
+TEST_P(ProtostreamObjectSourceTest, UseIntsForEnumsTest) {
+ Book book;
+ book.set_type(Book::ACTION_AND_ADVENTURE);
+
+ UseIntsForEnums();
+
+ ow_.StartObject("")
+ ->RenderInt32("type", 3)
+ ->EndObject();
+ DoTest(book, Book::descriptor());
+}
+
TEST_P(ProtostreamObjectSourceTest, UnknownEnum) {
Proto3Message message;
message.set_enum_value(static_cast<Proto3Message::NestedEnum>(1234));
@@ -1023,6 +1044,7 @@ TEST_P(ProtostreamObjectSourceTimestampTest, TimestampDurationDefaultValue) {
DoTest(out, TimestampDuration::descriptor());
}
+
} // namespace converter
} // namespace util
} // namespace protobuf
diff --git a/src/google/protobuf/util/internal/protostream_objectwriter.cc b/src/google/protobuf/util/internal/protostream_objectwriter.cc
index 6c15e862..6c9bc30e 100644
--- a/src/google/protobuf/util/internal/protostream_objectwriter.cc
+++ b/src/google/protobuf/util/internal/protostream_objectwriter.cc
@@ -1238,10 +1238,7 @@ bool ProtoStreamObjectWriter::IsMap(const google::protobuf::Field& field) {
const google::protobuf::Type* field_type =
typeinfo()->GetTypeByTypeUrl(field.type_url());
- // TODO(xiaofeng): Unify option names.
- return GetBoolOptionOrDefault(field_type->options(),
- "google.protobuf.MessageOptions.map_entry", false) ||
- GetBoolOptionOrDefault(field_type->options(), "map_entry", false);
+ return google::protobuf::util::converter::IsMap(field, *field_type);
}
bool ProtoStreamObjectWriter::IsAny(const google::protobuf::Field& field) {
diff --git a/src/google/protobuf/util/internal/protostream_objectwriter_test.cc b/src/google/protobuf/util/internal/protostream_objectwriter_test.cc
index e7b38520..a9b15e68 100644
--- a/src/google/protobuf/util/internal/protostream_objectwriter_test.cc
+++ b/src/google/protobuf/util/internal/protostream_objectwriter_test.cc
@@ -113,13 +113,13 @@ class BaseProtoStreamObjectWriterTest
listener_(),
output_(new GrowingArrayByteSink(1000)),
ow_() {
- vector<const Descriptor*> descriptors;
+ std::vector<const Descriptor*> descriptors;
descriptors.push_back(descriptor);
ResetTypeInfo(descriptors);
}
explicit BaseProtoStreamObjectWriterTest(
- vector<const Descriptor*> descriptors)
+ std::vector<const Descriptor*> descriptors)
: helper_(GetParam()),
listener_(),
output_(new GrowingArrayByteSink(1000)),
@@ -127,7 +127,7 @@ class BaseProtoStreamObjectWriterTest
ResetTypeInfo(descriptors);
}
- void ResetTypeInfo(vector<const Descriptor*> descriptors) {
+ void ResetTypeInfo(std::vector<const Descriptor*> descriptors) {
GOOGLE_CHECK(!descriptors.empty()) << "Must have at least one descriptor!";
helper_.ResetTypeInfo(descriptors);
ow_.reset(helper_.NewProtoWriter(GetTypeUrl(descriptors[0]), output_.get(),
@@ -135,7 +135,7 @@ class BaseProtoStreamObjectWriterTest
}
void ResetTypeInfo(const Descriptor* descriptor) {
- vector<const Descriptor*> descriptors;
+ std::vector<const Descriptor*> descriptors;
descriptors.push_back(descriptor);
ResetTypeInfo(descriptors);
}
@@ -1078,7 +1078,7 @@ class ProtoStreamObjectWriterTimestampDurationTest
: public BaseProtoStreamObjectWriterTest {
protected:
ProtoStreamObjectWriterTimestampDurationTest() {
- vector<const Descriptor*> descriptors;
+ std::vector<const Descriptor*> descriptors;
descriptors.push_back(TimestampDuration::descriptor());
descriptors.push_back(google::protobuf::Timestamp::descriptor());
descriptors.push_back(google::protobuf::Duration::descriptor());
@@ -1473,7 +1473,7 @@ class ProtoStreamObjectWriterStructTest
// Resets ProtoWriter with current set of options and other state.
void ResetProtoWriter() {
- vector<const Descriptor*> descriptors;
+ std::vector<const Descriptor*> descriptors;
descriptors.push_back(StructType::descriptor());
descriptors.push_back(google::protobuf::Struct::descriptor());
ResetTypeInfo(descriptors);
@@ -1664,7 +1664,7 @@ TEST_P(ProtoStreamObjectWriterMapTest, RepeatedMapKeyTest) {
class ProtoStreamObjectWriterAnyTest : public BaseProtoStreamObjectWriterTest {
protected:
ProtoStreamObjectWriterAnyTest() {
- vector<const Descriptor*> descriptors;
+ std::vector<const Descriptor*> descriptors;
descriptors.push_back(AnyOut::descriptor());
descriptors.push_back(Book::descriptor());
descriptors.push_back(google::protobuf::Any::descriptor());
@@ -2308,7 +2308,7 @@ class ProtoStreamObjectWriterFieldMaskTest
: public BaseProtoStreamObjectWriterTest {
protected:
ProtoStreamObjectWriterFieldMaskTest() {
- vector<const Descriptor*> descriptors;
+ std::vector<const Descriptor*> descriptors;
descriptors.push_back(FieldMaskTest::descriptor());
descriptors.push_back(google::protobuf::FieldMask::descriptor());
ResetTypeInfo(descriptors);
@@ -2560,7 +2560,7 @@ class ProtoStreamObjectWriterWrappersTest
: public BaseProtoStreamObjectWriterTest {
protected:
ProtoStreamObjectWriterWrappersTest() {
- vector<const Descriptor*> descriptors;
+ std::vector<const Descriptor*> descriptors;
descriptors.push_back(Int32Wrapper::descriptor());
descriptors.push_back(google::protobuf::Int32Value::descriptor());
ResetTypeInfo(descriptors);
@@ -2583,7 +2583,7 @@ class ProtoStreamObjectWriterOneOfsTest
: public BaseProtoStreamObjectWriterTest {
protected:
ProtoStreamObjectWriterOneOfsTest() {
- vector<const Descriptor*> descriptors;
+ std::vector<const Descriptor*> descriptors;
descriptors.push_back(OneOfsRequest::descriptor());
descriptors.push_back(google::protobuf::Struct::descriptor());
ResetTypeInfo(descriptors);
diff --git a/src/google/protobuf/util/internal/type_info.cc b/src/google/protobuf/util/internal/type_info.cc
index 00a8ee7a..17d58475 100644
--- a/src/google/protobuf/util/internal/type_info.cc
+++ b/src/google/protobuf/util/internal/type_info.cc
@@ -60,7 +60,8 @@ class TypeInfoForTypeResolver : public TypeInfo {
virtual util::StatusOr<const google::protobuf::Type*> ResolveTypeUrl(
StringPiece type_url) const {
- map<StringPiece, StatusOrType>::iterator it = cached_types_.find(type_url);
+ std::map<StringPiece, StatusOrType>::iterator it =
+ cached_types_.find(type_url);
if (it != cached_types_.end()) {
return it->second;
}
@@ -85,7 +86,8 @@ class TypeInfoForTypeResolver : public TypeInfo {
virtual const google::protobuf::Enum* GetEnumByTypeUrl(
StringPiece type_url) const {
- map<StringPiece, StatusOrEnum>::iterator it = cached_enums_.find(type_url);
+ std::map<StringPiece, StatusOrEnum>::iterator it =
+ cached_enums_.find(type_url);
if (it != cached_enums_.end()) {
return it->second.ok() ? it->second.ValueOrDie() : NULL;
}
@@ -123,8 +125,8 @@ class TypeInfoForTypeResolver : public TypeInfo {
typedef util::StatusOr<const google::protobuf::Enum*> StatusOrEnum;
template <typename T>
- static void DeleteCachedTypes(map<StringPiece, T>* cached_types) {
- for (typename map<StringPiece, T>::iterator it = cached_types->begin();
+ static void DeleteCachedTypes(std::map<StringPiece, T>* cached_types) {
+ for (typename std::map<StringPiece, T>::iterator it = cached_types->begin();
it != cached_types->end(); ++it) {
if (it->second.ok()) {
delete it->second.ValueOrDie();
@@ -151,13 +153,13 @@ class TypeInfoForTypeResolver : public TypeInfo {
// Stores string values that will be referenced by StringPieces in
// cached_types_, cached_enums_ and camel_case_name_table_.
- mutable set<string> string_storage_;
+ mutable std::set<string> string_storage_;
- mutable map<StringPiece, StatusOrType> cached_types_;
- mutable map<StringPiece, StatusOrEnum> cached_enums_;
+ mutable std::map<StringPiece, StatusOrType> cached_types_;
+ mutable std::map<StringPiece, StatusOrEnum> cached_enums_;
- mutable set<const google::protobuf::Type*> indexed_types_;
- mutable map<StringPiece, StringPiece> camel_case_name_table_;
+ mutable std::set<const google::protobuf::Type*> indexed_types_;
+ mutable std::map<StringPiece, StringPiece> camel_case_name_table_;
};
} // namespace
diff --git a/src/google/protobuf/util/internal/type_info_test_helper.cc b/src/google/protobuf/util/internal/type_info_test_helper.cc
index 49e18ed0..737ba9e4 100644
--- a/src/google/protobuf/util/internal/type_info_test_helper.cc
+++ b/src/google/protobuf/util/internal/type_info_test_helper.cc
@@ -55,7 +55,7 @@ namespace testing {
void TypeInfoTestHelper::ResetTypeInfo(
- const vector<const Descriptor*>& descriptors) {
+ const std::vector<const Descriptor*>& descriptors) {
switch (type_) {
case USE_TYPE_RESOLVER: {
const DescriptorPool* pool = descriptors[0]->file()->pool();
@@ -73,14 +73,14 @@ void TypeInfoTestHelper::ResetTypeInfo(
}
void TypeInfoTestHelper::ResetTypeInfo(const Descriptor* descriptor) {
- vector<const Descriptor*> descriptors;
+ std::vector<const Descriptor*> descriptors;
descriptors.push_back(descriptor);
ResetTypeInfo(descriptors);
}
void TypeInfoTestHelper::ResetTypeInfo(const Descriptor* descriptor1,
const Descriptor* descriptor2) {
- vector<const Descriptor*> descriptors;
+ std::vector<const Descriptor*> descriptors;
descriptors.push_back(descriptor1);
descriptors.push_back(descriptor2);
ResetTypeInfo(descriptors);
diff --git a/src/google/protobuf/util/internal/type_info_test_helper.h b/src/google/protobuf/util/internal/type_info_test_helper.h
index 1a279849..1a196715 100644
--- a/src/google/protobuf/util/internal/type_info_test_helper.h
+++ b/src/google/protobuf/util/internal/type_info_test_helper.h
@@ -64,7 +64,7 @@ class TypeInfoTestHelper {
explicit TypeInfoTestHelper(TypeInfoSource type) : type_(type) {}
// Creates a TypeInfo object for the given set of descriptors.
- void ResetTypeInfo(const vector<const Descriptor*>& descriptors);
+ void ResetTypeInfo(const std::vector<const Descriptor*>& descriptors);
// Convinent overloads.
void ResetTypeInfo(const Descriptor* descriptor);
diff --git a/src/google/protobuf/util/internal/utility.cc b/src/google/protobuf/util/internal/utility.cc
index 9aab3481..6daf24eb 100644
--- a/src/google/protobuf/util/internal/utility.cc
+++ b/src/google/protobuf/util/internal/utility.cc
@@ -30,6 +30,8 @@
#include <google/protobuf/util/internal/utility.h>
+#include <algorithm>
+
#include <google/protobuf/stubs/callback.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h>
@@ -41,8 +43,6 @@
#include <google/protobuf/stubs/map_util.h>
#include <google/protobuf/stubs/mathlimits.h>
-#include <algorithm>
-
namespace google {
namespace protobuf {
namespace util {
@@ -324,7 +324,7 @@ string ToSnakeCase(StringPiece input) {
return result;
}
-set<string>* well_known_types_ = NULL;
+std::set<string>* well_known_types_ = NULL;
GOOGLE_PROTOBUF_DECLARE_ONCE(well_known_types_init_);
const char* well_known_types_name_array_[] = {
"google.protobuf.Timestamp", "google.protobuf.Duration",
@@ -337,7 +337,7 @@ const char* well_known_types_name_array_[] = {
void DeleteWellKnownTypes() { delete well_known_types_; }
void InitWellKnownTypes() {
- well_known_types_ = new set<string>;
+ well_known_types_ = new std::set<string>;
for (int i = 0; i < GOOGLE_ARRAYSIZE(well_known_types_name_array_); ++i) {
well_known_types_->insert(well_known_types_name_array_[i]);
}
@@ -356,15 +356,25 @@ bool IsValidBoolString(const string& bool_string) {
bool IsMap(const google::protobuf::Field& field,
const google::protobuf::Type& type) {
- return (field.cardinality() ==
- google::protobuf::Field_Cardinality_CARDINALITY_REPEATED &&
+ return field.cardinality() ==
+ google::protobuf::Field_Cardinality_CARDINALITY_REPEATED &&
+ (GetBoolOptionOrDefault(type.options(), "map_entry", false) ||
+ GetBoolOptionOrDefault(type.options(),
+ "google.protobuf.MessageOptions.map_entry", false) ||
GetBoolOptionOrDefault(type.options(),
- "google.protobuf.MessageOptions.map_entry", false));
+ "google.protobuf.MessageOptions.map_entry",
+ false));
}
bool IsMessageSetWireFormat(const google::protobuf::Type& type) {
- return GetBoolOptionOrDefault(
- type.options(), "google.protobuf.MessageOptions.message_set_wire_format", false);
+ return GetBoolOptionOrDefault(type.options(), "message_set_wire_format",
+ false) ||
+ GetBoolOptionOrDefault(type.options(),
+ "google.protobuf.MessageOptions.message_set_wire_format",
+ false) ||
+ GetBoolOptionOrDefault(
+ type.options(),
+ "google.protobuf.MessageOptions.message_set_wire_format", false);
}
string DoubleAsString(double value) {
diff --git a/src/google/protobuf/util/json_format_proto3.proto b/src/google/protobuf/util/json_format_proto3.proto
index 3835b30e..8a0441c8 100644
--- a/src/google/protobuf/util/json_format_proto3.proto
+++ b/src/google/protobuf/util/json_format_proto3.proto
@@ -32,6 +32,8 @@ syntax = "proto3";
package proto3;
+option java_package = "com.google.protobuf.util";
+option java_outer_classname = "JsonFormatProto3";
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
diff --git a/src/google/protobuf/util/json_util.cc b/src/google/protobuf/util/json_util.cc
index 5974cc4a..129b6eaf 100644
--- a/src/google/protobuf/util/json_util.cc
+++ b/src/google/protobuf/util/json_util.cc
@@ -82,6 +82,7 @@ util::Status BinaryToJsonStream(TypeResolver* resolver,
google::protobuf::Type type;
RETURN_IF_ERROR(resolver->ResolveMessageType(type_url, &type));
converter::ProtoStreamObjectSource proto_source(&in_stream, resolver, type);
+ proto_source.set_use_ints_for_enums(options.always_print_enums_as_ints);
io::CodedOutputStream out_stream(json_output);
converter::JsonObjectWriter json_writer(options.add_whitespace ? " " : "",
&out_stream);
diff --git a/src/google/protobuf/util/json_util.h b/src/google/protobuf/util/json_util.h
index 0e45ef81..53b1d1ba 100644
--- a/src/google/protobuf/util/json_util.h
+++ b/src/google/protobuf/util/json_util.h
@@ -61,9 +61,13 @@ struct JsonPrintOptions {
// set to 0 will be omitted. Set this flag to true will override the default
// behavior and print primitive fields regardless of their values.
bool always_print_primitive_fields;
+ // Whether to always print enums as ints. By default they are rendered as
+ // strings.
+ bool always_print_enums_as_ints;
JsonPrintOptions() : add_whitespace(false),
- always_print_primitive_fields(false) {
+ always_print_primitive_fields(false),
+ always_print_enums_as_ints(false) {
}
};
diff --git a/src/google/protobuf/util/json_util_test.cc b/src/google/protobuf/util/json_util_test.cc
index 24ff5fd6..796718d5 100644
--- a/src/google/protobuf/util/json_util_test.cc
+++ b/src/google/protobuf/util/json_util_test.cc
@@ -36,6 +36,7 @@
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/descriptor_database.h>
#include <google/protobuf/dynamic_message.h>
+#include <google/protobuf/util/internal/testdata/maps.pb.h>
#include <google/protobuf/util/json_format_proto3.pb.h>
#include <google/protobuf/util/type_resolver.h>
#include <google/protobuf/util/type_resolver_util.h>
@@ -50,6 +51,7 @@ using proto3::FOO;
using proto3::BAR;
using proto3::TestMessage;
using proto3::TestMap;
+using testing::MapIn;
static const char kTypeUrlPrefix[] = "type.googleapis.com";
@@ -62,7 +64,7 @@ static string GetTypeUrl(const Descriptor* message) {
// only cover some very basic cases to make sure the wrappers have forwarded
// parameters to the underlying implementation correctly. More detailed
// tests are contained in the //net/proto2/util/converter directory.
-class JsonUtilTest : public testing::Test {
+class JsonUtilTest : public ::testing::Test {
protected:
JsonUtilTest() {
}
@@ -158,6 +160,29 @@ TEST_F(JsonUtilTest, TestDefaultValues) {
ToJson(m, options));
}
+TEST_F(JsonUtilTest, TestAlwaysPrintEnumsAsInts) {
+ TestMessage orig;
+ orig.set_enum_value(proto3::EnumType::BAR);
+ orig.add_repeated_enum_value(proto3::EnumType::FOO);
+ orig.add_repeated_enum_value(proto3::EnumType::BAR);
+
+ JsonPrintOptions print_options;
+ print_options.always_print_enums_as_ints = true;
+
+ string expected_json =
+ "{\"enumValue\":1,\"repeatedEnumValue\":[0,1]}";
+ EXPECT_EQ(expected_json, ToJson(orig, print_options));
+
+ TestMessage parsed;
+ JsonParseOptions parse_options;
+ ASSERT_TRUE(FromJson(expected_json, &parsed, parse_options));
+
+ EXPECT_EQ(proto3::EnumType::BAR, parsed.enum_value());
+ EXPECT_EQ(2, parsed.repeated_enum_value_size());
+ EXPECT_EQ(proto3::EnumType::FOO, parsed.repeated_enum_value(0));
+ EXPECT_EQ(proto3::EnumType::BAR, parsed.repeated_enum_value(1));
+}
+
TEST_F(JsonUtilTest, ParseMessage) {
// Some random message but good enough to verify that the parsing warpper
// functions are working properly.
@@ -196,6 +221,17 @@ TEST_F(JsonUtilTest, ParseMap) {
EXPECT_EQ(message.DebugString(), other.DebugString());
}
+TEST_F(JsonUtilTest, ParsePrimitiveMapIn) {
+ MapIn message;
+ JsonPrintOptions print_options;
+ print_options.always_print_primitive_fields = true;
+ JsonParseOptions parse_options;
+ EXPECT_EQ("{\"other\":\"\",\"things\":[],\"mapInput\":{}}", ToJson(message, print_options));
+ MapIn other;
+ ASSERT_TRUE(FromJson(ToJson(message, print_options), &other, parse_options));
+ EXPECT_EQ(message.DebugString(), other.DebugString());
+}
+
TEST_F(JsonUtilTest, TestParseIgnoreUnknownFields) {
TestMessage m;
JsonParseOptions options;
@@ -251,11 +287,11 @@ TEST_F(JsonUtilTest, TestDynamicMessage) {
EXPECT_EQ(ToJson(generated, options), ToJson(*message, options));
}
-typedef pair<char*, int> Segment;
+typedef std::pair<char*, int> Segment;
// A ZeroCopyOutputStream that writes to multiple buffers.
class SegmentedZeroCopyOutputStream : public io::ZeroCopyOutputStream {
public:
- explicit SegmentedZeroCopyOutputStream(list<Segment> segments)
+ explicit SegmentedZeroCopyOutputStream(std::list<Segment> segments)
: segments_(segments), last_segment_(static_cast<char*>(NULL), 0), byte_count_(0) {}
virtual bool Next(void** buffer, int* length) {
@@ -281,7 +317,7 @@ class SegmentedZeroCopyOutputStream : public io::ZeroCopyOutputStream {
virtual int64 ByteCount() const { return byte_count_; }
private:
- list<Segment> segments_;
+ std::list<Segment> segments_;
Segment last_segment_;
int64 byte_count_;
};
@@ -299,7 +335,7 @@ TEST(ZeroCopyStreamByteSinkTest, TestAllInputOutputPatterns) {
for (int split_pattern = 0; split_pattern < (1 << (kOutputBufferLength - 1));
split_pattern += kSkippedPatternCount) {
// Split the buffer into small segments according to the split_pattern.
- list<Segment> segments;
+ std::list<Segment> segments;
int segment_start = 0;
for (int i = 0; i < kOutputBufferLength - 1; ++i) {
if (split_pattern & (1 << i)) {
diff --git a/src/google/protobuf/util/message_differencer.cc b/src/google/protobuf/util/message_differencer.cc
index 328b40d8..203d8388 100644
--- a/src/google/protobuf/util/message_differencer.cc
+++ b/src/google/protobuf/util/message_differencer.cc
@@ -73,7 +73,7 @@ class MessageDifferencer::MultipleFieldsMapKeyComparator
public:
MultipleFieldsMapKeyComparator(
MessageDifferencer* message_differencer,
- const vector<vector<const FieldDescriptor*> >& key_field_paths)
+ const std::vector<std::vector<const FieldDescriptor*> >& key_field_paths)
: message_differencer_(message_differencer),
key_field_paths_(key_field_paths) {
GOOGLE_CHECK(!key_field_paths_.empty());
@@ -85,14 +85,14 @@ class MessageDifferencer::MultipleFieldsMapKeyComparator
MessageDifferencer* message_differencer,
const FieldDescriptor* key)
: message_differencer_(message_differencer) {
- vector<const FieldDescriptor*> key_field_path;
+ std::vector<const FieldDescriptor*> key_field_path;
key_field_path.push_back(key);
key_field_paths_.push_back(key_field_path);
}
virtual bool IsMatch(
const Message& message1,
const Message& message2,
- const vector<SpecificField>& parent_fields) const {
+ const std::vector<SpecificField>& parent_fields) const {
for (int i = 0; i < key_field_paths_.size(); ++i) {
if (!IsMatchInternal(message1, message2, parent_fields,
key_field_paths_[i], 0)) {
@@ -105,11 +105,11 @@ class MessageDifferencer::MultipleFieldsMapKeyComparator
bool IsMatchInternal(
const Message& message1,
const Message& message2,
- const vector<SpecificField>& parent_fields,
- const vector<const FieldDescriptor*>& key_field_path,
+ const std::vector<SpecificField>& parent_fields,
+ const std::vector<const FieldDescriptor*>& key_field_path,
int path_index) const {
const FieldDescriptor* field = key_field_path[path_index];
- vector<SpecificField> current_parent_fields(parent_fields);
+ std::vector<SpecificField> current_parent_fields(parent_fields);
if (path_index == key_field_path.size() - 1) {
if (field->is_repeated()) {
if (!message_differencer_->CompareRepeatedField(
@@ -146,7 +146,7 @@ class MessageDifferencer::MultipleFieldsMapKeyComparator
}
}
MessageDifferencer* message_differencer_;
- vector<vector<const FieldDescriptor*> > key_field_paths_;
+ std::vector<std::vector<const FieldDescriptor*> > key_field_paths_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MultipleFieldsMapKeyComparator);
};
@@ -283,10 +283,10 @@ void MessageDifferencer::TreatAsMap(const FieldDescriptor* field,
void MessageDifferencer::TreatAsMapWithMultipleFieldsAsKey(
const FieldDescriptor* field,
- const vector<const FieldDescriptor*>& key_fields) {
- vector<vector<const FieldDescriptor*> > key_field_paths;
+ const std::vector<const FieldDescriptor*>& key_fields) {
+ std::vector<std::vector<const FieldDescriptor*> > key_field_paths;
for (int i = 0; i < key_fields.size(); ++i) {
- vector<const FieldDescriptor*> key_field_path;
+ std::vector<const FieldDescriptor*> key_field_path;
key_field_path.push_back(key_fields[i]);
key_field_paths.push_back(key_field_path);
}
@@ -295,14 +295,15 @@ void MessageDifferencer::TreatAsMapWithMultipleFieldsAsKey(
void MessageDifferencer::TreatAsMapWithMultipleFieldPathsAsKey(
const FieldDescriptor* field,
- const vector<vector<const FieldDescriptor*> >& key_field_paths) {
+ const std::vector<std::vector<const FieldDescriptor*> >& key_field_paths) {
GOOGLE_CHECK(field->is_repeated()) << "Field must be repeated: "
<< field->full_name();
GOOGLE_CHECK_EQ(FieldDescriptor::CPPTYPE_MESSAGE, field->cpp_type())
<< "Field has to be message type. Field name is: "
<< field->full_name();
for (int i = 0; i < key_field_paths.size(); ++i) {
- const vector<const FieldDescriptor*>& key_field_path = key_field_paths[i];
+ const std::vector<const FieldDescriptor*>& key_field_path =
+ key_field_paths[i];
for (int j = 0; j < key_field_path.size(); ++j) {
const FieldDescriptor* parent_field =
j == 0 ? field : key_field_path[j - 1];
@@ -390,7 +391,7 @@ bool MessageDifferencer::FieldBefore(const FieldDescriptor* field1,
bool MessageDifferencer::Compare(const Message& message1,
const Message& message2) {
- vector<SpecificField> parent_fields;
+ std::vector<SpecificField> parent_fields;
bool result = false;
@@ -411,20 +412,20 @@ bool MessageDifferencer::Compare(const Message& message1,
bool MessageDifferencer::CompareWithFields(
const Message& message1,
const Message& message2,
- const vector<const FieldDescriptor*>& message1_fields_arg,
- const vector<const FieldDescriptor*>& message2_fields_arg) {
+ const std::vector<const FieldDescriptor*>& message1_fields_arg,
+ const std::vector<const FieldDescriptor*>& message2_fields_arg) {
if (message1.GetDescriptor() != message2.GetDescriptor()) {
GOOGLE_LOG(DFATAL) << "Comparison between two messages with different "
<< "descriptors.";
return false;
}
- vector<SpecificField> parent_fields;
+ std::vector<SpecificField> parent_fields;
bool result = false;
- vector<const FieldDescriptor*> message1_fields(message1_fields_arg);
- vector<const FieldDescriptor*> message2_fields(message2_fields_arg);
+ std::vector<const FieldDescriptor*> message1_fields(message1_fields_arg);
+ std::vector<const FieldDescriptor*> message2_fields(message2_fields_arg);
std::sort(message1_fields.begin(), message1_fields.end(), FieldBefore);
std::sort(message2_fields.begin(), message2_fields.end(), FieldBefore);
@@ -451,7 +452,7 @@ bool MessageDifferencer::CompareWithFields(
bool MessageDifferencer::Compare(
const Message& message1,
const Message& message2,
- vector<SpecificField>* parent_fields) {
+ std::vector<SpecificField>* parent_fields) {
const Descriptor* descriptor1 = message1.GetDescriptor();
const Descriptor* descriptor2 = message2.GetDescriptor();
if (descriptor1 != descriptor2) {
@@ -473,10 +474,10 @@ bool MessageDifferencer::Compare(
const Reflection* reflection2 = message2.GetReflection();
// Retrieve all the set fields, including extensions.
- vector<const FieldDescriptor*> message1_fields;
+ std::vector<const FieldDescriptor*> message1_fields;
message1_fields.reserve(1 + message1.GetDescriptor()->field_count());
- vector<const FieldDescriptor*> message2_fields;
+ std::vector<const FieldDescriptor*> message2_fields;
message2_fields.reserve(1 + message2.GetDescriptor()->field_count());
reflection1->ListFields(message1, &message1_fields);
@@ -514,15 +515,15 @@ bool MessageDifferencer::Compare(
bool MessageDifferencer::CompareRequestedFieldsUsingSettings(
const Message& message1,
const Message& message2,
- const vector<const FieldDescriptor*>& message1_fields,
- const vector<const FieldDescriptor*>& message2_fields,
- vector<SpecificField>* parent_fields) {
+ const std::vector<const FieldDescriptor*>& message1_fields,
+ const std::vector<const FieldDescriptor*>& message2_fields,
+ std::vector<SpecificField>* parent_fields) {
if (scope_ == FULL) {
if (message_field_comparison_ == EQUIVALENT) {
// We need to merge the field lists of both messages (i.e.
// we are merely checking for a difference in field values,
// rather than the addition or deletion of fields).
- vector<const FieldDescriptor*> fields_union;
+ std::vector<const FieldDescriptor*> fields_union;
CombineFields(message1_fields, FULL, message2_fields, FULL,
&fields_union);
return CompareWithFieldsInternal(message1, message2, fields_union,
@@ -544,7 +545,7 @@ bool MessageDifferencer::CompareRequestedFieldsUsingSettings(
// but only the intersection for message2. This way, any fields
// only present in message2 will be ignored, but any fields only
// present in message1 will be marked as a difference.
- vector<const FieldDescriptor*> fields_intersection;
+ std::vector<const FieldDescriptor*> fields_intersection;
CombineFields(message1_fields, PARTIAL, message2_fields, PARTIAL,
&fields_intersection);
return CompareWithFieldsInternal(message1, message2, message1_fields,
@@ -554,11 +555,11 @@ bool MessageDifferencer::CompareRequestedFieldsUsingSettings(
}
void MessageDifferencer::CombineFields(
- const vector<const FieldDescriptor*>& fields1,
+ const std::vector<const FieldDescriptor*>& fields1,
Scope fields1_scope,
- const vector<const FieldDescriptor*>& fields2,
+ const std::vector<const FieldDescriptor*>& fields2,
Scope fields2_scope,
- vector<const FieldDescriptor*>* combined_fields) {
+ std::vector<const FieldDescriptor*>* combined_fields) {
int index1 = 0;
int index2 = 0;
@@ -588,9 +589,9 @@ void MessageDifferencer::CombineFields(
bool MessageDifferencer::CompareWithFieldsInternal(
const Message& message1,
const Message& message2,
- const vector<const FieldDescriptor*>& message1_fields,
- const vector<const FieldDescriptor*>& message2_fields,
- vector<SpecificField>* parent_fields) {
+ const std::vector<const FieldDescriptor*>& message1_fields,
+ const std::vector<const FieldDescriptor*>& message2_fields,
+ std::vector<SpecificField>* parent_fields) {
bool isDifferent = false;
int field_index1 = 0;
int field_index2 = 0;
@@ -746,13 +747,12 @@ bool MessageDifferencer::CompareWithFieldsInternal(
return !isDifferent;
}
-bool MessageDifferencer::IsMatch(const FieldDescriptor* repeated_field,
- const MapKeyComparator* key_comparator,
- const Message* message1,
- const Message* message2,
- const vector<SpecificField>& parent_fields,
- int index1, int index2) {
- vector<SpecificField> current_parent_fields(parent_fields);
+bool MessageDifferencer::IsMatch(
+ const FieldDescriptor* repeated_field,
+ const MapKeyComparator* key_comparator, const Message* message1,
+ const Message* message2, const std::vector<SpecificField>& parent_fields,
+ int index1, int index2) {
+ std::vector<SpecificField> current_parent_fields(parent_fields);
if (repeated_field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) {
return CompareFieldValueUsingParentFields(
*message1, *message2, repeated_field, index1, index2,
@@ -792,7 +792,7 @@ bool MessageDifferencer::CompareRepeatedField(
const Message& message1,
const Message& message2,
const FieldDescriptor* repeated_field,
- vector<SpecificField>* parent_fields) {
+ std::vector<SpecificField>* parent_fields) {
// the input FieldDescriptor is guaranteed to be repeated field.
const Reflection* reflection1 = message1.GetReflection();
const Reflection* reflection2 = message2.GetReflection();
@@ -813,8 +813,8 @@ bool MessageDifferencer::CompareRepeatedField(
// These two list are used for store the index of the correspondent
// element in peer repeated field.
- vector<int> match_list1;
- vector<int> match_list2;
+ std::vector<int> match_list1;
+ std::vector<int> match_list2;
// Try to match indices of the repeated fields. Return false if match fails
// and there's no detailed report needed.
@@ -899,7 +899,7 @@ bool MessageDifferencer::CompareFieldValue(const Message& message1,
bool MessageDifferencer::CompareFieldValueUsingParentFields(
const Message& message1, const Message& message2,
const FieldDescriptor* field, int index1, int index2,
- vector<SpecificField>* parent_fields) {
+ std::vector<SpecificField>* parent_fields) {
FieldContext field_context(parent_fields);
FieldComparator::ComparisonResult result = GetFieldComparisonResult(
message1, message2, field, index1, index2, &field_context);
@@ -938,7 +938,7 @@ bool MessageDifferencer::CompareFieldValueUsingParentFields(
}
bool MessageDifferencer::CheckPathChanged(
- const vector<SpecificField>& field_path) {
+ const std::vector<SpecificField>& field_path) {
for (int i = 0; i < field_path.size(); ++i) {
if (field_path[i].index != field_path[i].new_index) return true;
}
@@ -962,7 +962,7 @@ bool MessageDifferencer::IsIgnored(
const Message& message1,
const Message& message2,
const FieldDescriptor* field,
- const vector<SpecificField>& parent_fields) {
+ const std::vector<SpecificField>& parent_fields) {
if (ignored_fields_.find(field) != ignored_fields_.end()) {
return true;
}
@@ -977,7 +977,8 @@ bool MessageDifferencer::IsIgnored(
bool MessageDifferencer::IsUnknownFieldIgnored(
const Message& message1, const Message& message2,
- const SpecificField& field, const vector<SpecificField>& parent_fields) {
+ const SpecificField& field,
+ const std::vector<SpecificField>& parent_fields) {
for (int i = 0; i < ignore_criteria_.size(); ++i) {
if (ignore_criteria_[i]->IsUnknownFieldIgnored(message1, message2, field,
parent_fields)) {
@@ -999,7 +1000,7 @@ const MessageDifferencer::MapKeyComparator* MessageDifferencer
namespace {
-typedef pair<int, const UnknownField*> IndexUnknownFieldPair;
+typedef std::pair<int, const UnknownField*> IndexUnknownFieldPair;
struct UnknownFieldOrdering {
inline bool operator()(const IndexUnknownFieldPair& a,
@@ -1050,7 +1051,7 @@ bool MessageDifferencer::CompareUnknownFields(
const Message& message1, const Message& message2,
const google::protobuf::UnknownFieldSet& unknown_field_set1,
const google::protobuf::UnknownFieldSet& unknown_field_set2,
- vector<SpecificField>* parent_field) {
+ std::vector<SpecificField>* parent_field) {
// Ignore unknown fields in EQUIVALENT mode.
if (message_field_comparison_ == EQUIVALENT) return true;
@@ -1066,8 +1067,8 @@ bool MessageDifferencer::CompareUnknownFields(
// two sets -- that is, differing values for the same tag. We use
// IndexUnknownFieldPairs to keep track of the field's original index for
// reporting purposes.
- vector<IndexUnknownFieldPair> fields1; // unknown_field_set1, sorted
- vector<IndexUnknownFieldPair> fields2; // unknown_field_set2, sorted
+ std::vector<IndexUnknownFieldPair> fields1; // unknown_field_set1, sorted
+ std::vector<IndexUnknownFieldPair> fields2; // unknown_field_set2, sorted
fields1.reserve(unknown_field_set1.field_count());
fields2.reserve(unknown_field_set2.field_count());
@@ -1270,7 +1271,7 @@ class MaximumMatcher {
// the x-th node on the right side is matched to y-th node on the left side.
// match_list1[i] == -1 means the node is not matched. Same with match_list2.
MaximumMatcher(int count1, int count2, NodeMatchCallback* callback,
- vector<int>* match_list1, vector<int>* match_list2);
+ std::vector<int>* match_list1, std::vector<int>* match_list2);
// Find a maximum match and return the number of matched node pairs.
// If early_return is true, this method will return 0 immediately when it
// finds that not all nodes on the left side can be matched.
@@ -1282,21 +1283,21 @@ class MaximumMatcher {
// Find an argumenting path starting from the node v on the left side. If a
// path can be found, update match_list2_ to reflect the path and return
// true.
- bool FindArgumentPathDFS(int v, vector<bool>* visited);
+ bool FindArgumentPathDFS(int v, std::vector<bool>* visited);
int count1_;
int count2_;
google::protobuf::scoped_ptr<NodeMatchCallback> match_callback_;
- map<pair<int, int>, bool> cached_match_results_;
- vector<int>* match_list1_;
- vector<int>* match_list2_;
+ std::map<std::pair<int, int>, bool> cached_match_results_;
+ std::vector<int>* match_list1_;
+ std::vector<int>* match_list2_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MaximumMatcher);
};
MaximumMatcher::MaximumMatcher(int count1, int count2,
NodeMatchCallback* callback,
- vector<int>* match_list1,
- vector<int>* match_list2)
+ std::vector<int>* match_list1,
+ std::vector<int>* match_list2)
: count1_(count1), count2_(count2), match_callback_(callback),
match_list1_(match_list1), match_list2_(match_list2) {
match_list1_->assign(count1, -1);
@@ -1306,7 +1307,7 @@ MaximumMatcher::MaximumMatcher(int count1, int count2,
int MaximumMatcher::FindMaximumMatch(bool early_return) {
int result = 0;
for (int i = 0; i < count1_; ++i) {
- vector<bool> visited(count1_);
+ std::vector<bool> visited(count1_);
if (FindArgumentPathDFS(i, &visited)) {
++result;
} else if (early_return) {
@@ -1324,8 +1325,9 @@ int MaximumMatcher::FindMaximumMatch(bool early_return) {
}
bool MaximumMatcher::Match(int left, int right) {
- pair<int, int> p(left, right);
- map<pair<int, int>, bool>::iterator it = cached_match_results_.find(p);
+ std::pair<int, int> p(left, right);
+ std::map<std::pair<int, int>, bool>::iterator it =
+ cached_match_results_.find(p);
if (it != cached_match_results_.end()) {
return it->second;
}
@@ -1333,7 +1335,7 @@ bool MaximumMatcher::Match(int left, int right) {
return cached_match_results_[p];
}
-bool MaximumMatcher::FindArgumentPathDFS(int v, vector<bool>* visited) {
+bool MaximumMatcher::FindArgumentPathDFS(int v, std::vector<bool>* visited) {
(*visited)[v] = true;
// We try to match those un-matched nodes on the right side first. This is
// the step that the navie greedy matching algorithm uses. In the best cases
@@ -1369,9 +1371,9 @@ bool MessageDifferencer::MatchRepeatedFieldIndices(
const Message& message1,
const Message& message2,
const FieldDescriptor* repeated_field,
- const vector<SpecificField>& parent_fields,
- vector<int>* match_list1,
- vector<int>* match_list2) {
+ const std::vector<SpecificField>& parent_fields,
+ std::vector<int>* match_list1,
+ std::vector<int>* match_list2) {
const int count1 =
message1.GetReflection()->FieldSize(message1, repeated_field);
const int count2 =
@@ -1392,7 +1394,8 @@ bool MessageDifferencer::MatchRepeatedFieldIndices(
// doesn't necessarily imply Compare(b, c). Therefore a naive greedy
// algorithm will fail to find a maximum matching.
// Here we use the argumenting path algorithm.
- MaximumMatcher::NodeMatchCallback* callback = NewPermanentCallback(
+ MaximumMatcher::NodeMatchCallback* callback =
+ NewPermanentCallback(
this, &MessageDifferencer::IsMatch,
repeated_field, key_comparator,
&message1, &message2, parent_fields);
@@ -1485,7 +1488,7 @@ MessageDifferencer::StreamReporter::~StreamReporter() {
}
void MessageDifferencer::StreamReporter::PrintPath(
- const vector<SpecificField>& field_path, bool left_side) {
+ const std::vector<SpecificField>& field_path, bool left_side) {
for (int i = 0; i < field_path.size(); ++i) {
if (i > 0) {
printer_->Print(".");
@@ -1514,7 +1517,7 @@ void MessageDifferencer::StreamReporter::PrintPath(
void MessageDifferencer::
StreamReporter::PrintValue(const Message& message,
- const vector<SpecificField>& field_path,
+ const std::vector<SpecificField>& field_path,
bool left_side) {
const SpecificField& specific_field = field_path.back();
const FieldDescriptor* field = specific_field.field;
@@ -1587,7 +1590,7 @@ void MessageDifferencer::StreamReporter::Print(const string& str) {
void MessageDifferencer::StreamReporter::ReportAdded(
const Message& message1,
const Message& message2,
- const vector<SpecificField>& field_path) {
+ const std::vector<SpecificField>& field_path) {
printer_->Print("added: ");
PrintPath(field_path, false);
printer_->Print(": ");
@@ -1598,7 +1601,7 @@ void MessageDifferencer::StreamReporter::ReportAdded(
void MessageDifferencer::StreamReporter::ReportDeleted(
const Message& message1,
const Message& message2,
- const vector<SpecificField>& field_path) {
+ const std::vector<SpecificField>& field_path) {
printer_->Print("deleted: ");
PrintPath(field_path, true);
printer_->Print(": ");
@@ -1609,7 +1612,7 @@ void MessageDifferencer::StreamReporter::ReportDeleted(
void MessageDifferencer::StreamReporter::ReportModified(
const Message& message1,
const Message& message2,
- const vector<SpecificField>& field_path) {
+ const std::vector<SpecificField>& field_path) {
if (!report_modified_aggregates_ && field_path.back().field == NULL) {
if (field_path.back().unknown_field_type == UnknownField::TYPE_GROUP) {
// Any changes to the subfields have already been printed.
@@ -1639,7 +1642,7 @@ void MessageDifferencer::StreamReporter::ReportModified(
void MessageDifferencer::StreamReporter::ReportMoved(
const Message& message1,
const Message& message2,
- const vector<SpecificField>& field_path) {
+ const std::vector<SpecificField>& field_path) {
printer_->Print("moved: ");
PrintPath(field_path, true);
printer_->Print(" -> ");
@@ -1652,7 +1655,7 @@ void MessageDifferencer::StreamReporter::ReportMoved(
void MessageDifferencer::StreamReporter::ReportMatched(
const Message& message1,
const Message& message2,
- const vector<SpecificField>& field_path) {
+ const std::vector<SpecificField>& field_path) {
printer_->Print("matched: ");
PrintPath(field_path, true);
if (CheckPathChanged(field_path)) {
@@ -1667,7 +1670,7 @@ void MessageDifferencer::StreamReporter::ReportMatched(
void MessageDifferencer::StreamReporter::ReportIgnored(
const Message& message1,
const Message& message2,
- const vector<SpecificField>& field_path) {
+ const std::vector<SpecificField>& field_path) {
printer_->Print("ignored: ");
PrintPath(field_path, true);
if (CheckPathChanged(field_path)) {
@@ -1679,7 +1682,7 @@ void MessageDifferencer::StreamReporter::ReportIgnored(
void MessageDifferencer::StreamReporter::ReportUnknownFieldIgnored(
const Message& message1, const Message& message2,
- const vector<SpecificField>& field_path) {
+ const std::vector<SpecificField>& field_path) {
printer_->Print("ignored: ");
PrintPath(field_path, true);
if (CheckPathChanged(field_path)) {
diff --git a/src/google/protobuf/util/message_differencer.h b/src/google/protobuf/util/message_differencer.h
index fde37cf9..d99223cb 100644
--- a/src/google/protobuf/util/message_differencer.h
+++ b/src/google/protobuf/util/message_differencer.h
@@ -821,7 +821,6 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
FieldSet ignored_fields_;
- bool compare_unknown_fields_;
bool report_matches_;
string* output_string_;
diff --git a/src/google/protobuf/util/message_differencer_unittest.cc b/src/google/protobuf/util/message_differencer_unittest.cc
index ed43c512..30b27dba 100755
--- a/src/google/protobuf/util/message_differencer_unittest.cc
+++ b/src/google/protobuf/util/message_differencer_unittest.cc
@@ -66,7 +66,7 @@ namespace {
const FieldDescriptor* GetFieldDescriptor(
const Message& message, const string& field_name) {
- vector<string> field_path =
+ std::vector<string> field_path =
Split(field_name, ".", true);
const Descriptor* descriptor = message.GetDescriptor();
const FieldDescriptor* field = NULL;
@@ -790,8 +790,8 @@ TEST(MessageDifferencerTest, SpecifiedFieldsEqualityAllTest) {
TestUtil::SetAllFields(&msg1);
TestUtil::SetAllFields(&msg2);
- vector<const FieldDescriptor*> fields1;
- vector<const FieldDescriptor*> fields2;
+ std::vector<const FieldDescriptor*> fields1;
+ std::vector<const FieldDescriptor*> fields2;
msg1.GetReflection()->ListFields(msg1, &fields1);
msg2.GetReflection()->ListFields(msg2, &fields2);
@@ -805,8 +805,8 @@ TEST(MessageDifferencerTest, SpecifiedFieldsInequalityAllTest) {
TestUtil::SetAllFields(&msg1);
- vector<const FieldDescriptor*> fields1;
- vector<const FieldDescriptor*> fields2;
+ std::vector<const FieldDescriptor*> fields1;
+ std::vector<const FieldDescriptor*> fields2;
msg1.GetReflection()->ListFields(msg1, &fields1);
msg2.GetReflection()->ListFields(msg2, &fields2);
@@ -820,7 +820,7 @@ TEST(MessageDifferencerTest, SpecifiedFieldsEmptyListAlwaysSucceeds) {
TestUtil::SetAllFields(&msg1);
- vector<const FieldDescriptor*> empty_fields;
+ std::vector<const FieldDescriptor*> empty_fields;
util::MessageDifferencer differencer;
EXPECT_TRUE(differencer.CompareWithFields(msg1, msg2,
@@ -835,7 +835,7 @@ TEST(MessageDifferencerTest, SpecifiedFieldsCompareWithSelf) {
unittest::TestAllTypes msg1;
TestUtil::SetAllFields(&msg1);
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
msg1.GetReflection()->ListFields(msg1, &fields);
util::MessageDifferencer differencer;
@@ -843,7 +843,7 @@ TEST(MessageDifferencerTest, SpecifiedFieldsCompareWithSelf) {
{
// Compare with a subset of fields.
- vector<const FieldDescriptor*> compare_fields;
+ std::vector<const FieldDescriptor*> compare_fields;
for (int i = 0; i < fields.size(); ++i) {
if (i % 2 == 0) {
compare_fields.push_back(fields[i]);
@@ -856,8 +856,8 @@ TEST(MessageDifferencerTest, SpecifiedFieldsCompareWithSelf) {
// Specify a different set of fields to compare, even though we're using the
// same message. This should fail, since we are explicitly saying that the
// set of fields are different.
- vector<const FieldDescriptor*> compare_fields1;
- vector<const FieldDescriptor*> compare_fields2;
+ std::vector<const FieldDescriptor*> compare_fields1;
+ std::vector<const FieldDescriptor*> compare_fields2;
for (int i = 0; i < fields.size(); ++i) {
if (i % 2 == 0) {
compare_fields1.push_back(fields[i]);
@@ -880,8 +880,8 @@ TEST(MessageDifferencerTest, SpecifiedFieldsEqualityAllShuffledTest) {
TestUtil::SetAllFields(&msg1);
TestUtil::SetAllFields(&msg2);
- vector<const FieldDescriptor*> fields1;
- vector<const FieldDescriptor*> fields2;
+ std::vector<const FieldDescriptor*> fields1;
+ std::vector<const FieldDescriptor*> fields2;
msg1.GetReflection()->ListFields(msg1, &fields1);
msg2.GetReflection()->ListFields(msg2, &fields2);
@@ -899,10 +899,10 @@ TEST(MessageDifferencerTest, SpecifiedFieldsSubsetEqualityTest) {
TestUtil::SetAllFields(&msg1);
TestUtil::SetAllFields(&msg2);
- vector<const FieldDescriptor*> fields1;
+ std::vector<const FieldDescriptor*> fields1;
msg1.GetReflection()->ListFields(msg1, &fields1);
- vector<const FieldDescriptor*> compare_fields;
+ std::vector<const FieldDescriptor*> compare_fields;
// Only compare the field descriptors with even indices.
for (int i = 0; i < fields1.size(); ++i) {
if (i % 2 == 0) {
@@ -925,11 +925,11 @@ TEST(MessageDifferencerTest,
TestUtil::SetAllFields(&msg1);
TestUtil::SetAllFields(&msg2);
- vector<const FieldDescriptor*> fields1;
+ std::vector<const FieldDescriptor*> fields1;
const Reflection* reflection = msg1.GetReflection();
reflection->ListFields(msg1, &fields1);
- vector<const FieldDescriptor*> compare_fields;
+ std::vector<const FieldDescriptor*> compare_fields;
// Only compare the field descriptors with even indices.
for (int i = 0; i < fields1.size(); ++i) {
if (i % 2 == 0) {
@@ -954,10 +954,10 @@ TEST(MessageDifferencerTest, SpecifiedFieldsDetectsDifferencesTest) {
TestUtil::SetAllFields(&msg2);
TestUtil::ModifyRepeatedFields(&msg2);
- vector<const FieldDescriptor*> fields1;
+ std::vector<const FieldDescriptor*> fields1;
msg1.GetReflection()->ListFields(msg1, &fields1);
- vector<const FieldDescriptor*> compare_fields;
+ std::vector<const FieldDescriptor*> compare_fields;
// Only compare the repeated field descriptors.
for (int i = 0; i < fields1.size(); ++i) {
if (fields1[i]->is_repeated()) {
@@ -977,8 +977,8 @@ TEST(MessageDifferencerTest, SpecifiedFieldsEquivalenceAllTest) {
TestUtil::SetAllFields(&msg1);
TestUtil::SetAllFields(&msg2);
- vector<const FieldDescriptor*> fields1;
- vector<const FieldDescriptor*> fields2;
+ std::vector<const FieldDescriptor*> fields1;
+ std::vector<const FieldDescriptor*> fields2;
msg1.GetReflection()->ListFields(msg1, &fields1);
msg2.GetReflection()->ListFields(msg2, &fields2);
@@ -1011,8 +1011,8 @@ TEST(MessageDifferencerTest,
// actually doing something.
msg2.set_optional_uint64(23);
- vector<const FieldDescriptor*> fields1;
- vector<const FieldDescriptor*> fields2;
+ std::vector<const FieldDescriptor*> fields1;
+ std::vector<const FieldDescriptor*> fields2;
fields1.push_back(optional_int32_desc);
fields1.push_back(default_int64_desc);
@@ -1286,7 +1286,7 @@ TEST(MessageDifferencerTest, RepeatedFieldMapTest_MultipleFieldsAsKey) {
util::MessageDifferencer differencer;
differencer.TreatAsSet(GetFieldDescriptor(msg1, "item.ra"));
EXPECT_FALSE(differencer.Compare(msg1, msg2));
- vector<const FieldDescriptor*> key_fields;
+ std::vector<const FieldDescriptor*> key_fields;
key_fields.push_back(GetFieldDescriptor(msg1, "item.a"));
key_fields.push_back(GetFieldDescriptor(msg1, "item.ra"));
differencer.TreatAsMapWithMultipleFieldsAsKey(
@@ -1363,11 +1363,11 @@ TEST(MessageDifferencerTest, RepeatedFieldMapTest_MultipleFieldPathsAsKey) {
util::MessageDifferencer differencer;
differencer.TreatAsSet(GetFieldDescriptor(msg1, "item.m.rc"));
EXPECT_FALSE(differencer.Compare(msg1, msg2));
- vector<vector<const FieldDescriptor*> > key_field_paths;
- vector<const FieldDescriptor*> key_field_path1;
+ std::vector<std::vector<const FieldDescriptor*> > key_field_paths;
+ std::vector<const FieldDescriptor*> key_field_path1;
key_field_path1.push_back(GetFieldDescriptor(msg1, "item.m"));
key_field_path1.push_back(GetFieldDescriptor(msg1, "item.m.a"));
- vector<const FieldDescriptor*> key_field_path2;
+ std::vector<const FieldDescriptor*> key_field_path2;
key_field_path2.push_back(GetFieldDescriptor(msg1, "item.m"));
key_field_path2.push_back(GetFieldDescriptor(msg1, "item.m.rc"));
key_field_paths.push_back(key_field_path1);
@@ -1413,7 +1413,7 @@ TEST(MessageDifferencerTest, RepeatedFieldMapTest_IgnoredKeyFields) {
item->set_b("world");
// Compare
util::MessageDifferencer differencer;
- vector<const FieldDescriptor*> key_fields;
+ std::vector<const FieldDescriptor*> key_fields;
key_fields.push_back(GetFieldDescriptor(msg1, "item.a"));
key_fields.push_back(GetFieldDescriptor(msg1, "item.ra"));
differencer.TreatAsMapWithMultipleFieldsAsKey(
@@ -1457,7 +1457,8 @@ class TestIgnorer : public util::MessageDifferencer::IgnoreCriteria {
virtual bool IsIgnored(
const Message& message1, const Message& message2,
const FieldDescriptor* field,
- const vector<util::MessageDifferencer::SpecificField>& parent_fields) {
+ const std::vector<util::MessageDifferencer::SpecificField>&
+ parent_fields) {
string name = "";
for (int i = 0; i < parent_fields.size(); ++i) {
name += parent_fields[i].field->name() + ".";
@@ -1502,7 +1503,7 @@ class ValueProductMapKeyComparator
typedef util::MessageDifferencer::SpecificField SpecificField;
virtual bool IsMatch(
const Message &message1, const Message &message2,
- const vector<SpecificField>& parent_fields) const {
+ const std::vector<SpecificField>& parent_fields) const {
const Reflection* reflection1 = message1.GetReflection();
const Reflection* reflection2 = message2.GetReflection();
// FieldDescriptor for item.ra
@@ -1863,7 +1864,7 @@ TEST(MessageDifferencerTest, IgnoreField_TrumpsCompareWithFields) {
const FieldDescriptor* c = GetFieldDescriptor(msg1, "c");
const FieldDescriptor* rc = GetFieldDescriptor(msg1, "rc");
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
fields.push_back(c);
fields.push_back(rc);
@@ -1899,12 +1900,12 @@ class ParentSavingFieldComparator : public util::FieldComparator {
}
}
- vector<google::protobuf::util::MessageDifferencer::SpecificField> parent_fields() {
+ std::vector<google::protobuf::util::MessageDifferencer::SpecificField> parent_fields() {
return parent_fields_;
}
private:
- vector<google::protobuf::util::MessageDifferencer::SpecificField> parent_fields_;
+ std::vector<google::protobuf::util::MessageDifferencer::SpecificField> parent_fields_;
};
// Tests if MessageDifferencer sends the parent fields in the FieldContext
diff --git a/src/google/protobuf/util/time_util.h b/src/google/protobuf/util/time_util.h
index 432c9f0a..b8846935 100644
--- a/src/google/protobuf/util/time_util.h
+++ b/src/google/protobuf/util/time_util.h
@@ -237,7 +237,7 @@ inline Duration operator%(const Duration& d1, const Duration& d2) {
return result %= d2;
}
-inline ostream& operator<<(ostream& out, const Duration& d) {
+inline std::ostream& operator<<(std::ostream& out, const Duration& d) {
out << google::protobuf::util::TimeUtil::ToString(d);
return out;
}
@@ -284,7 +284,7 @@ inline Timestamp operator-(const Timestamp& t, const Duration& d) {
}
LIBPROTOBUF_EXPORT Duration operator-(const Timestamp& t1, const Timestamp& t2);
-inline ostream& operator<<(ostream& out, const Timestamp& t) {
+inline std::ostream& operator<<(std::ostream& out, const Timestamp& t) {
out << google::protobuf::util::TimeUtil::ToString(t);
return out;
}
diff --git a/src/google/protobuf/util/type_resolver_util.cc b/src/google/protobuf/util/type_resolver_util.cc
index 96393903..febaa41f 100644
--- a/src/google/protobuf/util/type_resolver_util.cc
+++ b/src/google/protobuf/util/type_resolver_util.cc
@@ -54,17 +54,6 @@ using util::Status;
using util::error::INVALID_ARGUMENT;
using util::error::NOT_FOUND;
-bool SplitTypeUrl(const string& type_url, string* url_prefix,
- string* message_name) {
- size_t pos = type_url.find_last_of("/");
- if (pos == string::npos) {
- return false;
- }
- *url_prefix = type_url.substr(0, pos);
- *message_name = type_url.substr(pos + 1);
- return true;
-}
-
class DescriptorPoolTypeResolver : public TypeResolver {
public:
DescriptorPoolTypeResolver(const string& url_prefix,
@@ -72,38 +61,27 @@ class DescriptorPoolTypeResolver : public TypeResolver {
: url_prefix_(url_prefix), pool_(pool) {}
Status ResolveMessageType(const string& type_url, Type* type) {
- string url_prefix, message_name;
- if (!SplitTypeUrl(type_url, &url_prefix, &message_name) ||
- url_prefix != url_prefix_) {
- return Status(INVALID_ARGUMENT,
- StrCat("Invalid type URL, type URLs must be of the form '",
- url_prefix_, "/<typename>', got: ", type_url));
+ string type_name;
+ Status status = ParseTypeUrl(type_url, &type_name);
+ if (!status.ok()) {
+ return status;
}
- if (url_prefix != url_prefix_) {
- return Status(INVALID_ARGUMENT,
- "Cannot resolve types from URL: " + url_prefix);
- }
- const Descriptor* descriptor = pool_->FindMessageTypeByName(message_name);
+
+ const Descriptor* descriptor = pool_->FindMessageTypeByName(type_name);
if (descriptor == NULL) {
- return Status(NOT_FOUND,
- "Invalid type URL, unknown type: " + message_name);
+ return Status(NOT_FOUND, "Invalid type URL, unknown type: " + type_name);
}
ConvertDescriptor(descriptor, type);
return Status();
}
Status ResolveEnumType(const string& type_url, Enum* enum_type) {
- string url_prefix, type_name;
- if (!SplitTypeUrl(type_url, &url_prefix, &type_name) ||
- url_prefix != url_prefix_) {
- return Status(INVALID_ARGUMENT,
- StrCat("Invalid type URL, type URLs must be of the form '",
- url_prefix_, "/<typename>', got: ", type_url));
- }
- if (url_prefix != url_prefix_) {
- return Status(INVALID_ARGUMENT,
- "Cannot resolve types from URL: " + url_prefix);
+ string type_name;
+ Status status = ParseTypeUrl(type_url, &type_name);
+ if (!status.ok()) {
+ return status;
}
+
const EnumDescriptor* descriptor = pool_->FindEnumTypeByName(type_name);
if (descriptor == NULL) {
return Status(NOT_FOUND, "Invalid type URL, unknown type: " + type_name);
@@ -203,6 +181,16 @@ class DescriptorPoolTypeResolver : public TypeResolver {
return url_prefix_ + "/" + descriptor->full_name();
}
+ Status ParseTypeUrl(const string& type_url, string* type_name) {
+ if (type_url.substr(0, url_prefix_.size() + 1) != url_prefix_ + "/") {
+ return Status(INVALID_ARGUMENT,
+ StrCat("Invalid type URL, type URLs must be of the form '",
+ url_prefix_, "/<typename>', got: ", type_url));
+ }
+ *type_name = type_url.substr(url_prefix_.size() + 1);
+ return Status();
+ }
+
string DefaultValueAsString(const FieldDescriptor* descriptor) {
switch (descriptor->cpp_type()) {
case FieldDescriptor::CPPTYPE_INT32:
diff --git a/src/google/protobuf/wire_format.cc b/src/google/protobuf/wire_format.cc
index 147478be..bd5b2489 100644
--- a/src/google/protobuf/wire_format.cc
+++ b/src/google/protobuf/wire_format.cc
@@ -42,6 +42,8 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/descriptor.h>
+#include <google/protobuf/dynamic_message.h>
+#include <google/protobuf/map_field.h>
#include <google/protobuf/wire_format_lite_inl.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/io/coded_stream.h>
@@ -792,7 +794,7 @@ void WireFormat::SerializeWithCachedSizes(
const Reflection* message_reflection = message.GetReflection();
int expected_endpoint = output->ByteCount() + size;
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
message_reflection->ListFields(message, &fields);
for (int i = 0; i < fields.size(); i++) {
SerializeFieldWithCachedSizes(fields[i], message, output);
@@ -834,6 +836,13 @@ void WireFormat::SerializeFieldWithCachedSizes(
count = 1;
}
+ // map_entries is for maps that'll be deterministically serialized.
+ std::vector<const Message*> map_entries;
+ if (count > 1 && field->is_map() && output->IsSerializationDeterministic()) {
+ map_entries =
+ DynamicMapSorter::Sort(message, count, message_reflection, field);
+ }
+
const bool is_packed = field->is_packed();
if (is_packed && count > 0) {
WireFormatLite::WriteTag(field->number(),
@@ -877,15 +886,17 @@ void WireFormat::SerializeFieldWithCachedSizes(
HANDLE_PRIMITIVE_TYPE(BOOL, bool, Bool, Bool)
#undef HANDLE_PRIMITIVE_TYPE
-#define HANDLE_TYPE(TYPE, TYPE_METHOD, CPPTYPE_METHOD) \
- case FieldDescriptor::TYPE_##TYPE: \
- WireFormatLite::Write##TYPE_METHOD( \
- field->number(), \
- field->is_repeated() ? \
- message_reflection->GetRepeated##CPPTYPE_METHOD( \
- message, field, j) : \
- message_reflection->Get##CPPTYPE_METHOD(message, field), \
- output); \
+#define HANDLE_TYPE(TYPE, TYPE_METHOD, CPPTYPE_METHOD) \
+ case FieldDescriptor::TYPE_##TYPE: \
+ WireFormatLite::Write##TYPE_METHOD( \
+ field->number(), \
+ field->is_repeated() ? \
+ (map_entries.empty() ? \
+ message_reflection->GetRepeated##CPPTYPE_METHOD( \
+ message, field, j) : \
+ *map_entries[j]) : \
+ message_reflection->Get##CPPTYPE_METHOD(message, field), \
+ output); \
break;
HANDLE_TYPE(GROUP , Group , Message)
@@ -970,7 +981,7 @@ size_t WireFormat::ByteSize(const Message& message) {
size_t our_size = 0;
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
message_reflection->ListFields(message, &fields);
for (int i = 0; i < fields.size(); i++) {
our_size += FieldByteSize(fields[i], message);
diff --git a/src/google/protobuf/wire_format.h b/src/google/protobuf/wire_format.h
index de8ea574..5e9aca52 100644
--- a/src/google/protobuf/wire_format.h
+++ b/src/google/protobuf/wire_format.h
@@ -327,6 +327,9 @@ inline void WireFormat::VerifyUTF8StringNamedField(
#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
WireFormatLite::VerifyUtf8String(
data, size, static_cast<WireFormatLite::Operation>(op), field_name);
+#else
+ // Avoid the compiler warning about unused variables.
+ (void)data; (void)size; (void)op; (void)field_name;
#endif
}
diff --git a/src/google/protobuf/wire_format_lite.cc b/src/google/protobuf/wire_format_lite.cc
index 5bed7af4..e46ac400 100644
--- a/src/google/protobuf/wire_format_lite.cc
+++ b/src/google/protobuf/wire_format_lite.cc
@@ -34,6 +34,9 @@
#include <google/protobuf/wire_format_lite_inl.h>
+#ifdef __SSE_4_1__
+#include <immintrin.h>
+#endif
#include <stack>
#include <string>
#include <vector>
@@ -337,6 +340,90 @@ bool WireFormatLite::ReadPackedEnumPreserveUnknowns(
return true;
}
+namespace {
+void EncodeFixedSizeValue(float v, uint8* dest) {
+ WireFormatLite::WriteFloatNoTagToArray(v, dest);
+}
+
+void EncodeFixedSizeValue(double v, uint8* dest) {
+ WireFormatLite::WriteDoubleNoTagToArray(v, dest);
+}
+
+void EncodeFixedSizeValue(uint32 v, uint8* dest) {
+ WireFormatLite::WriteFixed32NoTagToArray(v, dest);
+}
+
+void EncodeFixedSizeValue(uint64 v, uint8* dest) {
+ WireFormatLite::WriteFixed64NoTagToArray(v, dest);
+}
+
+void EncodeFixedSizeValue(int32 v, uint8* dest) {
+ WireFormatLite::WriteSFixed32NoTagToArray(v, dest);
+}
+
+void EncodeFixedSizeValue(int64 v, uint8* dest) {
+ WireFormatLite::WriteSFixed64NoTagToArray(v, dest);
+}
+
+void EncodeFixedSizeValue(bool v, uint8* dest) {
+ WireFormatLite::WriteBoolNoTagToArray(v, dest);
+}
+} // anonymous namespace
+
+template <typename CType>
+static void WriteArray(const CType* a, int n, io::CodedOutputStream* output) {
+#if defined(PROTOBUF_LITTLE_ENDIAN)
+ output->WriteRaw(reinterpret_cast<const char*>(a), n * sizeof(a[0]));
+#else
+ const int kAtATime = 128;
+ uint8 buf[sizeof(CType) * kAtATime];
+ for (int i = 0; i < n; i += kAtATime) {
+ int to_do = min(kAtATime, n - i);
+ uint8* ptr = buf;
+ for (int j = 0; j < to_do; j++) {
+ EncodeFixedSizeValue(a[i+j], ptr);
+ ptr += sizeof(a[0]);
+ }
+ output->WriteRaw(buf, to_do * sizeof(a[0]));
+ }
+#endif
+}
+
+void WireFormatLite::WriteFloatArray(const float* a, int n,
+ io::CodedOutputStream* output) {
+ WriteArray<float>(a, n, output);
+}
+
+void WireFormatLite::WriteDoubleArray(const double* a, int n,
+ io::CodedOutputStream* output) {
+ WriteArray<double>(a, n, output);
+}
+
+void WireFormatLite::WriteFixed32Array(const uint32* a, int n,
+ io::CodedOutputStream* output) {
+ WriteArray<uint32>(a, n, output);
+}
+
+void WireFormatLite::WriteFixed64Array(const uint64* a, int n,
+ io::CodedOutputStream* output) {
+ WriteArray<uint64>(a, n, output);
+}
+
+void WireFormatLite::WriteSFixed32Array(const int32* a, int n,
+ io::CodedOutputStream* output) {
+ WriteArray<int32>(a, n, output);
+}
+
+void WireFormatLite::WriteSFixed64Array(const int64* a, int n,
+ io::CodedOutputStream* output) {
+ WriteArray<int64>(a, n, output);
+}
+
+void WireFormatLite::WriteBoolArray(const bool* a, int n,
+ io::CodedOutputStream* output) {
+ WriteArray<bool>(a, n, output);
+}
+
void WireFormatLite::WriteInt32(int field_number, int32 value,
io::CodedOutputStream* output) {
WriteTag(field_number, WIRETYPE_VARINT, output);
@@ -467,7 +554,7 @@ void WireFormatLite::WriteGroupMaybeToArray(int field_number,
uint8* target = output->GetDirectBufferForNBytesAndAdvance(size);
if (target != NULL) {
uint8* end = value.InternalSerializeWithCachedSizesToArray(
- output->IsSerializationDeterminstic(), target);
+ output->IsSerializationDeterministic(), target);
GOOGLE_DCHECK_EQ(end - target, size);
} else {
value.SerializeWithCachedSizes(output);
@@ -484,7 +571,7 @@ void WireFormatLite::WriteMessageMaybeToArray(int field_number,
uint8* target = output->GetDirectBufferForNBytesAndAdvance(size);
if (target != NULL) {
uint8* end = value.InternalSerializeWithCachedSizesToArray(
- output->IsSerializationDeterminstic(), target);
+ output->IsSerializationDeterministic(), target);
GOOGLE_DCHECK_EQ(end - target, size);
} else {
value.SerializeWithCachedSizes(output);
@@ -540,6 +627,152 @@ bool WireFormatLite::VerifyUtf8String(const char* data,
return true;
}
+#ifdef __SSE_4_1__
+template<typename T, bool ZigZag, bool SignExtended>
+static size_t VarintSize(
+ const T* data, const int n,
+ const internal::enable_if<sizeof(T) == 4>::type* = NULL) {
+#if __cplusplus >= 201103L
+ // is_unsigned<T> => !ZigZag
+ static_assert((std::is_unsigned<T>::value ^ ZigZag) ||
+ std::is_signed<T>::value,
+ "Cannot ZigZag encode unsigned types");
+ // is_unsigned<T> => !SignExtended
+ static_assert((std::is_unsigned<T>::value ^ SignExtended) ||
+ std::is_signed<T>::value,
+ "Cannot SignExtended unsigned types");
+#endif
+
+ union vus32 {
+ uint32 u[4];
+ int32 s[4];
+ __m128i v;
+ };
+
+ static const vus32 ones = {{1, 1, 1, 1}};
+
+ // CodedOutputStream::VarintSize32SignExtended returns 10 for negative
+ // numbers. We can apply the UInt32Size algorithm, and simultaneously logical
+ // shift the MSB into the LSB to determine if it is negative.
+ static const vus32 fives = {{5, 5, 5, 5}};
+
+ // sum is the vectorized-output of calling CodedOutputStream::VarintSize32 on
+ // the processed elements.
+ //
+ // msb_sum is the count of set most-significant bits. When computing the
+ // vectorized CodedOutputStream::VarintSize32SignExtended, negative values
+ // have the most significant bit set. VarintSize32SignExtended returns 10 and
+ // VarintSize32 returns 5. msb_sum allows us to compute:
+ // VarintSize32SignExtended = msb_sum * 5 + VarintSize32
+ vus32 sum, v, msb_sum;
+ sum.v = _mm_setzero_si128();
+ msb_sum.v = _mm_setzero_si128();
+
+ int rounded = n & ~(3);
+ int i;
+ for (i = 0; i < rounded; i += 4) {
+ v.v = _mm_loadu_si128(reinterpret_cast<const __m128i*>(&data[i]));
+
+ if (ZigZag) {
+ // Note: the right-shift must be arithmetic
+ v.v = _mm_xor_si128(_mm_slli_epi32(v.v, 1), _mm_srai_epi32(v.v, 31));
+ }
+
+ sum.v = _mm_add_epi32(sum.v, ones.v);
+ if (SignExtended) {
+ msb_sum.v = _mm_add_epi32(msb_sum.v, _mm_srli_epi32(v.v, 31));
+ }
+
+ v.v = _mm_srli_epi32(v.v, 7);
+
+ for (int j = 0; j < 4; j++) {
+ __m128i min = _mm_min_epi32(v.v, ones.v);
+
+ sum.v = _mm_add_epi32(sum.v, min);
+ v.v = _mm_srli_epi32(v.v, 7);
+ }
+ }
+
+ if (SignExtended) {
+ vus32 extensions;
+ extensions.v = _mm_mullo_epi32(msb_sum.v, fives.v);
+
+ sum.v = _mm_add_epi32(sum.v, extensions.v);
+ }
+
+ // TODO(ckennelly): Can we avoid the sign conversion?
+ size_t out = _mm_cvtsi128_si32(
+ _mm_hadd_epi32(_mm_hadd_epi32(sum.v, ones.v), ones.v));
+
+ // Finish tail.
+ for (; i < n; i++) {
+ if (ZigZag) {
+ out += WireFormatLite::SInt32Size(data[i]);
+ } else if (SignExtended) {
+ out += WireFormatLite::Int32Size(data[i]);
+ } else {
+ out += WireFormatLite::UInt32Size(data[i]);
+ }
+ }
+
+ return out;
+}
+
+size_t WireFormatLite::Int32Size(const RepeatedField<int32>& value) {
+ return VarintSize<int32, false, true>(value.data(), value.size());
+}
+
+size_t WireFormatLite::UInt32Size(const RepeatedField<uint32>& value) {
+ return VarintSize<uint32, false, false>(value.data(), value.size());
+}
+
+size_t WireFormatLite::SInt32Size(const RepeatedField<int32>& value) {
+ return VarintSize<int32, true, true>(value.data(), value.size());
+}
+
+size_t WireFormatLite::EnumSize(const RepeatedField<int>& value) {
+ // On ILP64, sizeof(int) == 8, which would require a different template.
+ return VarintSize<int, false, true>(value.data(), value.size());
+}
+
+#else // !__SSE_4_1__
+size_t WireFormatLite::Int32Size(const RepeatedField<int32>& value) {
+ size_t out = 0;
+ const int n = value.size();
+ for (int i = 0; i < n; i++) {
+ out += Int32Size(value.Get(i));
+ }
+ return out;
+}
+
+size_t WireFormatLite::UInt32Size(const RepeatedField<uint32>& value) {
+ size_t out = 0;
+ const int n = value.size();
+ for (int i = 0; i < n; i++) {
+ out += UInt32Size(value.Get(i));
+ }
+ return out;
+}
+
+size_t WireFormatLite::SInt32Size(const RepeatedField<int32>& value) {
+ size_t out = 0;
+ const int n = value.size();
+ for (int i = 0; i < n; i++) {
+ out += SInt32Size(value.Get(i));
+ }
+ return out;
+}
+
+size_t WireFormatLite::EnumSize(const RepeatedField<int>& value) {
+ size_t out = 0;
+ const int n = value.size();
+ for (int i = 0; i < n; i++) {
+ out += EnumSize(value.Get(i));
+ }
+ return out;
+}
+#endif
+
} // namespace internal
} // namespace protobuf
} // namespace google
diff --git a/src/google/protobuf/wire_format_lite.h b/src/google/protobuf/wire_format_lite.h
index eeb3650f..60355144 100644
--- a/src/google/protobuf/wire_format_lite.h
+++ b/src/google/protobuf/wire_format_lite.h
@@ -42,9 +42,20 @@
#include <string>
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/repeated_field.h>
#include <google/protobuf/message_lite.h>
#include <google/protobuf/io/coded_stream.h> // for CodedOutputStream::Varint32Size
+// Avoid conflict with iOS where <ConditionalMacros.h> #defines TYPE_BOOL.
+//
+// If some one needs the macro TYPE_BOOL in a file that includes this header, it's
+// possible to bring it back using push/pop_macro as follows.
+//
+// #pragma push_macro("TYPE_BOOL")
+// #include this header and/or all headers that need the macro to be undefined.
+// #pragma pop_macro("TYPE_BOOL")
+#undef TYPE_BOOL
+
namespace google {
namespace protobuf {
@@ -243,7 +254,15 @@ class LIBPROTOBUF_EXPORT WireFormatLite {
#define input io::CodedInputStream* input_arg
#define output io::CodedOutputStream* output_arg
#define field_number int field_number_arg
+#ifdef NDEBUG
#define INL GOOGLE_ATTRIBUTE_ALWAYS_INLINE
+#else
+// Avoid excessive inlining in non-optimized builds. Without other optimizations
+// the inlining is not going to provide benefits anyway and the huge resulting
+// functions, especially in the proto-generated serialization functions, produce
+// stack frames so large that many tests run into stack overflows (b/32192897).
+#define INL
+#endif
// Read fields, not including tags. The assumption is that you already
// read the tag to determine what field to read.
@@ -371,6 +390,15 @@ class LIBPROTOBUF_EXPORT WireFormatLite {
INL static void WriteBoolNoTag (bool value, output);
INL static void WriteEnumNoTag (int value, output);
+ // Write array of primitive fields, without tags
+ static void WriteFloatArray (const float* a, int n, output);
+ static void WriteDoubleArray (const double* a, int n, output);
+ static void WriteFixed32Array (const uint32* a, int n, output);
+ static void WriteFixed64Array (const uint64* a, int n, output);
+ static void WriteSFixed32Array(const int32* a, int n, output);
+ static void WriteSFixed64Array(const int64* a, int n, output);
+ static void WriteBoolArray (const bool* a, int n, output);
+
// Write fields, including tags.
static void WriteInt32 (field_number, int32 value, output);
static void WriteInt64 (field_number, int64 value, output);
@@ -519,6 +547,14 @@ class LIBPROTOBUF_EXPORT WireFormatLite {
static inline size_t SInt64Size ( int64 value);
static inline size_t EnumSize ( int value);
+ static size_t Int32Size (const RepeatedField< int32>& value);
+ static inline size_t Int64Size (const RepeatedField< int64>& value);
+ static size_t UInt32Size(const RepeatedField<uint32>& value);
+ static inline size_t UInt64Size(const RepeatedField<uint64>& value);
+ static size_t SInt32Size(const RepeatedField< int32>& value);
+ static inline size_t SInt64Size(const RepeatedField< int64>& value);
+ static size_t EnumSize (const RepeatedField< int>& value);
+
// These types always have the same size.
static const size_t kFixed32Size = 4;
static const size_t kFixed64Size = 8;
diff --git a/src/google/protobuf/wire_format_lite_inl.h b/src/google/protobuf/wire_format_lite_inl.h
index 1963fac8..aa3bb3a6 100644
--- a/src/google/protobuf/wire_format_lite_inl.h
+++ b/src/google/protobuf/wire_format_lite_inl.h
@@ -274,8 +274,9 @@ inline bool WireFormatLite::ReadRepeatedFixedSizePrimitive(
// The number of bytes each type occupies on the wire.
const int per_value_size = tag_size + sizeof(value);
+ // parentheses around (std::min) prevents macro expansion of min(...)
int elements_available =
- std::min(values->Capacity() - values->size(), size / per_value_size);
+ (std::min)(values->Capacity() - values->size(), size / per_value_size);
int num_read = 0;
while (num_read < elements_available &&
(buffer = io::CodedInputStream::ExpectTagFromArray(
@@ -366,8 +367,9 @@ inline bool WireFormatLite::ReadPackedFixedSizePrimitive(
if (bytes_limit == -1) {
bytes_limit = input->BytesUntilLimit();
} else {
+ // parentheses around (std::min) prevents macro expansion of min(...)
bytes_limit =
- std::min(bytes_limit, static_cast<int64>(input->BytesUntilLimit()));
+ (std::min)(bytes_limit, static_cast<int64>(input->BytesUntilLimit()));
}
if (bytes_limit >= new_bytes) {
// Fast-path that pre-allocates *values to the final size.
@@ -862,7 +864,39 @@ inline size_t WireFormatLite::MessageSizeNoVirtual(
}
inline size_t WireFormatLite::LengthDelimitedSize(size_t length) {
- return io::CodedOutputStream::VarintSize32(length) + length;
+ // The static_cast here prevents an error in certain compiler configurations
+ // but is not technically correct--if length is too large to fit in a uint32
+ // then it will be silently truncated. We will need to fix this if we ever
+ // decide to start supporting serialized messages greater than 2 GiB in size.
+ return length + io::CodedOutputStream::VarintSize32(
+ static_cast<uint32>(length));
+}
+
+size_t WireFormatLite::Int64Size (const RepeatedField< int64>& value) {
+ size_t out = 0;
+ const int n = value.size();
+ for (int i = 0; i < n; i++) {
+ out += Int64Size(value.Get(i));
+ }
+ return out;
+}
+
+size_t WireFormatLite::UInt64Size(const RepeatedField<uint64>& value) {
+ size_t out = 0;
+ const int n = value.size();
+ for (int i = 0; i < n; i++) {
+ out += UInt64Size(value.Get(i));
+ }
+ return out;
+}
+
+size_t WireFormatLite::SInt64Size(const RepeatedField< int64>& value) {
+ size_t out = 0;
+ const int n = value.size();
+ for (int i = 0; i < n; i++) {
+ out += SInt64Size(value.Get(i));
+ }
+ return out;
}
} // namespace internal
diff --git a/src/google/protobuf/wire_format_unittest.cc b/src/google/protobuf/wire_format_unittest.cc
index 4e4add66..897fec00 100644
--- a/src/google/protobuf/wire_format_unittest.cc
+++ b/src/google/protobuf/wire_format_unittest.cc
@@ -1138,7 +1138,7 @@ class Utf8ValidationTest : public ::testing::Test {
TEST_F(Utf8ValidationTest, WriteInvalidUTF8String) {
string wire_buffer;
protobuf_unittest::OneString input;
- vector<string> errors;
+ std::vector<string> errors;
{
ScopedMemoryLog log;
WriteMessage(kInvalidUTF8String, &input, &wire_buffer);
@@ -1162,7 +1162,7 @@ TEST_F(Utf8ValidationTest, ReadInvalidUTF8String) {
protobuf_unittest::OneString input;
WriteMessage(kInvalidUTF8String, &input, &wire_buffer);
protobuf_unittest::OneString output;
- vector<string> errors;
+ std::vector<string> errors;
{
ScopedMemoryLog log;
ReadMessage(wire_buffer, &output);
@@ -1185,7 +1185,7 @@ TEST_F(Utf8ValidationTest, ReadInvalidUTF8String) {
TEST_F(Utf8ValidationTest, WriteValidUTF8String) {
string wire_buffer;
protobuf_unittest::OneString input;
- vector<string> errors;
+ std::vector<string> errors;
{
ScopedMemoryLog log;
WriteMessage(kValidUTF8String, &input, &wire_buffer);
@@ -1199,7 +1199,7 @@ TEST_F(Utf8ValidationTest, ReadValidUTF8String) {
protobuf_unittest::OneString input;
WriteMessage(kValidUTF8String, &input, &wire_buffer);
protobuf_unittest::OneString output;
- vector<string> errors;
+ std::vector<string> errors;
{
ScopedMemoryLog log;
ReadMessage(wire_buffer, &output);
@@ -1213,7 +1213,7 @@ TEST_F(Utf8ValidationTest, ReadValidUTF8String) {
TEST_F(Utf8ValidationTest, WriteArbitraryBytes) {
string wire_buffer;
protobuf_unittest::OneBytes input;
- vector<string> errors;
+ std::vector<string> errors;
{
ScopedMemoryLog log;
WriteMessage(kInvalidUTF8String, &input, &wire_buffer);
@@ -1227,7 +1227,7 @@ TEST_F(Utf8ValidationTest, ReadArbitraryBytes) {
protobuf_unittest::OneBytes input;
WriteMessage(kInvalidUTF8String, &input, &wire_buffer);
protobuf_unittest::OneBytes output;
- vector<string> errors;
+ std::vector<string> errors;
{
ScopedMemoryLog log;
ReadMessage(wire_buffer, &output);
@@ -1245,7 +1245,7 @@ TEST_F(Utf8ValidationTest, ParseRepeatedString) {
string wire_buffer = input.SerializeAsString();
protobuf_unittest::MoreString output;
- vector<string> errors;
+ std::vector<string> errors;
{
ScopedMemoryLog log;
ReadMessage(wire_buffer, &output);
@@ -1264,7 +1264,7 @@ TEST_F(Utf8ValidationTest, ParseRepeatedString) {
TEST_F(Utf8ValidationTest, OldVerifyUTF8String) {
string data(kInvalidUTF8String);
- vector<string> errors;
+ std::vector<string> errors;
{
ScopedMemoryLog log;
WireFormat::VerifyUTF8String(data.data(), data.size(),
@@ -1283,6 +1283,136 @@ TEST_F(Utf8ValidationTest, OldVerifyUTF8String) {
}
+TEST(RepeatedVarint, Int32) {
+ RepeatedField<int32> v;
+
+ // Insert -2^n, 2^n and 2^n-1.
+ for (int n = 0; n < 10; n++) {
+ v.Add(-(1 << n));
+ v.Add(1 << n);
+ v.Add((1 << n) - 1);
+ }
+
+ // Check consistency with the scalar Int32Size.
+ size_t expected = 0;
+ for (int i = 0; i < v.size(); i++) {
+ expected += WireFormatLite::Int32Size(v[i]);
+ }
+
+ EXPECT_EQ(expected, WireFormatLite::Int32Size(v));
+}
+
+TEST(RepeatedVarint, Int64) {
+ RepeatedField<int64> v;
+
+ // Insert -2^n, 2^n and 2^n-1.
+ for (int n = 0; n < 10; n++) {
+ v.Add(-(1 << n));
+ v.Add(1 << n);
+ v.Add((1 << n) - 1);
+ }
+
+ // Check consistency with the scalar Int64Size.
+ size_t expected = 0;
+ for (int i = 0; i < v.size(); i++) {
+ expected += WireFormatLite::Int64Size(v[i]);
+ }
+
+ EXPECT_EQ(expected, WireFormatLite::Int64Size(v));
+}
+
+TEST(RepeatedVarint, SInt32) {
+ RepeatedField<int32> v;
+
+ // Insert -2^n, 2^n and 2^n-1.
+ for (int n = 0; n < 10; n++) {
+ v.Add(-(1 << n));
+ v.Add(1 << n);
+ v.Add((1 << n) - 1);
+ }
+
+ // Check consistency with the scalar SInt32Size.
+ size_t expected = 0;
+ for (int i = 0; i < v.size(); i++) {
+ expected += WireFormatLite::SInt32Size(v[i]);
+ }
+
+ EXPECT_EQ(expected, WireFormatLite::SInt32Size(v));
+}
+
+TEST(RepeatedVarint, SInt64) {
+ RepeatedField<int64> v;
+
+ // Insert -2^n, 2^n and 2^n-1.
+ for (int n = 0; n < 10; n++) {
+ v.Add(-(1 << n));
+ v.Add(1 << n);
+ v.Add((1 << n) - 1);
+ }
+
+ // Check consistency with the scalar SInt64Size.
+ size_t expected = 0;
+ for (int i = 0; i < v.size(); i++) {
+ expected += WireFormatLite::SInt64Size(v[i]);
+ }
+
+ EXPECT_EQ(expected, WireFormatLite::SInt64Size(v));
+}
+
+TEST(RepeatedVarint, UInt32) {
+ RepeatedField<uint32> v;
+
+ // Insert 2^n and 2^n-1.
+ for (int n = 0; n < 10; n++) {
+ v.Add(1 << n);
+ v.Add((1 << n) - 1);
+ }
+
+ // Check consistency with the scalar UInt32Size.
+ size_t expected = 0;
+ for (int i = 0; i < v.size(); i++) {
+ expected += WireFormatLite::UInt32Size(v[i]);
+ }
+
+ EXPECT_EQ(expected, WireFormatLite::UInt32Size(v));
+}
+
+TEST(RepeatedVarint, UInt64) {
+ RepeatedField<uint64> v;
+
+ // Insert 2^n and 2^n-1.
+ for (int n = 0; n < 10; n++) {
+ v.Add(1 << n);
+ v.Add((1 << n) - 1);
+ }
+
+ // Check consistency with the scalar UInt64Size.
+ size_t expected = 0;
+ for (int i = 0; i < v.size(); i++) {
+ expected += WireFormatLite::UInt64Size(v[i]);
+ }
+
+ EXPECT_EQ(expected, WireFormatLite::UInt64Size(v));
+}
+
+TEST(RepeatedVarint, Enum) {
+ RepeatedField<int> v;
+
+ // Insert 2^n and 2^n-1.
+ for (int n = 0; n < 10; n++) {
+ v.Add(1 << n);
+ v.Add((1 << n) - 1);
+ }
+
+ // Check consistency with the scalar EnumSize.
+ size_t expected = 0;
+ for (int i = 0; i < v.size(); i++) {
+ expected += WireFormatLite::EnumSize(v[i]);
+ }
+
+ EXPECT_EQ(expected, WireFormatLite::EnumSize(v));
+}
+
} // namespace
} // namespace internal
} // namespace protobuf
diff --git a/src/google/protobuf/wrappers.pb.cc b/src/google/protobuf/wrappers.pb.cc
index 35364066..0dad64a4 100644
--- a/src/google/protobuf/wrappers.pb.cc
+++ b/src/google/protobuf/wrappers.pb.cc
@@ -19,301 +19,204 @@
namespace google {
namespace protobuf {
+class DoubleValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<DoubleValue> {
+} _DoubleValue_default_instance_;
+class FloatValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FloatValue> {
+} _FloatValue_default_instance_;
+class Int64ValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Int64Value> {
+} _Int64Value_default_instance_;
+class UInt64ValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<UInt64Value> {
+} _UInt64Value_default_instance_;
+class Int32ValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Int32Value> {
+} _Int32Value_default_instance_;
+class UInt32ValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<UInt32Value> {
+} _UInt32Value_default_instance_;
+class BoolValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<BoolValue> {
+} _BoolValue_default_instance_;
+class StringValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<StringValue> {
+} _StringValue_default_instance_;
+class BytesValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<BytesValue> {
+} _BytesValue_default_instance_;
+
+namespace protobuf_google_2fprotobuf_2fwrappers_2eproto {
+
namespace {
-const ::google::protobuf::Descriptor* DoubleValue_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- DoubleValue_reflection_ = NULL;
-const ::google::protobuf::Descriptor* FloatValue_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- FloatValue_reflection_ = NULL;
-const ::google::protobuf::Descriptor* Int64Value_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- Int64Value_reflection_ = NULL;
-const ::google::protobuf::Descriptor* UInt64Value_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- UInt64Value_reflection_ = NULL;
-const ::google::protobuf::Descriptor* Int32Value_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- Int32Value_reflection_ = NULL;
-const ::google::protobuf::Descriptor* UInt32Value_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- UInt32Value_reflection_ = NULL;
-const ::google::protobuf::Descriptor* BoolValue_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- BoolValue_reflection_ = NULL;
-const ::google::protobuf::Descriptor* StringValue_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- StringValue_reflection_ = NULL;
-const ::google::protobuf::Descriptor* BytesValue_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- BytesValue_reflection_ = NULL;
+::google::protobuf::Metadata file_level_metadata[9];
} // namespace
-
-void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto() GOOGLE_ATTRIBUTE_COLD;
-void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto() {
- protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto();
- const ::google::protobuf::FileDescriptor* file =
- ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
- "google/protobuf/wrappers.proto");
- GOOGLE_CHECK(file != NULL);
- DoubleValue_descriptor_ = file->message_type(0);
- static const int DoubleValue_offsets_[1] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DoubleValue, value_),
- };
- DoubleValue_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- DoubleValue_descriptor_,
- DoubleValue::internal_default_instance(),
- DoubleValue_offsets_,
- -1,
- -1,
- -1,
- sizeof(DoubleValue),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DoubleValue, _internal_metadata_));
- FloatValue_descriptor_ = file->message_type(1);
- static const int FloatValue_offsets_[1] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FloatValue, value_),
- };
- FloatValue_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- FloatValue_descriptor_,
- FloatValue::internal_default_instance(),
- FloatValue_offsets_,
- -1,
- -1,
- -1,
- sizeof(FloatValue),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FloatValue, _internal_metadata_));
- Int64Value_descriptor_ = file->message_type(2);
- static const int Int64Value_offsets_[1] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int64Value, value_),
- };
- Int64Value_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- Int64Value_descriptor_,
- Int64Value::internal_default_instance(),
- Int64Value_offsets_,
- -1,
- -1,
- -1,
- sizeof(Int64Value),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int64Value, _internal_metadata_));
- UInt64Value_descriptor_ = file->message_type(3);
- static const int UInt64Value_offsets_[1] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt64Value, value_),
- };
- UInt64Value_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- UInt64Value_descriptor_,
- UInt64Value::internal_default_instance(),
- UInt64Value_offsets_,
- -1,
- -1,
- -1,
- sizeof(UInt64Value),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt64Value, _internal_metadata_));
- Int32Value_descriptor_ = file->message_type(4);
- static const int Int32Value_offsets_[1] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int32Value, value_),
- };
- Int32Value_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- Int32Value_descriptor_,
- Int32Value::internal_default_instance(),
- Int32Value_offsets_,
- -1,
- -1,
- -1,
- sizeof(Int32Value),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int32Value, _internal_metadata_));
- UInt32Value_descriptor_ = file->message_type(5);
- static const int UInt32Value_offsets_[1] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt32Value, value_),
- };
- UInt32Value_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- UInt32Value_descriptor_,
- UInt32Value::internal_default_instance(),
- UInt32Value_offsets_,
- -1,
- -1,
- -1,
- sizeof(UInt32Value),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt32Value, _internal_metadata_));
- BoolValue_descriptor_ = file->message_type(6);
- static const int BoolValue_offsets_[1] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BoolValue, value_),
- };
- BoolValue_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- BoolValue_descriptor_,
- BoolValue::internal_default_instance(),
- BoolValue_offsets_,
- -1,
- -1,
- -1,
- sizeof(BoolValue),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BoolValue, _internal_metadata_));
- StringValue_descriptor_ = file->message_type(7);
- static const int StringValue_offsets_[1] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(StringValue, value_),
- };
- StringValue_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- StringValue_descriptor_,
- StringValue::internal_default_instance(),
- StringValue_offsets_,
- -1,
- -1,
- -1,
- sizeof(StringValue),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(StringValue, _internal_metadata_));
- BytesValue_descriptor_ = file->message_type(8);
- static const int BytesValue_offsets_[1] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BytesValue, value_),
- };
- BytesValue_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- BytesValue_descriptor_,
- BytesValue::internal_default_instance(),
- BytesValue_offsets_,
- -1,
- -1,
- -1,
- sizeof(BytesValue),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BytesValue, _internal_metadata_));
-}
+const ::google::protobuf::uint32 TableStruct::offsets[] = {
+ ~0u, // no _has_bits_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DoubleValue, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DoubleValue, value_),
+ ~0u, // no _has_bits_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FloatValue, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FloatValue, value_),
+ ~0u, // no _has_bits_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int64Value, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int64Value, value_),
+ ~0u, // no _has_bits_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt64Value, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt64Value, value_),
+ ~0u, // no _has_bits_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int32Value, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int32Value, value_),
+ ~0u, // no _has_bits_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt32Value, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt32Value, value_),
+ ~0u, // no _has_bits_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BoolValue, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BoolValue, value_),
+ ~0u, // no _has_bits_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(StringValue, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(StringValue, value_),
+ ~0u, // no _has_bits_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BytesValue, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BytesValue, value_),
+};
+
+static const ::google::protobuf::internal::MigrationSchema schemas[] = {
+ { 0, -1, sizeof(DoubleValue)},
+ { 5, -1, sizeof(FloatValue)},
+ { 10, -1, sizeof(Int64Value)},
+ { 15, -1, sizeof(UInt64Value)},
+ { 20, -1, sizeof(Int32Value)},
+ { 25, -1, sizeof(UInt32Value)},
+ { 30, -1, sizeof(BoolValue)},
+ { 35, -1, sizeof(StringValue)},
+ { 40, -1, sizeof(BytesValue)},
+};
+
+static ::google::protobuf::Message const * const file_default_instances[] = {
+ reinterpret_cast<const ::google::protobuf::Message*>(&_DoubleValue_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_FloatValue_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_Int64Value_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_UInt64Value_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_Int32Value_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_UInt32Value_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_BoolValue_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_StringValue_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_BytesValue_default_instance_),
+};
namespace {
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
+void protobuf_AssignDescriptors() {
+ AddDescriptors();
+ ::google::protobuf::MessageFactory* factory = NULL;
+ AssignDescriptors(
+ "google/protobuf/wrappers.proto", schemas, file_default_instances, TableStruct::offsets, factory,
+ file_level_metadata, NULL, NULL);
+}
+
void protobuf_AssignDescriptorsOnce() {
- ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
- &protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto);
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);
}
void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;
void protobuf_RegisterTypes(const ::std::string&) {
protobuf_AssignDescriptorsOnce();
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- DoubleValue_descriptor_, DoubleValue::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- FloatValue_descriptor_, FloatValue::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- Int64Value_descriptor_, Int64Value::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- UInt64Value_descriptor_, UInt64Value::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- Int32Value_descriptor_, Int32Value::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- UInt32Value_descriptor_, UInt32Value::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- BoolValue_descriptor_, BoolValue::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- StringValue_descriptor_, StringValue::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- BytesValue_descriptor_, BytesValue::internal_default_instance());
+ ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 9);
}
} // namespace
-void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto() {
- DoubleValue_default_instance_.Shutdown();
- delete DoubleValue_reflection_;
- FloatValue_default_instance_.Shutdown();
- delete FloatValue_reflection_;
- Int64Value_default_instance_.Shutdown();
- delete Int64Value_reflection_;
- UInt64Value_default_instance_.Shutdown();
- delete UInt64Value_reflection_;
- Int32Value_default_instance_.Shutdown();
- delete Int32Value_reflection_;
- UInt32Value_default_instance_.Shutdown();
- delete UInt32Value_reflection_;
- BoolValue_default_instance_.Shutdown();
- delete BoolValue_reflection_;
- StringValue_default_instance_.Shutdown();
- delete StringValue_reflection_;
- BytesValue_default_instance_.Shutdown();
- delete BytesValue_reflection_;
-}
-
-void protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl() {
+void TableStruct::Shutdown() {
+ _DoubleValue_default_instance_.Shutdown();
+ delete file_level_metadata[0].reflection;
+ _FloatValue_default_instance_.Shutdown();
+ delete file_level_metadata[1].reflection;
+ _Int64Value_default_instance_.Shutdown();
+ delete file_level_metadata[2].reflection;
+ _UInt64Value_default_instance_.Shutdown();
+ delete file_level_metadata[3].reflection;
+ _Int32Value_default_instance_.Shutdown();
+ delete file_level_metadata[4].reflection;
+ _UInt32Value_default_instance_.Shutdown();
+ delete file_level_metadata[5].reflection;
+ _BoolValue_default_instance_.Shutdown();
+ delete file_level_metadata[6].reflection;
+ _StringValue_default_instance_.Shutdown();
+ delete file_level_metadata[7].reflection;
+ _BytesValue_default_instance_.Shutdown();
+ delete file_level_metadata[8].reflection;
+}
+
+void TableStruct::InitDefaultsImpl() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
- DoubleValue_default_instance_.DefaultConstruct();
- FloatValue_default_instance_.DefaultConstruct();
- Int64Value_default_instance_.DefaultConstruct();
- UInt64Value_default_instance_.DefaultConstruct();
- Int32Value_default_instance_.DefaultConstruct();
- UInt32Value_default_instance_.DefaultConstruct();
- BoolValue_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- StringValue_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- BytesValue_default_instance_.DefaultConstruct();
- DoubleValue_default_instance_.get_mutable()->InitAsDefaultInstance();
- FloatValue_default_instance_.get_mutable()->InitAsDefaultInstance();
- Int64Value_default_instance_.get_mutable()->InitAsDefaultInstance();
- UInt64Value_default_instance_.get_mutable()->InitAsDefaultInstance();
- Int32Value_default_instance_.get_mutable()->InitAsDefaultInstance();
- UInt32Value_default_instance_.get_mutable()->InitAsDefaultInstance();
- BoolValue_default_instance_.get_mutable()->InitAsDefaultInstance();
- StringValue_default_instance_.get_mutable()->InitAsDefaultInstance();
- BytesValue_default_instance_.get_mutable()->InitAsDefaultInstance();
-}
-
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_once_);
-void protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto() {
- ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_once_,
- &protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl);
-}
-void protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl() {
- GOOGLE_PROTOBUF_VERIFY_VERSION;
-
- protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ ::google::protobuf::internal::InitProtobufDefaults();
+ _DoubleValue_default_instance_.DefaultConstruct();
+ _FloatValue_default_instance_.DefaultConstruct();
+ _Int64Value_default_instance_.DefaultConstruct();
+ _UInt64Value_default_instance_.DefaultConstruct();
+ _Int32Value_default_instance_.DefaultConstruct();
+ _UInt32Value_default_instance_.DefaultConstruct();
+ _BoolValue_default_instance_.DefaultConstruct();
+ _StringValue_default_instance_.DefaultConstruct();
+ _BytesValue_default_instance_.DefaultConstruct();
+}
+
+void InitDefaults() {
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);
+}
+void AddDescriptorsImpl() {
+ InitDefaults();
+ static const char descriptor[] = {
+ "\n\036google/protobuf/wrappers.proto\022\017google"
+ ".protobuf\"\034\n\013DoubleValue\022\r\n\005value\030\001 \001(\001\""
+ "\033\n\nFloatValue\022\r\n\005value\030\001 \001(\002\"\033\n\nInt64Val"
+ "ue\022\r\n\005value\030\001 \001(\003\"\034\n\013UInt64Value\022\r\n\005valu"
+ "e\030\001 \001(\004\"\033\n\nInt32Value\022\r\n\005value\030\001 \001(\005\"\034\n\013"
+ "UInt32Value\022\r\n\005value\030\001 \001(\r\"\032\n\tBoolValue\022"
+ "\r\n\005value\030\001 \001(\010\"\034\n\013StringValue\022\r\n\005value\030\001"
+ " \001(\t\"\033\n\nBytesValue\022\r\n\005value\030\001 \001(\014B|\n\023com"
+ ".google.protobufB\rWrappersProtoP\001Z*githu"
+ "b.com/golang/protobuf/ptypes/wrappers\370\001\001"
+ "\242\002\003GPB\252\002\036Google.Protobuf.WellKnownTypesb"
+ "\006proto3"
+ };
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
- "\n\036google/protobuf/wrappers.proto\022\017google"
- ".protobuf\"\034\n\013DoubleValue\022\r\n\005value\030\001 \001(\001\""
- "\033\n\nFloatValue\022\r\n\005value\030\001 \001(\002\"\033\n\nInt64Val"
- "ue\022\r\n\005value\030\001 \001(\003\"\034\n\013UInt64Value\022\r\n\005valu"
- "e\030\001 \001(\004\"\033\n\nInt32Value\022\r\n\005value\030\001 \001(\005\"\034\n\013"
- "UInt32Value\022\r\n\005value\030\001 \001(\r\"\032\n\tBoolValue\022"
- "\r\n\005value\030\001 \001(\010\"\034\n\013StringValue\022\r\n\005value\030\001"
- " \001(\t\"\033\n\nBytesValue\022\r\n\005value\030\001 \001(\014B|\n\023com"
- ".google.protobufB\rWrappersProtoP\001Z*githu"
- "b.com/golang/protobuf/ptypes/wrappers\370\001\001"
- "\242\002\003GPB\252\002\036Google.Protobuf.WellKnownTypesb"
- "\006proto3", 447);
+ descriptor, 447);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"google/protobuf/wrappers.proto", &protobuf_RegisterTypes);
- ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto);
+ ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);
}
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_once_);
-void protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto() {
- ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_once_,
- &protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl);
+void AddDescriptors() {
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
}
// Force AddDescriptors() to be called at static initialization time.
-struct StaticDescriptorInitializer_google_2fprotobuf_2fwrappers_2eproto {
- StaticDescriptorInitializer_google_2fprotobuf_2fwrappers_2eproto() {
- protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto();
+struct StaticDescriptorInitializer {
+ StaticDescriptorInitializer() {
+ AddDescriptors();
}
-} static_descriptor_initializer_google_2fprotobuf_2fwrappers_2eproto_;
+} static_descriptor_initializer;
-namespace {
-
-static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN;
-static void MergeFromFail(int line) {
- ::google::protobuf::internal::MergeFromFail(__FILE__, line);
-}
-
-} // namespace
+} // namespace protobuf_google_2fprotobuf_2fwrappers_2eproto
// ===================================================================
@@ -324,7 +227,9 @@ const int DoubleValue::kValueFieldNumber;
DoubleValue::DoubleValue()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.DoubleValue)
}
@@ -332,21 +237,18 @@ DoubleValue::DoubleValue(::google::protobuf::Arena* arena)
: ::google::protobuf::Message(),
_internal_metadata_(arena) {
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults();
#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.DoubleValue)
}
-
-void DoubleValue::InitAsDefaultInstance() {
-}
-
DoubleValue::DoubleValue(const DoubleValue& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ value_ = from.value_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.DoubleValue)
}
@@ -380,17 +282,15 @@ void DoubleValue::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* DoubleValue::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return DoubleValue_descriptor_;
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[0].descriptor;
}
const DoubleValue& DoubleValue::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<DoubleValue> DoubleValue_default_instance_;
-
DoubleValue* DoubleValue::New(::google::protobuf::Arena* arena) const {
return ::google::protobuf::Arena::CreateMessage<DoubleValue>(arena);
}
@@ -406,13 +306,14 @@ bool DoubleValue::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.DoubleValue)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional double value = 1;
+ // double value = 1;
case 1: {
- if (tag == 9) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(9u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>(
@@ -420,7 +321,6 @@ bool DoubleValue::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -448,7 +348,7 @@ failure:
void DoubleValue::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.DoubleValue)
- // optional double value = 1;
+ // double value = 1;
if (this->value() != 0) {
::google::protobuf::internal::WireFormatLite::WriteDouble(1, this->value(), output);
}
@@ -458,9 +358,9 @@ void DoubleValue::SerializeWithCachedSizes(
::google::protobuf::uint8* DoubleValue::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DoubleValue)
- // optional double value = 1;
+ // double value = 1;
if (this->value() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteDoubleToArray(1, this->value(), target);
}
@@ -473,7 +373,7 @@ size_t DoubleValue::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.DoubleValue)
size_t total_size = 0;
- // optional double value = 1;
+ // double value = 1;
if (this->value() != 0) {
total_size += 1 + 8;
}
@@ -487,7 +387,7 @@ size_t DoubleValue::ByteSizeLong() const {
void DoubleValue::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.DoubleValue)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const DoubleValue* source =
::google::protobuf::internal::DynamicCastToGenerated<const DoubleValue>(
&from);
@@ -496,21 +396,14 @@ void DoubleValue::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.DoubleValue)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void DoubleValue::MergeFrom(const DoubleValue& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DoubleValue)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void DoubleValue::UnsafeMergeFrom(const DoubleValue& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
if (from.value() != 0) {
set_value(from.value());
}
@@ -527,11 +420,10 @@ void DoubleValue::CopyFrom(const DoubleValue& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.DoubleValue)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool DoubleValue::IsInitialized() const {
-
return true;
}
@@ -540,10 +432,13 @@ void DoubleValue::Swap(DoubleValue* other) {
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
- DoubleValue temp;
- temp.UnsafeMergeFrom(*this);
- CopyFrom(*other);
- other->CopyFrom(temp);
+ DoubleValue* temp = New(GetArenaNoVirtual());
+ temp->MergeFrom(*other);
+ other->CopyFrom(*this);
+ InternalSwap(temp);
+ if (GetArenaNoVirtual() == NULL) {
+ delete temp;
+ }
}
}
void DoubleValue::UnsafeArenaSwap(DoubleValue* other) {
@@ -553,22 +448,18 @@ void DoubleValue::UnsafeArenaSwap(DoubleValue* other) {
}
void DoubleValue::InternalSwap(DoubleValue* other) {
std::swap(value_, other->value_);
- _internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata DoubleValue::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = DoubleValue_descriptor_;
- metadata.reflection = DoubleValue_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[0];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// DoubleValue
-// optional double value = 1;
+// double value = 1;
void DoubleValue::clear_value() {
value_ = 0;
}
@@ -582,9 +473,6 @@ void DoubleValue::set_value(double value) {
// @@protoc_insertion_point(field_set:google.protobuf.DoubleValue.value)
}
-inline const DoubleValue* DoubleValue::internal_default_instance() {
- return &DoubleValue_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -595,7 +483,9 @@ const int FloatValue::kValueFieldNumber;
FloatValue::FloatValue()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.FloatValue)
}
@@ -603,21 +493,18 @@ FloatValue::FloatValue(::google::protobuf::Arena* arena)
: ::google::protobuf::Message(),
_internal_metadata_(arena) {
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults();
#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.FloatValue)
}
-
-void FloatValue::InitAsDefaultInstance() {
-}
-
FloatValue::FloatValue(const FloatValue& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ value_ = from.value_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.FloatValue)
}
@@ -651,17 +538,15 @@ void FloatValue::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* FloatValue::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return FloatValue_descriptor_;
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[1].descriptor;
}
const FloatValue& FloatValue::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<FloatValue> FloatValue_default_instance_;
-
FloatValue* FloatValue::New(::google::protobuf::Arena* arena) const {
return ::google::protobuf::Arena::CreateMessage<FloatValue>(arena);
}
@@ -677,13 +562,14 @@ bool FloatValue::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.FloatValue)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional float value = 1;
+ // float value = 1;
case 1: {
- if (tag == 13) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(13u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
@@ -691,7 +577,6 @@ bool FloatValue::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -719,7 +604,7 @@ failure:
void FloatValue::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.FloatValue)
- // optional float value = 1;
+ // float value = 1;
if (this->value() != 0) {
::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->value(), output);
}
@@ -729,9 +614,9 @@ void FloatValue::SerializeWithCachedSizes(
::google::protobuf::uint8* FloatValue::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FloatValue)
- // optional float value = 1;
+ // float value = 1;
if (this->value() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->value(), target);
}
@@ -744,7 +629,7 @@ size_t FloatValue::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FloatValue)
size_t total_size = 0;
- // optional float value = 1;
+ // float value = 1;
if (this->value() != 0) {
total_size += 1 + 4;
}
@@ -758,7 +643,7 @@ size_t FloatValue::ByteSizeLong() const {
void FloatValue::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FloatValue)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const FloatValue* source =
::google::protobuf::internal::DynamicCastToGenerated<const FloatValue>(
&from);
@@ -767,21 +652,14 @@ void FloatValue::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FloatValue)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void FloatValue::MergeFrom(const FloatValue& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FloatValue)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void FloatValue::UnsafeMergeFrom(const FloatValue& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
if (from.value() != 0) {
set_value(from.value());
}
@@ -798,11 +676,10 @@ void FloatValue::CopyFrom(const FloatValue& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FloatValue)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool FloatValue::IsInitialized() const {
-
return true;
}
@@ -811,10 +688,13 @@ void FloatValue::Swap(FloatValue* other) {
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
- FloatValue temp;
- temp.UnsafeMergeFrom(*this);
- CopyFrom(*other);
- other->CopyFrom(temp);
+ FloatValue* temp = New(GetArenaNoVirtual());
+ temp->MergeFrom(*other);
+ other->CopyFrom(*this);
+ InternalSwap(temp);
+ if (GetArenaNoVirtual() == NULL) {
+ delete temp;
+ }
}
}
void FloatValue::UnsafeArenaSwap(FloatValue* other) {
@@ -824,22 +704,18 @@ void FloatValue::UnsafeArenaSwap(FloatValue* other) {
}
void FloatValue::InternalSwap(FloatValue* other) {
std::swap(value_, other->value_);
- _internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata FloatValue::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = FloatValue_descriptor_;
- metadata.reflection = FloatValue_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[1];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// FloatValue
-// optional float value = 1;
+// float value = 1;
void FloatValue::clear_value() {
value_ = 0;
}
@@ -853,9 +729,6 @@ void FloatValue::set_value(float value) {
// @@protoc_insertion_point(field_set:google.protobuf.FloatValue.value)
}
-inline const FloatValue* FloatValue::internal_default_instance() {
- return &FloatValue_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -866,7 +739,9 @@ const int Int64Value::kValueFieldNumber;
Int64Value::Int64Value()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.Int64Value)
}
@@ -874,21 +749,18 @@ Int64Value::Int64Value(::google::protobuf::Arena* arena)
: ::google::protobuf::Message(),
_internal_metadata_(arena) {
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults();
#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Int64Value)
}
-
-void Int64Value::InitAsDefaultInstance() {
-}
-
Int64Value::Int64Value(const Int64Value& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ value_ = from.value_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.Int64Value)
}
@@ -922,17 +794,15 @@ void Int64Value::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* Int64Value::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return Int64Value_descriptor_;
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[2].descriptor;
}
const Int64Value& Int64Value::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<Int64Value> Int64Value_default_instance_;
-
Int64Value* Int64Value::New(::google::protobuf::Arena* arena) const {
return ::google::protobuf::Arena::CreateMessage<Int64Value>(arena);
}
@@ -948,13 +818,14 @@ bool Int64Value::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Int64Value)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional int64 value = 1;
+ // int64 value = 1;
case 1: {
- if (tag == 8) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(8u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(
@@ -962,7 +833,6 @@ bool Int64Value::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -990,7 +860,7 @@ failure:
void Int64Value::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.Int64Value)
- // optional int64 value = 1;
+ // int64 value = 1;
if (this->value() != 0) {
::google::protobuf::internal::WireFormatLite::WriteInt64(1, this->value(), output);
}
@@ -1000,9 +870,9 @@ void Int64Value::SerializeWithCachedSizes(
::google::protobuf::uint8* Int64Value::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Int64Value)
- // optional int64 value = 1;
+ // int64 value = 1;
if (this->value() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(1, this->value(), target);
}
@@ -1015,7 +885,7 @@ size_t Int64Value::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Int64Value)
size_t total_size = 0;
- // optional int64 value = 1;
+ // int64 value = 1;
if (this->value() != 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int64Size(
@@ -1031,7 +901,7 @@ size_t Int64Value::ByteSizeLong() const {
void Int64Value::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Int64Value)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const Int64Value* source =
::google::protobuf::internal::DynamicCastToGenerated<const Int64Value>(
&from);
@@ -1040,21 +910,14 @@ void Int64Value::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Int64Value)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void Int64Value::MergeFrom(const Int64Value& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Int64Value)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void Int64Value::UnsafeMergeFrom(const Int64Value& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
if (from.value() != 0) {
set_value(from.value());
}
@@ -1071,11 +934,10 @@ void Int64Value::CopyFrom(const Int64Value& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Int64Value)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool Int64Value::IsInitialized() const {
-
return true;
}
@@ -1084,10 +946,13 @@ void Int64Value::Swap(Int64Value* other) {
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
- Int64Value temp;
- temp.UnsafeMergeFrom(*this);
- CopyFrom(*other);
- other->CopyFrom(temp);
+ Int64Value* temp = New(GetArenaNoVirtual());
+ temp->MergeFrom(*other);
+ other->CopyFrom(*this);
+ InternalSwap(temp);
+ if (GetArenaNoVirtual() == NULL) {
+ delete temp;
+ }
}
}
void Int64Value::UnsafeArenaSwap(Int64Value* other) {
@@ -1097,22 +962,18 @@ void Int64Value::UnsafeArenaSwap(Int64Value* other) {
}
void Int64Value::InternalSwap(Int64Value* other) {
std::swap(value_, other->value_);
- _internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata Int64Value::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = Int64Value_descriptor_;
- metadata.reflection = Int64Value_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[2];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// Int64Value
-// optional int64 value = 1;
+// int64 value = 1;
void Int64Value::clear_value() {
value_ = GOOGLE_LONGLONG(0);
}
@@ -1126,9 +987,6 @@ void Int64Value::set_value(::google::protobuf::int64 value) {
// @@protoc_insertion_point(field_set:google.protobuf.Int64Value.value)
}
-inline const Int64Value* Int64Value::internal_default_instance() {
- return &Int64Value_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -1139,7 +997,9 @@ const int UInt64Value::kValueFieldNumber;
UInt64Value::UInt64Value()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.UInt64Value)
}
@@ -1147,21 +1007,18 @@ UInt64Value::UInt64Value(::google::protobuf::Arena* arena)
: ::google::protobuf::Message(),
_internal_metadata_(arena) {
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults();
#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.UInt64Value)
}
-
-void UInt64Value::InitAsDefaultInstance() {
-}
-
UInt64Value::UInt64Value(const UInt64Value& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ value_ = from.value_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.UInt64Value)
}
@@ -1195,17 +1052,15 @@ void UInt64Value::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* UInt64Value::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return UInt64Value_descriptor_;
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[3].descriptor;
}
const UInt64Value& UInt64Value::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<UInt64Value> UInt64Value_default_instance_;
-
UInt64Value* UInt64Value::New(::google::protobuf::Arena* arena) const {
return ::google::protobuf::Arena::CreateMessage<UInt64Value>(arena);
}
@@ -1221,13 +1076,14 @@ bool UInt64Value::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.UInt64Value)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional uint64 value = 1;
+ // uint64 value = 1;
case 1: {
- if (tag == 8) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(8u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>(
@@ -1235,7 +1091,6 @@ bool UInt64Value::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -1263,7 +1118,7 @@ failure:
void UInt64Value::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.UInt64Value)
- // optional uint64 value = 1;
+ // uint64 value = 1;
if (this->value() != 0) {
::google::protobuf::internal::WireFormatLite::WriteUInt64(1, this->value(), output);
}
@@ -1273,9 +1128,9 @@ void UInt64Value::SerializeWithCachedSizes(
::google::protobuf::uint8* UInt64Value::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UInt64Value)
- // optional uint64 value = 1;
+ // uint64 value = 1;
if (this->value() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(1, this->value(), target);
}
@@ -1288,7 +1143,7 @@ size_t UInt64Value::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.UInt64Value)
size_t total_size = 0;
- // optional uint64 value = 1;
+ // uint64 value = 1;
if (this->value() != 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::UInt64Size(
@@ -1304,7 +1159,7 @@ size_t UInt64Value::ByteSizeLong() const {
void UInt64Value::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.UInt64Value)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const UInt64Value* source =
::google::protobuf::internal::DynamicCastToGenerated<const UInt64Value>(
&from);
@@ -1313,21 +1168,14 @@ void UInt64Value::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.UInt64Value)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void UInt64Value::MergeFrom(const UInt64Value& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UInt64Value)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void UInt64Value::UnsafeMergeFrom(const UInt64Value& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
if (from.value() != 0) {
set_value(from.value());
}
@@ -1344,11 +1192,10 @@ void UInt64Value::CopyFrom(const UInt64Value& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.UInt64Value)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool UInt64Value::IsInitialized() const {
-
return true;
}
@@ -1357,10 +1204,13 @@ void UInt64Value::Swap(UInt64Value* other) {
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
- UInt64Value temp;
- temp.UnsafeMergeFrom(*this);
- CopyFrom(*other);
- other->CopyFrom(temp);
+ UInt64Value* temp = New(GetArenaNoVirtual());
+ temp->MergeFrom(*other);
+ other->CopyFrom(*this);
+ InternalSwap(temp);
+ if (GetArenaNoVirtual() == NULL) {
+ delete temp;
+ }
}
}
void UInt64Value::UnsafeArenaSwap(UInt64Value* other) {
@@ -1370,22 +1220,18 @@ void UInt64Value::UnsafeArenaSwap(UInt64Value* other) {
}
void UInt64Value::InternalSwap(UInt64Value* other) {
std::swap(value_, other->value_);
- _internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata UInt64Value::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = UInt64Value_descriptor_;
- metadata.reflection = UInt64Value_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[3];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// UInt64Value
-// optional uint64 value = 1;
+// uint64 value = 1;
void UInt64Value::clear_value() {
value_ = GOOGLE_ULONGLONG(0);
}
@@ -1399,9 +1245,6 @@ void UInt64Value::set_value(::google::protobuf::uint64 value) {
// @@protoc_insertion_point(field_set:google.protobuf.UInt64Value.value)
}
-inline const UInt64Value* UInt64Value::internal_default_instance() {
- return &UInt64Value_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -1412,7 +1255,9 @@ const int Int32Value::kValueFieldNumber;
Int32Value::Int32Value()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.Int32Value)
}
@@ -1420,21 +1265,18 @@ Int32Value::Int32Value(::google::protobuf::Arena* arena)
: ::google::protobuf::Message(),
_internal_metadata_(arena) {
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults();
#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Int32Value)
}
-
-void Int32Value::InitAsDefaultInstance() {
-}
-
Int32Value::Int32Value(const Int32Value& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ value_ = from.value_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.Int32Value)
}
@@ -1468,17 +1310,15 @@ void Int32Value::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* Int32Value::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return Int32Value_descriptor_;
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[4].descriptor;
}
const Int32Value& Int32Value::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<Int32Value> Int32Value_default_instance_;
-
Int32Value* Int32Value::New(::google::protobuf::Arena* arena) const {
return ::google::protobuf::Arena::CreateMessage<Int32Value>(arena);
}
@@ -1494,13 +1334,14 @@ bool Int32Value::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Int32Value)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional int32 value = 1;
+ // int32 value = 1;
case 1: {
- if (tag == 8) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(8u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
@@ -1508,7 +1349,6 @@ bool Int32Value::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -1536,7 +1376,7 @@ failure:
void Int32Value::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.Int32Value)
- // optional int32 value = 1;
+ // int32 value = 1;
if (this->value() != 0) {
::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->value(), output);
}
@@ -1546,9 +1386,9 @@ void Int32Value::SerializeWithCachedSizes(
::google::protobuf::uint8* Int32Value::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Int32Value)
- // optional int32 value = 1;
+ // int32 value = 1;
if (this->value() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->value(), target);
}
@@ -1561,7 +1401,7 @@ size_t Int32Value::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Int32Value)
size_t total_size = 0;
- // optional int32 value = 1;
+ // int32 value = 1;
if (this->value() != 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
@@ -1577,7 +1417,7 @@ size_t Int32Value::ByteSizeLong() const {
void Int32Value::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Int32Value)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const Int32Value* source =
::google::protobuf::internal::DynamicCastToGenerated<const Int32Value>(
&from);
@@ -1586,21 +1426,14 @@ void Int32Value::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Int32Value)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void Int32Value::MergeFrom(const Int32Value& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Int32Value)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void Int32Value::UnsafeMergeFrom(const Int32Value& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
if (from.value() != 0) {
set_value(from.value());
}
@@ -1617,11 +1450,10 @@ void Int32Value::CopyFrom(const Int32Value& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Int32Value)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool Int32Value::IsInitialized() const {
-
return true;
}
@@ -1630,10 +1462,13 @@ void Int32Value::Swap(Int32Value* other) {
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
- Int32Value temp;
- temp.UnsafeMergeFrom(*this);
- CopyFrom(*other);
- other->CopyFrom(temp);
+ Int32Value* temp = New(GetArenaNoVirtual());
+ temp->MergeFrom(*other);
+ other->CopyFrom(*this);
+ InternalSwap(temp);
+ if (GetArenaNoVirtual() == NULL) {
+ delete temp;
+ }
}
}
void Int32Value::UnsafeArenaSwap(Int32Value* other) {
@@ -1643,22 +1478,18 @@ void Int32Value::UnsafeArenaSwap(Int32Value* other) {
}
void Int32Value::InternalSwap(Int32Value* other) {
std::swap(value_, other->value_);
- _internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata Int32Value::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = Int32Value_descriptor_;
- metadata.reflection = Int32Value_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[4];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// Int32Value
-// optional int32 value = 1;
+// int32 value = 1;
void Int32Value::clear_value() {
value_ = 0;
}
@@ -1672,9 +1503,6 @@ void Int32Value::set_value(::google::protobuf::int32 value) {
// @@protoc_insertion_point(field_set:google.protobuf.Int32Value.value)
}
-inline const Int32Value* Int32Value::internal_default_instance() {
- return &Int32Value_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -1685,7 +1513,9 @@ const int UInt32Value::kValueFieldNumber;
UInt32Value::UInt32Value()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.UInt32Value)
}
@@ -1693,21 +1523,18 @@ UInt32Value::UInt32Value(::google::protobuf::Arena* arena)
: ::google::protobuf::Message(),
_internal_metadata_(arena) {
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults();
#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.UInt32Value)
}
-
-void UInt32Value::InitAsDefaultInstance() {
-}
-
UInt32Value::UInt32Value(const UInt32Value& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ value_ = from.value_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.UInt32Value)
}
@@ -1741,17 +1568,15 @@ void UInt32Value::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* UInt32Value::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return UInt32Value_descriptor_;
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[5].descriptor;
}
const UInt32Value& UInt32Value::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<UInt32Value> UInt32Value_default_instance_;
-
UInt32Value* UInt32Value::New(::google::protobuf::Arena* arena) const {
return ::google::protobuf::Arena::CreateMessage<UInt32Value>(arena);
}
@@ -1767,13 +1592,14 @@ bool UInt32Value::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.UInt32Value)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional uint32 value = 1;
+ // uint32 value = 1;
case 1: {
- if (tag == 8) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(8u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
@@ -1781,7 +1607,6 @@ bool UInt32Value::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -1809,7 +1634,7 @@ failure:
void UInt32Value::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.UInt32Value)
- // optional uint32 value = 1;
+ // uint32 value = 1;
if (this->value() != 0) {
::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->value(), output);
}
@@ -1819,9 +1644,9 @@ void UInt32Value::SerializeWithCachedSizes(
::google::protobuf::uint8* UInt32Value::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UInt32Value)
- // optional uint32 value = 1;
+ // uint32 value = 1;
if (this->value() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->value(), target);
}
@@ -1834,7 +1659,7 @@ size_t UInt32Value::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.UInt32Value)
size_t total_size = 0;
- // optional uint32 value = 1;
+ // uint32 value = 1;
if (this->value() != 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::UInt32Size(
@@ -1850,7 +1675,7 @@ size_t UInt32Value::ByteSizeLong() const {
void UInt32Value::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.UInt32Value)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const UInt32Value* source =
::google::protobuf::internal::DynamicCastToGenerated<const UInt32Value>(
&from);
@@ -1859,21 +1684,14 @@ void UInt32Value::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.UInt32Value)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void UInt32Value::MergeFrom(const UInt32Value& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UInt32Value)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void UInt32Value::UnsafeMergeFrom(const UInt32Value& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
if (from.value() != 0) {
set_value(from.value());
}
@@ -1890,11 +1708,10 @@ void UInt32Value::CopyFrom(const UInt32Value& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.UInt32Value)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool UInt32Value::IsInitialized() const {
-
return true;
}
@@ -1903,10 +1720,13 @@ void UInt32Value::Swap(UInt32Value* other) {
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
- UInt32Value temp;
- temp.UnsafeMergeFrom(*this);
- CopyFrom(*other);
- other->CopyFrom(temp);
+ UInt32Value* temp = New(GetArenaNoVirtual());
+ temp->MergeFrom(*other);
+ other->CopyFrom(*this);
+ InternalSwap(temp);
+ if (GetArenaNoVirtual() == NULL) {
+ delete temp;
+ }
}
}
void UInt32Value::UnsafeArenaSwap(UInt32Value* other) {
@@ -1916,22 +1736,18 @@ void UInt32Value::UnsafeArenaSwap(UInt32Value* other) {
}
void UInt32Value::InternalSwap(UInt32Value* other) {
std::swap(value_, other->value_);
- _internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata UInt32Value::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = UInt32Value_descriptor_;
- metadata.reflection = UInt32Value_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[5];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// UInt32Value
-// optional uint32 value = 1;
+// uint32 value = 1;
void UInt32Value::clear_value() {
value_ = 0u;
}
@@ -1945,9 +1761,6 @@ void UInt32Value::set_value(::google::protobuf::uint32 value) {
// @@protoc_insertion_point(field_set:google.protobuf.UInt32Value.value)
}
-inline const UInt32Value* UInt32Value::internal_default_instance() {
- return &UInt32Value_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -1958,7 +1771,9 @@ const int BoolValue::kValueFieldNumber;
BoolValue::BoolValue()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.BoolValue)
}
@@ -1966,21 +1781,18 @@ BoolValue::BoolValue(::google::protobuf::Arena* arena)
: ::google::protobuf::Message(),
_internal_metadata_(arena) {
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults();
#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.BoolValue)
}
-
-void BoolValue::InitAsDefaultInstance() {
-}
-
BoolValue::BoolValue(const BoolValue& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ value_ = from.value_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.BoolValue)
}
@@ -2014,17 +1826,15 @@ void BoolValue::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* BoolValue::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return BoolValue_descriptor_;
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[6].descriptor;
}
const BoolValue& BoolValue::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<BoolValue> BoolValue_default_instance_;
-
BoolValue* BoolValue::New(::google::protobuf::Arena* arena) const {
return ::google::protobuf::Arena::CreateMessage<BoolValue>(arena);
}
@@ -2040,13 +1850,14 @@ bool BoolValue::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.BoolValue)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional bool value = 1;
+ // bool value = 1;
case 1: {
- if (tag == 8) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(8u)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
@@ -2054,7 +1865,6 @@ bool BoolValue::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -2082,7 +1892,7 @@ failure:
void BoolValue::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.BoolValue)
- // optional bool value = 1;
+ // bool value = 1;
if (this->value() != 0) {
::google::protobuf::internal::WireFormatLite::WriteBool(1, this->value(), output);
}
@@ -2092,9 +1902,9 @@ void BoolValue::SerializeWithCachedSizes(
::google::protobuf::uint8* BoolValue::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.BoolValue)
- // optional bool value = 1;
+ // bool value = 1;
if (this->value() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->value(), target);
}
@@ -2107,7 +1917,7 @@ size_t BoolValue::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.BoolValue)
size_t total_size = 0;
- // optional bool value = 1;
+ // bool value = 1;
if (this->value() != 0) {
total_size += 1 + 1;
}
@@ -2121,7 +1931,7 @@ size_t BoolValue::ByteSizeLong() const {
void BoolValue::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.BoolValue)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const BoolValue* source =
::google::protobuf::internal::DynamicCastToGenerated<const BoolValue>(
&from);
@@ -2130,21 +1940,14 @@ void BoolValue::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.BoolValue)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void BoolValue::MergeFrom(const BoolValue& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.BoolValue)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void BoolValue::UnsafeMergeFrom(const BoolValue& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
if (from.value() != 0) {
set_value(from.value());
}
@@ -2161,11 +1964,10 @@ void BoolValue::CopyFrom(const BoolValue& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.BoolValue)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool BoolValue::IsInitialized() const {
-
return true;
}
@@ -2174,10 +1976,13 @@ void BoolValue::Swap(BoolValue* other) {
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
- BoolValue temp;
- temp.UnsafeMergeFrom(*this);
- CopyFrom(*other);
- other->CopyFrom(temp);
+ BoolValue* temp = New(GetArenaNoVirtual());
+ temp->MergeFrom(*other);
+ other->CopyFrom(*this);
+ InternalSwap(temp);
+ if (GetArenaNoVirtual() == NULL) {
+ delete temp;
+ }
}
}
void BoolValue::UnsafeArenaSwap(BoolValue* other) {
@@ -2187,22 +1992,18 @@ void BoolValue::UnsafeArenaSwap(BoolValue* other) {
}
void BoolValue::InternalSwap(BoolValue* other) {
std::swap(value_, other->value_);
- _internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata BoolValue::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = BoolValue_descriptor_;
- metadata.reflection = BoolValue_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[6];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// BoolValue
-// optional bool value = 1;
+// bool value = 1;
void BoolValue::clear_value() {
value_ = false;
}
@@ -2216,9 +2017,6 @@ void BoolValue::set_value(bool value) {
// @@protoc_insertion_point(field_set:google.protobuf.BoolValue.value)
}
-inline const BoolValue* BoolValue::internal_default_instance() {
- return &BoolValue_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -2229,7 +2027,9 @@ const int StringValue::kValueFieldNumber;
StringValue::StringValue()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.StringValue)
}
@@ -2237,21 +2037,22 @@ StringValue::StringValue(::google::protobuf::Arena* arena)
: ::google::protobuf::Message(),
_internal_metadata_(arena) {
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults();
#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.StringValue)
}
-
-void StringValue::InitAsDefaultInstance() {
-}
-
StringValue::StringValue(const StringValue& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.value().size() > 0) {
+ value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.value(),
+ GetArenaNoVirtual());
+ }
// @@protoc_insertion_point(copy_constructor:google.protobuf.StringValue)
}
@@ -2286,17 +2087,15 @@ void StringValue::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* StringValue::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return StringValue_descriptor_;
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[7].descriptor;
}
const StringValue& StringValue::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<StringValue> StringValue_default_instance_;
-
StringValue* StringValue::New(::google::protobuf::Arena* arena) const {
return ::google::protobuf::Arena::CreateMessage<StringValue>(arena);
}
@@ -2312,13 +2111,14 @@ bool StringValue::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.StringValue)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional string value = 1;
+ // string value = 1;
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_value()));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
@@ -2328,7 +2128,6 @@ bool StringValue::MergePartialFromCodedStream(
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -2356,7 +2155,7 @@ failure:
void StringValue::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.StringValue)
- // optional string value = 1;
+ // string value = 1;
if (this->value().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->value().data(), this->value().length(),
@@ -2371,9 +2170,9 @@ void StringValue::SerializeWithCachedSizes(
::google::protobuf::uint8* StringValue::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.StringValue)
- // optional string value = 1;
+ // string value = 1;
if (this->value().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->value().data(), this->value().length(),
@@ -2392,7 +2191,7 @@ size_t StringValue::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.StringValue)
size_t total_size = 0;
- // optional string value = 1;
+ // string value = 1;
if (this->value().size() > 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
@@ -2408,7 +2207,7 @@ size_t StringValue::ByteSizeLong() const {
void StringValue::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.StringValue)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const StringValue* source =
::google::protobuf::internal::DynamicCastToGenerated<const StringValue>(
&from);
@@ -2417,21 +2216,14 @@ void StringValue::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.StringValue)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void StringValue::MergeFrom(const StringValue& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.StringValue)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void StringValue::UnsafeMergeFrom(const StringValue& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
if (from.value().size() > 0) {
set_value(from.value());
}
@@ -2448,11 +2240,10 @@ void StringValue::CopyFrom(const StringValue& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.StringValue)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool StringValue::IsInitialized() const {
-
return true;
}
@@ -2461,10 +2252,13 @@ void StringValue::Swap(StringValue* other) {
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
- StringValue temp;
- temp.UnsafeMergeFrom(*this);
- CopyFrom(*other);
- other->CopyFrom(temp);
+ StringValue* temp = New(GetArenaNoVirtual());
+ temp->MergeFrom(*other);
+ other->CopyFrom(*this);
+ InternalSwap(temp);
+ if (GetArenaNoVirtual() == NULL) {
+ delete temp;
+ }
}
}
void StringValue::UnsafeArenaSwap(StringValue* other) {
@@ -2474,28 +2268,24 @@ void StringValue::UnsafeArenaSwap(StringValue* other) {
}
void StringValue::InternalSwap(StringValue* other) {
value_.Swap(&other->value_);
- _internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata StringValue::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = StringValue_descriptor_;
- metadata.reflection = StringValue_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[7];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// StringValue
-// optional string value = 1;
+// string value = 1;
void StringValue::clear_value() {
value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
}
const ::std::string& StringValue::value() const {
// @@protoc_insertion_point(field_get:google.protobuf.StringValue.value)
- return value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return value_.Get();
}
void StringValue::set_value(const ::std::string& value) {
@@ -2555,9 +2345,6 @@ void StringValue::unsafe_arena_set_allocated_value(
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.StringValue.value)
}
-inline const StringValue* StringValue::internal_default_instance() {
- return &StringValue_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// ===================================================================
@@ -2568,7 +2355,9 @@ const int BytesValue::kValueFieldNumber;
BytesValue::BytesValue()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults();
+ }
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.BytesValue)
}
@@ -2576,21 +2365,22 @@ BytesValue::BytesValue(::google::protobuf::Arena* arena)
: ::google::protobuf::Message(),
_internal_metadata_(arena) {
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults();
#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.BytesValue)
}
-
-void BytesValue::InitAsDefaultInstance() {
-}
-
BytesValue::BytesValue(const BytesValue& from)
: ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
+ _internal_metadata_(NULL),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.value().size() > 0) {
+ value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.value(),
+ GetArenaNoVirtual());
+ }
// @@protoc_insertion_point(copy_constructor:google.protobuf.BytesValue)
}
@@ -2625,17 +2415,15 @@ void BytesValue::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* BytesValue::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return BytesValue_descriptor_;
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[8].descriptor;
}
const BytesValue& BytesValue::default_instance() {
- protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::InitDefaults();
return *internal_default_instance();
}
-::google::protobuf::internal::ExplicitlyConstructed<BytesValue> BytesValue_default_instance_;
-
BytesValue* BytesValue::New(::google::protobuf::Arena* arena) const {
return ::google::protobuf::Arena::CreateMessage<BytesValue>(arena);
}
@@ -2651,19 +2439,19 @@ bool BytesValue::MergePartialFromCodedStream(
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.BytesValue)
for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional bytes value = 1;
+ // bytes value = 1;
case 1: {
- if (tag == 10) {
+ if (static_cast<::google::protobuf::uint8>(tag) ==
+ static_cast<::google::protobuf::uint8>(10u)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
input, this->mutable_value()));
} else {
goto handle_unusual;
}
- if (input->ExpectAtEnd()) goto success;
break;
}
@@ -2691,7 +2479,7 @@ failure:
void BytesValue::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.BytesValue)
- // optional bytes value = 1;
+ // bytes value = 1;
if (this->value().size() > 0) {
::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(
1, this->value(), output);
@@ -2702,9 +2490,9 @@ void BytesValue::SerializeWithCachedSizes(
::google::protobuf::uint8* BytesValue::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
+ (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.BytesValue)
- // optional bytes value = 1;
+ // bytes value = 1;
if (this->value().size() > 0) {
target =
::google::protobuf::internal::WireFormatLite::WriteBytesToArray(
@@ -2719,7 +2507,7 @@ size_t BytesValue::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.BytesValue)
size_t total_size = 0;
- // optional bytes value = 1;
+ // bytes value = 1;
if (this->value().size() > 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::BytesSize(
@@ -2735,7 +2523,7 @@ size_t BytesValue::ByteSizeLong() const {
void BytesValue::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.BytesValue)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ GOOGLE_DCHECK_NE(&from, this);
const BytesValue* source =
::google::protobuf::internal::DynamicCastToGenerated<const BytesValue>(
&from);
@@ -2744,21 +2532,14 @@ void BytesValue::MergeFrom(const ::google::protobuf::Message& from) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.BytesValue)
- UnsafeMergeFrom(*source);
+ MergeFrom(*source);
}
}
void BytesValue::MergeFrom(const BytesValue& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.BytesValue)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void BytesValue::UnsafeMergeFrom(const BytesValue& from) {
- GOOGLE_DCHECK(&from != this);
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
if (from.value().size() > 0) {
set_value(from.value());
}
@@ -2775,11 +2556,10 @@ void BytesValue::CopyFrom(const BytesValue& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.BytesValue)
if (&from == this) return;
Clear();
- UnsafeMergeFrom(from);
+ MergeFrom(from);
}
bool BytesValue::IsInitialized() const {
-
return true;
}
@@ -2788,10 +2568,13 @@ void BytesValue::Swap(BytesValue* other) {
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
- BytesValue temp;
- temp.UnsafeMergeFrom(*this);
- CopyFrom(*other);
- other->CopyFrom(temp);
+ BytesValue* temp = New(GetArenaNoVirtual());
+ temp->MergeFrom(*other);
+ other->CopyFrom(*this);
+ InternalSwap(temp);
+ if (GetArenaNoVirtual() == NULL) {
+ delete temp;
+ }
}
}
void BytesValue::UnsafeArenaSwap(BytesValue* other) {
@@ -2801,28 +2584,24 @@ void BytesValue::UnsafeArenaSwap(BytesValue* other) {
}
void BytesValue::InternalSwap(BytesValue* other) {
value_.Swap(&other->value_);
- _internal_metadata_.Swap(&other->_internal_metadata_);
std::swap(_cached_size_, other->_cached_size_);
}
::google::protobuf::Metadata BytesValue::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = BytesValue_descriptor_;
- metadata.reflection = BytesValue_reflection_;
- return metadata;
+ protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[8];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
// BytesValue
-// optional bytes value = 1;
+// bytes value = 1;
void BytesValue::clear_value() {
value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
}
const ::std::string& BytesValue::value() const {
// @@protoc_insertion_point(field_get:google.protobuf.BytesValue.value)
- return value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return value_.Get();
}
void BytesValue::set_value(const ::std::string& value) {
@@ -2882,9 +2661,6 @@ void BytesValue::unsafe_arena_set_allocated_value(
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.BytesValue.value)
}
-inline const BytesValue* BytesValue::internal_default_instance() {
- return &BytesValue_default_instance_.get();
-}
#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
// @@protoc_insertion_point(namespace_scope)
diff --git a/src/google/protobuf/wrappers.pb.h b/src/google/protobuf/wrappers.pb.h
index 568f8669..61b0510d 100644
--- a/src/google/protobuf/wrappers.pb.h
+++ b/src/google/protobuf/wrappers.pb.h
@@ -8,45 +8,72 @@
#include <google/protobuf/stubs/common.h>
-#if GOOGLE_PROTOBUF_VERSION < 3001000
+#if GOOGLE_PROTOBUF_VERSION < 3002000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
#endif
+#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata.h>
#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/extension_set.h>
+#include <google/protobuf/repeated_field.h> // IWYU pragma: export
+#include <google/protobuf/extension_set.h> // IWYU pragma: export
#include <google/protobuf/unknown_field_set.h>
// @@protoc_insertion_point(includes)
-
namespace google {
namespace protobuf {
-
-// Internal implementation detail -- do not call these.
-void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto();
-void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto();
-void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto();
-void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto();
-
class BoolValue;
+class BoolValueDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern BoolValueDefaultTypeInternal _BoolValue_default_instance_;
class BytesValue;
+class BytesValueDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern BytesValueDefaultTypeInternal _BytesValue_default_instance_;
class DoubleValue;
+class DoubleValueDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern DoubleValueDefaultTypeInternal _DoubleValue_default_instance_;
class FloatValue;
+class FloatValueDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern FloatValueDefaultTypeInternal _FloatValue_default_instance_;
class Int32Value;
+class Int32ValueDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern Int32ValueDefaultTypeInternal _Int32Value_default_instance_;
class Int64Value;
+class Int64ValueDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern Int64ValueDefaultTypeInternal _Int64Value_default_instance_;
class StringValue;
+class StringValueDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern StringValueDefaultTypeInternal _StringValue_default_instance_;
class UInt32Value;
+class UInt32ValueDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern UInt32ValueDefaultTypeInternal _UInt32Value_default_instance_;
class UInt64Value;
+class UInt64ValueDefaultTypeInternal;
+LIBPROTOBUF_EXPORT extern UInt64ValueDefaultTypeInternal _UInt64Value_default_instance_;
+} // namespace protobuf
+} // namespace google
+
+namespace google {
+namespace protobuf {
+
+namespace protobuf_google_2fprotobuf_2fwrappers_2eproto {
+// Internal implementation detail -- do not call these.
+struct LIBPROTOBUF_EXPORT TableStruct {
+ static const ::google::protobuf::uint32 offsets[];
+ static void InitDefaultsImpl();
+ static void Shutdown();
+};
+void LIBPROTOBUF_EXPORT AddDescriptors();
+void LIBPROTOBUF_EXPORT InitDefaults();
+} // namespace protobuf_google_2fprotobuf_2fwrappers_2eproto
// ===================================================================
@@ -62,47 +89,53 @@ class LIBPROTOBUF_EXPORT DoubleValue : public ::google::protobuf::Message /* @@p
return *this;
}
- inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }
- inline void* GetMaybeArenaPointer() const {
+ inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {
+ return GetArenaNoVirtual();
+ }
+ inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {
return MaybeArenaPtr();
}
static const ::google::protobuf::Descriptor* descriptor();
static const DoubleValue& default_instance();
- static const DoubleValue* internal_default_instance();
+ static inline const DoubleValue* internal_default_instance() {
+ return reinterpret_cast<const DoubleValue*>(
+ &_DoubleValue_default_instance_);
+ }
void UnsafeArenaSwap(DoubleValue* other);
void Swap(DoubleValue* other);
// implements Message ----------------------------------------------
- inline DoubleValue* New() const { return New(NULL); }
+ inline DoubleValue* New() const PROTOBUF_FINAL { return New(NULL); }
- DoubleValue* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ DoubleValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const DoubleValue& from);
void MergeFrom(const DoubleValue& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(DoubleValue* other);
- void UnsafeMergeFrom(const DoubleValue& from);
protected:
explicit DoubleValue(::google::protobuf::Arena* arena);
private:
@@ -117,13 +150,13 @@ class LIBPROTOBUF_EXPORT DoubleValue : public ::google::protobuf::Message /* @@p
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
- // optional double value = 1;
+ // double value = 1;
void clear_value();
static const int kValueFieldNumber = 1;
double value() const;
@@ -138,15 +171,8 @@ class LIBPROTOBUF_EXPORT DoubleValue : public ::google::protobuf::Message /* @@p
typedef void DestructorSkippable_;
double value_;
mutable int _cached_size_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<DoubleValue> DoubleValue_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT FloatValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FloatValue) */ {
@@ -161,47 +187,53 @@ class LIBPROTOBUF_EXPORT FloatValue : public ::google::protobuf::Message /* @@pr
return *this;
}
- inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }
- inline void* GetMaybeArenaPointer() const {
+ inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {
+ return GetArenaNoVirtual();
+ }
+ inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {
return MaybeArenaPtr();
}
static const ::google::protobuf::Descriptor* descriptor();
static const FloatValue& default_instance();
- static const FloatValue* internal_default_instance();
+ static inline const FloatValue* internal_default_instance() {
+ return reinterpret_cast<const FloatValue*>(
+ &_FloatValue_default_instance_);
+ }
void UnsafeArenaSwap(FloatValue* other);
void Swap(FloatValue* other);
// implements Message ----------------------------------------------
- inline FloatValue* New() const { return New(NULL); }
+ inline FloatValue* New() const PROTOBUF_FINAL { return New(NULL); }
- FloatValue* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ FloatValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const FloatValue& from);
void MergeFrom(const FloatValue& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(FloatValue* other);
- void UnsafeMergeFrom(const FloatValue& from);
protected:
explicit FloatValue(::google::protobuf::Arena* arena);
private:
@@ -216,13 +248,13 @@ class LIBPROTOBUF_EXPORT FloatValue : public ::google::protobuf::Message /* @@pr
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
- // optional float value = 1;
+ // float value = 1;
void clear_value();
static const int kValueFieldNumber = 1;
float value() const;
@@ -237,15 +269,8 @@ class LIBPROTOBUF_EXPORT FloatValue : public ::google::protobuf::Message /* @@pr
typedef void DestructorSkippable_;
float value_;
mutable int _cached_size_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<FloatValue> FloatValue_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT Int64Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Int64Value) */ {
@@ -260,47 +285,53 @@ class LIBPROTOBUF_EXPORT Int64Value : public ::google::protobuf::Message /* @@pr
return *this;
}
- inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }
- inline void* GetMaybeArenaPointer() const {
+ inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {
+ return GetArenaNoVirtual();
+ }
+ inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {
return MaybeArenaPtr();
}
static const ::google::protobuf::Descriptor* descriptor();
static const Int64Value& default_instance();
- static const Int64Value* internal_default_instance();
+ static inline const Int64Value* internal_default_instance() {
+ return reinterpret_cast<const Int64Value*>(
+ &_Int64Value_default_instance_);
+ }
void UnsafeArenaSwap(Int64Value* other);
void Swap(Int64Value* other);
// implements Message ----------------------------------------------
- inline Int64Value* New() const { return New(NULL); }
+ inline Int64Value* New() const PROTOBUF_FINAL { return New(NULL); }
- Int64Value* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ Int64Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Int64Value& from);
void MergeFrom(const Int64Value& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(Int64Value* other);
- void UnsafeMergeFrom(const Int64Value& from);
protected:
explicit Int64Value(::google::protobuf::Arena* arena);
private:
@@ -315,13 +346,13 @@ class LIBPROTOBUF_EXPORT Int64Value : public ::google::protobuf::Message /* @@pr
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
- // optional int64 value = 1;
+ // int64 value = 1;
void clear_value();
static const int kValueFieldNumber = 1;
::google::protobuf::int64 value() const;
@@ -336,15 +367,8 @@ class LIBPROTOBUF_EXPORT Int64Value : public ::google::protobuf::Message /* @@pr
typedef void DestructorSkippable_;
::google::protobuf::int64 value_;
mutable int _cached_size_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<Int64Value> Int64Value_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT UInt64Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UInt64Value) */ {
@@ -359,47 +383,53 @@ class LIBPROTOBUF_EXPORT UInt64Value : public ::google::protobuf::Message /* @@p
return *this;
}
- inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }
- inline void* GetMaybeArenaPointer() const {
+ inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {
+ return GetArenaNoVirtual();
+ }
+ inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {
return MaybeArenaPtr();
}
static const ::google::protobuf::Descriptor* descriptor();
static const UInt64Value& default_instance();
- static const UInt64Value* internal_default_instance();
+ static inline const UInt64Value* internal_default_instance() {
+ return reinterpret_cast<const UInt64Value*>(
+ &_UInt64Value_default_instance_);
+ }
void UnsafeArenaSwap(UInt64Value* other);
void Swap(UInt64Value* other);
// implements Message ----------------------------------------------
- inline UInt64Value* New() const { return New(NULL); }
+ inline UInt64Value* New() const PROTOBUF_FINAL { return New(NULL); }
- UInt64Value* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ UInt64Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const UInt64Value& from);
void MergeFrom(const UInt64Value& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(UInt64Value* other);
- void UnsafeMergeFrom(const UInt64Value& from);
protected:
explicit UInt64Value(::google::protobuf::Arena* arena);
private:
@@ -414,13 +444,13 @@ class LIBPROTOBUF_EXPORT UInt64Value : public ::google::protobuf::Message /* @@p
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
- // optional uint64 value = 1;
+ // uint64 value = 1;
void clear_value();
static const int kValueFieldNumber = 1;
::google::protobuf::uint64 value() const;
@@ -435,15 +465,8 @@ class LIBPROTOBUF_EXPORT UInt64Value : public ::google::protobuf::Message /* @@p
typedef void DestructorSkippable_;
::google::protobuf::uint64 value_;
mutable int _cached_size_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<UInt64Value> UInt64Value_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT Int32Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Int32Value) */ {
@@ -458,47 +481,53 @@ class LIBPROTOBUF_EXPORT Int32Value : public ::google::protobuf::Message /* @@pr
return *this;
}
- inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }
- inline void* GetMaybeArenaPointer() const {
+ inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {
+ return GetArenaNoVirtual();
+ }
+ inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {
return MaybeArenaPtr();
}
static const ::google::protobuf::Descriptor* descriptor();
static const Int32Value& default_instance();
- static const Int32Value* internal_default_instance();
+ static inline const Int32Value* internal_default_instance() {
+ return reinterpret_cast<const Int32Value*>(
+ &_Int32Value_default_instance_);
+ }
void UnsafeArenaSwap(Int32Value* other);
void Swap(Int32Value* other);
// implements Message ----------------------------------------------
- inline Int32Value* New() const { return New(NULL); }
+ inline Int32Value* New() const PROTOBUF_FINAL { return New(NULL); }
- Int32Value* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ Int32Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const Int32Value& from);
void MergeFrom(const Int32Value& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(Int32Value* other);
- void UnsafeMergeFrom(const Int32Value& from);
protected:
explicit Int32Value(::google::protobuf::Arena* arena);
private:
@@ -513,13 +542,13 @@ class LIBPROTOBUF_EXPORT Int32Value : public ::google::protobuf::Message /* @@pr
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
- // optional int32 value = 1;
+ // int32 value = 1;
void clear_value();
static const int kValueFieldNumber = 1;
::google::protobuf::int32 value() const;
@@ -534,15 +563,8 @@ class LIBPROTOBUF_EXPORT Int32Value : public ::google::protobuf::Message /* @@pr
typedef void DestructorSkippable_;
::google::protobuf::int32 value_;
mutable int _cached_size_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<Int32Value> Int32Value_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT UInt32Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UInt32Value) */ {
@@ -557,47 +579,53 @@ class LIBPROTOBUF_EXPORT UInt32Value : public ::google::protobuf::Message /* @@p
return *this;
}
- inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }
- inline void* GetMaybeArenaPointer() const {
+ inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {
+ return GetArenaNoVirtual();
+ }
+ inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {
return MaybeArenaPtr();
}
static const ::google::protobuf::Descriptor* descriptor();
static const UInt32Value& default_instance();
- static const UInt32Value* internal_default_instance();
+ static inline const UInt32Value* internal_default_instance() {
+ return reinterpret_cast<const UInt32Value*>(
+ &_UInt32Value_default_instance_);
+ }
void UnsafeArenaSwap(UInt32Value* other);
void Swap(UInt32Value* other);
// implements Message ----------------------------------------------
- inline UInt32Value* New() const { return New(NULL); }
+ inline UInt32Value* New() const PROTOBUF_FINAL { return New(NULL); }
- UInt32Value* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ UInt32Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const UInt32Value& from);
void MergeFrom(const UInt32Value& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(UInt32Value* other);
- void UnsafeMergeFrom(const UInt32Value& from);
protected:
explicit UInt32Value(::google::protobuf::Arena* arena);
private:
@@ -612,13 +640,13 @@ class LIBPROTOBUF_EXPORT UInt32Value : public ::google::protobuf::Message /* @@p
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
- // optional uint32 value = 1;
+ // uint32 value = 1;
void clear_value();
static const int kValueFieldNumber = 1;
::google::protobuf::uint32 value() const;
@@ -633,15 +661,8 @@ class LIBPROTOBUF_EXPORT UInt32Value : public ::google::protobuf::Message /* @@p
typedef void DestructorSkippable_;
::google::protobuf::uint32 value_;
mutable int _cached_size_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<UInt32Value> UInt32Value_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT BoolValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.BoolValue) */ {
@@ -656,47 +677,53 @@ class LIBPROTOBUF_EXPORT BoolValue : public ::google::protobuf::Message /* @@pro
return *this;
}
- inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }
- inline void* GetMaybeArenaPointer() const {
+ inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {
+ return GetArenaNoVirtual();
+ }
+ inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {
return MaybeArenaPtr();
}
static const ::google::protobuf::Descriptor* descriptor();
static const BoolValue& default_instance();
- static const BoolValue* internal_default_instance();
+ static inline const BoolValue* internal_default_instance() {
+ return reinterpret_cast<const BoolValue*>(
+ &_BoolValue_default_instance_);
+ }
void UnsafeArenaSwap(BoolValue* other);
void Swap(BoolValue* other);
// implements Message ----------------------------------------------
- inline BoolValue* New() const { return New(NULL); }
+ inline BoolValue* New() const PROTOBUF_FINAL { return New(NULL); }
- BoolValue* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ BoolValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const BoolValue& from);
void MergeFrom(const BoolValue& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(BoolValue* other);
- void UnsafeMergeFrom(const BoolValue& from);
protected:
explicit BoolValue(::google::protobuf::Arena* arena);
private:
@@ -711,13 +738,13 @@ class LIBPROTOBUF_EXPORT BoolValue : public ::google::protobuf::Message /* @@pro
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
- // optional bool value = 1;
+ // bool value = 1;
void clear_value();
static const int kValueFieldNumber = 1;
bool value() const;
@@ -732,15 +759,8 @@ class LIBPROTOBUF_EXPORT BoolValue : public ::google::protobuf::Message /* @@pro
typedef void DestructorSkippable_;
bool value_;
mutable int _cached_size_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<BoolValue> BoolValue_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT StringValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.StringValue) */ {
@@ -755,47 +775,53 @@ class LIBPROTOBUF_EXPORT StringValue : public ::google::protobuf::Message /* @@p
return *this;
}
- inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }
- inline void* GetMaybeArenaPointer() const {
+ inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {
+ return GetArenaNoVirtual();
+ }
+ inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {
return MaybeArenaPtr();
}
static const ::google::protobuf::Descriptor* descriptor();
static const StringValue& default_instance();
- static const StringValue* internal_default_instance();
+ static inline const StringValue* internal_default_instance() {
+ return reinterpret_cast<const StringValue*>(
+ &_StringValue_default_instance_);
+ }
void UnsafeArenaSwap(StringValue* other);
void Swap(StringValue* other);
// implements Message ----------------------------------------------
- inline StringValue* New() const { return New(NULL); }
+ inline StringValue* New() const PROTOBUF_FINAL { return New(NULL); }
- StringValue* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ StringValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const StringValue& from);
void MergeFrom(const StringValue& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(StringValue* other);
- void UnsafeMergeFrom(const StringValue& from);
protected:
explicit StringValue(::google::protobuf::Arena* arena);
private:
@@ -810,13 +836,13 @@ class LIBPROTOBUF_EXPORT StringValue : public ::google::protobuf::Message /* @@p
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
- // optional string value = 1;
+ // string value = 1;
void clear_value();
static const int kValueFieldNumber = 1;
const ::std::string& value() const;
@@ -839,15 +865,8 @@ class LIBPROTOBUF_EXPORT StringValue : public ::google::protobuf::Message /* @@p
typedef void DestructorSkippable_;
::google::protobuf::internal::ArenaStringPtr value_;
mutable int _cached_size_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<StringValue> StringValue_default_instance_;
-
// -------------------------------------------------------------------
class LIBPROTOBUF_EXPORT BytesValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.BytesValue) */ {
@@ -862,47 +881,53 @@ class LIBPROTOBUF_EXPORT BytesValue : public ::google::protobuf::Message /* @@pr
return *this;
}
- inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }
- inline void* GetMaybeArenaPointer() const {
+ inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {
+ return GetArenaNoVirtual();
+ }
+ inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {
return MaybeArenaPtr();
}
static const ::google::protobuf::Descriptor* descriptor();
static const BytesValue& default_instance();
- static const BytesValue* internal_default_instance();
+ static inline const BytesValue* internal_default_instance() {
+ return reinterpret_cast<const BytesValue*>(
+ &_BytesValue_default_instance_);
+ }
void UnsafeArenaSwap(BytesValue* other);
void Swap(BytesValue* other);
// implements Message ----------------------------------------------
- inline BytesValue* New() const { return New(NULL); }
+ inline BytesValue* New() const PROTOBUF_FINAL { return New(NULL); }
- BytesValue* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
+ BytesValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const BytesValue& from);
void MergeFrom(const BytesValue& from);
- void Clear();
- bool IsInitialized() const;
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
- size_t ByteSizeLong() const;
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
+ const PROTOBUF_FINAL {
+ return InternalSerializeWithCachedSizesToArray(
+ ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
}
- int GetCachedSize() const { return _cached_size_; }
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
- void SetCachedSize(int size) const;
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(BytesValue* other);
- void UnsafeMergeFrom(const BytesValue& from);
protected:
explicit BytesValue(::google::protobuf::Arena* arena);
private:
@@ -917,13 +942,13 @@ class LIBPROTOBUF_EXPORT BytesValue : public ::google::protobuf::Message /* @@pr
}
public:
- ::google::protobuf::Metadata GetMetadata() const;
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
- // optional bytes value = 1;
+ // bytes value = 1;
void clear_value();
static const int kValueFieldNumber = 1;
const ::std::string& value() const;
@@ -946,15 +971,8 @@ class LIBPROTOBUF_EXPORT BytesValue : public ::google::protobuf::Message /* @@pr
typedef void DestructorSkippable_;
::google::protobuf::internal::ArenaStringPtr value_;
mutable int _cached_size_;
- friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl();
- friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl();
- friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto();
- friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto();
-
- void InitAsDefaultInstance();
+ friend struct LIBPROTOBUF_EXPORT protobuf_google_2fprotobuf_2fwrappers_2eproto::TableStruct;
};
-extern ::google::protobuf::internal::ExplicitlyConstructed<BytesValue> BytesValue_default_instance_;
-
// ===================================================================
@@ -963,7 +981,7 @@ extern ::google::protobuf::internal::ExplicitlyConstructed<BytesValue> BytesValu
#if !PROTOBUF_INLINE_NOT_IN_HEADERS
// DoubleValue
-// optional double value = 1;
+// double value = 1;
inline void DoubleValue::clear_value() {
value_ = 0;
}
@@ -977,14 +995,11 @@ inline void DoubleValue::set_value(double value) {
// @@protoc_insertion_point(field_set:google.protobuf.DoubleValue.value)
}
-inline const DoubleValue* DoubleValue::internal_default_instance() {
- return &DoubleValue_default_instance_.get();
-}
// -------------------------------------------------------------------
// FloatValue
-// optional float value = 1;
+// float value = 1;
inline void FloatValue::clear_value() {
value_ = 0;
}
@@ -998,14 +1013,11 @@ inline void FloatValue::set_value(float value) {
// @@protoc_insertion_point(field_set:google.protobuf.FloatValue.value)
}
-inline const FloatValue* FloatValue::internal_default_instance() {
- return &FloatValue_default_instance_.get();
-}
// -------------------------------------------------------------------
// Int64Value
-// optional int64 value = 1;
+// int64 value = 1;
inline void Int64Value::clear_value() {
value_ = GOOGLE_LONGLONG(0);
}
@@ -1019,14 +1031,11 @@ inline void Int64Value::set_value(::google::protobuf::int64 value) {
// @@protoc_insertion_point(field_set:google.protobuf.Int64Value.value)
}
-inline const Int64Value* Int64Value::internal_default_instance() {
- return &Int64Value_default_instance_.get();
-}
// -------------------------------------------------------------------
// UInt64Value
-// optional uint64 value = 1;
+// uint64 value = 1;
inline void UInt64Value::clear_value() {
value_ = GOOGLE_ULONGLONG(0);
}
@@ -1040,14 +1049,11 @@ inline void UInt64Value::set_value(::google::protobuf::uint64 value) {
// @@protoc_insertion_point(field_set:google.protobuf.UInt64Value.value)
}
-inline const UInt64Value* UInt64Value::internal_default_instance() {
- return &UInt64Value_default_instance_.get();
-}
// -------------------------------------------------------------------
// Int32Value
-// optional int32 value = 1;
+// int32 value = 1;
inline void Int32Value::clear_value() {
value_ = 0;
}
@@ -1061,14 +1067,11 @@ inline void Int32Value::set_value(::google::protobuf::int32 value) {
// @@protoc_insertion_point(field_set:google.protobuf.Int32Value.value)
}
-inline const Int32Value* Int32Value::internal_default_instance() {
- return &Int32Value_default_instance_.get();
-}
// -------------------------------------------------------------------
// UInt32Value
-// optional uint32 value = 1;
+// uint32 value = 1;
inline void UInt32Value::clear_value() {
value_ = 0u;
}
@@ -1082,14 +1085,11 @@ inline void UInt32Value::set_value(::google::protobuf::uint32 value) {
// @@protoc_insertion_point(field_set:google.protobuf.UInt32Value.value)
}
-inline const UInt32Value* UInt32Value::internal_default_instance() {
- return &UInt32Value_default_instance_.get();
-}
// -------------------------------------------------------------------
// BoolValue
-// optional bool value = 1;
+// bool value = 1;
inline void BoolValue::clear_value() {
value_ = false;
}
@@ -1103,20 +1103,17 @@ inline void BoolValue::set_value(bool value) {
// @@protoc_insertion_point(field_set:google.protobuf.BoolValue.value)
}
-inline const BoolValue* BoolValue::internal_default_instance() {
- return &BoolValue_default_instance_.get();
-}
// -------------------------------------------------------------------
// StringValue
-// optional string value = 1;
+// string value = 1;
inline void StringValue::clear_value() {
value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
}
inline const ::std::string& StringValue::value() const {
// @@protoc_insertion_point(field_get:google.protobuf.StringValue.value)
- return value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return value_.Get();
}
inline void StringValue::set_value(const ::std::string& value) {
@@ -1176,20 +1173,17 @@ inline void StringValue::unsafe_arena_set_allocated_value(
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.StringValue.value)
}
-inline const StringValue* StringValue::internal_default_instance() {
- return &StringValue_default_instance_.get();
-}
// -------------------------------------------------------------------
// BytesValue
-// optional bytes value = 1;
+// bytes value = 1;
inline void BytesValue::clear_value() {
value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
}
inline const ::std::string& BytesValue::value() const {
// @@protoc_insertion_point(field_get:google.protobuf.BytesValue.value)
- return value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ return value_.Get();
}
inline void BytesValue::set_value(const ::std::string& value) {
@@ -1249,9 +1243,6 @@ inline void BytesValue::unsafe_arena_set_allocated_value(
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.BytesValue.value)
}
-inline const BytesValue* BytesValue::internal_default_instance() {
- return &BytesValue_default_instance_.get();
-}
#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS
// -------------------------------------------------------------------
@@ -1272,6 +1263,7 @@ inline const BytesValue* BytesValue::internal_default_instance() {
// @@protoc_insertion_point(namespace_scope)
+
} // namespace protobuf
} // namespace google
diff --git a/tests.sh b/tests.sh
index 4ac6b7c6..981d20cc 100755
--- a/tests.sh
+++ b/tests.sh
@@ -38,11 +38,21 @@ build_cpp() {
make check -j2
cd conformance && make test_cpp && cd ..
- # Verify benchmarking code can build successfully.
- git submodule init
- git submodule update
- cd third_party/benchmark && cmake -DCMAKE_BUILD_TYPE=Release && make && cd ../..
- cd benchmarks && make && ./generate-datasets && cd ..
+ # The benchmark code depends on cmake, so test if it is installed before
+ # trying to do the build.
+ # NOTE: The travis macOS images say they have cmake, but the xcode8.1 image
+ # appears to be missing it: https://github.com/travis-ci/travis-ci/issues/6996
+ if [[ $(type cmake 2>/dev/null) ]]; then
+ # Verify benchmarking code can build successfully.
+ git submodule init
+ git submodule update
+ cd third_party/benchmark && cmake -DCMAKE_BUILD_TYPE=Release && make && cd ../..
+ cd benchmarks && make && ./generate-datasets && cd ..
+ else
+ echo ""
+ echo "WARNING: Skipping validation of the bench marking code, cmake isn't installed."
+ echo ""
+ fi
}
build_cpp_distcheck() {
@@ -51,8 +61,9 @@ build_cpp_distcheck() {
make dist
# List all files that should be included in the distribution package.
- git ls-files | grep "^\(java\|python\|objectivec\|csharp\|js\|ruby\|cmake\|examples\)" |\
- grep -v ".gitignore" | grep -v "java/compatibility_tests" > dist.lst
+ git ls-files | grep "^\(java\|python\|objectivec\|csharp\|js\|ruby\|php\|cmake\|examples\)" |\
+ grep -v ".gitignore" | grep -v "java/compatibility_tests" |\
+ grep -v "python/compatibility_tests" | grep -v "csharp/compatibility_tests" > dist.lst
# Unzip the dist tar file.
DIST=`ls *.tar.gz`
tar -xf $DIST
@@ -89,7 +100,7 @@ build_csharp() {
echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update -qq
sudo apt-get install -qq mono-devel referenceassemblies-pcl nunit
-
+
# Then install the dotnet SDK as per Ubuntu 14.04 instructions on dot.net.
sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
@@ -108,6 +119,9 @@ build_csharp() {
(cd csharp/src; dotnet restore)
csharp/buildall.sh
cd conformance && make test_csharp && cd ..
+
+ # Run csharp compatibility test between 3.0.0 and the current version.
+ csharp/compatibility_tests/v3.0.0/test.sh 3.0.0
}
build_golang() {
@@ -265,15 +279,6 @@ build_objectivec_osx() {
}
build_objectivec_cocoapods_integration() {
- # First, load the RVM environment in bash, needed to update ruby.
- source ~/.rvm/scripts/rvm
- # Update rvm to the latest version. This is needed to solve
- # https://github.com/google/protobuf/issues/1786 and may not be needed in the
- # future when Travis updates the default version of rvm.
- rvm get head
- # Update ruby to 2.2.3 as the default one crashes with segmentation faults
- # when using pod.
- rvm use 2.2.3 --install --binary --fuzzy
# Update pod to the latest version.
gem install cocoapods --no-ri --no-rdoc
objectivec/Tests/CocoaPods/run_tests.sh
@@ -310,6 +315,16 @@ build_python_cpp() {
cd ..
}
+build_python_compatibility() {
+ internal_build_cpp
+ # Use the unit-tests extraced from 2.5.0 to test the compatibilty.
+ cd python/compatibility_tests/v2.5.0
+ # Test between 2.5.0 and the current version.
+ ./test.sh 2.5.0
+ # Test between 3.0.0-beta-1 and the current version.
+ ./test.sh 3.0.0-beta-1
+}
+
build_ruby21() {
internal_build_cpp # For conformance tests.
cd ruby && bash travis-test.sh ruby-2.1 && cd ..
@@ -327,7 +342,9 @@ build_jruby() {
build_ruby_all() {
build_ruby21
build_ruby22
- build_jruby
+ # TODO(teboring): Disable jruby test temperarily for it randomly fails.
+ # https://grpc-testing.appspot.com/job/protobuf_pull_request/735/consoleFull.
+ # build_jruby
}
build_javascript() {
@@ -335,6 +352,19 @@ build_javascript() {
cd js && npm install && npm test && cd ..
}
+generate_php_test_proto() {
+ internal_build_cpp
+ pushd php/tests
+ # Generate test file
+ rm -rf generated
+ mkdir generated
+ ../../src/protoc --php_out=generated proto/test.proto proto/test_include.proto proto/test_no_namespace.proto
+ pushd ../../src
+ ./protoc --php_out=../php/tests/generated google/protobuf/empty.proto
+ popd
+ popd
+}
+
use_php() {
VERSION=$1
PHP=`which php`
@@ -346,6 +376,7 @@ use_php() {
cp "/usr/bin/php$VERSION" $PHP
cp "/usr/bin/php-config$VERSION" $PHP_CONFIG
cp "/usr/bin/phpize$VERSION" $PHPIZE
+ generate_php_test_proto
}
use_php_zts() {
@@ -356,6 +387,7 @@ use_php_zts() {
ln -sfn "/usr/local/php-${VERSION}-zts/bin/php" $PHP
ln -sfn "/usr/local/php-${VERSION}-zts/bin/php-config" $PHP_CONFIG
ln -sfn "/usr/local/php-${VERSION}-zts/bin/phpize" $PHPIZE
+ generate_php_test_proto
}
use_php_bc() {
@@ -366,59 +398,92 @@ use_php_bc() {
ln -sfn "/usr/local/php-${VERSION}-bc/bin/php" $PHP
ln -sfn "/usr/local/php-${VERSION}-bc/bin/php-config" $PHP_CONFIG
ln -sfn "/usr/local/php-${VERSION}-bc/bin/phpize" $PHPIZE
+ generate_php_test_proto
}
build_php5.5() {
use_php 5.5
+ pushd php
rm -rf vendor
cp -r /usr/local/vendor-5.5 vendor
./vendor/bin/phpunit
+ popd
+ pushd conformance
+ # TODO(teboring): Add it back
+ # make test_php
+ popd
}
build_php5.5_c() {
use_php 5.5
cd php/tests && /bin/bash ./test.sh && cd ../..
+ pushd conformance
+ make test_php_c
+ popd
}
build_php5.5_zts_c() {
use_php_zts 5.5
wget https://phar.phpunit.de/phpunit-old.phar -O /usr/bin/phpunit
cd php/tests && /bin/bash ./test.sh && cd ../..
+ pushd conformance
+ make test_php_c
+ popd
}
build_php5.5_32() {
use_php_bc 5.5
+ pushd php
rm -rf vendor
cp -r /usr/local/vendor-5.5 vendor
./vendor/bin/phpunit
+ popd
+ # TODO(teboring): Add conformance test.
+ # pushd conformance
+ # make test_php
+ # popd
}
build_php5.5_c_32() {
use_php_bc 5.5
wget https://phar.phpunit.de/phpunit-old.phar -O /usr/bin/phpunit
cd php/tests && /bin/bash ./test.sh && cd ../..
+ # TODO(teboring): Add conformance test.
+ # pushd conformance
+ # make test_php_c
+ # popd
}
build_php5.6() {
use_php 5.6
+ pushd php
rm -rf vendor
cp -r /usr/local/vendor-5.6 vendor
./vendor/bin/phpunit
+ popd
+ pushd conformance
+ # TODO(teboring): Add it back
+ # make test_php
+ popd
}
build_php5.6_c() {
use_php 5.6
cd php/tests && /bin/bash ./test.sh && cd ../..
+ pushd conformance
+ make test_php_c
+ popd
}
build_php5.6_mac() {
+ generate_php_test_proto
# Install PHP
curl -s https://php-osx.liip.ch/install.sh | bash -s 5.6
PHP_FOLDER=`find /usr/local -type d -name "php5-5.6*"` # The folder name may change upon time
export PATH="$PHP_FOLDER/bin:$PATH"
# Install phpunit
- curl https://phar.phpunit.de/phpunit.phar -L -o phpunit.phar
+ curl https://phar.phpunit.de/phpunit-5.6.10.phar -L -o phpunit.phar
chmod +x phpunit.phar
sudo mv phpunit.phar /usr/local/bin/phpunit
@@ -429,18 +494,30 @@ build_php5.6_mac() {
# Test
cd php/tests && /bin/bash ./test.sh && cd ../..
+ pushd conformance
+ make test_php_c
+ popd
}
build_php7.0() {
use_php 7.0
+ pushd php
rm -rf vendor
cp -r /usr/local/vendor-7.0 vendor
./vendor/bin/phpunit
+ popd
+ pushd conformance
+ # TODO(teboring): Add it back
+ # make test_php
+ popd
}
build_php7.0_c() {
use_php 7.0
cd php/tests && /bin/bash ./test.sh && cd ../..
+ pushd conformance
+ make test_php_c
+ popd
}
build_php_all() {
@@ -485,6 +562,7 @@ Usage: $0 { cpp |
objectivec_cocoapods_integration |
python |
python_cpp |
+ python_compatibility |
ruby21 |
ruby22 |
jruby |