protoc 2.6.1.1 → 2.6.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,318 @@
|
|
|
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
|
+
// Author: kenton@google.com (Kenton Varda)
|
|
32
|
+
// Based on original Protocol Buffers design by
|
|
33
|
+
// Sanjay Ghemawat, Jeff Dean, and others.
|
|
34
|
+
//
|
|
35
|
+
// Contains classes used to keep track of unrecognized fields seen while
|
|
36
|
+
// parsing a protocol message.
|
|
37
|
+
|
|
38
|
+
#ifndef GOOGLE_PROTOBUF_UNKNOWN_FIELD_SET_H__
|
|
39
|
+
#define GOOGLE_PROTOBUF_UNKNOWN_FIELD_SET_H__
|
|
40
|
+
|
|
41
|
+
#include <assert.h>
|
|
42
|
+
#include <string>
|
|
43
|
+
#include <vector>
|
|
44
|
+
#include <google/protobuf/stubs/common.h>
|
|
45
|
+
|
|
46
|
+
namespace google {
|
|
47
|
+
namespace protobuf {
|
|
48
|
+
namespace io {
|
|
49
|
+
class CodedInputStream; // coded_stream.h
|
|
50
|
+
class CodedOutputStream; // coded_stream.h
|
|
51
|
+
class ZeroCopyInputStream; // zero_copy_stream.h
|
|
52
|
+
}
|
|
53
|
+
namespace internal {
|
|
54
|
+
class WireFormat; // wire_format.h
|
|
55
|
+
class MessageSetFieldSkipperUsingCord;
|
|
56
|
+
// extension_set_heavy.cc
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
class Message; // message.h
|
|
60
|
+
class UnknownField; // below
|
|
61
|
+
|
|
62
|
+
// An UnknownFieldSet contains fields that were encountered while parsing a
|
|
63
|
+
// message but were not defined by its type. Keeping track of these can be
|
|
64
|
+
// useful, especially in that they may be written if the message is serialized
|
|
65
|
+
// again without being cleared in between. This means that software which
|
|
66
|
+
// simply receives messages and forwards them to other servers does not need
|
|
67
|
+
// to be updated every time a new field is added to the message definition.
|
|
68
|
+
//
|
|
69
|
+
// To get the UnknownFieldSet attached to any message, call
|
|
70
|
+
// Reflection::GetUnknownFields().
|
|
71
|
+
//
|
|
72
|
+
// This class is necessarily tied to the protocol buffer wire format, unlike
|
|
73
|
+
// the Reflection interface which is independent of any serialization scheme.
|
|
74
|
+
class LIBPROTOBUF_EXPORT UnknownFieldSet {
|
|
75
|
+
public:
|
|
76
|
+
UnknownFieldSet();
|
|
77
|
+
~UnknownFieldSet();
|
|
78
|
+
|
|
79
|
+
// Remove all fields.
|
|
80
|
+
inline void Clear();
|
|
81
|
+
|
|
82
|
+
// Remove all fields and deallocate internal data objects
|
|
83
|
+
void ClearAndFreeMemory();
|
|
84
|
+
|
|
85
|
+
// Is this set empty?
|
|
86
|
+
inline bool empty() const;
|
|
87
|
+
|
|
88
|
+
// Merge the contents of some other UnknownFieldSet with this one.
|
|
89
|
+
void MergeFrom(const UnknownFieldSet& other);
|
|
90
|
+
|
|
91
|
+
// Swaps the contents of some other UnknownFieldSet with this one.
|
|
92
|
+
inline void Swap(UnknownFieldSet* x);
|
|
93
|
+
|
|
94
|
+
// Computes (an estimate of) the total number of bytes currently used for
|
|
95
|
+
// storing the unknown fields in memory. Does NOT include
|
|
96
|
+
// sizeof(*this) in the calculation.
|
|
97
|
+
int SpaceUsedExcludingSelf() const;
|
|
98
|
+
|
|
99
|
+
// Version of SpaceUsed() including sizeof(*this).
|
|
100
|
+
int SpaceUsed() const;
|
|
101
|
+
|
|
102
|
+
// Returns the number of fields present in the UnknownFieldSet.
|
|
103
|
+
inline int field_count() const;
|
|
104
|
+
// Get a field in the set, where 0 <= index < field_count(). The fields
|
|
105
|
+
// appear in the order in which they were added.
|
|
106
|
+
inline const UnknownField& field(int index) const;
|
|
107
|
+
// Get a mutable pointer to a field in the set, where
|
|
108
|
+
// 0 <= index < field_count(). The fields appear in the order in which
|
|
109
|
+
// they were added.
|
|
110
|
+
inline UnknownField* mutable_field(int index);
|
|
111
|
+
|
|
112
|
+
// Adding fields ---------------------------------------------------
|
|
113
|
+
|
|
114
|
+
void AddVarint(int number, uint64 value);
|
|
115
|
+
void AddFixed32(int number, uint32 value);
|
|
116
|
+
void AddFixed64(int number, uint64 value);
|
|
117
|
+
void AddLengthDelimited(int number, const string& value);
|
|
118
|
+
string* AddLengthDelimited(int number);
|
|
119
|
+
UnknownFieldSet* AddGroup(int number);
|
|
120
|
+
|
|
121
|
+
// Adds an unknown field from another set.
|
|
122
|
+
void AddField(const UnknownField& field);
|
|
123
|
+
|
|
124
|
+
// Delete fields with indices in the range [start .. start+num-1].
|
|
125
|
+
// Caution: implementation moves all fields with indices [start+num .. ].
|
|
126
|
+
void DeleteSubrange(int start, int num);
|
|
127
|
+
|
|
128
|
+
// Delete all fields with a specific field number. The order of left fields
|
|
129
|
+
// is preserved.
|
|
130
|
+
// Caution: implementation moves all fields after the first deleted field.
|
|
131
|
+
void DeleteByNumber(int number);
|
|
132
|
+
|
|
133
|
+
// Parsing helpers -------------------------------------------------
|
|
134
|
+
// These work exactly like the similarly-named methods of Message.
|
|
135
|
+
|
|
136
|
+
bool MergeFromCodedStream(io::CodedInputStream* input);
|
|
137
|
+
bool ParseFromCodedStream(io::CodedInputStream* input);
|
|
138
|
+
bool ParseFromZeroCopyStream(io::ZeroCopyInputStream* input);
|
|
139
|
+
bool ParseFromArray(const void* data, int size);
|
|
140
|
+
inline bool ParseFromString(const string& data) {
|
|
141
|
+
return ParseFromArray(data.data(), static_cast<int>(data.size()));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
private:
|
|
145
|
+
|
|
146
|
+
void ClearFallback();
|
|
147
|
+
|
|
148
|
+
vector<UnknownField>* fields_;
|
|
149
|
+
|
|
150
|
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(UnknownFieldSet);
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// Represents one field in an UnknownFieldSet.
|
|
154
|
+
class LIBPROTOBUF_EXPORT UnknownField {
|
|
155
|
+
public:
|
|
156
|
+
enum Type {
|
|
157
|
+
TYPE_VARINT,
|
|
158
|
+
TYPE_FIXED32,
|
|
159
|
+
TYPE_FIXED64,
|
|
160
|
+
TYPE_LENGTH_DELIMITED,
|
|
161
|
+
TYPE_GROUP
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
// The field's tag number, as seen on the wire.
|
|
165
|
+
inline int number() const;
|
|
166
|
+
|
|
167
|
+
// The field type.
|
|
168
|
+
inline Type type() const;
|
|
169
|
+
|
|
170
|
+
// Accessors -------------------------------------------------------
|
|
171
|
+
// Each method works only for UnknownFields of the corresponding type.
|
|
172
|
+
|
|
173
|
+
inline uint64 varint() const;
|
|
174
|
+
inline uint32 fixed32() const;
|
|
175
|
+
inline uint64 fixed64() const;
|
|
176
|
+
inline const string& length_delimited() const;
|
|
177
|
+
inline const UnknownFieldSet& group() const;
|
|
178
|
+
|
|
179
|
+
inline void set_varint(uint64 value);
|
|
180
|
+
inline void set_fixed32(uint32 value);
|
|
181
|
+
inline void set_fixed64(uint64 value);
|
|
182
|
+
inline void set_length_delimited(const string& value);
|
|
183
|
+
inline string* mutable_length_delimited();
|
|
184
|
+
inline UnknownFieldSet* mutable_group();
|
|
185
|
+
|
|
186
|
+
// Serialization API.
|
|
187
|
+
// These methods can take advantage of the underlying implementation and may
|
|
188
|
+
// archieve a better performance than using getters to retrieve the data and
|
|
189
|
+
// do the serialization yourself.
|
|
190
|
+
void SerializeLengthDelimitedNoTag(io::CodedOutputStream* output) const;
|
|
191
|
+
uint8* SerializeLengthDelimitedNoTagToArray(uint8* target) const;
|
|
192
|
+
|
|
193
|
+
inline int GetLengthDelimitedSize() const;
|
|
194
|
+
|
|
195
|
+
private:
|
|
196
|
+
friend class UnknownFieldSet;
|
|
197
|
+
|
|
198
|
+
// If this UnknownField contains a pointer, delete it.
|
|
199
|
+
void Delete();
|
|
200
|
+
|
|
201
|
+
// Make a deep copy of any pointers in this UnknownField.
|
|
202
|
+
void DeepCopy();
|
|
203
|
+
|
|
204
|
+
// Set the wire type of this UnknownField. Should only be used when this
|
|
205
|
+
// UnknownField is being created.
|
|
206
|
+
inline void SetType(Type type);
|
|
207
|
+
|
|
208
|
+
uint32 number_;
|
|
209
|
+
uint32 type_;
|
|
210
|
+
union {
|
|
211
|
+
uint64 varint_;
|
|
212
|
+
uint32 fixed32_;
|
|
213
|
+
uint64 fixed64_;
|
|
214
|
+
mutable union {
|
|
215
|
+
string* string_value_;
|
|
216
|
+
} length_delimited_;
|
|
217
|
+
UnknownFieldSet* group_;
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
// ===================================================================
|
|
222
|
+
// inline implementations
|
|
223
|
+
|
|
224
|
+
inline void UnknownFieldSet::Clear() {
|
|
225
|
+
if (fields_ != NULL) {
|
|
226
|
+
ClearFallback();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
inline bool UnknownFieldSet::empty() const {
|
|
231
|
+
return fields_ == NULL || fields_->empty();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
inline void UnknownFieldSet::Swap(UnknownFieldSet* x) {
|
|
235
|
+
std::swap(fields_, x->fields_);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
inline int UnknownFieldSet::field_count() const {
|
|
239
|
+
return (fields_ == NULL) ? 0 : static_cast<int>(fields_->size());
|
|
240
|
+
}
|
|
241
|
+
inline const UnknownField& UnknownFieldSet::field(int index) const {
|
|
242
|
+
return (*fields_)[index];
|
|
243
|
+
}
|
|
244
|
+
inline UnknownField* UnknownFieldSet::mutable_field(int index) {
|
|
245
|
+
return &(*fields_)[index];
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
inline void UnknownFieldSet::AddLengthDelimited(
|
|
249
|
+
int number, const string& value) {
|
|
250
|
+
AddLengthDelimited(number)->assign(value);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
inline int UnknownField::number() const { return number_; }
|
|
255
|
+
inline UnknownField::Type UnknownField::type() const {
|
|
256
|
+
return static_cast<Type>(type_);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
inline uint64 UnknownField::varint() const {
|
|
260
|
+
assert(type() == TYPE_VARINT);
|
|
261
|
+
return varint_;
|
|
262
|
+
}
|
|
263
|
+
inline uint32 UnknownField::fixed32() const {
|
|
264
|
+
assert(type() == TYPE_FIXED32);
|
|
265
|
+
return fixed32_;
|
|
266
|
+
}
|
|
267
|
+
inline uint64 UnknownField::fixed64() const {
|
|
268
|
+
assert(type() == TYPE_FIXED64);
|
|
269
|
+
return fixed64_;
|
|
270
|
+
}
|
|
271
|
+
inline const string& UnknownField::length_delimited() const {
|
|
272
|
+
assert(type() == TYPE_LENGTH_DELIMITED);
|
|
273
|
+
return *length_delimited_.string_value_;
|
|
274
|
+
}
|
|
275
|
+
inline const UnknownFieldSet& UnknownField::group() const {
|
|
276
|
+
assert(type() == TYPE_GROUP);
|
|
277
|
+
return *group_;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
inline void UnknownField::set_varint(uint64 value) {
|
|
281
|
+
assert(type() == TYPE_VARINT);
|
|
282
|
+
varint_ = value;
|
|
283
|
+
}
|
|
284
|
+
inline void UnknownField::set_fixed32(uint32 value) {
|
|
285
|
+
assert(type() == TYPE_FIXED32);
|
|
286
|
+
fixed32_ = value;
|
|
287
|
+
}
|
|
288
|
+
inline void UnknownField::set_fixed64(uint64 value) {
|
|
289
|
+
assert(type() == TYPE_FIXED64);
|
|
290
|
+
fixed64_ = value;
|
|
291
|
+
}
|
|
292
|
+
inline void UnknownField::set_length_delimited(const string& value) {
|
|
293
|
+
assert(type() == TYPE_LENGTH_DELIMITED);
|
|
294
|
+
length_delimited_.string_value_->assign(value);
|
|
295
|
+
}
|
|
296
|
+
inline string* UnknownField::mutable_length_delimited() {
|
|
297
|
+
assert(type() == TYPE_LENGTH_DELIMITED);
|
|
298
|
+
return length_delimited_.string_value_;
|
|
299
|
+
}
|
|
300
|
+
inline UnknownFieldSet* UnknownField::mutable_group() {
|
|
301
|
+
assert(type() == TYPE_GROUP);
|
|
302
|
+
return group_;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
inline int UnknownField::GetLengthDelimitedSize() const {
|
|
306
|
+
GOOGLE_DCHECK_EQ(TYPE_LENGTH_DELIMITED, type());
|
|
307
|
+
return static_cast<int>(length_delimited_.string_value_->size());
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
inline void UnknownField::SetType(Type type) {
|
|
311
|
+
type_ = type;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
} // namespace protobuf
|
|
316
|
+
|
|
317
|
+
} // namespace google
|
|
318
|
+
#endif // GOOGLE_PROTOBUF_UNKNOWN_FIELD_SET_H__
|
|
@@ -0,0 +1,599 @@
|
|
|
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
|
+
// Author: kenton@google.com (Kenton Varda)
|
|
32
|
+
// Based on original Protocol Buffers design by
|
|
33
|
+
// Sanjay Ghemawat, Jeff Dean, and others.
|
|
34
|
+
//
|
|
35
|
+
// This test is testing a lot more than just the UnknownFieldSet class. It
|
|
36
|
+
// tests handling of unknown fields throughout the system.
|
|
37
|
+
|
|
38
|
+
#include <google/protobuf/unknown_field_set.h>
|
|
39
|
+
#include <google/protobuf/descriptor.h>
|
|
40
|
+
#include <google/protobuf/io/coded_stream.h>
|
|
41
|
+
#include <google/protobuf/io/zero_copy_stream_impl.h>
|
|
42
|
+
#include <google/protobuf/wire_format.h>
|
|
43
|
+
#include <google/protobuf/unittest.pb.h>
|
|
44
|
+
#include <google/protobuf/test_util.h>
|
|
45
|
+
|
|
46
|
+
#include <google/protobuf/stubs/common.h>
|
|
47
|
+
#include <google/protobuf/testing/googletest.h>
|
|
48
|
+
#include <gtest/gtest.h>
|
|
49
|
+
#include <google/protobuf/stubs/stl_util.h>
|
|
50
|
+
|
|
51
|
+
namespace google {
|
|
52
|
+
namespace protobuf {
|
|
53
|
+
|
|
54
|
+
using internal::WireFormat;
|
|
55
|
+
|
|
56
|
+
class UnknownFieldSetTest : public testing::Test {
|
|
57
|
+
protected:
|
|
58
|
+
virtual void SetUp() {
|
|
59
|
+
descriptor_ = unittest::TestAllTypes::descriptor();
|
|
60
|
+
TestUtil::SetAllFields(&all_fields_);
|
|
61
|
+
all_fields_.SerializeToString(&all_fields_data_);
|
|
62
|
+
ASSERT_TRUE(empty_message_.ParseFromString(all_fields_data_));
|
|
63
|
+
unknown_fields_ = empty_message_.mutable_unknown_fields();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const UnknownField* GetField(const string& name) {
|
|
67
|
+
const FieldDescriptor* field = descriptor_->FindFieldByName(name);
|
|
68
|
+
if (field == NULL) return NULL;
|
|
69
|
+
for (int i = 0; i < unknown_fields_->field_count(); i++) {
|
|
70
|
+
if (unknown_fields_->field(i).number() == field->number()) {
|
|
71
|
+
return &unknown_fields_->field(i);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return NULL;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Constructs a protocol buffer which contains fields with all the same
|
|
78
|
+
// numbers as all_fields_data_ except that each field is some other wire
|
|
79
|
+
// type.
|
|
80
|
+
string GetBizarroData() {
|
|
81
|
+
unittest::TestEmptyMessage bizarro_message;
|
|
82
|
+
UnknownFieldSet* bizarro_unknown_fields =
|
|
83
|
+
bizarro_message.mutable_unknown_fields();
|
|
84
|
+
for (int i = 0; i < unknown_fields_->field_count(); i++) {
|
|
85
|
+
const UnknownField& unknown_field = unknown_fields_->field(i);
|
|
86
|
+
if (unknown_field.type() == UnknownField::TYPE_VARINT) {
|
|
87
|
+
bizarro_unknown_fields->AddFixed32(unknown_field.number(), 1);
|
|
88
|
+
} else {
|
|
89
|
+
bizarro_unknown_fields->AddVarint(unknown_field.number(), 1);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
string data;
|
|
94
|
+
EXPECT_TRUE(bizarro_message.SerializeToString(&data));
|
|
95
|
+
return data;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const Descriptor* descriptor_;
|
|
99
|
+
unittest::TestAllTypes all_fields_;
|
|
100
|
+
string all_fields_data_;
|
|
101
|
+
|
|
102
|
+
// An empty message that has been parsed from all_fields_data_. So, it has
|
|
103
|
+
// unknown fields of every type.
|
|
104
|
+
unittest::TestEmptyMessage empty_message_;
|
|
105
|
+
UnknownFieldSet* unknown_fields_;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
namespace {
|
|
109
|
+
|
|
110
|
+
TEST_F(UnknownFieldSetTest, AllFieldsPresent) {
|
|
111
|
+
// All fields of TestAllTypes should be present, in numeric order (because
|
|
112
|
+
// that's the order we parsed them in). Fields that are not valid field
|
|
113
|
+
// numbers of TestAllTypes should NOT be present.
|
|
114
|
+
|
|
115
|
+
int pos = 0;
|
|
116
|
+
|
|
117
|
+
for (int i = 0; i < 1000; i++) {
|
|
118
|
+
const FieldDescriptor* field = descriptor_->FindFieldByNumber(i);
|
|
119
|
+
if (field != NULL) {
|
|
120
|
+
ASSERT_LT(pos, unknown_fields_->field_count());
|
|
121
|
+
// Do not check oneof field if it is not set.
|
|
122
|
+
if (field->containing_oneof() == NULL) {
|
|
123
|
+
EXPECT_EQ(i, unknown_fields_->field(pos++).number());
|
|
124
|
+
} else if (i == unknown_fields_->field(pos).number()) {
|
|
125
|
+
pos++;
|
|
126
|
+
}
|
|
127
|
+
if (field->is_repeated()) {
|
|
128
|
+
// Should have a second instance.
|
|
129
|
+
ASSERT_LT(pos, unknown_fields_->field_count());
|
|
130
|
+
EXPECT_EQ(i, unknown_fields_->field(pos++).number());
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
EXPECT_EQ(unknown_fields_->field_count(), pos);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
TEST_F(UnknownFieldSetTest, Varint) {
|
|
138
|
+
const UnknownField* field = GetField("optional_int32");
|
|
139
|
+
ASSERT_TRUE(field != NULL);
|
|
140
|
+
|
|
141
|
+
ASSERT_EQ(UnknownField::TYPE_VARINT, field->type());
|
|
142
|
+
EXPECT_EQ(all_fields_.optional_int32(), field->varint());
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
TEST_F(UnknownFieldSetTest, Fixed32) {
|
|
146
|
+
const UnknownField* field = GetField("optional_fixed32");
|
|
147
|
+
ASSERT_TRUE(field != NULL);
|
|
148
|
+
|
|
149
|
+
ASSERT_EQ(UnknownField::TYPE_FIXED32, field->type());
|
|
150
|
+
EXPECT_EQ(all_fields_.optional_fixed32(), field->fixed32());
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
TEST_F(UnknownFieldSetTest, Fixed64) {
|
|
154
|
+
const UnknownField* field = GetField("optional_fixed64");
|
|
155
|
+
ASSERT_TRUE(field != NULL);
|
|
156
|
+
|
|
157
|
+
ASSERT_EQ(UnknownField::TYPE_FIXED64, field->type());
|
|
158
|
+
EXPECT_EQ(all_fields_.optional_fixed64(), field->fixed64());
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
TEST_F(UnknownFieldSetTest, LengthDelimited) {
|
|
162
|
+
const UnknownField* field = GetField("optional_string");
|
|
163
|
+
ASSERT_TRUE(field != NULL);
|
|
164
|
+
|
|
165
|
+
ASSERT_EQ(UnknownField::TYPE_LENGTH_DELIMITED, field->type());
|
|
166
|
+
EXPECT_EQ(all_fields_.optional_string(), field->length_delimited());
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
TEST_F(UnknownFieldSetTest, Group) {
|
|
170
|
+
const UnknownField* field = GetField("optionalgroup");
|
|
171
|
+
ASSERT_TRUE(field != NULL);
|
|
172
|
+
|
|
173
|
+
ASSERT_EQ(UnknownField::TYPE_GROUP, field->type());
|
|
174
|
+
ASSERT_EQ(1, field->group().field_count());
|
|
175
|
+
|
|
176
|
+
const UnknownField& nested_field = field->group().field(0);
|
|
177
|
+
const FieldDescriptor* nested_field_descriptor =
|
|
178
|
+
unittest::TestAllTypes::OptionalGroup::descriptor()->FindFieldByName("a");
|
|
179
|
+
ASSERT_TRUE(nested_field_descriptor != NULL);
|
|
180
|
+
|
|
181
|
+
EXPECT_EQ(nested_field_descriptor->number(), nested_field.number());
|
|
182
|
+
ASSERT_EQ(UnknownField::TYPE_VARINT, nested_field.type());
|
|
183
|
+
EXPECT_EQ(all_fields_.optionalgroup().a(), nested_field.varint());
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
TEST_F(UnknownFieldSetTest, SerializeFastAndSlowAreEquivalent) {
|
|
187
|
+
int size = WireFormat::ComputeUnknownFieldsSize(
|
|
188
|
+
empty_message_.unknown_fields());
|
|
189
|
+
string slow_buffer;
|
|
190
|
+
string fast_buffer;
|
|
191
|
+
slow_buffer.resize(size);
|
|
192
|
+
fast_buffer.resize(size);
|
|
193
|
+
|
|
194
|
+
uint8* target = reinterpret_cast<uint8*>(string_as_array(&fast_buffer));
|
|
195
|
+
uint8* result = WireFormat::SerializeUnknownFieldsToArray(
|
|
196
|
+
empty_message_.unknown_fields(), target);
|
|
197
|
+
EXPECT_EQ(size, result - target);
|
|
198
|
+
|
|
199
|
+
{
|
|
200
|
+
io::ArrayOutputStream raw_stream(string_as_array(&slow_buffer), size, 1);
|
|
201
|
+
io::CodedOutputStream output_stream(&raw_stream);
|
|
202
|
+
WireFormat::SerializeUnknownFields(empty_message_.unknown_fields(),
|
|
203
|
+
&output_stream);
|
|
204
|
+
ASSERT_FALSE(output_stream.HadError());
|
|
205
|
+
}
|
|
206
|
+
EXPECT_TRUE(fast_buffer == slow_buffer);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
TEST_F(UnknownFieldSetTest, Serialize) {
|
|
210
|
+
// Check that serializing the UnknownFieldSet produces the original data
|
|
211
|
+
// again.
|
|
212
|
+
|
|
213
|
+
string data;
|
|
214
|
+
empty_message_.SerializeToString(&data);
|
|
215
|
+
|
|
216
|
+
// Don't use EXPECT_EQ because we don't want to dump raw binary data to
|
|
217
|
+
// stdout.
|
|
218
|
+
EXPECT_TRUE(data == all_fields_data_);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
TEST_F(UnknownFieldSetTest, ParseViaReflection) {
|
|
222
|
+
// Make sure fields are properly parsed to the UnknownFieldSet when parsing
|
|
223
|
+
// via reflection.
|
|
224
|
+
|
|
225
|
+
unittest::TestEmptyMessage message;
|
|
226
|
+
io::ArrayInputStream raw_input(all_fields_data_.data(),
|
|
227
|
+
all_fields_data_.size());
|
|
228
|
+
io::CodedInputStream input(&raw_input);
|
|
229
|
+
ASSERT_TRUE(WireFormat::ParseAndMergePartial(&input, &message));
|
|
230
|
+
|
|
231
|
+
EXPECT_EQ(message.DebugString(), empty_message_.DebugString());
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
TEST_F(UnknownFieldSetTest, SerializeViaReflection) {
|
|
235
|
+
// Make sure fields are properly written from the UnknownFieldSet when
|
|
236
|
+
// serializing via reflection.
|
|
237
|
+
|
|
238
|
+
string data;
|
|
239
|
+
|
|
240
|
+
{
|
|
241
|
+
io::StringOutputStream raw_output(&data);
|
|
242
|
+
io::CodedOutputStream output(&raw_output);
|
|
243
|
+
int size = WireFormat::ByteSize(empty_message_);
|
|
244
|
+
WireFormat::SerializeWithCachedSizes(empty_message_, size, &output);
|
|
245
|
+
ASSERT_FALSE(output.HadError());
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// Don't use EXPECT_EQ because we don't want to dump raw binary data to
|
|
249
|
+
// stdout.
|
|
250
|
+
EXPECT_TRUE(data == all_fields_data_);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
TEST_F(UnknownFieldSetTest, CopyFrom) {
|
|
254
|
+
unittest::TestEmptyMessage message;
|
|
255
|
+
|
|
256
|
+
message.CopyFrom(empty_message_);
|
|
257
|
+
|
|
258
|
+
EXPECT_EQ(empty_message_.DebugString(), message.DebugString());
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
TEST_F(UnknownFieldSetTest, Swap) {
|
|
262
|
+
unittest::TestEmptyMessage other_message;
|
|
263
|
+
ASSERT_TRUE(other_message.ParseFromString(GetBizarroData()));
|
|
264
|
+
|
|
265
|
+
EXPECT_GT(empty_message_.unknown_fields().field_count(), 0);
|
|
266
|
+
EXPECT_GT(other_message.unknown_fields().field_count(), 0);
|
|
267
|
+
const string debug_string = empty_message_.DebugString();
|
|
268
|
+
const string other_debug_string = other_message.DebugString();
|
|
269
|
+
EXPECT_NE(debug_string, other_debug_string);
|
|
270
|
+
|
|
271
|
+
empty_message_.Swap(&other_message);
|
|
272
|
+
EXPECT_EQ(debug_string, other_message.DebugString());
|
|
273
|
+
EXPECT_EQ(other_debug_string, empty_message_.DebugString());
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
TEST_F(UnknownFieldSetTest, SwapWithSelf) {
|
|
277
|
+
const string debug_string = empty_message_.DebugString();
|
|
278
|
+
EXPECT_GT(empty_message_.unknown_fields().field_count(), 0);
|
|
279
|
+
|
|
280
|
+
empty_message_.Swap(&empty_message_);
|
|
281
|
+
EXPECT_GT(empty_message_.unknown_fields().field_count(), 0);
|
|
282
|
+
EXPECT_EQ(debug_string, empty_message_.DebugString());
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
TEST_F(UnknownFieldSetTest, MergeFrom) {
|
|
286
|
+
unittest::TestEmptyMessage source, destination;
|
|
287
|
+
|
|
288
|
+
destination.mutable_unknown_fields()->AddVarint(1, 1);
|
|
289
|
+
destination.mutable_unknown_fields()->AddVarint(3, 2);
|
|
290
|
+
source.mutable_unknown_fields()->AddVarint(2, 3);
|
|
291
|
+
source.mutable_unknown_fields()->AddVarint(3, 4);
|
|
292
|
+
|
|
293
|
+
destination.MergeFrom(source);
|
|
294
|
+
|
|
295
|
+
EXPECT_EQ(
|
|
296
|
+
// Note: The ordering of fields here depends on the ordering of adds
|
|
297
|
+
// and merging, above.
|
|
298
|
+
"1: 1\n"
|
|
299
|
+
"3: 2\n"
|
|
300
|
+
"2: 3\n"
|
|
301
|
+
"3: 4\n",
|
|
302
|
+
destination.DebugString());
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
TEST_F(UnknownFieldSetTest, Clear) {
|
|
307
|
+
// Clear the set.
|
|
308
|
+
empty_message_.Clear();
|
|
309
|
+
EXPECT_EQ(0, unknown_fields_->field_count());
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
TEST_F(UnknownFieldSetTest, ClearAndFreeMemory) {
|
|
313
|
+
EXPECT_GT(unknown_fields_->field_count(), 0);
|
|
314
|
+
unknown_fields_->ClearAndFreeMemory();
|
|
315
|
+
EXPECT_EQ(0, unknown_fields_->field_count());
|
|
316
|
+
unknown_fields_->AddVarint(123456, 654321);
|
|
317
|
+
EXPECT_EQ(1, unknown_fields_->field_count());
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
TEST_F(UnknownFieldSetTest, ParseKnownAndUnknown) {
|
|
321
|
+
// Test mixing known and unknown fields when parsing.
|
|
322
|
+
|
|
323
|
+
unittest::TestEmptyMessage source;
|
|
324
|
+
source.mutable_unknown_fields()->AddVarint(123456, 654321);
|
|
325
|
+
string data;
|
|
326
|
+
ASSERT_TRUE(source.SerializeToString(&data));
|
|
327
|
+
|
|
328
|
+
unittest::TestAllTypes destination;
|
|
329
|
+
ASSERT_TRUE(destination.ParseFromString(all_fields_data_ + data));
|
|
330
|
+
|
|
331
|
+
TestUtil::ExpectAllFieldsSet(destination);
|
|
332
|
+
ASSERT_EQ(1, destination.unknown_fields().field_count());
|
|
333
|
+
ASSERT_EQ(UnknownField::TYPE_VARINT,
|
|
334
|
+
destination.unknown_fields().field(0).type());
|
|
335
|
+
EXPECT_EQ(654321, destination.unknown_fields().field(0).varint());
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
TEST_F(UnknownFieldSetTest, WrongTypeTreatedAsUnknown) {
|
|
339
|
+
// Test that fields of the wrong wire type are treated like unknown fields
|
|
340
|
+
// when parsing.
|
|
341
|
+
|
|
342
|
+
unittest::TestAllTypes all_types_message;
|
|
343
|
+
unittest::TestEmptyMessage empty_message;
|
|
344
|
+
string bizarro_data = GetBizarroData();
|
|
345
|
+
ASSERT_TRUE(all_types_message.ParseFromString(bizarro_data));
|
|
346
|
+
ASSERT_TRUE(empty_message.ParseFromString(bizarro_data));
|
|
347
|
+
|
|
348
|
+
// All fields should have been interpreted as unknown, so the debug strings
|
|
349
|
+
// should be the same.
|
|
350
|
+
EXPECT_EQ(empty_message.DebugString(), all_types_message.DebugString());
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
TEST_F(UnknownFieldSetTest, WrongTypeTreatedAsUnknownViaReflection) {
|
|
354
|
+
// Same as WrongTypeTreatedAsUnknown but via the reflection interface.
|
|
355
|
+
|
|
356
|
+
unittest::TestAllTypes all_types_message;
|
|
357
|
+
unittest::TestEmptyMessage empty_message;
|
|
358
|
+
string bizarro_data = GetBizarroData();
|
|
359
|
+
io::ArrayInputStream raw_input(bizarro_data.data(), bizarro_data.size());
|
|
360
|
+
io::CodedInputStream input(&raw_input);
|
|
361
|
+
ASSERT_TRUE(WireFormat::ParseAndMergePartial(&input, &all_types_message));
|
|
362
|
+
ASSERT_TRUE(empty_message.ParseFromString(bizarro_data));
|
|
363
|
+
|
|
364
|
+
EXPECT_EQ(empty_message.DebugString(), all_types_message.DebugString());
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
TEST_F(UnknownFieldSetTest, UnknownExtensions) {
|
|
368
|
+
// Make sure fields are properly parsed to the UnknownFieldSet even when
|
|
369
|
+
// they are declared as extension numbers.
|
|
370
|
+
|
|
371
|
+
unittest::TestEmptyMessageWithExtensions message;
|
|
372
|
+
ASSERT_TRUE(message.ParseFromString(all_fields_data_));
|
|
373
|
+
|
|
374
|
+
EXPECT_EQ(message.DebugString(), empty_message_.DebugString());
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
TEST_F(UnknownFieldSetTest, UnknownExtensionsReflection) {
|
|
378
|
+
// Same as UnknownExtensions except parsing via reflection.
|
|
379
|
+
|
|
380
|
+
unittest::TestEmptyMessageWithExtensions message;
|
|
381
|
+
io::ArrayInputStream raw_input(all_fields_data_.data(),
|
|
382
|
+
all_fields_data_.size());
|
|
383
|
+
io::CodedInputStream input(&raw_input);
|
|
384
|
+
ASSERT_TRUE(WireFormat::ParseAndMergePartial(&input, &message));
|
|
385
|
+
|
|
386
|
+
EXPECT_EQ(message.DebugString(), empty_message_.DebugString());
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
TEST_F(UnknownFieldSetTest, WrongExtensionTypeTreatedAsUnknown) {
|
|
390
|
+
// Test that fields of the wrong wire type are treated like unknown fields
|
|
391
|
+
// when parsing extensions.
|
|
392
|
+
|
|
393
|
+
unittest::TestAllExtensions all_extensions_message;
|
|
394
|
+
unittest::TestEmptyMessage empty_message;
|
|
395
|
+
string bizarro_data = GetBizarroData();
|
|
396
|
+
ASSERT_TRUE(all_extensions_message.ParseFromString(bizarro_data));
|
|
397
|
+
ASSERT_TRUE(empty_message.ParseFromString(bizarro_data));
|
|
398
|
+
|
|
399
|
+
// All fields should have been interpreted as unknown, so the debug strings
|
|
400
|
+
// should be the same.
|
|
401
|
+
EXPECT_EQ(empty_message.DebugString(), all_extensions_message.DebugString());
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
TEST_F(UnknownFieldSetTest, UnknownEnumValue) {
|
|
405
|
+
using unittest::TestAllTypes;
|
|
406
|
+
using unittest::TestAllExtensions;
|
|
407
|
+
using unittest::TestEmptyMessage;
|
|
408
|
+
|
|
409
|
+
const FieldDescriptor* singular_field =
|
|
410
|
+
TestAllTypes::descriptor()->FindFieldByName("optional_nested_enum");
|
|
411
|
+
const FieldDescriptor* repeated_field =
|
|
412
|
+
TestAllTypes::descriptor()->FindFieldByName("repeated_nested_enum");
|
|
413
|
+
ASSERT_TRUE(singular_field != NULL);
|
|
414
|
+
ASSERT_TRUE(repeated_field != NULL);
|
|
415
|
+
|
|
416
|
+
string data;
|
|
417
|
+
|
|
418
|
+
{
|
|
419
|
+
TestEmptyMessage empty_message;
|
|
420
|
+
UnknownFieldSet* unknown_fields = empty_message.mutable_unknown_fields();
|
|
421
|
+
unknown_fields->AddVarint(singular_field->number(), TestAllTypes::BAR);
|
|
422
|
+
unknown_fields->AddVarint(singular_field->number(), 5); // not valid
|
|
423
|
+
unknown_fields->AddVarint(repeated_field->number(), TestAllTypes::FOO);
|
|
424
|
+
unknown_fields->AddVarint(repeated_field->number(), 4); // not valid
|
|
425
|
+
unknown_fields->AddVarint(repeated_field->number(), TestAllTypes::BAZ);
|
|
426
|
+
unknown_fields->AddVarint(repeated_field->number(), 6); // not valid
|
|
427
|
+
empty_message.SerializeToString(&data);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
{
|
|
431
|
+
TestAllTypes message;
|
|
432
|
+
ASSERT_TRUE(message.ParseFromString(data));
|
|
433
|
+
EXPECT_EQ(TestAllTypes::BAR, message.optional_nested_enum());
|
|
434
|
+
ASSERT_EQ(2, message.repeated_nested_enum_size());
|
|
435
|
+
EXPECT_EQ(TestAllTypes::FOO, message.repeated_nested_enum(0));
|
|
436
|
+
EXPECT_EQ(TestAllTypes::BAZ, message.repeated_nested_enum(1));
|
|
437
|
+
|
|
438
|
+
const UnknownFieldSet& unknown_fields = message.unknown_fields();
|
|
439
|
+
ASSERT_EQ(3, unknown_fields.field_count());
|
|
440
|
+
|
|
441
|
+
EXPECT_EQ(singular_field->number(), unknown_fields.field(0).number());
|
|
442
|
+
ASSERT_EQ(UnknownField::TYPE_VARINT, unknown_fields.field(0).type());
|
|
443
|
+
EXPECT_EQ(5, unknown_fields.field(0).varint());
|
|
444
|
+
|
|
445
|
+
EXPECT_EQ(repeated_field->number(), unknown_fields.field(1).number());
|
|
446
|
+
ASSERT_EQ(UnknownField::TYPE_VARINT, unknown_fields.field(1).type());
|
|
447
|
+
EXPECT_EQ(4, unknown_fields.field(1).varint());
|
|
448
|
+
|
|
449
|
+
EXPECT_EQ(repeated_field->number(), unknown_fields.field(2).number());
|
|
450
|
+
ASSERT_EQ(UnknownField::TYPE_VARINT, unknown_fields.field(2).type());
|
|
451
|
+
EXPECT_EQ(6, unknown_fields.field(2).varint());
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
{
|
|
455
|
+
using unittest::optional_nested_enum_extension;
|
|
456
|
+
using unittest::repeated_nested_enum_extension;
|
|
457
|
+
|
|
458
|
+
TestAllExtensions message;
|
|
459
|
+
ASSERT_TRUE(message.ParseFromString(data));
|
|
460
|
+
EXPECT_EQ(TestAllTypes::BAR,
|
|
461
|
+
message.GetExtension(optional_nested_enum_extension));
|
|
462
|
+
ASSERT_EQ(2, message.ExtensionSize(repeated_nested_enum_extension));
|
|
463
|
+
EXPECT_EQ(TestAllTypes::FOO,
|
|
464
|
+
message.GetExtension(repeated_nested_enum_extension, 0));
|
|
465
|
+
EXPECT_EQ(TestAllTypes::BAZ,
|
|
466
|
+
message.GetExtension(repeated_nested_enum_extension, 1));
|
|
467
|
+
|
|
468
|
+
const UnknownFieldSet& unknown_fields = message.unknown_fields();
|
|
469
|
+
ASSERT_EQ(3, unknown_fields.field_count());
|
|
470
|
+
|
|
471
|
+
EXPECT_EQ(singular_field->number(), unknown_fields.field(0).number());
|
|
472
|
+
ASSERT_EQ(UnknownField::TYPE_VARINT, unknown_fields.field(0).type());
|
|
473
|
+
EXPECT_EQ(5, unknown_fields.field(0).varint());
|
|
474
|
+
|
|
475
|
+
EXPECT_EQ(repeated_field->number(), unknown_fields.field(1).number());
|
|
476
|
+
ASSERT_EQ(UnknownField::TYPE_VARINT, unknown_fields.field(1).type());
|
|
477
|
+
EXPECT_EQ(4, unknown_fields.field(1).varint());
|
|
478
|
+
|
|
479
|
+
EXPECT_EQ(repeated_field->number(), unknown_fields.field(2).number());
|
|
480
|
+
ASSERT_EQ(UnknownField::TYPE_VARINT, unknown_fields.field(2).type());
|
|
481
|
+
EXPECT_EQ(6, unknown_fields.field(2).varint());
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
TEST_F(UnknownFieldSetTest, SpaceUsed) {
|
|
486
|
+
unittest::TestEmptyMessage empty_message;
|
|
487
|
+
|
|
488
|
+
// Make sure an unknown field set has zero space used until a field is
|
|
489
|
+
// actually added.
|
|
490
|
+
int base_size = empty_message.SpaceUsed();
|
|
491
|
+
UnknownFieldSet* unknown_fields = empty_message.mutable_unknown_fields();
|
|
492
|
+
EXPECT_EQ(base_size, empty_message.SpaceUsed());
|
|
493
|
+
|
|
494
|
+
// Make sure each thing we add to the set increases the SpaceUsed().
|
|
495
|
+
unknown_fields->AddVarint(1, 0);
|
|
496
|
+
EXPECT_LT(base_size, empty_message.SpaceUsed());
|
|
497
|
+
base_size = empty_message.SpaceUsed();
|
|
498
|
+
|
|
499
|
+
string* str = unknown_fields->AddLengthDelimited(1);
|
|
500
|
+
EXPECT_LT(base_size, empty_message.SpaceUsed());
|
|
501
|
+
base_size = empty_message.SpaceUsed();
|
|
502
|
+
|
|
503
|
+
str->assign(sizeof(string) + 1, 'x');
|
|
504
|
+
EXPECT_LT(base_size, empty_message.SpaceUsed());
|
|
505
|
+
base_size = empty_message.SpaceUsed();
|
|
506
|
+
|
|
507
|
+
UnknownFieldSet* group = unknown_fields->AddGroup(1);
|
|
508
|
+
EXPECT_LT(base_size, empty_message.SpaceUsed());
|
|
509
|
+
base_size = empty_message.SpaceUsed();
|
|
510
|
+
|
|
511
|
+
group->AddVarint(1, 0);
|
|
512
|
+
EXPECT_LT(base_size, empty_message.SpaceUsed());
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
TEST_F(UnknownFieldSetTest, Empty) {
|
|
517
|
+
UnknownFieldSet unknown_fields;
|
|
518
|
+
EXPECT_TRUE(unknown_fields.empty());
|
|
519
|
+
unknown_fields.AddVarint(6, 123);
|
|
520
|
+
EXPECT_FALSE(unknown_fields.empty());
|
|
521
|
+
unknown_fields.Clear();
|
|
522
|
+
EXPECT_TRUE(unknown_fields.empty());
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
TEST_F(UnknownFieldSetTest, DeleteSubrange) {
|
|
526
|
+
// Exhaustively test the deletion of every possible subrange in arrays of all
|
|
527
|
+
// sizes from 0 through 9.
|
|
528
|
+
for (int size = 0; size < 10; ++size) {
|
|
529
|
+
for (int num = 0; num <= size; ++num) {
|
|
530
|
+
for (int start = 0; start < size - num; ++start) {
|
|
531
|
+
// Create a set with "size" fields.
|
|
532
|
+
UnknownFieldSet unknown;
|
|
533
|
+
for (int i = 0; i < size; ++i) {
|
|
534
|
+
unknown.AddFixed32(i, i);
|
|
535
|
+
}
|
|
536
|
+
// Delete the specified subrange.
|
|
537
|
+
unknown.DeleteSubrange(start, num);
|
|
538
|
+
// Make sure the resulting field values are still correct.
|
|
539
|
+
EXPECT_EQ(size - num, unknown.field_count());
|
|
540
|
+
for (int i = 0; i < unknown.field_count(); ++i) {
|
|
541
|
+
if (i < start) {
|
|
542
|
+
EXPECT_EQ(i, unknown.field(i).fixed32());
|
|
543
|
+
} else {
|
|
544
|
+
EXPECT_EQ(i + num, unknown.field(i).fixed32());
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
void CheckDeleteByNumber(const vector<int>& field_numbers, int deleted_number,
|
|
553
|
+
const vector<int>& expected_field_nubmers) {
|
|
554
|
+
UnknownFieldSet unknown_fields;
|
|
555
|
+
for (int i = 0; i < field_numbers.size(); ++i) {
|
|
556
|
+
unknown_fields.AddFixed32(field_numbers[i], i);
|
|
557
|
+
}
|
|
558
|
+
unknown_fields.DeleteByNumber(deleted_number);
|
|
559
|
+
ASSERT_EQ(expected_field_nubmers.size(), unknown_fields.field_count());
|
|
560
|
+
for (int i = 0; i < expected_field_nubmers.size(); ++i) {
|
|
561
|
+
EXPECT_EQ(expected_field_nubmers[i],
|
|
562
|
+
unknown_fields.field(i).number());
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
#define MAKE_VECTOR(x) vector<int>(x, x + GOOGLE_ARRAYSIZE(x))
|
|
567
|
+
TEST_F(UnknownFieldSetTest, DeleteByNumber) {
|
|
568
|
+
CheckDeleteByNumber(vector<int>(), 1, vector<int>());
|
|
569
|
+
static const int kTestFieldNumbers1[] = {1, 2, 3};
|
|
570
|
+
static const int kFieldNumberToDelete1 = 1;
|
|
571
|
+
static const int kExpectedFieldNumbers1[] = {2, 3};
|
|
572
|
+
CheckDeleteByNumber(MAKE_VECTOR(kTestFieldNumbers1), kFieldNumberToDelete1,
|
|
573
|
+
MAKE_VECTOR(kExpectedFieldNumbers1));
|
|
574
|
+
static const int kTestFieldNumbers2[] = {1, 2, 3};
|
|
575
|
+
static const int kFieldNumberToDelete2 = 2;
|
|
576
|
+
static const int kExpectedFieldNumbers2[] = {1, 3};
|
|
577
|
+
CheckDeleteByNumber(MAKE_VECTOR(kTestFieldNumbers2), kFieldNumberToDelete2,
|
|
578
|
+
MAKE_VECTOR(kExpectedFieldNumbers2));
|
|
579
|
+
static const int kTestFieldNumbers3[] = {1, 2, 3};
|
|
580
|
+
static const int kFieldNumberToDelete3 = 3;
|
|
581
|
+
static const int kExpectedFieldNumbers3[] = {1, 2};
|
|
582
|
+
CheckDeleteByNumber(MAKE_VECTOR(kTestFieldNumbers3), kFieldNumberToDelete3,
|
|
583
|
+
MAKE_VECTOR(kExpectedFieldNumbers3));
|
|
584
|
+
static const int kTestFieldNumbers4[] = {1, 2, 1, 4, 1};
|
|
585
|
+
static const int kFieldNumberToDelete4 = 1;
|
|
586
|
+
static const int kExpectedFieldNumbers4[] = {2, 4};
|
|
587
|
+
CheckDeleteByNumber(MAKE_VECTOR(kTestFieldNumbers4), kFieldNumberToDelete4,
|
|
588
|
+
MAKE_VECTOR(kExpectedFieldNumbers4));
|
|
589
|
+
static const int kTestFieldNumbers5[] = {1, 2, 3, 4, 5};
|
|
590
|
+
static const int kFieldNumberToDelete5 = 6;
|
|
591
|
+
static const int kExpectedFieldNumbers5[] = {1, 2, 3, 4, 5};
|
|
592
|
+
CheckDeleteByNumber(MAKE_VECTOR(kTestFieldNumbers5), kFieldNumberToDelete5,
|
|
593
|
+
MAKE_VECTOR(kExpectedFieldNumbers5));
|
|
594
|
+
}
|
|
595
|
+
#undef MAKE_VECTOR
|
|
596
|
+
} // namespace
|
|
597
|
+
|
|
598
|
+
} // namespace protobuf
|
|
599
|
+
} // namespace google
|