protoc 2.6.1.1 → 2.6.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/protoc/Makefile.in +10 -13
- data/ext/protoc/extconf.rb +0 -1
- data/ext/protoc/protobuf/CHANGES.txt +593 -0
- data/ext/protoc/protobuf/CONTRIBUTORS.txt +93 -0
- data/ext/protoc/protobuf/INSTALL.txt +237 -0
- data/ext/protoc/protobuf/LICENSE +33 -0
- data/ext/protoc/protobuf/Makefile.am +267 -0
- data/ext/protoc/protobuf/README.md +167 -0
- data/ext/protoc/protobuf/autogen.sh +41 -0
- data/ext/protoc/protobuf/benchmarks/ProtoBench.java +203 -0
- data/ext/protoc/protobuf/benchmarks/google_message1.dat +0 -0
- data/ext/protoc/protobuf/benchmarks/google_message2.dat +0 -0
- data/ext/protoc/protobuf/benchmarks/google_size.proto +136 -0
- data/ext/protoc/protobuf/benchmarks/google_speed.proto +136 -0
- data/ext/protoc/protobuf/benchmarks/readme.txt +50 -0
- data/ext/protoc/protobuf/configure.ac +159 -0
- data/ext/protoc/protobuf/editors/README.txt +5 -0
- data/ext/protoc/protobuf/editors/proto.vim +105 -0
- data/ext/protoc/protobuf/editors/protobuf-mode.el +220 -0
- data/ext/protoc/protobuf/examples/AddPerson.java +95 -0
- data/ext/protoc/protobuf/examples/ListPeople.java +50 -0
- data/ext/protoc/protobuf/examples/Makefile +58 -0
- data/ext/protoc/protobuf/examples/README.txt +29 -0
- data/ext/protoc/protobuf/examples/add_person.cc +95 -0
- data/ext/protoc/protobuf/examples/add_person.py +58 -0
- data/ext/protoc/protobuf/examples/addressbook.proto +30 -0
- data/ext/protoc/protobuf/examples/list_people.cc +68 -0
- data/ext/protoc/protobuf/examples/list_people.py +38 -0
- data/ext/protoc/protobuf/generate_descriptor_proto.sh +33 -0
- data/ext/protoc/protobuf/java/README.txt +96 -0
- data/ext/protoc/protobuf/java/pom.xml +217 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/AbstractMessage.java +466 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/AbstractMessageLite.java +355 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/AbstractParser.java +253 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/BlockingRpcChannel.java +51 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/BlockingService.java +64 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/BoundedByteString.java +163 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/ByteString.java +1022 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/CodedInputStream.java +1311 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/CodedOutputStream.java +1297 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Descriptors.java +2238 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/DynamicMessage.java +622 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Extension.java +96 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/ExtensionRegistry.java +392 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/ExtensionRegistryLite.java +185 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/FieldSet.java +907 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/GeneratedMessage.java +2213 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/GeneratedMessageLite.java +949 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Internal.java +391 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java +122 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/LazyField.java +154 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/LazyFieldLite.java +176 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/LazyStringArrayList.java +367 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/LazyStringList.java +163 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/LiteralByteString.java +362 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Message.java +244 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/MessageLite.java +320 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java +60 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/MessageOrBuilder.java +143 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/MessageReflection.java +931 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Parser.java +261 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/ProtocolMessageEnum.java +58 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/ProtocolStringList.java +48 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/RepeatedFieldBuilder.java +696 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/RopeByteString.java +957 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/RpcCallback.java +47 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/RpcChannel.java +71 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/RpcController.java +118 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/RpcUtil.java +134 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Service.java +117 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/ServiceException.java +52 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/SingleFieldBuilder.java +241 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/SmallSortedMap.java +618 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/TextFormat.java +1984 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/UninitializedMessageException.java +99 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/UnknownFieldSet.java +995 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java +205 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Utf8.java +349 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/WireFormat.java +163 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/AbstractMessageTest.java +527 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/BoundedByteStringTest.java +68 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/ByteStringTest.java +759 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/CheckUtf8Test.java +141 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/CodedInputStreamTest.java +769 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/CodedOutputStreamTest.java +401 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/DeprecatedFieldTest.java +80 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/DescriptorsTest.java +735 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/DynamicMessageTest.java +326 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/ForceFieldBuildersPreRun.java +48 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/GeneratedMessageTest.java +1515 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/IsValidUtf8Test.java +180 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/IsValidUtf8TestUtil.java +421 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LazyFieldLiteTest.java +134 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LazyFieldTest.java +121 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LazyMessageLiteTest.java +319 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LazyStringArrayListTest.java +174 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LazyStringEndToEndTest.java +143 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LiteEqualsAndHashTest.java +85 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LiteTest.java +148 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LiteralByteStringTest.java +396 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/MessageTest.java +353 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/NestedBuildersTest.java +185 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/ParserTest.java +381 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/RepeatedFieldBuilderTest.java +190 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/RopeByteStringSubstringTest.java +97 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/RopeByteStringTest.java +115 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/ServiceTest.java +320 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/SingleFieldBuilderTest.java +155 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/SmallSortedMapTest.java +420 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/TestBadIdentifiers.java +96 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/TestUtil.java +4124 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/TextFormatTest.java +994 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/UnknownFieldSetTest.java +653 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/UnmodifiableLazyStringListTest.java +227 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/WireFormatTest.java +606 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/lazy_fields_lite.proto +61 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/lite_equals_and_hash.proto +55 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/multiple_files_test.proto +77 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/nested_builders_test.proto +53 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/nested_extension.proto +46 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/nested_extension_lite.proto +48 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/non_nested_extension.proto +49 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/non_nested_extension_lite.proto +50 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/outer_class_name_test.proto +38 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/outer_class_name_test2.proto +42 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/outer_class_name_test3.proto +43 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/test_bad_identifiers.proto +157 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/test_check_utf8.proto +50 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/test_check_utf8_size.proto +51 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/test_custom_options.proto +43 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/test_extra_interfaces.proto +60 -0
- data/ext/protoc/protobuf/m4/ac_system_extensions.m4 +37 -0
- data/ext/protoc/protobuf/m4/acx_check_suncc.m4 +75 -0
- data/ext/protoc/protobuf/m4/acx_pthread.m4 +397 -0
- data/ext/protoc/protobuf/m4/stl_hash.m4 +72 -0
- data/ext/protoc/protobuf/more_tests/Makefile +41 -0
- data/ext/protoc/protobuf/post_process_dist.sh +60 -0
- data/ext/protoc/protobuf/protobuf-lite.pc.in +13 -0
- data/ext/protoc/protobuf/protobuf.pc.in +14 -0
- data/ext/protoc/protobuf/python/README.txt +105 -0
- data/ext/protoc/protobuf/python/ez_setup.py +284 -0
- data/ext/protoc/protobuf/python/google/__init__.py +1 -0
- data/ext/protoc/protobuf/python/google/protobuf/__init__.py +0 -0
- data/ext/protoc/protobuf/python/google/protobuf/descriptor.py +849 -0
- data/ext/protoc/protobuf/python/google/protobuf/descriptor_database.py +137 -0
- data/ext/protoc/protobuf/python/google/protobuf/descriptor_pool.py +643 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/__init__.py +0 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/api_implementation.cc +139 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/api_implementation.py +89 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/api_implementation_default_test.py +63 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/containers.py +269 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/cpp_message.py +663 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/decoder.py +831 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/descriptor_database_test.py +63 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/descriptor_pool_test.py +564 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/descriptor_pool_test1.proto +94 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/descriptor_pool_test2.proto +70 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/descriptor_python_test.py +54 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/descriptor_test.py +669 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/encoder.py +788 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/enum_type_wrapper.py +89 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/factory_test1.proto +57 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/factory_test2.proto +92 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/generator_test.py +343 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/message_factory_python_test.py +54 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/message_factory_test.py +131 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/message_listener.py +78 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/message_python_test.py +54 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/message_test.py +681 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/missing_enum_values.proto +50 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/more_extensions.proto +58 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/more_extensions_dynamic.proto +49 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/more_messages.proto +51 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/python_message.py +1251 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/reflection_test.py +2934 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/service_reflection_test.py +136 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/symbol_database_test.py +120 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/test_bad_identifiers.proto +52 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/test_util.py +662 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/text_encoding_test.py +68 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/text_format_test.py +743 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/type_checkers.py +328 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/unknown_fields_test.py +231 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/wire_format.py +268 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/wire_format_test.py +253 -0
- data/ext/protoc/protobuf/python/google/protobuf/message.py +284 -0
- data/ext/protoc/protobuf/python/google/protobuf/message_factory.py +155 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/README +6 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/__init__.py +0 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/cpp_message.py +61 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/descriptor.cc +357 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/descriptor.h +96 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/descriptor_cpp2_test.py +58 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/extension_dict.cc +338 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/extension_dict.h +123 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/message.cc +2561 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/message.h +305 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/message_factory_cpp2_test.py +56 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/proto2_api_test.proto +38 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/python.proto +66 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/python_protobuf.h +57 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/reflection_cpp2_generated_test.py +94 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/repeated_composite_container.cc +763 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/repeated_composite_container.h +172 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/repeated_scalar_container.cc +825 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/repeated_scalar_container.h +112 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/scoped_pyobject_ptr.h +95 -0
- data/ext/protoc/protobuf/python/google/protobuf/reflection.py +205 -0
- data/ext/protoc/protobuf/python/google/protobuf/service.py +226 -0
- data/ext/protoc/protobuf/python/google/protobuf/service_reflection.py +284 -0
- data/ext/protoc/protobuf/python/google/protobuf/symbol_database.py +185 -0
- data/ext/protoc/protobuf/python/google/protobuf/text_encoding.py +110 -0
- data/ext/protoc/protobuf/python/google/protobuf/text_format.py +873 -0
- data/ext/protoc/protobuf/python/mox.py +1401 -0
- data/ext/protoc/protobuf/python/setup.py +201 -0
- data/ext/protoc/protobuf/python/stubout.py +140 -0
- data/ext/protoc/protobuf/src/Makefile.am +418 -0
- data/ext/protoc/protobuf/src/google/protobuf/SEBS +240 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/code_generator.cc +84 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/code_generator.h +145 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/command_line_interface.cc +1603 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/command_line_interface.h +378 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/command_line_interface_unittest.cc +1654 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc +158 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.cc +288 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.h +103 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.cc +431 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.h +122 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.cc +210 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.h +86 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_field.cc +166 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_field.h +185 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_file.cc +665 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_file.h +99 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_generator.cc +125 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_generator.h +72 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.cc +494 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.h +206 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_message.cc +2645 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_message.h +175 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.cc +375 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.h +121 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_options.h +58 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc +123 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc +451 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.h +123 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_service.cc +334 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_service.h +118 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.cc +642 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.h +127 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto +132 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_unittest.cc +2074 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_unittest.h +51 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/importer.cc +480 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/importer.h +317 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/importer_unittest.cc +617 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_context.cc +195 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_context.h +95 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_doc_comment.cc +233 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_doc_comment.h +69 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_doc_comment_unittest.cc +67 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_enum.cc +333 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_enum.h +99 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_enum_field.cc +778 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_enum_field.h +158 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_extension.cc +207 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_extension.h +109 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_field.cc +213 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_field.h +162 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_file.cc +534 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_file.h +115 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_generator.cc +158 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_generator.h +72 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_generator_factory.cc +77 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_generator_factory.h +101 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_helpers.cc +737 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_helpers.h +322 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_lazy_message_field.cc +826 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_lazy_message_field.h +121 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_message.cc +1666 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_message.h +140 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_message_field.cc +1343 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_message_field.h +173 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_name_resolver.cc +266 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_name_resolver.h +124 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_plugin_unittest.cc +124 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_primitive_field.cc +877 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_primitive_field.h +160 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_service.cc +473 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_service.h +135 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_shared_code_generator.cc +201 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_shared_code_generator.h +90 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_string_field.cc +1056 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_string_field.h +160 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/main.cc +61 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/mock_code_generator.cc +240 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/mock_code_generator.h +117 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/package_info.h +64 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/parser.cc +1750 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/parser.h +522 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/parser_unittest.cc +2612 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/plugin.cc +163 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/plugin.h +72 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/plugin.pb.cc +1148 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/plugin.pb.h +897 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/plugin.proto +147 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/python/python_generator.cc +1262 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/python/python_generator.h +166 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/python/python_plugin_unittest.cc +118 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/subprocess.cc +463 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/subprocess.h +108 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/test_plugin.cc +51 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/zip_output_unittest.sh +91 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/zip_writer.cc +218 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/zip_writer.h +93 -0
- data/ext/protoc/protobuf/src/google/protobuf/descriptor.cc +5420 -0
- data/ext/protoc/protobuf/src/google/protobuf/descriptor.h +1691 -0
- data/ext/protoc/protobuf/src/google/protobuf/descriptor.pb.cc +9135 -0
- data/ext/protoc/protobuf/src/google/protobuf/descriptor.pb.h +6761 -0
- data/ext/protoc/protobuf/src/google/protobuf/descriptor.proto +687 -0
- data/ext/protoc/protobuf/src/google/protobuf/descriptor_database.cc +543 -0
- data/ext/protoc/protobuf/src/google/protobuf/descriptor_database.h +369 -0
- data/ext/protoc/protobuf/src/google/protobuf/descriptor_database_unittest.cc +748 -0
- data/ext/protoc/protobuf/src/google/protobuf/descriptor_pb2_test.py +54 -0
- data/ext/protoc/protobuf/src/google/protobuf/descriptor_unittest.cc +5501 -0
- data/ext/protoc/protobuf/src/google/protobuf/dynamic_message.cc +764 -0
- data/ext/protoc/protobuf/src/google/protobuf/dynamic_message.h +148 -0
- data/ext/protoc/protobuf/src/google/protobuf/dynamic_message_unittest.cc +230 -0
- data/ext/protoc/protobuf/src/google/protobuf/extension_set.cc +1663 -0
- data/ext/protoc/protobuf/src/google/protobuf/extension_set.h +1234 -0
- data/ext/protoc/protobuf/src/google/protobuf/extension_set_heavy.cc +734 -0
- data/ext/protoc/protobuf/src/google/protobuf/extension_set_unittest.cc +1095 -0
- data/ext/protoc/protobuf/src/google/protobuf/generated_enum_reflection.h +91 -0
- data/ext/protoc/protobuf/src/google/protobuf/generated_message_reflection.cc +1683 -0
- data/ext/protoc/protobuf/src/google/protobuf/generated_message_reflection.h +504 -0
- data/ext/protoc/protobuf/src/google/protobuf/generated_message_reflection_unittest.cc +795 -0
- data/ext/protoc/protobuf/src/google/protobuf/generated_message_util.cc +65 -0
- data/ext/protoc/protobuf/src/google/protobuf/generated_message_util.h +113 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/coded_stream.cc +914 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/coded_stream.h +1220 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/coded_stream_inl.h +69 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/coded_stream_unittest.cc +1378 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/gzip_stream.cc +326 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/gzip_stream.h +209 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/gzip_stream_unittest.sh +44 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/package_info.h +54 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/printer.cc +198 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/printer.h +136 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/printer_unittest.cc +285 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/strtod.cc +113 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/strtod.h +50 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/tokenizer.cc +1127 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/tokenizer.h +402 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/tokenizer_unittest.cc +999 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream.cc +57 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream.h +248 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream_impl.cc +473 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream_impl.h +358 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc +405 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h +354 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream_unittest.cc +965 -0
- data/ext/protoc/protobuf/src/google/protobuf/lite_unittest.cc +350 -0
- data/ext/protoc/protobuf/src/google/protobuf/message.cc +358 -0
- data/ext/protoc/protobuf/src/google/protobuf/message.h +866 -0
- data/ext/protoc/protobuf/src/google/protobuf/message_lite.cc +335 -0
- data/ext/protoc/protobuf/src/google/protobuf/message_lite.h +247 -0
- data/ext/protoc/protobuf/src/google/protobuf/message_unittest.cc +427 -0
- data/ext/protoc/protobuf/src/google/protobuf/package_info.h +64 -0
- data/ext/protoc/protobuf/src/google/protobuf/reflection_ops.cc +269 -0
- data/ext/protoc/protobuf/src/google/protobuf/reflection_ops.h +81 -0
- data/ext/protoc/protobuf/src/google/protobuf/reflection_ops_unittest.cc +475 -0
- data/ext/protoc/protobuf/src/google/protobuf/repeated_field.cc +87 -0
- data/ext/protoc/protobuf/src/google/protobuf/repeated_field.h +1603 -0
- data/ext/protoc/protobuf/src/google/protobuf/repeated_field_reflection_unittest.cc +195 -0
- data/ext/protoc/protobuf/src/google/protobuf/repeated_field_unittest.cc +1442 -0
- data/ext/protoc/protobuf/src/google/protobuf/service.cc +46 -0
- data/ext/protoc/protobuf/src/google/protobuf/service.h +291 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops.h +227 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_arm64_gcc.h +325 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_arm_gcc.h +151 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_arm_qnx.h +146 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_atomicword_compat.h +122 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h +137 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_macosx.h +225 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_mips_gcc.h +313 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_pnacl.h +73 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_solaris.h +188 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_tsan.h +219 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc +137 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_gcc.h +293 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc +112 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_msvc.h +150 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/common.cc +395 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/common.h +1226 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/common_unittest.cc +357 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/hash.h +232 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/map_util.h +771 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/once.cc +99 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/once.h +166 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/once_unittest.cc +253 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/platform_macros.h +103 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/shared_ptr.h +470 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/stl_util.h +121 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/stringprintf.cc +175 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/stringprintf.h +76 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/stringprintf_unittest.cc +152 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/structurally_valid.cc +536 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/structurally_valid_unittest.cc +40 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/strutil.cc +1279 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/strutil.h +562 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/strutil_unittest.cc +73 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/substitute.cc +134 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/substitute.h +170 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/template_util.h +138 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/template_util_unittest.cc +130 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/type_traits.h +336 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/type_traits_unittest.cc +628 -0
- data/ext/protoc/protobuf/src/google/protobuf/test_util.cc +3345 -0
- data/ext/protoc/protobuf/src/google/protobuf/test_util.h +215 -0
- data/ext/protoc/protobuf/src/google/protobuf/test_util_lite.cc +1585 -0
- data/ext/protoc/protobuf/src/google/protobuf/test_util_lite.h +101 -0
- data/ext/protoc/protobuf/src/google/protobuf/testdata/bad_utf8_string +1 -0
- data/ext/protoc/protobuf/src/google/protobuf/testdata/golden_message +0 -0
- data/ext/protoc/protobuf/src/google/protobuf/testdata/golden_message_oneof_implemented +0 -0
- data/ext/protoc/protobuf/src/google/protobuf/testdata/golden_packed_fields_message +0 -0
- data/ext/protoc/protobuf/src/google/protobuf/testdata/text_format_unittest_data.txt +134 -0
- data/ext/protoc/protobuf/src/google/protobuf/testdata/text_format_unittest_data_oneof_implemented.txt +129 -0
- data/ext/protoc/protobuf/src/google/protobuf/testdata/text_format_unittest_data_pointy.txt +134 -0
- data/ext/protoc/protobuf/src/google/protobuf/testdata/text_format_unittest_data_pointy_oneof.txt +129 -0
- data/ext/protoc/protobuf/src/google/protobuf/testdata/text_format_unittest_extensions_data.txt +134 -0
- data/ext/protoc/protobuf/src/google/protobuf/testdata/text_format_unittest_extensions_data_pointy.txt +134 -0
- data/ext/protoc/protobuf/src/google/protobuf/testing/file.cc +194 -0
- data/ext/protoc/protobuf/src/google/protobuf/testing/file.h +97 -0
- data/ext/protoc/protobuf/src/google/protobuf/testing/googletest.cc +255 -0
- data/ext/protoc/protobuf/src/google/protobuf/testing/googletest.h +102 -0
- data/ext/protoc/protobuf/src/google/protobuf/testing/zcgunzip.cc +73 -0
- data/ext/protoc/protobuf/src/google/protobuf/testing/zcgzip.cc +79 -0
- data/ext/protoc/protobuf/src/google/protobuf/text_format.cc +1746 -0
- data/ext/protoc/protobuf/src/google/protobuf/text_format.h +473 -0
- data/ext/protoc/protobuf/src/google/protobuf/text_format_unittest.cc +1479 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest.proto +861 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest_custom_options.proto +393 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest_embed_optimize_for.proto +50 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest_empty.proto +37 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest_enormous_descriptor.proto +1046 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest_import.proto +64 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest_import_lite.proto +51 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest_import_public.proto +40 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest_import_public_lite.proto +42 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest_lite.proto +384 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest_lite_imports_nonlite.proto +43 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest_mset.proto +83 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest_no_generic_services.proto +53 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest_optimize_for.proto +66 -0
- data/ext/protoc/protobuf/src/google/protobuf/unknown_field_set.cc +265 -0
- data/ext/protoc/protobuf/src/google/protobuf/unknown_field_set.h +318 -0
- data/ext/protoc/protobuf/src/google/protobuf/unknown_field_set_unittest.cc +599 -0
- data/ext/protoc/protobuf/src/google/protobuf/wire_format.cc +1101 -0
- data/ext/protoc/protobuf/src/google/protobuf/wire_format.h +336 -0
- data/ext/protoc/protobuf/src/google/protobuf/wire_format_lite.cc +471 -0
- data/ext/protoc/protobuf/src/google/protobuf/wire_format_lite.h +661 -0
- data/ext/protoc/protobuf/src/google/protobuf/wire_format_lite_inl.h +860 -0
- data/ext/protoc/protobuf/src/google/protobuf/wire_format_unittest.cc +1120 -0
- data/ext/protoc/protobuf/src/solaris/libstdc++.la +51 -0
- data/ext/protoc/protobuf/vsprojects/config.h +29 -0
- data/ext/protoc/protobuf/vsprojects/convert2008to2005.sh +20 -0
- data/ext/protoc/protobuf/vsprojects/extract_includes.bat +50 -0
- data/ext/protoc/protobuf/vsprojects/libprotobuf-lite.vcproj +302 -0
- data/ext/protoc/protobuf/vsprojects/libprotobuf.vcproj +470 -0
- data/ext/protoc/protobuf/vsprojects/libprotoc.vcproj +466 -0
- data/ext/protoc/protobuf/vsprojects/lite-test.vcproj +305 -0
- data/ext/protoc/protobuf/vsprojects/protobuf.sln +92 -0
- data/ext/protoc/protobuf/vsprojects/protoc.vcproj +192 -0
- data/ext/protoc/protobuf/vsprojects/readme.txt +114 -0
- data/ext/protoc/protobuf/vsprojects/test_plugin.vcproj +209 -0
- data/ext/protoc/protobuf/vsprojects/tests.vcproj +681 -0
- data/lib/protoc/version.rb +1 -1
- metadata +480 -3
@@ -0,0 +1,60 @@
|
|
1
|
+
// Protocol Buffers - Google's data interchange format
|
2
|
+
// Copyright 2008 Google Inc. All rights reserved.
|
3
|
+
// https://developers.google.com/protocol-buffers/
|
4
|
+
//
|
5
|
+
// Redistribution and use in source and binary forms, with or without
|
6
|
+
// modification, are permitted provided that the following conditions are
|
7
|
+
// met:
|
8
|
+
//
|
9
|
+
// * Redistributions of source code must retain the above copyright
|
10
|
+
// notice, this list of conditions and the following disclaimer.
|
11
|
+
// * Redistributions in binary form must reproduce the above
|
12
|
+
// copyright notice, this list of conditions and the following disclaimer
|
13
|
+
// in the documentation and/or other materials provided with the
|
14
|
+
// distribution.
|
15
|
+
// * Neither the name of Google Inc. nor the names of its
|
16
|
+
// contributors may be used to endorse or promote products derived from
|
17
|
+
// this software without specific prior written permission.
|
18
|
+
//
|
19
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
20
|
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
21
|
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
22
|
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
25
|
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
26
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
27
|
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
28
|
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
|
31
|
+
package com.google.protobuf;
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Base interface for methods common to {@link MessageLite}
|
35
|
+
* and {@link MessageLite.Builder} to provide type equivalency.
|
36
|
+
*
|
37
|
+
* @author jonp@google.com (Jon Perlow)
|
38
|
+
*/
|
39
|
+
public interface MessageLiteOrBuilder {
|
40
|
+
/**
|
41
|
+
* Get an instance of the type with no fields set. Because no fields are set,
|
42
|
+
* all getters for singular fields will return default values and repeated
|
43
|
+
* fields will appear empty.
|
44
|
+
* This may or may not be a singleton. This differs from the
|
45
|
+
* {@code getDefaultInstance()} method of generated message classes in that
|
46
|
+
* this method is an abstract method of the {@code MessageLite} interface
|
47
|
+
* whereas {@code getDefaultInstance()} is a static method of a specific
|
48
|
+
* class. They return the same thing.
|
49
|
+
*/
|
50
|
+
MessageLite getDefaultInstanceForType();
|
51
|
+
|
52
|
+
/**
|
53
|
+
* Returns true if all required fields in the message and all embedded
|
54
|
+
* messages are set, false otherwise.
|
55
|
+
*
|
56
|
+
* <p>See also: {@link MessageOrBuilder#getInitializationErrorString()}
|
57
|
+
*/
|
58
|
+
boolean isInitialized();
|
59
|
+
|
60
|
+
}
|
@@ -0,0 +1,143 @@
|
|
1
|
+
// Protocol Buffers - Google's data interchange format
|
2
|
+
// Copyright 2008 Google Inc. All rights reserved.
|
3
|
+
// https://developers.google.com/protocol-buffers/
|
4
|
+
//
|
5
|
+
// Redistribution and use in source and binary forms, with or without
|
6
|
+
// modification, are permitted provided that the following conditions are
|
7
|
+
// met:
|
8
|
+
//
|
9
|
+
// * Redistributions of source code must retain the above copyright
|
10
|
+
// notice, this list of conditions and the following disclaimer.
|
11
|
+
// * Redistributions in binary form must reproduce the above
|
12
|
+
// copyright notice, this list of conditions and the following disclaimer
|
13
|
+
// in the documentation and/or other materials provided with the
|
14
|
+
// distribution.
|
15
|
+
// * Neither the name of Google Inc. nor the names of its
|
16
|
+
// contributors may be used to endorse or promote products derived from
|
17
|
+
// this software without specific prior written permission.
|
18
|
+
//
|
19
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
20
|
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
21
|
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
22
|
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
25
|
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
26
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
27
|
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
28
|
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
|
31
|
+
package com.google.protobuf;
|
32
|
+
|
33
|
+
import java.util.List;
|
34
|
+
import java.util.Map;
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Base interface for methods common to {@link Message} and
|
38
|
+
* {@link Message.Builder} to provide type equivalency.
|
39
|
+
*
|
40
|
+
* @author jonp@google.com (Jon Perlow)
|
41
|
+
*/
|
42
|
+
public interface MessageOrBuilder extends MessageLiteOrBuilder {
|
43
|
+
|
44
|
+
// (From MessageLite, re-declared here only for return type covariance.)
|
45
|
+
//@Override (Java 1.6 override semantics, but we must support 1.5)
|
46
|
+
Message getDefaultInstanceForType();
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Returns a list of field paths (e.g. "foo.bar.baz") of required fields
|
50
|
+
* which are not set in this message. You should call
|
51
|
+
* {@link MessageLiteOrBuilder#isInitialized()} first to check if there
|
52
|
+
* are any missing fields, as that method is likely to be much faster
|
53
|
+
* than this one even when the message is fully-initialized.
|
54
|
+
*/
|
55
|
+
List<String> findInitializationErrors();
|
56
|
+
|
57
|
+
/**
|
58
|
+
* Returns a comma-delimited list of required fields which are not set
|
59
|
+
* in this message object. You should call
|
60
|
+
* {@link MessageLiteOrBuilder#isInitialized()} first to check if there
|
61
|
+
* are any missing fields, as that method is likely to be much faster
|
62
|
+
* than this one even when the message is fully-initialized.
|
63
|
+
*/
|
64
|
+
String getInitializationErrorString();
|
65
|
+
|
66
|
+
/**
|
67
|
+
* Get the message's type's descriptor. This differs from the
|
68
|
+
* {@code getDescriptor()} method of generated message classes in that
|
69
|
+
* this method is an abstract method of the {@code Message} interface
|
70
|
+
* whereas {@code getDescriptor()} is a static method of a specific class.
|
71
|
+
* They return the same thing.
|
72
|
+
*/
|
73
|
+
Descriptors.Descriptor getDescriptorForType();
|
74
|
+
|
75
|
+
/**
|
76
|
+
* Returns a collection of all the fields in this message which are set
|
77
|
+
* and their corresponding values. A singular ("required" or "optional")
|
78
|
+
* field is set iff hasField() returns true for that field. A "repeated"
|
79
|
+
* field is set iff getRepeatedFieldCount() is greater than zero. The
|
80
|
+
* values are exactly what would be returned by calling
|
81
|
+
* {@link #getField(Descriptors.FieldDescriptor)} for each field. The map
|
82
|
+
* is guaranteed to be a sorted map, so iterating over it will return fields
|
83
|
+
* in order by field number.
|
84
|
+
* <br>
|
85
|
+
* If this is for a builder, the returned map may or may not reflect future
|
86
|
+
* changes to the builder. Either way, the returned map is itself
|
87
|
+
* unmodifiable.
|
88
|
+
*/
|
89
|
+
Map<Descriptors.FieldDescriptor, Object> getAllFields();
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Returns true if the given oneof is set.
|
93
|
+
* @throws IllegalArgumentException if
|
94
|
+
* {@code oneof.getContainingType() != getDescriptorForType()}.
|
95
|
+
*/
|
96
|
+
boolean hasOneof(Descriptors.OneofDescriptor oneof);
|
97
|
+
|
98
|
+
/**
|
99
|
+
* Obtains the FieldDescriptor if the given oneof is set. Returns null
|
100
|
+
* if no field is set.
|
101
|
+
*/
|
102
|
+
Descriptors.FieldDescriptor getOneofFieldDescriptor(
|
103
|
+
Descriptors.OneofDescriptor oneof);
|
104
|
+
|
105
|
+
/**
|
106
|
+
* Returns true if the given field is set. This is exactly equivalent to
|
107
|
+
* calling the generated "has" accessor method corresponding to the field.
|
108
|
+
* @throws IllegalArgumentException The field is a repeated field, or
|
109
|
+
* {@code field.getContainingType() != getDescriptorForType()}.
|
110
|
+
*/
|
111
|
+
boolean hasField(Descriptors.FieldDescriptor field);
|
112
|
+
|
113
|
+
/**
|
114
|
+
* Obtains the value of the given field, or the default value if it is
|
115
|
+
* not set. For primitive fields, the boxed primitive value is returned.
|
116
|
+
* For enum fields, the EnumValueDescriptor for the value is returned. For
|
117
|
+
* embedded message fields, the sub-message is returned. For repeated
|
118
|
+
* fields, a java.util.List is returned.
|
119
|
+
*/
|
120
|
+
Object getField(Descriptors.FieldDescriptor field);
|
121
|
+
|
122
|
+
/**
|
123
|
+
* Gets the number of elements of a repeated field. This is exactly
|
124
|
+
* equivalent to calling the generated "Count" accessor method corresponding
|
125
|
+
* to the field.
|
126
|
+
* @throws IllegalArgumentException The field is not a repeated field, or
|
127
|
+
* {@code field.getContainingType() != getDescriptorForType()}.
|
128
|
+
*/
|
129
|
+
int getRepeatedFieldCount(Descriptors.FieldDescriptor field);
|
130
|
+
|
131
|
+
/**
|
132
|
+
* Gets an element of a repeated field. For primitive fields, the boxed
|
133
|
+
* primitive value is returned. For enum fields, the EnumValueDescriptor
|
134
|
+
* for the value is returned. For embedded message fields, the sub-message
|
135
|
+
* is returned.
|
136
|
+
* @throws IllegalArgumentException The field is not a repeated field, or
|
137
|
+
* {@code field.getContainingType() != getDescriptorForType()}.
|
138
|
+
*/
|
139
|
+
Object getRepeatedField(Descriptors.FieldDescriptor field, int index);
|
140
|
+
|
141
|
+
/** Get the {@link UnknownFieldSet} for this message. */
|
142
|
+
UnknownFieldSet getUnknownFields();
|
143
|
+
}
|
@@ -0,0 +1,931 @@
|
|
1
|
+
// Protocol Buffers - Google's data interchange format
|
2
|
+
// Copyright 2008 Google Inc. All rights reserved.
|
3
|
+
// https://developers.google.com/protocol-buffers/
|
4
|
+
//
|
5
|
+
// Redistribution and use in source and binary forms, with or without
|
6
|
+
// modification, are permitted provided that the following conditions are
|
7
|
+
// met:
|
8
|
+
//
|
9
|
+
// * Redistributions of source code must retain the above copyright
|
10
|
+
// notice, this list of conditions and the following disclaimer.
|
11
|
+
// * Redistributions in binary form must reproduce the above
|
12
|
+
// copyright notice, this list of conditions and the following disclaimer
|
13
|
+
// in the documentation and/or other materials provided with the
|
14
|
+
// distribution.
|
15
|
+
// * Neither the name of Google Inc. nor the names of its
|
16
|
+
// contributors may be used to endorse or promote products derived from
|
17
|
+
// this software without specific prior written permission.
|
18
|
+
//
|
19
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
20
|
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
21
|
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
22
|
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
25
|
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
26
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
27
|
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
28
|
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
|
31
|
+
package com.google.protobuf;
|
32
|
+
|
33
|
+
import com.google.protobuf.Descriptors.FieldDescriptor;
|
34
|
+
|
35
|
+
import java.io.IOException;
|
36
|
+
import java.util.ArrayList;
|
37
|
+
import java.util.List;
|
38
|
+
import java.util.Map;
|
39
|
+
import java.util.TreeMap;
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Reflection utility methods shared by both mutable and immutable messages.
|
43
|
+
*
|
44
|
+
* @author liujisi@google.com (Pherl Liu)
|
45
|
+
*/
|
46
|
+
class MessageReflection {
|
47
|
+
|
48
|
+
static void writeMessageTo(Message message, CodedOutputStream output,
|
49
|
+
boolean alwaysWriteRequiredFields)
|
50
|
+
throws IOException {
|
51
|
+
final boolean isMessageSet =
|
52
|
+
message.getDescriptorForType().getOptions().getMessageSetWireFormat();
|
53
|
+
|
54
|
+
Map<FieldDescriptor, Object> fields = message.getAllFields();
|
55
|
+
if (alwaysWriteRequiredFields) {
|
56
|
+
fields = new TreeMap<FieldDescriptor, Object>(fields);
|
57
|
+
for (final FieldDescriptor field :
|
58
|
+
message.getDescriptorForType().getFields()) {
|
59
|
+
if (field.isRequired() && !fields.containsKey(field)) {
|
60
|
+
fields.put(field, message.getField(field));
|
61
|
+
}
|
62
|
+
}
|
63
|
+
}
|
64
|
+
for (final Map.Entry<Descriptors.FieldDescriptor, Object> entry :
|
65
|
+
fields.entrySet()) {
|
66
|
+
final Descriptors.FieldDescriptor field = entry.getKey();
|
67
|
+
final Object value = entry.getValue();
|
68
|
+
if (isMessageSet && field.isExtension() &&
|
69
|
+
field.getType() == Descriptors.FieldDescriptor.Type.MESSAGE &&
|
70
|
+
!field.isRepeated()) {
|
71
|
+
output.writeMessageSetExtension(field.getNumber(), (Message) value);
|
72
|
+
} else {
|
73
|
+
FieldSet.writeField(field, value, output);
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
final UnknownFieldSet unknownFields = message.getUnknownFields();
|
78
|
+
if (isMessageSet) {
|
79
|
+
unknownFields.writeAsMessageSetTo(output);
|
80
|
+
} else {
|
81
|
+
unknownFields.writeTo(output);
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
static int getSerializedSize(Message message) {
|
86
|
+
int size = 0;
|
87
|
+
final boolean isMessageSet =
|
88
|
+
message.getDescriptorForType().getOptions().getMessageSetWireFormat();
|
89
|
+
|
90
|
+
for (final Map.Entry<Descriptors.FieldDescriptor, Object> entry :
|
91
|
+
message.getAllFields().entrySet()) {
|
92
|
+
final Descriptors.FieldDescriptor field = entry.getKey();
|
93
|
+
final Object value = entry.getValue();
|
94
|
+
if (isMessageSet && field.isExtension() &&
|
95
|
+
field.getType() == Descriptors.FieldDescriptor.Type.MESSAGE &&
|
96
|
+
!field.isRepeated()) {
|
97
|
+
size += CodedOutputStream.computeMessageSetExtensionSize(
|
98
|
+
field.getNumber(), (Message) value);
|
99
|
+
} else {
|
100
|
+
size += FieldSet.computeFieldSize(field, value);
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
final UnknownFieldSet unknownFields = message.getUnknownFields();
|
105
|
+
if (isMessageSet) {
|
106
|
+
size += unknownFields.getSerializedSizeAsMessageSet();
|
107
|
+
} else {
|
108
|
+
size += unknownFields.getSerializedSize();
|
109
|
+
}
|
110
|
+
return size;
|
111
|
+
}
|
112
|
+
|
113
|
+
static String delimitWithCommas(List<String> parts) {
|
114
|
+
StringBuilder result = new StringBuilder();
|
115
|
+
for (String part : parts) {
|
116
|
+
if (result.length() > 0) {
|
117
|
+
result.append(", ");
|
118
|
+
}
|
119
|
+
result.append(part);
|
120
|
+
}
|
121
|
+
return result.toString();
|
122
|
+
}
|
123
|
+
|
124
|
+
@SuppressWarnings("unchecked")
|
125
|
+
static boolean isInitialized(MessageOrBuilder message) {
|
126
|
+
// Check that all required fields are present.
|
127
|
+
for (final Descriptors.FieldDescriptor field : message
|
128
|
+
.getDescriptorForType()
|
129
|
+
.getFields()) {
|
130
|
+
if (field.isRequired()) {
|
131
|
+
if (!message.hasField(field)) {
|
132
|
+
return false;
|
133
|
+
}
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
137
|
+
// Check that embedded messages are initialized.
|
138
|
+
for (final Map.Entry<Descriptors.FieldDescriptor, Object> entry :
|
139
|
+
message.getAllFields().entrySet()) {
|
140
|
+
final Descriptors.FieldDescriptor field = entry.getKey();
|
141
|
+
if (field.getJavaType() == Descriptors.FieldDescriptor.JavaType.MESSAGE) {
|
142
|
+
if (field.isRepeated()) {
|
143
|
+
for (final Message element
|
144
|
+
: (List<Message>) entry.getValue()) {
|
145
|
+
if (!element.isInitialized()) {
|
146
|
+
return false;
|
147
|
+
}
|
148
|
+
}
|
149
|
+
} else {
|
150
|
+
if (!((Message) entry.getValue()).isInitialized()) {
|
151
|
+
return false;
|
152
|
+
}
|
153
|
+
}
|
154
|
+
}
|
155
|
+
}
|
156
|
+
|
157
|
+
return true;
|
158
|
+
}
|
159
|
+
|
160
|
+
private static String subMessagePrefix(final String prefix,
|
161
|
+
final Descriptors.FieldDescriptor field,
|
162
|
+
final int index) {
|
163
|
+
final StringBuilder result = new StringBuilder(prefix);
|
164
|
+
if (field.isExtension()) {
|
165
|
+
result.append('(')
|
166
|
+
.append(field.getFullName())
|
167
|
+
.append(')');
|
168
|
+
} else {
|
169
|
+
result.append(field.getName());
|
170
|
+
}
|
171
|
+
if (index != -1) {
|
172
|
+
result.append('[')
|
173
|
+
.append(index)
|
174
|
+
.append(']');
|
175
|
+
}
|
176
|
+
result.append('.');
|
177
|
+
return result.toString();
|
178
|
+
}
|
179
|
+
|
180
|
+
private static void findMissingFields(final MessageOrBuilder message,
|
181
|
+
final String prefix,
|
182
|
+
final List<String> results) {
|
183
|
+
for (final Descriptors.FieldDescriptor field :
|
184
|
+
message.getDescriptorForType().getFields()) {
|
185
|
+
if (field.isRequired() && !message.hasField(field)) {
|
186
|
+
results.add(prefix + field.getName());
|
187
|
+
}
|
188
|
+
}
|
189
|
+
|
190
|
+
for (final Map.Entry<Descriptors.FieldDescriptor, Object> entry :
|
191
|
+
message.getAllFields().entrySet()) {
|
192
|
+
final Descriptors.FieldDescriptor field = entry.getKey();
|
193
|
+
final Object value = entry.getValue();
|
194
|
+
|
195
|
+
if (field.getJavaType() == Descriptors.FieldDescriptor.JavaType.MESSAGE) {
|
196
|
+
if (field.isRepeated()) {
|
197
|
+
int i = 0;
|
198
|
+
for (final Object element : (List) value) {
|
199
|
+
findMissingFields((MessageOrBuilder) element,
|
200
|
+
subMessagePrefix(prefix, field, i++),
|
201
|
+
results);
|
202
|
+
}
|
203
|
+
} else {
|
204
|
+
if (message.hasField(field)) {
|
205
|
+
findMissingFields((MessageOrBuilder) value,
|
206
|
+
subMessagePrefix(prefix, field, -1),
|
207
|
+
results);
|
208
|
+
}
|
209
|
+
}
|
210
|
+
}
|
211
|
+
}
|
212
|
+
}
|
213
|
+
|
214
|
+
/**
|
215
|
+
* Populates {@code this.missingFields} with the full "path" of each missing
|
216
|
+
* required field in the given message.
|
217
|
+
*/
|
218
|
+
static List<String> findMissingFields(
|
219
|
+
final MessageOrBuilder message) {
|
220
|
+
final List<String> results = new ArrayList<String>();
|
221
|
+
findMissingFields(message, "", results);
|
222
|
+
return results;
|
223
|
+
}
|
224
|
+
|
225
|
+
static interface MergeTarget {
|
226
|
+
enum ContainerType {
|
227
|
+
MESSAGE, EXTENSION_SET
|
228
|
+
}
|
229
|
+
|
230
|
+
/**
|
231
|
+
* Returns the descriptor for the target.
|
232
|
+
*/
|
233
|
+
public Descriptors.Descriptor getDescriptorForType();
|
234
|
+
|
235
|
+
public ContainerType getContainerType();
|
236
|
+
|
237
|
+
public ExtensionRegistry.ExtensionInfo findExtensionByName(
|
238
|
+
ExtensionRegistry registry, String name);
|
239
|
+
|
240
|
+
public ExtensionRegistry.ExtensionInfo findExtensionByNumber(
|
241
|
+
ExtensionRegistry registry, Descriptors.Descriptor containingType,
|
242
|
+
int fieldNumber);
|
243
|
+
|
244
|
+
/**
|
245
|
+
* Obtains the value of the given field, or the default value if it is not
|
246
|
+
* set. For primitive fields, the boxed primitive value is returned. For
|
247
|
+
* enum fields, the EnumValueDescriptor for the value is returned. For
|
248
|
+
* embedded message fields, the sub-message is returned. For repeated
|
249
|
+
* fields, a java.util.List is returned.
|
250
|
+
*/
|
251
|
+
public Object getField(Descriptors.FieldDescriptor field);
|
252
|
+
|
253
|
+
/**
|
254
|
+
* Returns true if the given field is set. This is exactly equivalent to
|
255
|
+
* calling the generated "has" accessor method corresponding to the field.
|
256
|
+
*
|
257
|
+
* @throws IllegalArgumentException The field is a repeated field, or {@code
|
258
|
+
* field.getContainingType() != getDescriptorForType()}.
|
259
|
+
*/
|
260
|
+
boolean hasField(Descriptors.FieldDescriptor field);
|
261
|
+
|
262
|
+
/**
|
263
|
+
* Sets a field to the given value. The value must be of the correct type
|
264
|
+
* for this field, i.e. the same type that
|
265
|
+
* {@link Message#getField(Descriptors.FieldDescriptor)}
|
266
|
+
* would return.
|
267
|
+
*/
|
268
|
+
MergeTarget setField(Descriptors.FieldDescriptor field, Object value);
|
269
|
+
|
270
|
+
/**
|
271
|
+
* Clears the field. This is exactly equivalent to calling the generated
|
272
|
+
* "clear" accessor method corresponding to the field.
|
273
|
+
*/
|
274
|
+
MergeTarget clearField(Descriptors.FieldDescriptor field);
|
275
|
+
|
276
|
+
/**
|
277
|
+
* Sets an element of a repeated field to the given value. The value must
|
278
|
+
* be of the correct type for this field, i.e. the same type that {@link
|
279
|
+
* Message#getRepeatedField(Descriptors.FieldDescriptor, int)} would return.
|
280
|
+
*
|
281
|
+
* @throws IllegalArgumentException The field is not a repeated field, or
|
282
|
+
* {@code field.getContainingType() !=
|
283
|
+
* getDescriptorForType()}.
|
284
|
+
*/
|
285
|
+
MergeTarget setRepeatedField(Descriptors.FieldDescriptor field,
|
286
|
+
int index, Object value);
|
287
|
+
|
288
|
+
/**
|
289
|
+
* Like {@code setRepeatedField}, but appends the value as a new element.
|
290
|
+
*
|
291
|
+
* @throws IllegalArgumentException The field is not a repeated field, or
|
292
|
+
* {@code field.getContainingType() !=
|
293
|
+
* getDescriptorForType()}.
|
294
|
+
*/
|
295
|
+
MergeTarget addRepeatedField(Descriptors.FieldDescriptor field,
|
296
|
+
Object value);
|
297
|
+
|
298
|
+
/**
|
299
|
+
* Returns true if the given oneof is set.
|
300
|
+
*
|
301
|
+
* @throws IllegalArgumentException if
|
302
|
+
* {@code oneof.getContainingType() != getDescriptorForType()}.
|
303
|
+
*/
|
304
|
+
boolean hasOneof(Descriptors.OneofDescriptor oneof);
|
305
|
+
|
306
|
+
/**
|
307
|
+
* Clears the oneof. This is exactly equivalent to calling the generated
|
308
|
+
* "clear" accessor method corresponding to the oneof.
|
309
|
+
*/
|
310
|
+
MergeTarget clearOneof(Descriptors.OneofDescriptor oneof);
|
311
|
+
|
312
|
+
/**
|
313
|
+
* Obtains the FieldDescriptor if the given oneof is set. Returns null
|
314
|
+
* if no field is set.
|
315
|
+
*/
|
316
|
+
Descriptors.FieldDescriptor getOneofFieldDescriptor(Descriptors.OneofDescriptor oneof);
|
317
|
+
|
318
|
+
/**
|
319
|
+
* Parse the input stream into a sub field group defined based on either
|
320
|
+
* FieldDescriptor or the default instance.
|
321
|
+
*/
|
322
|
+
Object parseGroup(CodedInputStream input, ExtensionRegistryLite registry,
|
323
|
+
Descriptors.FieldDescriptor descriptor, Message defaultInstance)
|
324
|
+
throws IOException;
|
325
|
+
|
326
|
+
/**
|
327
|
+
* Parse the input stream into a sub field message defined based on either
|
328
|
+
* FieldDescriptor or the default instance.
|
329
|
+
*/
|
330
|
+
Object parseMessage(CodedInputStream input, ExtensionRegistryLite registry,
|
331
|
+
Descriptors.FieldDescriptor descriptor, Message defaultInstance)
|
332
|
+
throws IOException;
|
333
|
+
|
334
|
+
/**
|
335
|
+
* Parse from a ByteString into a sub field message defined based on either
|
336
|
+
* FieldDescriptor or the default instance. There isn't a varint indicating
|
337
|
+
* the length of the message at the beginning of the input ByteString.
|
338
|
+
*/
|
339
|
+
Object parseMessageFromBytes(
|
340
|
+
ByteString bytes, ExtensionRegistryLite registry,
|
341
|
+
Descriptors.FieldDescriptor descriptor, Message defaultInstance)
|
342
|
+
throws IOException;
|
343
|
+
|
344
|
+
/**
|
345
|
+
* Read a primitive field from input. Note that builders and mutable
|
346
|
+
* messages may use different Java types to represent a primtive field.
|
347
|
+
*/
|
348
|
+
Object readPrimitiveField(
|
349
|
+
CodedInputStream input, WireFormat.FieldType type,
|
350
|
+
boolean checkUtf8) throws IOException;
|
351
|
+
|
352
|
+
/**
|
353
|
+
* Returns a new merge target for a sub-field. When defaultInstance is
|
354
|
+
* provided, it indicates the descriptor is for an extension type, and
|
355
|
+
* implementations should create a new instance from the defaultInstance
|
356
|
+
* prototype directly.
|
357
|
+
*/
|
358
|
+
MergeTarget newMergeTargetForField(
|
359
|
+
Descriptors.FieldDescriptor descriptor,
|
360
|
+
Message defaultInstance);
|
361
|
+
|
362
|
+
/**
|
363
|
+
* Finishes the merge and returns the underlying object.
|
364
|
+
*/
|
365
|
+
Object finish();
|
366
|
+
}
|
367
|
+
|
368
|
+
static class BuilderAdapter implements MergeTarget {
|
369
|
+
|
370
|
+
private final Message.Builder builder;
|
371
|
+
|
372
|
+
public Descriptors.Descriptor getDescriptorForType() {
|
373
|
+
return builder.getDescriptorForType();
|
374
|
+
}
|
375
|
+
|
376
|
+
public BuilderAdapter(Message.Builder builder) {
|
377
|
+
this.builder = builder;
|
378
|
+
}
|
379
|
+
|
380
|
+
public Object getField(Descriptors.FieldDescriptor field) {
|
381
|
+
return builder.getField(field);
|
382
|
+
}
|
383
|
+
|
384
|
+
@Override
|
385
|
+
public boolean hasField(Descriptors.FieldDescriptor field) {
|
386
|
+
return builder.hasField(field);
|
387
|
+
}
|
388
|
+
|
389
|
+
public MergeTarget setField(Descriptors.FieldDescriptor field,
|
390
|
+
Object value) {
|
391
|
+
builder.setField(field, value);
|
392
|
+
return this;
|
393
|
+
}
|
394
|
+
|
395
|
+
public MergeTarget clearField(Descriptors.FieldDescriptor field) {
|
396
|
+
builder.clearField(field);
|
397
|
+
return this;
|
398
|
+
}
|
399
|
+
|
400
|
+
public MergeTarget setRepeatedField(
|
401
|
+
Descriptors.FieldDescriptor field, int index, Object value) {
|
402
|
+
builder.setRepeatedField(field, index, value);
|
403
|
+
return this;
|
404
|
+
}
|
405
|
+
|
406
|
+
public MergeTarget addRepeatedField(
|
407
|
+
Descriptors.FieldDescriptor field, Object value) {
|
408
|
+
builder.addRepeatedField(field, value);
|
409
|
+
return this;
|
410
|
+
}
|
411
|
+
|
412
|
+
@Override
|
413
|
+
public boolean hasOneof(Descriptors.OneofDescriptor oneof) {
|
414
|
+
return builder.hasOneof(oneof);
|
415
|
+
}
|
416
|
+
|
417
|
+
@Override
|
418
|
+
public MergeTarget clearOneof(Descriptors.OneofDescriptor oneof) {
|
419
|
+
builder.clearOneof(oneof);
|
420
|
+
return this;
|
421
|
+
}
|
422
|
+
|
423
|
+
@Override
|
424
|
+
public Descriptors.FieldDescriptor getOneofFieldDescriptor(Descriptors.OneofDescriptor oneof) {
|
425
|
+
return builder.getOneofFieldDescriptor(oneof);
|
426
|
+
}
|
427
|
+
|
428
|
+
public ContainerType getContainerType() {
|
429
|
+
return ContainerType.MESSAGE;
|
430
|
+
}
|
431
|
+
|
432
|
+
public ExtensionRegistry.ExtensionInfo findExtensionByName(
|
433
|
+
ExtensionRegistry registry, String name) {
|
434
|
+
return registry.findImmutableExtensionByName(name);
|
435
|
+
}
|
436
|
+
|
437
|
+
public ExtensionRegistry.ExtensionInfo findExtensionByNumber(
|
438
|
+
ExtensionRegistry registry, Descriptors.Descriptor containingType,
|
439
|
+
int fieldNumber) {
|
440
|
+
return registry.findImmutableExtensionByNumber(containingType,
|
441
|
+
fieldNumber);
|
442
|
+
}
|
443
|
+
|
444
|
+
public Object parseGroup(CodedInputStream input,
|
445
|
+
ExtensionRegistryLite extensionRegistry,
|
446
|
+
Descriptors.FieldDescriptor field, Message defaultInstance)
|
447
|
+
throws IOException {
|
448
|
+
Message.Builder subBuilder;
|
449
|
+
// When default instance is not null. The field is an extension field.
|
450
|
+
if (defaultInstance != null) {
|
451
|
+
subBuilder = defaultInstance.newBuilderForType();
|
452
|
+
} else {
|
453
|
+
subBuilder = builder.newBuilderForField(field);
|
454
|
+
}
|
455
|
+
if (!field.isRepeated()) {
|
456
|
+
Message originalMessage = (Message) getField(field);
|
457
|
+
if (originalMessage != null) {
|
458
|
+
subBuilder.mergeFrom(originalMessage);
|
459
|
+
}
|
460
|
+
}
|
461
|
+
input.readGroup(field.getNumber(), subBuilder, extensionRegistry);
|
462
|
+
return subBuilder.buildPartial();
|
463
|
+
}
|
464
|
+
|
465
|
+
public Object parseMessage(CodedInputStream input,
|
466
|
+
ExtensionRegistryLite extensionRegistry,
|
467
|
+
Descriptors.FieldDescriptor field, Message defaultInstance)
|
468
|
+
throws IOException {
|
469
|
+
Message.Builder subBuilder;
|
470
|
+
// When default instance is not null. The field is an extension field.
|
471
|
+
if (defaultInstance != null) {
|
472
|
+
subBuilder = defaultInstance.newBuilderForType();
|
473
|
+
} else {
|
474
|
+
subBuilder = builder.newBuilderForField(field);
|
475
|
+
}
|
476
|
+
if (!field.isRepeated()) {
|
477
|
+
Message originalMessage = (Message) getField(field);
|
478
|
+
if (originalMessage != null) {
|
479
|
+
subBuilder.mergeFrom(originalMessage);
|
480
|
+
}
|
481
|
+
}
|
482
|
+
input.readMessage(subBuilder, extensionRegistry);
|
483
|
+
return subBuilder.buildPartial();
|
484
|
+
}
|
485
|
+
|
486
|
+
public Object parseMessageFromBytes(ByteString bytes,
|
487
|
+
ExtensionRegistryLite extensionRegistry,
|
488
|
+
Descriptors.FieldDescriptor field, Message defaultInstance)
|
489
|
+
throws IOException {
|
490
|
+
Message.Builder subBuilder;
|
491
|
+
// When default instance is not null. The field is an extension field.
|
492
|
+
if (defaultInstance != null) {
|
493
|
+
subBuilder = defaultInstance.newBuilderForType();
|
494
|
+
} else {
|
495
|
+
subBuilder = builder.newBuilderForField(field);
|
496
|
+
}
|
497
|
+
if (!field.isRepeated()) {
|
498
|
+
Message originalMessage = (Message) getField(field);
|
499
|
+
if (originalMessage != null) {
|
500
|
+
subBuilder.mergeFrom(originalMessage);
|
501
|
+
}
|
502
|
+
}
|
503
|
+
subBuilder.mergeFrom(bytes, extensionRegistry);
|
504
|
+
return subBuilder.buildPartial();
|
505
|
+
}
|
506
|
+
|
507
|
+
public MergeTarget newMergeTargetForField(Descriptors.FieldDescriptor field,
|
508
|
+
Message defaultInstance) {
|
509
|
+
if (defaultInstance != null) {
|
510
|
+
return new BuilderAdapter(
|
511
|
+
defaultInstance.newBuilderForType());
|
512
|
+
} else {
|
513
|
+
return new BuilderAdapter(builder.newBuilderForField(field));
|
514
|
+
}
|
515
|
+
}
|
516
|
+
|
517
|
+
public Object readPrimitiveField(
|
518
|
+
CodedInputStream input, WireFormat.FieldType type,
|
519
|
+
boolean checkUtf8) throws IOException {
|
520
|
+
return FieldSet.readPrimitiveField(input, type, checkUtf8);
|
521
|
+
}
|
522
|
+
|
523
|
+
public Object finish() {
|
524
|
+
return builder.buildPartial();
|
525
|
+
}
|
526
|
+
}
|
527
|
+
|
528
|
+
|
529
|
+
static class ExtensionAdapter implements MergeTarget {
|
530
|
+
|
531
|
+
private final FieldSet<Descriptors.FieldDescriptor> extensions;
|
532
|
+
|
533
|
+
ExtensionAdapter(FieldSet<Descriptors.FieldDescriptor> extensions) {
|
534
|
+
this.extensions = extensions;
|
535
|
+
}
|
536
|
+
|
537
|
+
public Descriptors.Descriptor getDescriptorForType() {
|
538
|
+
throw new UnsupportedOperationException(
|
539
|
+
"getDescriptorForType() called on FieldSet object");
|
540
|
+
}
|
541
|
+
|
542
|
+
public Object getField(Descriptors.FieldDescriptor field) {
|
543
|
+
return extensions.getField(field);
|
544
|
+
}
|
545
|
+
|
546
|
+
public boolean hasField(Descriptors.FieldDescriptor field) {
|
547
|
+
return extensions.hasField(field);
|
548
|
+
}
|
549
|
+
|
550
|
+
public MergeTarget setField(Descriptors.FieldDescriptor field,
|
551
|
+
Object value) {
|
552
|
+
extensions.setField(field, value);
|
553
|
+
return this;
|
554
|
+
}
|
555
|
+
|
556
|
+
public MergeTarget clearField(Descriptors.FieldDescriptor field) {
|
557
|
+
extensions.clearField(field);
|
558
|
+
return this;
|
559
|
+
}
|
560
|
+
|
561
|
+
public MergeTarget setRepeatedField(
|
562
|
+
Descriptors.FieldDescriptor field, int index, Object value) {
|
563
|
+
extensions.setRepeatedField(field, index, value);
|
564
|
+
return this;
|
565
|
+
}
|
566
|
+
|
567
|
+
public MergeTarget addRepeatedField(
|
568
|
+
Descriptors.FieldDescriptor field, Object value) {
|
569
|
+
extensions.addRepeatedField(field, value);
|
570
|
+
return this;
|
571
|
+
}
|
572
|
+
|
573
|
+
@Override
|
574
|
+
public boolean hasOneof(Descriptors.OneofDescriptor oneof) {
|
575
|
+
return false;
|
576
|
+
}
|
577
|
+
|
578
|
+
@Override
|
579
|
+
public MergeTarget clearOneof(Descriptors.OneofDescriptor oneof) {
|
580
|
+
// Nothing to clear.
|
581
|
+
return this;
|
582
|
+
}
|
583
|
+
|
584
|
+
@Override
|
585
|
+
public Descriptors.FieldDescriptor getOneofFieldDescriptor(Descriptors.OneofDescriptor oneof) {
|
586
|
+
return null;
|
587
|
+
}
|
588
|
+
|
589
|
+
public ContainerType getContainerType() {
|
590
|
+
return ContainerType.EXTENSION_SET;
|
591
|
+
}
|
592
|
+
|
593
|
+
public ExtensionRegistry.ExtensionInfo findExtensionByName(
|
594
|
+
ExtensionRegistry registry, String name) {
|
595
|
+
return registry.findImmutableExtensionByName(name);
|
596
|
+
}
|
597
|
+
|
598
|
+
public ExtensionRegistry.ExtensionInfo findExtensionByNumber(
|
599
|
+
ExtensionRegistry registry, Descriptors.Descriptor containingType,
|
600
|
+
int fieldNumber) {
|
601
|
+
return registry.findImmutableExtensionByNumber(containingType,
|
602
|
+
fieldNumber);
|
603
|
+
}
|
604
|
+
|
605
|
+
public Object parseGroup(CodedInputStream input,
|
606
|
+
ExtensionRegistryLite registry, Descriptors.FieldDescriptor field,
|
607
|
+
Message defaultInstance) throws IOException {
|
608
|
+
Message.Builder subBuilder =
|
609
|
+
defaultInstance.newBuilderForType();
|
610
|
+
if (!field.isRepeated()) {
|
611
|
+
Message originalMessage = (Message) getField(field);
|
612
|
+
if (originalMessage != null) {
|
613
|
+
subBuilder.mergeFrom(originalMessage);
|
614
|
+
}
|
615
|
+
}
|
616
|
+
input.readGroup(field.getNumber(), subBuilder, registry);
|
617
|
+
return subBuilder.buildPartial();
|
618
|
+
}
|
619
|
+
|
620
|
+
public Object parseMessage(CodedInputStream input,
|
621
|
+
ExtensionRegistryLite registry, Descriptors.FieldDescriptor field,
|
622
|
+
Message defaultInstance) throws IOException {
|
623
|
+
Message.Builder subBuilder =
|
624
|
+
defaultInstance.newBuilderForType();
|
625
|
+
if (!field.isRepeated()) {
|
626
|
+
Message originalMessage = (Message) getField(field);
|
627
|
+
if (originalMessage != null) {
|
628
|
+
subBuilder.mergeFrom(originalMessage);
|
629
|
+
}
|
630
|
+
}
|
631
|
+
input.readMessage(subBuilder, registry);
|
632
|
+
return subBuilder.buildPartial();
|
633
|
+
}
|
634
|
+
|
635
|
+
public Object parseMessageFromBytes(ByteString bytes,
|
636
|
+
ExtensionRegistryLite registry, Descriptors.FieldDescriptor field,
|
637
|
+
Message defaultInstance) throws IOException {
|
638
|
+
Message.Builder subBuilder = defaultInstance.newBuilderForType();
|
639
|
+
if (!field.isRepeated()) {
|
640
|
+
Message originalMessage = (Message) getField(field);
|
641
|
+
if (originalMessage != null) {
|
642
|
+
subBuilder.mergeFrom(originalMessage);
|
643
|
+
}
|
644
|
+
}
|
645
|
+
subBuilder.mergeFrom(bytes, registry);
|
646
|
+
return subBuilder.buildPartial();
|
647
|
+
}
|
648
|
+
|
649
|
+
public MergeTarget newMergeTargetForField(
|
650
|
+
Descriptors.FieldDescriptor descriptor, Message defaultInstance) {
|
651
|
+
throw new UnsupportedOperationException(
|
652
|
+
"newMergeTargetForField() called on FieldSet object");
|
653
|
+
}
|
654
|
+
|
655
|
+
public Object readPrimitiveField(
|
656
|
+
CodedInputStream input, WireFormat.FieldType type,
|
657
|
+
boolean checkUtf8) throws IOException {
|
658
|
+
return FieldSet.readPrimitiveField(input, type, checkUtf8);
|
659
|
+
}
|
660
|
+
|
661
|
+
public Object finish() {
|
662
|
+
throw new UnsupportedOperationException(
|
663
|
+
"finish() called on FieldSet object");
|
664
|
+
}
|
665
|
+
}
|
666
|
+
|
667
|
+
/**
|
668
|
+
* Parses a single field into MergeTarget. The target can be Message.Builder,
|
669
|
+
* FieldSet or MutableMessage.
|
670
|
+
*
|
671
|
+
* Package-private because it is used by GeneratedMessage.ExtendableMessage.
|
672
|
+
*
|
673
|
+
* @param tag The tag, which should have already been read.
|
674
|
+
* @return {@code true} unless the tag is an end-group tag.
|
675
|
+
*/
|
676
|
+
static boolean mergeFieldFrom(
|
677
|
+
CodedInputStream input,
|
678
|
+
UnknownFieldSet.Builder unknownFields,
|
679
|
+
ExtensionRegistryLite extensionRegistry,
|
680
|
+
Descriptors.Descriptor type,
|
681
|
+
MergeTarget target,
|
682
|
+
int tag) throws IOException {
|
683
|
+
if (type.getOptions().getMessageSetWireFormat() &&
|
684
|
+
tag == WireFormat.MESSAGE_SET_ITEM_TAG) {
|
685
|
+
mergeMessageSetExtensionFromCodedStream(
|
686
|
+
input, unknownFields, extensionRegistry, type, target);
|
687
|
+
return true;
|
688
|
+
}
|
689
|
+
|
690
|
+
final int wireType = WireFormat.getTagWireType(tag);
|
691
|
+
final int fieldNumber = WireFormat.getTagFieldNumber(tag);
|
692
|
+
|
693
|
+
final Descriptors.FieldDescriptor field;
|
694
|
+
Message defaultInstance = null;
|
695
|
+
|
696
|
+
if (type.isExtensionNumber(fieldNumber)) {
|
697
|
+
// extensionRegistry may be either ExtensionRegistry or
|
698
|
+
// ExtensionRegistryLite. Since the type we are parsing is a full
|
699
|
+
// message, only a full ExtensionRegistry could possibly contain
|
700
|
+
// extensions of it. Otherwise we will treat the registry as if it
|
701
|
+
// were empty.
|
702
|
+
if (extensionRegistry instanceof ExtensionRegistry) {
|
703
|
+
final ExtensionRegistry.ExtensionInfo extension =
|
704
|
+
target.findExtensionByNumber((ExtensionRegistry) extensionRegistry,
|
705
|
+
type, fieldNumber);
|
706
|
+
if (extension == null) {
|
707
|
+
field = null;
|
708
|
+
} else {
|
709
|
+
field = extension.descriptor;
|
710
|
+
defaultInstance = extension.defaultInstance;
|
711
|
+
if (defaultInstance == null &&
|
712
|
+
field.getJavaType()
|
713
|
+
== Descriptors.FieldDescriptor.JavaType.MESSAGE) {
|
714
|
+
throw new IllegalStateException(
|
715
|
+
"Message-typed extension lacked default instance: " +
|
716
|
+
field.getFullName());
|
717
|
+
}
|
718
|
+
}
|
719
|
+
} else {
|
720
|
+
field = null;
|
721
|
+
}
|
722
|
+
} else if (target.getContainerType() == MergeTarget.ContainerType.MESSAGE) {
|
723
|
+
field = type.findFieldByNumber(fieldNumber);
|
724
|
+
} else {
|
725
|
+
field = null;
|
726
|
+
}
|
727
|
+
|
728
|
+
boolean unknown = false;
|
729
|
+
boolean packed = false;
|
730
|
+
if (field == null) {
|
731
|
+
unknown = true; // Unknown field.
|
732
|
+
} else if (wireType == FieldSet.getWireFormatForFieldType(
|
733
|
+
field.getLiteType(),
|
734
|
+
false /* isPacked */)) {
|
735
|
+
packed = false;
|
736
|
+
} else if (field.isPackable() &&
|
737
|
+
wireType == FieldSet.getWireFormatForFieldType(
|
738
|
+
field.getLiteType(),
|
739
|
+
true /* isPacked */)) {
|
740
|
+
packed = true;
|
741
|
+
} else {
|
742
|
+
unknown = true; // Unknown wire type.
|
743
|
+
}
|
744
|
+
|
745
|
+
if (unknown) { // Unknown field or wrong wire type. Skip.
|
746
|
+
return unknownFields.mergeFieldFrom(tag, input);
|
747
|
+
}
|
748
|
+
|
749
|
+
if (packed) {
|
750
|
+
final int length = input.readRawVarint32();
|
751
|
+
final int limit = input.pushLimit(length);
|
752
|
+
if (field.getLiteType() == WireFormat.FieldType.ENUM) {
|
753
|
+
while (input.getBytesUntilLimit() > 0) {
|
754
|
+
final int rawValue = input.readEnum();
|
755
|
+
final Object value = field.getEnumType().findValueByNumber(rawValue);
|
756
|
+
if (value == null) {
|
757
|
+
// If the number isn't recognized as a valid value for this
|
758
|
+
// enum, drop it (don't even add it to unknownFields).
|
759
|
+
return true;
|
760
|
+
}
|
761
|
+
target.addRepeatedField(field, value);
|
762
|
+
}
|
763
|
+
} else {
|
764
|
+
while (input.getBytesUntilLimit() > 0) {
|
765
|
+
final Object value =
|
766
|
+
target.readPrimitiveField(input, field.getLiteType(), field.needsUtf8Check());
|
767
|
+
target.addRepeatedField(field, value);
|
768
|
+
}
|
769
|
+
}
|
770
|
+
input.popLimit(limit);
|
771
|
+
} else {
|
772
|
+
final Object value;
|
773
|
+
switch (field.getType()) {
|
774
|
+
case GROUP: {
|
775
|
+
value = target
|
776
|
+
.parseGroup(input, extensionRegistry, field, defaultInstance);
|
777
|
+
break;
|
778
|
+
}
|
779
|
+
case MESSAGE: {
|
780
|
+
value = target
|
781
|
+
.parseMessage(input, extensionRegistry, field, defaultInstance);
|
782
|
+
break;
|
783
|
+
}
|
784
|
+
case ENUM:
|
785
|
+
final int rawValue = input.readEnum();
|
786
|
+
value = field.getEnumType().findValueByNumber(rawValue);
|
787
|
+
// If the number isn't recognized as a valid value for this enum,
|
788
|
+
// drop it.
|
789
|
+
if (value == null) {
|
790
|
+
unknownFields.mergeVarintField(fieldNumber, rawValue);
|
791
|
+
return true;
|
792
|
+
}
|
793
|
+
break;
|
794
|
+
default:
|
795
|
+
value = target.readPrimitiveField(input, field.getLiteType(), field.needsUtf8Check());
|
796
|
+
break;
|
797
|
+
}
|
798
|
+
|
799
|
+
if (field.isRepeated()) {
|
800
|
+
target.addRepeatedField(field, value);
|
801
|
+
} else {
|
802
|
+
target.setField(field, value);
|
803
|
+
}
|
804
|
+
}
|
805
|
+
|
806
|
+
return true;
|
807
|
+
}
|
808
|
+
|
809
|
+
/**
|
810
|
+
* Called by {@code #mergeFieldFrom()} to parse a MessageSet extension into
|
811
|
+
* MergeTarget.
|
812
|
+
*/
|
813
|
+
private static void mergeMessageSetExtensionFromCodedStream(
|
814
|
+
CodedInputStream input,
|
815
|
+
UnknownFieldSet.Builder unknownFields,
|
816
|
+
ExtensionRegistryLite extensionRegistry,
|
817
|
+
Descriptors.Descriptor type,
|
818
|
+
MergeTarget target) throws IOException {
|
819
|
+
|
820
|
+
// The wire format for MessageSet is:
|
821
|
+
// message MessageSet {
|
822
|
+
// repeated group Item = 1 {
|
823
|
+
// required int32 typeId = 2;
|
824
|
+
// required bytes message = 3;
|
825
|
+
// }
|
826
|
+
// }
|
827
|
+
// "typeId" is the extension's field number. The extension can only be
|
828
|
+
// a message type, where "message" contains the encoded bytes of that
|
829
|
+
// message.
|
830
|
+
//
|
831
|
+
// In practice, we will probably never see a MessageSet item in which
|
832
|
+
// the message appears before the type ID, or where either field does not
|
833
|
+
// appear exactly once. However, in theory such cases are valid, so we
|
834
|
+
// should be prepared to accept them.
|
835
|
+
|
836
|
+
int typeId = 0;
|
837
|
+
ByteString rawBytes = null; // If we encounter "message" before "typeId"
|
838
|
+
ExtensionRegistry.ExtensionInfo extension = null;
|
839
|
+
|
840
|
+
// Read bytes from input, if we get it's type first then parse it eagerly,
|
841
|
+
// otherwise we store the raw bytes in a local variable.
|
842
|
+
while (true) {
|
843
|
+
final int tag = input.readTag();
|
844
|
+
if (tag == 0) {
|
845
|
+
break;
|
846
|
+
}
|
847
|
+
|
848
|
+
if (tag == WireFormat.MESSAGE_SET_TYPE_ID_TAG) {
|
849
|
+
typeId = input.readUInt32();
|
850
|
+
if (typeId != 0) {
|
851
|
+
// extensionRegistry may be either ExtensionRegistry or
|
852
|
+
// ExtensionRegistryLite. Since the type we are parsing is a full
|
853
|
+
// message, only a full ExtensionRegistry could possibly contain
|
854
|
+
// extensions of it. Otherwise we will treat the registry as if it
|
855
|
+
// were empty.
|
856
|
+
if (extensionRegistry instanceof ExtensionRegistry) {
|
857
|
+
extension = target.findExtensionByNumber(
|
858
|
+
(ExtensionRegistry) extensionRegistry, type, typeId);
|
859
|
+
}
|
860
|
+
}
|
861
|
+
|
862
|
+
} else if (tag == WireFormat.MESSAGE_SET_MESSAGE_TAG) {
|
863
|
+
if (typeId != 0) {
|
864
|
+
if (extension != null &&
|
865
|
+
ExtensionRegistryLite.isEagerlyParseMessageSets()) {
|
866
|
+
// We already know the type, so we can parse directly from the
|
867
|
+
// input with no copying. Hooray!
|
868
|
+
eagerlyMergeMessageSetExtension(
|
869
|
+
input, extension, extensionRegistry, target);
|
870
|
+
rawBytes = null;
|
871
|
+
continue;
|
872
|
+
}
|
873
|
+
}
|
874
|
+
// We haven't seen a type ID yet or we want parse message lazily.
|
875
|
+
rawBytes = input.readBytes();
|
876
|
+
|
877
|
+
} else { // Unknown tag. Skip it.
|
878
|
+
if (!input.skipField(tag)) {
|
879
|
+
break; // End of group
|
880
|
+
}
|
881
|
+
}
|
882
|
+
}
|
883
|
+
input.checkLastTagWas(WireFormat.MESSAGE_SET_ITEM_END_TAG);
|
884
|
+
|
885
|
+
// Process the raw bytes.
|
886
|
+
if (rawBytes != null && typeId != 0) { // Zero is not a valid type ID.
|
887
|
+
if (extension != null) { // We known the type
|
888
|
+
mergeMessageSetExtensionFromBytes(
|
889
|
+
rawBytes, extension, extensionRegistry, target);
|
890
|
+
} else { // We don't know how to parse this. Ignore it.
|
891
|
+
if (rawBytes != null) {
|
892
|
+
unknownFields.mergeField(typeId, UnknownFieldSet.Field.newBuilder()
|
893
|
+
.addLengthDelimited(rawBytes).build());
|
894
|
+
}
|
895
|
+
}
|
896
|
+
}
|
897
|
+
}
|
898
|
+
|
899
|
+
private static void mergeMessageSetExtensionFromBytes(
|
900
|
+
ByteString rawBytes,
|
901
|
+
ExtensionRegistry.ExtensionInfo extension,
|
902
|
+
ExtensionRegistryLite extensionRegistry,
|
903
|
+
MergeTarget target) throws IOException {
|
904
|
+
|
905
|
+
Descriptors.FieldDescriptor field = extension.descriptor;
|
906
|
+
boolean hasOriginalValue = target.hasField(field);
|
907
|
+
|
908
|
+
if (hasOriginalValue || ExtensionRegistryLite.isEagerlyParseMessageSets()) {
|
909
|
+
// If the field already exists, we just parse the field.
|
910
|
+
Object value = target.parseMessageFromBytes(
|
911
|
+
rawBytes, extensionRegistry,field, extension.defaultInstance);
|
912
|
+
target.setField(field, value);
|
913
|
+
} else {
|
914
|
+
// Use LazyField to load MessageSet lazily.
|
915
|
+
LazyField lazyField = new LazyField(
|
916
|
+
extension.defaultInstance, extensionRegistry, rawBytes);
|
917
|
+
target.setField(field, lazyField);
|
918
|
+
}
|
919
|
+
}
|
920
|
+
|
921
|
+
private static void eagerlyMergeMessageSetExtension(
|
922
|
+
CodedInputStream input,
|
923
|
+
ExtensionRegistry.ExtensionInfo extension,
|
924
|
+
ExtensionRegistryLite extensionRegistry,
|
925
|
+
MergeTarget target) throws IOException {
|
926
|
+
Descriptors.FieldDescriptor field = extension.descriptor;
|
927
|
+
Object value = target.parseMessage(input, extensionRegistry, field,
|
928
|
+
extension.defaultInstance);
|
929
|
+
target.setField(field, value);
|
930
|
+
}
|
931
|
+
}
|