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,124 @@
|
|
|
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
|
+
//
|
|
33
|
+
// TODO(kenton): Share code with the versions of this test in other languages?
|
|
34
|
+
// It seemed like parameterizing it would add more complexity than it is
|
|
35
|
+
// worth.
|
|
36
|
+
|
|
37
|
+
#include <memory>
|
|
38
|
+
|
|
39
|
+
#include <google/protobuf/compiler/java/java_generator.h>
|
|
40
|
+
#include <google/protobuf/compiler/command_line_interface.h>
|
|
41
|
+
#include <google/protobuf/io/zero_copy_stream.h>
|
|
42
|
+
#include <google/protobuf/io/printer.h>
|
|
43
|
+
|
|
44
|
+
#include <google/protobuf/testing/googletest.h>
|
|
45
|
+
#include <gtest/gtest.h>
|
|
46
|
+
#include <google/protobuf/testing/file.h>
|
|
47
|
+
|
|
48
|
+
namespace google {
|
|
49
|
+
namespace protobuf {
|
|
50
|
+
namespace compiler {
|
|
51
|
+
namespace java {
|
|
52
|
+
namespace {
|
|
53
|
+
|
|
54
|
+
class TestGenerator : public CodeGenerator {
|
|
55
|
+
public:
|
|
56
|
+
TestGenerator() {}
|
|
57
|
+
~TestGenerator() {}
|
|
58
|
+
|
|
59
|
+
virtual bool Generate(const FileDescriptor* file,
|
|
60
|
+
const string& parameter,
|
|
61
|
+
GeneratorContext* context,
|
|
62
|
+
string* error) const {
|
|
63
|
+
string filename = "Test.java";
|
|
64
|
+
TryInsert(filename, "outer_class_scope", context);
|
|
65
|
+
TryInsert(filename, "class_scope:foo.Bar", context);
|
|
66
|
+
TryInsert(filename, "class_scope:foo.Bar.Baz", context);
|
|
67
|
+
TryInsert(filename, "builder_scope:foo.Bar", context);
|
|
68
|
+
TryInsert(filename, "builder_scope:foo.Bar.Baz", context);
|
|
69
|
+
TryInsert(filename, "enum_scope:foo.Qux", context);
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
void TryInsert(const string& filename, const string& insertion_point,
|
|
74
|
+
GeneratorContext* context) const {
|
|
75
|
+
scoped_ptr<io::ZeroCopyOutputStream> output(
|
|
76
|
+
context->OpenForInsert(filename, insertion_point));
|
|
77
|
+
io::Printer printer(output.get(), '$');
|
|
78
|
+
printer.Print("// inserted $name$\n", "name", insertion_point);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// This test verifies that all the expected insertion points exist. It does
|
|
83
|
+
// not verify that they are correctly-placed; that would require actually
|
|
84
|
+
// compiling the output which is a bit more than I care to do for this test.
|
|
85
|
+
TEST(JavaPluginTest, PluginTest) {
|
|
86
|
+
GOOGLE_CHECK_OK(File::SetContents(TestTempDir() + "/test.proto",
|
|
87
|
+
"syntax = \"proto2\";\n"
|
|
88
|
+
"package foo;\n"
|
|
89
|
+
"option java_package = \"\";\n"
|
|
90
|
+
"option java_outer_classname = \"Test\";\n"
|
|
91
|
+
"message Bar {\n"
|
|
92
|
+
" message Baz {}\n"
|
|
93
|
+
"}\n"
|
|
94
|
+
"enum Qux { BLAH = 1; }\n",
|
|
95
|
+
true));
|
|
96
|
+
|
|
97
|
+
google::protobuf::compiler::CommandLineInterface cli;
|
|
98
|
+
cli.SetInputsAreProtoPathRelative(true);
|
|
99
|
+
|
|
100
|
+
JavaGenerator java_generator;
|
|
101
|
+
TestGenerator test_generator;
|
|
102
|
+
cli.RegisterGenerator("--java_out", &java_generator, "");
|
|
103
|
+
cli.RegisterGenerator("--test_out", &test_generator, "");
|
|
104
|
+
|
|
105
|
+
string proto_path = "-I" + TestTempDir();
|
|
106
|
+
string java_out = "--java_out=" + TestTempDir();
|
|
107
|
+
string test_out = "--test_out=" + TestTempDir();
|
|
108
|
+
|
|
109
|
+
const char* argv[] = {
|
|
110
|
+
"protoc",
|
|
111
|
+
proto_path.c_str(),
|
|
112
|
+
java_out.c_str(),
|
|
113
|
+
test_out.c_str(),
|
|
114
|
+
"test.proto"
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
EXPECT_EQ(0, cli.Run(5, argv));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
} // namespace
|
|
121
|
+
} // namespace java
|
|
122
|
+
} // namespace compiler
|
|
123
|
+
} // namespace protobuf
|
|
124
|
+
} // namespace google
|
|
@@ -0,0 +1,877 @@
|
|
|
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
|
+
#include <map>
|
|
36
|
+
#include <string>
|
|
37
|
+
|
|
38
|
+
#include <google/protobuf/stubs/common.h>
|
|
39
|
+
#include <google/protobuf/compiler/java/java_context.h>
|
|
40
|
+
#include <google/protobuf/compiler/java/java_doc_comment.h>
|
|
41
|
+
#include <google/protobuf/compiler/java/java_helpers.h>
|
|
42
|
+
#include <google/protobuf/compiler/java/java_name_resolver.h>
|
|
43
|
+
#include <google/protobuf/compiler/java/java_primitive_field.h>
|
|
44
|
+
#include <google/protobuf/io/printer.h>
|
|
45
|
+
#include <google/protobuf/wire_format.h>
|
|
46
|
+
#include <google/protobuf/stubs/strutil.h>
|
|
47
|
+
|
|
48
|
+
namespace google {
|
|
49
|
+
namespace protobuf {
|
|
50
|
+
namespace compiler {
|
|
51
|
+
namespace java {
|
|
52
|
+
|
|
53
|
+
using internal::WireFormat;
|
|
54
|
+
using internal::WireFormatLite;
|
|
55
|
+
|
|
56
|
+
namespace {
|
|
57
|
+
|
|
58
|
+
const char* PrimitiveTypeName(JavaType type) {
|
|
59
|
+
switch (type) {
|
|
60
|
+
case JAVATYPE_INT : return "int";
|
|
61
|
+
case JAVATYPE_LONG : return "long";
|
|
62
|
+
case JAVATYPE_FLOAT : return "float";
|
|
63
|
+
case JAVATYPE_DOUBLE : return "double";
|
|
64
|
+
case JAVATYPE_BOOLEAN: return "boolean";
|
|
65
|
+
case JAVATYPE_STRING : return "java.lang.String";
|
|
66
|
+
case JAVATYPE_BYTES : return "com.google.protobuf.ByteString";
|
|
67
|
+
case JAVATYPE_ENUM : return NULL;
|
|
68
|
+
case JAVATYPE_MESSAGE: return NULL;
|
|
69
|
+
|
|
70
|
+
// No default because we want the compiler to complain if any new
|
|
71
|
+
// JavaTypes are added.
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
GOOGLE_LOG(FATAL) << "Can't get here.";
|
|
75
|
+
return NULL;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
void SetPrimitiveVariables(const FieldDescriptor* descriptor,
|
|
79
|
+
int messageBitIndex,
|
|
80
|
+
int builderBitIndex,
|
|
81
|
+
const FieldGeneratorInfo* info,
|
|
82
|
+
ClassNameResolver* name_resolver,
|
|
83
|
+
map<string, string>* variables) {
|
|
84
|
+
SetCommonFieldVariables(descriptor, info, variables);
|
|
85
|
+
|
|
86
|
+
(*variables)["type"] = PrimitiveTypeName(GetJavaType(descriptor));
|
|
87
|
+
(*variables)["boxed_type"] = BoxedPrimitiveTypeName(GetJavaType(descriptor));
|
|
88
|
+
(*variables)["field_type"] = (*variables)["type"];
|
|
89
|
+
(*variables)["field_list_type"] = "java.util.List<" +
|
|
90
|
+
(*variables)["boxed_type"] + ">";
|
|
91
|
+
(*variables)["empty_list"] = "java.util.Collections.emptyList()";
|
|
92
|
+
(*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
|
|
93
|
+
(*variables)["default_init"] = IsDefaultValueJavaDefault(descriptor) ?
|
|
94
|
+
"" : ("= " + ImmutableDefaultValue(descriptor, name_resolver));
|
|
95
|
+
(*variables)["capitalized_type"] =
|
|
96
|
+
GetCapitalizedType(descriptor, /* immutable = */ true);
|
|
97
|
+
(*variables)["tag"] = SimpleItoa(WireFormat::MakeTag(descriptor));
|
|
98
|
+
(*variables)["tag_size"] = SimpleItoa(
|
|
99
|
+
WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
|
|
100
|
+
if (IsReferenceType(GetJavaType(descriptor))) {
|
|
101
|
+
(*variables)["null_check"] =
|
|
102
|
+
" if (value == null) {\n"
|
|
103
|
+
" throw new NullPointerException();\n"
|
|
104
|
+
" }\n";
|
|
105
|
+
} else {
|
|
106
|
+
(*variables)["null_check"] = "";
|
|
107
|
+
}
|
|
108
|
+
// TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
|
|
109
|
+
// by the proto compiler
|
|
110
|
+
(*variables)["deprecation"] = descriptor->options().deprecated()
|
|
111
|
+
? "@java.lang.Deprecated " : "";
|
|
112
|
+
int fixed_size = FixedSize(GetType(descriptor));
|
|
113
|
+
if (fixed_size != -1) {
|
|
114
|
+
(*variables)["fixed_size"] = SimpleItoa(fixed_size);
|
|
115
|
+
}
|
|
116
|
+
(*variables)["on_changed"] =
|
|
117
|
+
HasDescriptorMethods(descriptor->containing_type()) ? "onChanged();" : "";
|
|
118
|
+
|
|
119
|
+
if (SupportFieldPresence(descriptor->file())) {
|
|
120
|
+
// For singular messages and builders, one bit is used for the hasField bit.
|
|
121
|
+
(*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
|
|
122
|
+
(*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex);
|
|
123
|
+
|
|
124
|
+
// Note that these have a trailing ";".
|
|
125
|
+
(*variables)["set_has_field_bit_message"] =
|
|
126
|
+
GenerateSetBit(messageBitIndex) + ";";
|
|
127
|
+
(*variables)["set_has_field_bit_builder"] =
|
|
128
|
+
GenerateSetBit(builderBitIndex) + ";";
|
|
129
|
+
(*variables)["clear_has_field_bit_builder"] =
|
|
130
|
+
GenerateClearBit(builderBitIndex) + ";";
|
|
131
|
+
|
|
132
|
+
(*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
|
|
133
|
+
} else {
|
|
134
|
+
(*variables)["set_has_field_bit_message"] = "";
|
|
135
|
+
(*variables)["set_has_field_bit_builder"] = "";
|
|
136
|
+
(*variables)["clear_has_field_bit_builder"] = "";
|
|
137
|
+
|
|
138
|
+
if (descriptor->type() == FieldDescriptor::TYPE_BYTES) {
|
|
139
|
+
(*variables)["is_field_present_message"] =
|
|
140
|
+
"!" + (*variables)["name"] + "_.isEmpty()";
|
|
141
|
+
} else {
|
|
142
|
+
(*variables)["is_field_present_message"] =
|
|
143
|
+
(*variables)["name"] + "_ != " + (*variables)["default"];
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// For repated builders, one bit is used for whether the array is immutable.
|
|
148
|
+
(*variables)["get_mutable_bit_builder"] = GenerateGetBit(builderBitIndex);
|
|
149
|
+
(*variables)["set_mutable_bit_builder"] = GenerateSetBit(builderBitIndex);
|
|
150
|
+
(*variables)["clear_mutable_bit_builder"] = GenerateClearBit(builderBitIndex);
|
|
151
|
+
|
|
152
|
+
// For repeated fields, one bit is used for whether the array is immutable
|
|
153
|
+
// in the parsing constructor.
|
|
154
|
+
(*variables)["get_mutable_bit_parser"] =
|
|
155
|
+
GenerateGetBitMutableLocal(builderBitIndex);
|
|
156
|
+
(*variables)["set_mutable_bit_parser"] =
|
|
157
|
+
GenerateSetBitMutableLocal(builderBitIndex);
|
|
158
|
+
|
|
159
|
+
(*variables)["get_has_field_bit_from_local"] =
|
|
160
|
+
GenerateGetBitFromLocal(builderBitIndex);
|
|
161
|
+
(*variables)["set_has_field_bit_to_local"] =
|
|
162
|
+
GenerateSetBitToLocal(messageBitIndex);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
} // namespace
|
|
166
|
+
|
|
167
|
+
// ===================================================================
|
|
168
|
+
|
|
169
|
+
ImmutablePrimitiveFieldGenerator::
|
|
170
|
+
ImmutablePrimitiveFieldGenerator(const FieldDescriptor* descriptor,
|
|
171
|
+
int messageBitIndex,
|
|
172
|
+
int builderBitIndex,
|
|
173
|
+
Context* context)
|
|
174
|
+
: descriptor_(descriptor), messageBitIndex_(messageBitIndex),
|
|
175
|
+
builderBitIndex_(builderBitIndex), context_(context),
|
|
176
|
+
name_resolver_(context->GetNameResolver()) {
|
|
177
|
+
SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex,
|
|
178
|
+
context->GetFieldGeneratorInfo(descriptor),
|
|
179
|
+
name_resolver_, &variables_);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
ImmutablePrimitiveFieldGenerator::~ImmutablePrimitiveFieldGenerator() {}
|
|
183
|
+
|
|
184
|
+
int ImmutablePrimitiveFieldGenerator::GetNumBitsForMessage() const {
|
|
185
|
+
return 1;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
int ImmutablePrimitiveFieldGenerator::GetNumBitsForBuilder() const {
|
|
189
|
+
return 1;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
void ImmutablePrimitiveFieldGenerator::
|
|
193
|
+
GenerateInterfaceMembers(io::Printer* printer) const {
|
|
194
|
+
if (SupportFieldPresence(descriptor_->file())) {
|
|
195
|
+
WriteFieldDocComment(printer, descriptor_);
|
|
196
|
+
printer->Print(variables_,
|
|
197
|
+
"$deprecation$boolean has$capitalized_name$();\n");
|
|
198
|
+
}
|
|
199
|
+
WriteFieldDocComment(printer, descriptor_);
|
|
200
|
+
printer->Print(variables_,
|
|
201
|
+
"$deprecation$$type$ get$capitalized_name$();\n");
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
void ImmutablePrimitiveFieldGenerator::
|
|
205
|
+
GenerateMembers(io::Printer* printer) const {
|
|
206
|
+
printer->Print(variables_,
|
|
207
|
+
"private $field_type$ $name$_;\n");
|
|
208
|
+
PrintExtraFieldInfo(variables_, printer);
|
|
209
|
+
if (SupportFieldPresence(descriptor_->file())) {
|
|
210
|
+
WriteFieldDocComment(printer, descriptor_);
|
|
211
|
+
printer->Print(variables_,
|
|
212
|
+
"$deprecation$public boolean has$capitalized_name$() {\n"
|
|
213
|
+
" return $get_has_field_bit_message$;\n"
|
|
214
|
+
"}\n");
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
WriteFieldDocComment(printer, descriptor_);
|
|
218
|
+
printer->Print(variables_,
|
|
219
|
+
"$deprecation$public $type$ get$capitalized_name$() {\n"
|
|
220
|
+
" return $name$_;\n"
|
|
221
|
+
"}\n");
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
void ImmutablePrimitiveFieldGenerator::
|
|
225
|
+
GenerateBuilderMembers(io::Printer* printer) const {
|
|
226
|
+
printer->Print(variables_,
|
|
227
|
+
"private $field_type$ $name$_ $default_init$;\n");
|
|
228
|
+
|
|
229
|
+
if (SupportFieldPresence(descriptor_->file())) {
|
|
230
|
+
WriteFieldDocComment(printer, descriptor_);
|
|
231
|
+
printer->Print(variables_,
|
|
232
|
+
"$deprecation$public boolean has$capitalized_name$() {\n"
|
|
233
|
+
" return $get_has_field_bit_builder$;\n"
|
|
234
|
+
"}\n");
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
WriteFieldDocComment(printer, descriptor_);
|
|
238
|
+
printer->Print(variables_,
|
|
239
|
+
"$deprecation$public $type$ get$capitalized_name$() {\n"
|
|
240
|
+
" return $name$_;\n"
|
|
241
|
+
"}\n");
|
|
242
|
+
|
|
243
|
+
WriteFieldDocComment(printer, descriptor_);
|
|
244
|
+
printer->Print(variables_,
|
|
245
|
+
"$deprecation$public Builder set$capitalized_name$($type$ value) {\n"
|
|
246
|
+
"$null_check$"
|
|
247
|
+
" $set_has_field_bit_builder$\n"
|
|
248
|
+
" $name$_ = value;\n"
|
|
249
|
+
" $on_changed$\n"
|
|
250
|
+
" return this;\n"
|
|
251
|
+
"}\n");
|
|
252
|
+
|
|
253
|
+
WriteFieldDocComment(printer, descriptor_);
|
|
254
|
+
printer->Print(variables_,
|
|
255
|
+
"$deprecation$public Builder clear$capitalized_name$() {\n"
|
|
256
|
+
" $clear_has_field_bit_builder$\n");
|
|
257
|
+
JavaType type = GetJavaType(descriptor_);
|
|
258
|
+
if (type == JAVATYPE_STRING || type == JAVATYPE_BYTES) {
|
|
259
|
+
// The default value is not a simple literal so we want to avoid executing
|
|
260
|
+
// it multiple times. Instead, get the default out of the default instance.
|
|
261
|
+
printer->Print(variables_,
|
|
262
|
+
" $name$_ = getDefaultInstance().get$capitalized_name$();\n");
|
|
263
|
+
} else {
|
|
264
|
+
printer->Print(variables_,
|
|
265
|
+
" $name$_ = $default$;\n");
|
|
266
|
+
}
|
|
267
|
+
printer->Print(variables_,
|
|
268
|
+
" $on_changed$\n"
|
|
269
|
+
" return this;\n"
|
|
270
|
+
"}\n");
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
void ImmutablePrimitiveFieldGenerator::
|
|
274
|
+
GenerateFieldBuilderInitializationCode(io::Printer* printer) const {
|
|
275
|
+
// noop for primitives
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
void ImmutablePrimitiveFieldGenerator::
|
|
279
|
+
GenerateInitializationCode(io::Printer* printer) const {
|
|
280
|
+
printer->Print(variables_, "$name$_ = $default$;\n");
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
void ImmutablePrimitiveFieldGenerator::
|
|
284
|
+
GenerateBuilderClearCode(io::Printer* printer) const {
|
|
285
|
+
printer->Print(variables_,
|
|
286
|
+
"$name$_ = $default$;\n"
|
|
287
|
+
"$clear_has_field_bit_builder$\n");
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
void ImmutablePrimitiveFieldGenerator::
|
|
291
|
+
GenerateMergingCode(io::Printer* printer) const {
|
|
292
|
+
if (SupportFieldPresence(descriptor_->file())) {
|
|
293
|
+
printer->Print(variables_,
|
|
294
|
+
"if (other.has$capitalized_name$()) {\n"
|
|
295
|
+
" set$capitalized_name$(other.get$capitalized_name$());\n"
|
|
296
|
+
"}\n");
|
|
297
|
+
} else {
|
|
298
|
+
printer->Print(variables_,
|
|
299
|
+
"if (other.get$capitalized_name$() != $default$) {\n"
|
|
300
|
+
" set$capitalized_name$(other.get$capitalized_name$());\n"
|
|
301
|
+
"}\n");
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
void ImmutablePrimitiveFieldGenerator::
|
|
306
|
+
GenerateBuildingCode(io::Printer* printer) const {
|
|
307
|
+
if (SupportFieldPresence(descriptor_->file())) {
|
|
308
|
+
printer->Print(variables_,
|
|
309
|
+
"if ($get_has_field_bit_from_local$) {\n"
|
|
310
|
+
" $set_has_field_bit_to_local$;\n"
|
|
311
|
+
"}\n");
|
|
312
|
+
}
|
|
313
|
+
printer->Print(variables_,
|
|
314
|
+
"result.$name$_ = $name$_;\n");
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
void ImmutablePrimitiveFieldGenerator::
|
|
318
|
+
GenerateParsingCode(io::Printer* printer) const {
|
|
319
|
+
printer->Print(variables_,
|
|
320
|
+
"$set_has_field_bit_message$\n"
|
|
321
|
+
"$name$_ = input.read$capitalized_type$();\n");
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
void ImmutablePrimitiveFieldGenerator::
|
|
325
|
+
GenerateParsingDoneCode(io::Printer* printer) const {
|
|
326
|
+
// noop for primitives.
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
void ImmutablePrimitiveFieldGenerator::
|
|
330
|
+
GenerateSerializationCode(io::Printer* printer) const {
|
|
331
|
+
printer->Print(variables_,
|
|
332
|
+
"if ($is_field_present_message$) {\n"
|
|
333
|
+
" output.write$capitalized_type$($number$, $name$_);\n"
|
|
334
|
+
"}\n");
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
void ImmutablePrimitiveFieldGenerator::
|
|
338
|
+
GenerateSerializedSizeCode(io::Printer* printer) const {
|
|
339
|
+
printer->Print(variables_,
|
|
340
|
+
"if ($is_field_present_message$) {\n"
|
|
341
|
+
" size += com.google.protobuf.CodedOutputStream\n"
|
|
342
|
+
" .compute$capitalized_type$Size($number$, $name$_);\n"
|
|
343
|
+
"}\n");
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
void ImmutablePrimitiveFieldGenerator::
|
|
347
|
+
GenerateEqualsCode(io::Printer* printer) const {
|
|
348
|
+
switch (GetJavaType(descriptor_)) {
|
|
349
|
+
case JAVATYPE_INT:
|
|
350
|
+
case JAVATYPE_LONG:
|
|
351
|
+
case JAVATYPE_BOOLEAN:
|
|
352
|
+
printer->Print(variables_,
|
|
353
|
+
"result = result && (get$capitalized_name$()\n"
|
|
354
|
+
" == other.get$capitalized_name$());\n");
|
|
355
|
+
break;
|
|
356
|
+
|
|
357
|
+
case JAVATYPE_FLOAT:
|
|
358
|
+
printer->Print(variables_,
|
|
359
|
+
"result = result && (\n"
|
|
360
|
+
" java.lang.Float.floatToIntBits(get$capitalized_name$())\n"
|
|
361
|
+
" == java.lang.Float.floatToIntBits(\n"
|
|
362
|
+
" other.get$capitalized_name$()));\n");
|
|
363
|
+
break;
|
|
364
|
+
|
|
365
|
+
case JAVATYPE_DOUBLE:
|
|
366
|
+
printer->Print(variables_,
|
|
367
|
+
"result = result && (\n"
|
|
368
|
+
" java.lang.Double.doubleToLongBits(get$capitalized_name$())\n"
|
|
369
|
+
" == java.lang.Double.doubleToLongBits(\n"
|
|
370
|
+
" other.get$capitalized_name$()));\n");
|
|
371
|
+
break;
|
|
372
|
+
|
|
373
|
+
case JAVATYPE_STRING:
|
|
374
|
+
case JAVATYPE_BYTES:
|
|
375
|
+
printer->Print(variables_,
|
|
376
|
+
"result = result && get$capitalized_name$()\n"
|
|
377
|
+
" .equals(other.get$capitalized_name$());\n");
|
|
378
|
+
break;
|
|
379
|
+
|
|
380
|
+
case JAVATYPE_ENUM:
|
|
381
|
+
case JAVATYPE_MESSAGE:
|
|
382
|
+
default:
|
|
383
|
+
GOOGLE_LOG(FATAL) << "Can't get here.";
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
void ImmutablePrimitiveFieldGenerator::
|
|
389
|
+
GenerateHashCode(io::Printer* printer) const {
|
|
390
|
+
printer->Print(variables_,
|
|
391
|
+
"hash = (37 * hash) + $constant_name$;\n");
|
|
392
|
+
switch (GetJavaType(descriptor_)) {
|
|
393
|
+
case JAVATYPE_INT:
|
|
394
|
+
printer->Print(variables_,
|
|
395
|
+
"hash = (53 * hash) + get$capitalized_name$();\n");
|
|
396
|
+
break;
|
|
397
|
+
|
|
398
|
+
case JAVATYPE_LONG:
|
|
399
|
+
printer->Print(variables_,
|
|
400
|
+
"hash = (53 * hash) + com.google.protobuf.Internal.hashLong(\n"
|
|
401
|
+
" get$capitalized_name$());\n");
|
|
402
|
+
break;
|
|
403
|
+
|
|
404
|
+
case JAVATYPE_BOOLEAN:
|
|
405
|
+
printer->Print(variables_,
|
|
406
|
+
"hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(\n"
|
|
407
|
+
" get$capitalized_name$());\n");
|
|
408
|
+
break;
|
|
409
|
+
|
|
410
|
+
case JAVATYPE_FLOAT:
|
|
411
|
+
printer->Print(variables_,
|
|
412
|
+
"hash = (53 * hash) + java.lang.Float.floatToIntBits(\n"
|
|
413
|
+
" get$capitalized_name$());\n");
|
|
414
|
+
break;
|
|
415
|
+
|
|
416
|
+
case JAVATYPE_DOUBLE:
|
|
417
|
+
printer->Print(variables_,
|
|
418
|
+
"hash = (53 * hash) + com.google.protobuf.Internal.hashLong(\n"
|
|
419
|
+
" java.lang.Double.doubleToLongBits(get$capitalized_name$()));\n");
|
|
420
|
+
break;
|
|
421
|
+
|
|
422
|
+
case JAVATYPE_STRING:
|
|
423
|
+
case JAVATYPE_BYTES:
|
|
424
|
+
printer->Print(variables_,
|
|
425
|
+
"hash = (53 * hash) + get$capitalized_name$().hashCode();\n");
|
|
426
|
+
break;
|
|
427
|
+
|
|
428
|
+
case JAVATYPE_ENUM:
|
|
429
|
+
case JAVATYPE_MESSAGE:
|
|
430
|
+
default:
|
|
431
|
+
GOOGLE_LOG(FATAL) << "Can't get here.";
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
string ImmutablePrimitiveFieldGenerator::GetBoxedType() const {
|
|
437
|
+
return BoxedPrimitiveTypeName(GetJavaType(descriptor_));
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// ===================================================================
|
|
441
|
+
|
|
442
|
+
ImmutablePrimitiveOneofFieldGenerator::
|
|
443
|
+
ImmutablePrimitiveOneofFieldGenerator(const FieldDescriptor* descriptor,
|
|
444
|
+
int messageBitIndex,
|
|
445
|
+
int builderBitIndex,
|
|
446
|
+
Context* context)
|
|
447
|
+
: ImmutablePrimitiveFieldGenerator(
|
|
448
|
+
descriptor, messageBitIndex, builderBitIndex, context) {
|
|
449
|
+
const OneofGeneratorInfo* info =
|
|
450
|
+
context->GetOneofGeneratorInfo(descriptor->containing_oneof());
|
|
451
|
+
SetCommonOneofVariables(descriptor, info, &variables_);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
ImmutablePrimitiveOneofFieldGenerator::
|
|
455
|
+
~ImmutablePrimitiveOneofFieldGenerator() {}
|
|
456
|
+
|
|
457
|
+
void ImmutablePrimitiveOneofFieldGenerator::
|
|
458
|
+
GenerateMembers(io::Printer* printer) const {
|
|
459
|
+
PrintExtraFieldInfo(variables_, printer);
|
|
460
|
+
if (SupportFieldPresence(descriptor_->file())) {
|
|
461
|
+
WriteFieldDocComment(printer, descriptor_);
|
|
462
|
+
printer->Print(variables_,
|
|
463
|
+
"$deprecation$public boolean has$capitalized_name$() {\n"
|
|
464
|
+
" return $has_oneof_case_message$;\n"
|
|
465
|
+
"}\n");
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
WriteFieldDocComment(printer, descriptor_);
|
|
469
|
+
printer->Print(variables_,
|
|
470
|
+
"$deprecation$public $type$ get$capitalized_name$() {\n"
|
|
471
|
+
" if ($has_oneof_case_message$) {\n"
|
|
472
|
+
" return ($boxed_type$) $oneof_name$_;\n"
|
|
473
|
+
" }\n"
|
|
474
|
+
" return $default$;\n"
|
|
475
|
+
"}\n");
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
void ImmutablePrimitiveOneofFieldGenerator::
|
|
480
|
+
GenerateBuilderMembers(io::Printer* printer) const {
|
|
481
|
+
if (SupportFieldPresence(descriptor_->file())) {
|
|
482
|
+
WriteFieldDocComment(printer, descriptor_);
|
|
483
|
+
printer->Print(variables_,
|
|
484
|
+
"$deprecation$public boolean has$capitalized_name$() {\n"
|
|
485
|
+
" return $has_oneof_case_message$;\n"
|
|
486
|
+
"}\n");
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
WriteFieldDocComment(printer, descriptor_);
|
|
490
|
+
printer->Print(variables_,
|
|
491
|
+
"$deprecation$public $type$ get$capitalized_name$() {\n"
|
|
492
|
+
" if ($has_oneof_case_message$) {\n"
|
|
493
|
+
" return ($boxed_type$) $oneof_name$_;\n"
|
|
494
|
+
" }\n"
|
|
495
|
+
" return $default$;\n"
|
|
496
|
+
"}\n");
|
|
497
|
+
|
|
498
|
+
WriteFieldDocComment(printer, descriptor_);
|
|
499
|
+
printer->Print(variables_,
|
|
500
|
+
"$deprecation$public Builder set$capitalized_name$($type$ value) {\n"
|
|
501
|
+
"$null_check$"
|
|
502
|
+
" $set_oneof_case_message$;\n"
|
|
503
|
+
" $oneof_name$_ = value;\n"
|
|
504
|
+
" $on_changed$\n"
|
|
505
|
+
" return this;\n"
|
|
506
|
+
"}\n");
|
|
507
|
+
|
|
508
|
+
WriteFieldDocComment(printer, descriptor_);
|
|
509
|
+
printer->Print(variables_,
|
|
510
|
+
"$deprecation$public Builder clear$capitalized_name$() {\n"
|
|
511
|
+
" if ($has_oneof_case_message$) {\n"
|
|
512
|
+
" $clear_oneof_case_message$;\n"
|
|
513
|
+
" $oneof_name$_ = null;\n"
|
|
514
|
+
" $on_changed$\n"
|
|
515
|
+
" }\n"
|
|
516
|
+
" return this;\n"
|
|
517
|
+
"}\n");
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
void ImmutablePrimitiveOneofFieldGenerator::
|
|
521
|
+
GenerateBuildingCode(io::Printer* printer) const {
|
|
522
|
+
printer->Print(variables_,
|
|
523
|
+
"if ($has_oneof_case_message$) {\n"
|
|
524
|
+
" result.$oneof_name$_ = $oneof_name$_;\n"
|
|
525
|
+
"}\n");
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
void ImmutablePrimitiveOneofFieldGenerator::
|
|
529
|
+
GenerateMergingCode(io::Printer* printer) const {
|
|
530
|
+
printer->Print(variables_,
|
|
531
|
+
"set$capitalized_name$(other.get$capitalized_name$());\n");
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
void ImmutablePrimitiveOneofFieldGenerator::
|
|
535
|
+
GenerateParsingCode(io::Printer* printer) const {
|
|
536
|
+
printer->Print(variables_,
|
|
537
|
+
"$set_oneof_case_message$;\n"
|
|
538
|
+
"$oneof_name$_ = input.read$capitalized_type$();\n");
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
void ImmutablePrimitiveOneofFieldGenerator::
|
|
542
|
+
GenerateSerializationCode(io::Printer* printer) const {
|
|
543
|
+
printer->Print(variables_,
|
|
544
|
+
"if ($has_oneof_case_message$) {\n"
|
|
545
|
+
" output.write$capitalized_type$(\n"
|
|
546
|
+
" $number$, ($type$)(($boxed_type$) $oneof_name$_));\n"
|
|
547
|
+
"}\n");
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
void ImmutablePrimitiveOneofFieldGenerator::
|
|
551
|
+
GenerateSerializedSizeCode(io::Printer* printer) const {
|
|
552
|
+
printer->Print(variables_,
|
|
553
|
+
"if ($has_oneof_case_message$) {\n"
|
|
554
|
+
" size += com.google.protobuf.CodedOutputStream\n"
|
|
555
|
+
" .compute$capitalized_type$Size(\n"
|
|
556
|
+
" $number$, ($type$)(($boxed_type$) $oneof_name$_));\n"
|
|
557
|
+
"}\n");
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// ===================================================================
|
|
561
|
+
|
|
562
|
+
RepeatedImmutablePrimitiveFieldGenerator::
|
|
563
|
+
RepeatedImmutablePrimitiveFieldGenerator(const FieldDescriptor* descriptor,
|
|
564
|
+
int messageBitIndex,
|
|
565
|
+
int builderBitIndex,
|
|
566
|
+
Context* context)
|
|
567
|
+
: descriptor_(descriptor), messageBitIndex_(messageBitIndex),
|
|
568
|
+
builderBitIndex_(builderBitIndex), context_(context),
|
|
569
|
+
name_resolver_(context->GetNameResolver()) {
|
|
570
|
+
SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex,
|
|
571
|
+
context->GetFieldGeneratorInfo(descriptor),
|
|
572
|
+
name_resolver_, &variables_);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
RepeatedImmutablePrimitiveFieldGenerator::
|
|
576
|
+
~RepeatedImmutablePrimitiveFieldGenerator() {}
|
|
577
|
+
|
|
578
|
+
int RepeatedImmutablePrimitiveFieldGenerator::GetNumBitsForMessage() const {
|
|
579
|
+
return 0;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
int RepeatedImmutablePrimitiveFieldGenerator::GetNumBitsForBuilder() const {
|
|
583
|
+
return 1;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
void RepeatedImmutablePrimitiveFieldGenerator::
|
|
587
|
+
GenerateInterfaceMembers(io::Printer* printer) const {
|
|
588
|
+
WriteFieldDocComment(printer, descriptor_);
|
|
589
|
+
printer->Print(variables_,
|
|
590
|
+
"$deprecation$java.util.List<$boxed_type$> get$capitalized_name$List();\n");
|
|
591
|
+
WriteFieldDocComment(printer, descriptor_);
|
|
592
|
+
printer->Print(variables_,
|
|
593
|
+
"$deprecation$int get$capitalized_name$Count();\n");
|
|
594
|
+
WriteFieldDocComment(printer, descriptor_);
|
|
595
|
+
printer->Print(variables_,
|
|
596
|
+
"$deprecation$$type$ get$capitalized_name$(int index);\n");
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
void RepeatedImmutablePrimitiveFieldGenerator::
|
|
601
|
+
GenerateMembers(io::Printer* printer) const {
|
|
602
|
+
printer->Print(variables_,
|
|
603
|
+
"private $field_list_type$ $name$_;\n");
|
|
604
|
+
PrintExtraFieldInfo(variables_, printer);
|
|
605
|
+
WriteFieldDocComment(printer, descriptor_);
|
|
606
|
+
printer->Print(variables_,
|
|
607
|
+
"$deprecation$public java.util.List<$boxed_type$>\n"
|
|
608
|
+
" get$capitalized_name$List() {\n"
|
|
609
|
+
" return $name$_;\n" // note: unmodifiable list
|
|
610
|
+
"}\n");
|
|
611
|
+
WriteFieldDocComment(printer, descriptor_);
|
|
612
|
+
printer->Print(variables_,
|
|
613
|
+
"$deprecation$public int get$capitalized_name$Count() {\n"
|
|
614
|
+
" return $name$_.size();\n"
|
|
615
|
+
"}\n");
|
|
616
|
+
WriteFieldDocComment(printer, descriptor_);
|
|
617
|
+
printer->Print(variables_,
|
|
618
|
+
"$deprecation$public $type$ get$capitalized_name$(int index) {\n"
|
|
619
|
+
" return $name$_.get(index);\n"
|
|
620
|
+
"}\n");
|
|
621
|
+
|
|
622
|
+
if (descriptor_->options().packed() &&
|
|
623
|
+
HasGeneratedMethods(descriptor_->containing_type())) {
|
|
624
|
+
printer->Print(variables_,
|
|
625
|
+
"private int $name$MemoizedSerializedSize = -1;\n");
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
void RepeatedImmutablePrimitiveFieldGenerator::
|
|
630
|
+
GenerateBuilderMembers(io::Printer* printer) const {
|
|
631
|
+
// One field is the list and the bit field keeps track of whether the
|
|
632
|
+
// list is immutable. If it's immutable, the invariant is that it must
|
|
633
|
+
// either an instance of Collections.emptyList() or it's an ArrayList
|
|
634
|
+
// wrapped in a Collections.unmodifiableList() wrapper and nobody else has
|
|
635
|
+
// a refererence to the underlying ArrayList. This invariant allows us to
|
|
636
|
+
// share instances of lists between protocol buffers avoiding expensive
|
|
637
|
+
// memory allocations. Note, immutable is a strong guarantee here -- not
|
|
638
|
+
// just that the list cannot be modified via the reference but that the
|
|
639
|
+
// list can never be modified.
|
|
640
|
+
printer->Print(variables_,
|
|
641
|
+
"private $field_list_type$ $name$_ = $empty_list$;\n");
|
|
642
|
+
|
|
643
|
+
printer->Print(variables_,
|
|
644
|
+
"private void ensure$capitalized_name$IsMutable() {\n"
|
|
645
|
+
" if (!$get_mutable_bit_builder$) {\n"
|
|
646
|
+
" $name$_ = new java.util.ArrayList<$boxed_type$>($name$_);\n"
|
|
647
|
+
" $set_mutable_bit_builder$;\n"
|
|
648
|
+
" }\n"
|
|
649
|
+
"}\n");
|
|
650
|
+
|
|
651
|
+
// Note: We return an unmodifiable list because otherwise the caller
|
|
652
|
+
// could hold on to the returned list and modify it after the message
|
|
653
|
+
// has been built, thus mutating the message which is supposed to be
|
|
654
|
+
// immutable.
|
|
655
|
+
WriteFieldDocComment(printer, descriptor_);
|
|
656
|
+
printer->Print(variables_,
|
|
657
|
+
"$deprecation$public java.util.List<$boxed_type$>\n"
|
|
658
|
+
" get$capitalized_name$List() {\n"
|
|
659
|
+
" return java.util.Collections.unmodifiableList($name$_);\n"
|
|
660
|
+
"}\n");
|
|
661
|
+
WriteFieldDocComment(printer, descriptor_);
|
|
662
|
+
printer->Print(variables_,
|
|
663
|
+
"$deprecation$public int get$capitalized_name$Count() {\n"
|
|
664
|
+
" return $name$_.size();\n"
|
|
665
|
+
"}\n");
|
|
666
|
+
WriteFieldDocComment(printer, descriptor_);
|
|
667
|
+
printer->Print(variables_,
|
|
668
|
+
"$deprecation$public $type$ get$capitalized_name$(int index) {\n"
|
|
669
|
+
" return $name$_.get(index);\n"
|
|
670
|
+
"}\n");
|
|
671
|
+
WriteFieldDocComment(printer, descriptor_);
|
|
672
|
+
printer->Print(variables_,
|
|
673
|
+
"$deprecation$public Builder set$capitalized_name$(\n"
|
|
674
|
+
" int index, $type$ value) {\n"
|
|
675
|
+
"$null_check$"
|
|
676
|
+
" ensure$capitalized_name$IsMutable();\n"
|
|
677
|
+
" $name$_.set(index, value);\n"
|
|
678
|
+
" $on_changed$\n"
|
|
679
|
+
" return this;\n"
|
|
680
|
+
"}\n");
|
|
681
|
+
WriteFieldDocComment(printer, descriptor_);
|
|
682
|
+
printer->Print(variables_,
|
|
683
|
+
"$deprecation$public Builder add$capitalized_name$($type$ value) {\n"
|
|
684
|
+
"$null_check$"
|
|
685
|
+
" ensure$capitalized_name$IsMutable();\n"
|
|
686
|
+
" $name$_.add(value);\n"
|
|
687
|
+
" $on_changed$\n"
|
|
688
|
+
" return this;\n"
|
|
689
|
+
"}\n");
|
|
690
|
+
WriteFieldDocComment(printer, descriptor_);
|
|
691
|
+
printer->Print(variables_,
|
|
692
|
+
"$deprecation$public Builder addAll$capitalized_name$(\n"
|
|
693
|
+
" java.lang.Iterable<? extends $boxed_type$> values) {\n"
|
|
694
|
+
" ensure$capitalized_name$IsMutable();\n"
|
|
695
|
+
" com.google.protobuf.AbstractMessageLite.Builder.addAll(\n"
|
|
696
|
+
" values, $name$_);\n"
|
|
697
|
+
" $on_changed$\n"
|
|
698
|
+
" return this;\n"
|
|
699
|
+
"}\n");
|
|
700
|
+
WriteFieldDocComment(printer, descriptor_);
|
|
701
|
+
printer->Print(variables_,
|
|
702
|
+
"$deprecation$public Builder clear$capitalized_name$() {\n"
|
|
703
|
+
" $name$_ = $empty_list$;\n"
|
|
704
|
+
" $clear_mutable_bit_builder$;\n"
|
|
705
|
+
" $on_changed$\n"
|
|
706
|
+
" return this;\n"
|
|
707
|
+
"}\n");
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
void RepeatedImmutablePrimitiveFieldGenerator::
|
|
711
|
+
GenerateFieldBuilderInitializationCode(io::Printer* printer) const {
|
|
712
|
+
// noop for primitives
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
void RepeatedImmutablePrimitiveFieldGenerator::
|
|
716
|
+
GenerateInitializationCode(io::Printer* printer) const {
|
|
717
|
+
printer->Print(variables_, "$name$_ = $empty_list$;\n");
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
void RepeatedImmutablePrimitiveFieldGenerator::
|
|
721
|
+
GenerateBuilderClearCode(io::Printer* printer) const {
|
|
722
|
+
printer->Print(variables_,
|
|
723
|
+
"$name$_ = $empty_list$;\n"
|
|
724
|
+
"$clear_mutable_bit_builder$;\n");
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
void RepeatedImmutablePrimitiveFieldGenerator::
|
|
728
|
+
GenerateMergingCode(io::Printer* printer) const {
|
|
729
|
+
// The code below does two optimizations:
|
|
730
|
+
// 1. If the other list is empty, there's nothing to do. This ensures we
|
|
731
|
+
// don't allocate a new array if we already have an immutable one.
|
|
732
|
+
// 2. If the other list is non-empty and our current list is empty, we can
|
|
733
|
+
// reuse the other list which is guaranteed to be immutable.
|
|
734
|
+
printer->Print(variables_,
|
|
735
|
+
"if (!other.$name$_.isEmpty()) {\n"
|
|
736
|
+
" if ($name$_.isEmpty()) {\n"
|
|
737
|
+
" $name$_ = other.$name$_;\n"
|
|
738
|
+
" $clear_mutable_bit_builder$;\n"
|
|
739
|
+
" } else {\n"
|
|
740
|
+
" ensure$capitalized_name$IsMutable();\n"
|
|
741
|
+
" $name$_.addAll(other.$name$_);\n"
|
|
742
|
+
" }\n"
|
|
743
|
+
" $on_changed$\n"
|
|
744
|
+
"}\n");
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
void RepeatedImmutablePrimitiveFieldGenerator::
|
|
748
|
+
GenerateBuildingCode(io::Printer* printer) const {
|
|
749
|
+
// The code below ensures that the result has an immutable list. If our
|
|
750
|
+
// list is immutable, we can just reuse it. If not, we make it immutable.
|
|
751
|
+
printer->Print(variables_,
|
|
752
|
+
"if ($get_mutable_bit_builder$) {\n"
|
|
753
|
+
" $name$_ = java.util.Collections.unmodifiableList($name$_);\n"
|
|
754
|
+
" $clear_mutable_bit_builder$;\n"
|
|
755
|
+
"}\n"
|
|
756
|
+
"result.$name$_ = $name$_;\n");
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
void RepeatedImmutablePrimitiveFieldGenerator::
|
|
760
|
+
GenerateParsingCode(io::Printer* printer) const {
|
|
761
|
+
printer->Print(variables_,
|
|
762
|
+
"if (!$get_mutable_bit_parser$) {\n"
|
|
763
|
+
" $name$_ = new java.util.ArrayList<$boxed_type$>();\n"
|
|
764
|
+
" $set_mutable_bit_parser$;\n"
|
|
765
|
+
"}\n"
|
|
766
|
+
"$name$_.add(input.read$capitalized_type$());\n");
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
void RepeatedImmutablePrimitiveFieldGenerator::
|
|
770
|
+
GenerateParsingCodeFromPacked(io::Printer* printer) const {
|
|
771
|
+
printer->Print(variables_,
|
|
772
|
+
"int length = input.readRawVarint32();\n"
|
|
773
|
+
"int limit = input.pushLimit(length);\n"
|
|
774
|
+
"if (!$get_mutable_bit_parser$ && input.getBytesUntilLimit() > 0) {\n"
|
|
775
|
+
" $name$_ = new java.util.ArrayList<$boxed_type$>();\n"
|
|
776
|
+
" $set_mutable_bit_parser$;\n"
|
|
777
|
+
"}\n"
|
|
778
|
+
"while (input.getBytesUntilLimit() > 0) {\n"
|
|
779
|
+
" $name$_.add(input.read$capitalized_type$());\n"
|
|
780
|
+
"}\n"
|
|
781
|
+
"input.popLimit(limit);\n");
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
void RepeatedImmutablePrimitiveFieldGenerator::
|
|
785
|
+
GenerateParsingDoneCode(io::Printer* printer) const {
|
|
786
|
+
printer->Print(variables_,
|
|
787
|
+
"if ($get_mutable_bit_parser$) {\n"
|
|
788
|
+
" $name$_ = java.util.Collections.unmodifiableList($name$_);\n"
|
|
789
|
+
"}\n");
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
void RepeatedImmutablePrimitiveFieldGenerator::
|
|
793
|
+
GenerateSerializationCode(io::Printer* printer) const {
|
|
794
|
+
if (descriptor_->options().packed()) {
|
|
795
|
+
printer->Print(variables_,
|
|
796
|
+
"if (get$capitalized_name$List().size() > 0) {\n"
|
|
797
|
+
" output.writeRawVarint32($tag$);\n"
|
|
798
|
+
" output.writeRawVarint32($name$MemoizedSerializedSize);\n"
|
|
799
|
+
"}\n"
|
|
800
|
+
"for (int i = 0; i < $name$_.size(); i++) {\n"
|
|
801
|
+
" output.write$capitalized_type$NoTag($name$_.get(i));\n"
|
|
802
|
+
"}\n");
|
|
803
|
+
} else {
|
|
804
|
+
printer->Print(variables_,
|
|
805
|
+
"for (int i = 0; i < $name$_.size(); i++) {\n"
|
|
806
|
+
" output.write$capitalized_type$($number$, $name$_.get(i));\n"
|
|
807
|
+
"}\n");
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
void RepeatedImmutablePrimitiveFieldGenerator::
|
|
812
|
+
GenerateSerializedSizeCode(io::Printer* printer) const {
|
|
813
|
+
printer->Print(variables_,
|
|
814
|
+
"{\n"
|
|
815
|
+
" int dataSize = 0;\n");
|
|
816
|
+
printer->Indent();
|
|
817
|
+
|
|
818
|
+
if (FixedSize(GetType(descriptor_)) == -1) {
|
|
819
|
+
printer->Print(variables_,
|
|
820
|
+
"for (int i = 0; i < $name$_.size(); i++) {\n"
|
|
821
|
+
" dataSize += com.google.protobuf.CodedOutputStream\n"
|
|
822
|
+
" .compute$capitalized_type$SizeNoTag($name$_.get(i));\n"
|
|
823
|
+
"}\n");
|
|
824
|
+
} else {
|
|
825
|
+
printer->Print(variables_,
|
|
826
|
+
"dataSize = $fixed_size$ * get$capitalized_name$List().size();\n");
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
printer->Print(
|
|
830
|
+
"size += dataSize;\n");
|
|
831
|
+
|
|
832
|
+
if (descriptor_->options().packed()) {
|
|
833
|
+
printer->Print(variables_,
|
|
834
|
+
"if (!get$capitalized_name$List().isEmpty()) {\n"
|
|
835
|
+
" size += $tag_size$;\n"
|
|
836
|
+
" size += com.google.protobuf.CodedOutputStream\n"
|
|
837
|
+
" .computeInt32SizeNoTag(dataSize);\n"
|
|
838
|
+
"}\n");
|
|
839
|
+
} else {
|
|
840
|
+
printer->Print(variables_,
|
|
841
|
+
"size += $tag_size$ * get$capitalized_name$List().size();\n");
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
// cache the data size for packed fields.
|
|
845
|
+
if (descriptor_->options().packed()) {
|
|
846
|
+
printer->Print(variables_,
|
|
847
|
+
"$name$MemoizedSerializedSize = dataSize;\n");
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
printer->Outdent();
|
|
851
|
+
printer->Print("}\n");
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
void RepeatedImmutablePrimitiveFieldGenerator::
|
|
855
|
+
GenerateEqualsCode(io::Printer* printer) const {
|
|
856
|
+
printer->Print(variables_,
|
|
857
|
+
"result = result && get$capitalized_name$List()\n"
|
|
858
|
+
" .equals(other.get$capitalized_name$List());\n");
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
void RepeatedImmutablePrimitiveFieldGenerator::
|
|
862
|
+
GenerateHashCode(io::Printer* printer) const {
|
|
863
|
+
printer->Print(variables_,
|
|
864
|
+
"if (get$capitalized_name$Count() > 0) {\n"
|
|
865
|
+
" hash = (37 * hash) + $constant_name$;\n"
|
|
866
|
+
" hash = (53 * hash) + get$capitalized_name$List().hashCode();\n"
|
|
867
|
+
"}\n");
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
string RepeatedImmutablePrimitiveFieldGenerator::GetBoxedType() const {
|
|
871
|
+
return BoxedPrimitiveTypeName(GetJavaType(descriptor_));
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
} // namespace java
|
|
875
|
+
} // namespace compiler
|
|
876
|
+
} // namespace protobuf
|
|
877
|
+
} // namespace google
|